diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/OsgiSourceMojo.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/OsgiSourceMojo.java
index c5c04ed65c..6426f851f3 100644
--- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/OsgiSourceMojo.java
+++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/OsgiSourceMojo.java
@@ -61,10 +61,10 @@
/**
* Goal to create a JAR-package containing all the source files of a osgi project.
*/
-@Mojo(name = "plugin-source", defaultPhase = LifecyclePhase.PREPARE_PACKAGE, threadSafe = true)
+@Mojo(name = OsgiSourceMojo.GOAL, defaultPhase = LifecyclePhase.PREPARE_PACKAGE, threadSafe = true)
public class OsgiSourceMojo extends AbstractSourceJarMojo {
- private static final String GOAL = "plugin-source";
+ static final String GOAL = "plugin-source";
static final String MANIFEST_HEADER_ECLIPSE_SOURCE_BUNDLE = "Eclipse-SourceBundle";
private static final String MANIFEST_BUNDLE_LOCALIZATION_BASENAME = BUNDLE_LOCALIZATION_DEFAULT_BASENAME + "-src";
diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureMojo.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureMojo.java
index 3bf0b698d6..36cfcb7863 100644
--- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureMojo.java
+++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureMojo.java
@@ -30,7 +30,6 @@
import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
-import org.apache.maven.model.PluginExecution;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -90,9 +89,11 @@
* <originalFeature>/feature.properties
.
*
*/
-@Mojo(name = "feature-source", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true)
+@Mojo(name = SourceFeatureMojo.GOAL, defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true)
public class SourceFeatureMojo extends AbstractMojo {
+ static final String GOAL = "feature-source";
+
public enum MissingSourcesAction {
FAIL, WARN;
}
@@ -257,7 +258,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
projectHelper.attachArtifact(project, outputJarFile, SOURCES_FEATURE_CLASSIFIER);
if (!isP2GenerationEnabled()) {
logger.warn(
- "org.eclipse.tycho:tycho-p2-plugin seems not to be enabled but will be required if the generated feature is used in an update-site. You can add the following snippet to your pom: \n" //
+ "org.eclipse.tycho:tycho-p2-plugin seems not to be enabled but will be required if the generated source-feature is used in an update-site or another feature. You can add the following snippet to your pom: \n" //
+ " \n"
+ " org.eclipse.tycho\n" //
+ " tycho-p2-plugin\n" //
@@ -282,13 +283,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
protected boolean isP2GenerationEnabled() {
Plugin plugin = project.getPlugin("org.eclipse.tycho:tycho-p2-plugin");
- if (plugin != null) {
- PluginExecution execution = plugin.getExecutionsAsMap().get("attach-p2-metadata");
- if (execution != null) {
- return execution.getGoals().contains("p2-metadata");
- }
- }
- return false;
+ return plugin != null && plugin.getExecutions().stream().anyMatch(e -> e.getGoals().contains("p2-metadata"));
}
static File getSourcesFeatureOutputDir(MavenProject project) {
diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureP2MetadataProvider.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureP2MetadataProvider.java
index 0acc027a16..02cdd10585 100644
--- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureP2MetadataProvider.java
+++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureP2MetadataProvider.java
@@ -64,7 +64,8 @@ public Map getDependencyMetadata(MavenSession sessi
}
Plugin plugin = project.getPlugin("org.eclipse.tycho:tycho-source-plugin");
if (plugin != null) {
- PluginExecution execution = plugin.getExecutionsAsMap().get("feature-source");
+ PluginExecution execution = plugin.getExecutions().stream()
+ .filter(e -> e.getGoals().contains(SourceFeatureMojo.GOAL)).findFirst().orElse(null);
if (execution == null) {
return null;
}