diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java index c1691e20f5..15b2db1b87 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java @@ -125,9 +125,9 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti log.info("Tycho Builder: " + session.getUserProperties().getProperty(TychoConstants.SESSION_PROPERTY_TYCHO_BUILDER, "maven")); if (disableLifecycleParticipation(session)) { - buildListeners.notifyBuildStart(session); return; } + buildListeners.notifyBuildStart(session); List projects = session.getProjects(); try { validate(projects); diff --git a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/ConfigureMojo.java b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/ConfigureMojo.java new file mode 100644 index 0000000000..bafcda25cc --- /dev/null +++ b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/ConfigureMojo.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.extras.docbundle; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * This mojo is only there + */ +@Mojo(name = "configure-document-bundle-plugin", defaultPhase = LifecyclePhase.INITIALIZE, requiresDependencyResolution = ResolutionScope.NONE, threadSafe = true) +public class ConfigureMojo extends AbstractMojo { + + /** + * name of the parameter to inject javadoc source dependencies + */ + public static final String PARAM_INJECT_JAVADOC_DEPENDENCIES = "injectJavadocDependencies"; + @Parameter(name = PARAM_INJECT_JAVADOC_DEPENDENCIES) + private boolean dummyBoolean; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + throw new MojoFailureException("This mojo is not intended to be ever called"); + } + +} diff --git a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/JavadocBuildListener.java b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/JavadocBuildListener.java new file mode 100644 index 0000000000..54ffb14b29 --- /dev/null +++ b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/JavadocBuildListener.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.extras.docbundle; + +import java.util.Arrays; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.eclipse.tycho.build.BuildListener; +import org.eclipse.tycho.helper.PluginConfigurationHelper; +import org.eclipse.tycho.helper.PluginConfigurationHelper.Configuration; +import org.eclipse.tycho.helper.ProjectHelper; + +@Component(role = BuildListener.class, hint = "javadoc") +public class JavadocBuildListener implements BuildListener { + + private static final String JAVADOC_GOAL = "javadoc"; + private static final String ARTIFACT_ID = "maven-javadoc-plugin"; + private static final String GROUP_ID = "org.apache.maven.plugins"; + + @Requirement + private ProjectHelper projectHelper; + + @Requirement + private PluginConfigurationHelper configurationHelper; + + @Override + public void buildStarted(MavenSession session) { + for (MavenProject project : session.getProjects()) { + if (isJavadocProject(project, session)) { + Configuration configuration = configurationHelper.getConfiguration(GROUP_ID, ARTIFACT_ID, JAVADOC_GOAL, + project, session); + configuration.getString("sourcepath").ifPresent(sourcepath -> { + System.out.println("project " + project + " has sourcepath=" + sourcepath); + String[] pathString = sourcepath.split(";|:"); + System.out.println(Arrays.toString(pathString)); + }); + } + } + + } + + private boolean isJavadocProject(MavenProject project, MavenSession mavenSession) { + return projectHelper.hasPluginExecution(GROUP_ID, ARTIFACT_ID, JAVADOC_GOAL, project, mavenSession); + } + + @Override + public void buildEnded(MavenSession session) { + // nothing to do... + } + +} diff --git a/tycho-spi/src/main/java/org/eclipse/tycho/helper/PluginConfigurationHelper.java b/tycho-spi/src/main/java/org/eclipse/tycho/helper/PluginConfigurationHelper.java index 8509e842ea..1a74b5caca 100644 --- a/tycho-spi/src/main/java/org/eclipse/tycho/helper/PluginConfigurationHelper.java +++ b/tycho-spi/src/main/java/org/eclipse/tycho/helper/PluginConfigurationHelper.java @@ -20,12 +20,14 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; +import org.apache.maven.project.MavenProject; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.InterpolationFilterReader; @@ -58,6 +60,12 @@ public Configuration getConfiguration(Xpp3Dom configuration) { return new Configuration(configuration); } + public Configuration getConfiguration(String pluginGroupId, String pluginArtifactId, String goal, + MavenProject project, MavenSession mavenSession) { + return new Configuration( + projectHelper.getPluginConfiguration(pluginGroupId, pluginArtifactId, goal, project, mavenSession)); + } + public Configuration getConfiguration(Class mojo) { URL resource = mojo.getResource("/META-INF/maven/plugin.xml"); if (resource == null) { diff --git a/tycho-spi/src/main/java/org/eclipse/tycho/helper/ProjectHelper.java b/tycho-spi/src/main/java/org/eclipse/tycho/helper/ProjectHelper.java index a5c0fe9869..70e3b98640 100644 --- a/tycho-spi/src/main/java/org/eclipse/tycho/helper/ProjectHelper.java +++ b/tycho-spi/src/main/java/org/eclipse/tycho/helper/ProjectHelper.java @@ -86,7 +86,7 @@ public List getPlugins(MavenProject project, MavenSession mavenSession) * @param goal * @param project * @param mavenSession - * @return true if an execution was found or false otherwhise. + * @return true if an execution was found or false otherwise. */ public boolean hasPluginExecution(String pluginGroupId, String pluginArtifactId, String goal, MavenProject project, MavenSession mavenSession) { diff --git a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/VersionBumpBuildListener.java b/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/VersionBumpBuildListener.java index 54a0d17d57..9f5a6514c4 100644 --- a/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/VersionBumpBuildListener.java +++ b/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/VersionBumpBuildListener.java @@ -32,7 +32,7 @@ import org.eclipse.tycho.versions.pom.PomFile; import org.osgi.framework.Version; -@Component(role = BuildListener.class) +@Component(role = BuildListener.class, hint = "version-bump") public class VersionBumpBuildListener implements BuildListener { @Requirement @@ -79,10 +79,10 @@ public void buildEnded(MavenSession session) { String newVersion = suggestedVersion.map(String::valueOf) .orElseGet(() -> Versions.incrementVersion(currentVersion, VersionBumpMojo.getIncrement(session, project, projectHelper))); - boolean isSnapshot = currentVersion.endsWith(TychoConstants.SUFFIX_SNAPSHOT); - if (isSnapshot) { - newVersion += TychoConstants.SUFFIX_SNAPSHOT; - } + boolean isSnapshot = currentVersion.endsWith(TychoConstants.SUFFIX_SNAPSHOT); + if (isSnapshot) { + newVersion += TychoConstants.SUFFIX_SNAPSHOT; + } logger.info(project.getId() + " requires a version bump from " + currentVersion + " => " + newVersion); engine.setProjects(metadataReader.getProjects());