5353import org .eclipse .m2e .core .project .IMavenProjectFacade ;
5454import org .eclipse .m2e .core .project .IMavenProjectRegistry ;
5555import org .eclipse .m2e .core .project .IMojoExecutionFacade ;
56+ import org .eclipse .m2e .core .project .IPluginFacade ;
5657import org .eclipse .m2e .core .project .configurator .AbstractBuildParticipant ;
5758import org .eclipse .m2e .core .project .configurator .AbstractProjectConfigurator ;
5859import org .eclipse .m2e .core .project .configurator .ILifecycleMappingConfiguration ;
@@ -88,15 +89,13 @@ public class PDEMavenBundlePluginConfigurator extends AbstractProjectConfigurato
8889
8990 @ Override
9091 public void configure (ProjectConfigurationRequest request , IProgressMonitor monitor ) throws CoreException {
91- List <MojoExecution > executions = getMojoExecutions (request , monitor );
92+ List <IMojoExecutionFacade > executions = getMojoExecutionFacades (request , monitor );
9293 boolean hasManifestExecution = false ;
93- for (MojoExecution execution : executions ) {
94- Plugin plugin = execution .getPlugin ();
94+ for (IMojoExecutionFacade execution : executions ) {
95+ IPluginFacade plugin = execution .getPlugin ();
9596 if (isFelix (plugin )) {
9697 if (isFelixManifestGoal (execution )) {
97- IMojoExecutionFacade executionFacade = IMojoExecutionFacade .wrap (request .mavenProjectFacade (),
98- execution );
99- Boolean supportIncremental = executionFacade .getMojoParameterValue (
98+ Boolean supportIncremental = execution .getMojoParameterValue (
10099 FELIX_PARAM_SUPPORTINCREMENTALBUILD , Boolean .class , monitor );
101100 if (supportIncremental == null || !supportIncremental .booleanValue ()) {
102101 createWarningMarker (request , execution , SourceLocationHelper .CONFIGURATION ,
@@ -109,7 +108,7 @@ public void configure(ProjectConfigurationRequest request, IProgressMonitor moni
109108 }
110109 }
111110 if (!hasManifestExecution && !executions .isEmpty ()) {
112- MojoExecution execution = executions .get (0 );
111+ IMojoExecutionFacade execution = executions .get (0 );
113112 createWarningMarker (request , execution , "executions" ,
114113 "There is currently no execution that generates a manifest, consider adding an execution for one of the following goal: "
115114 + (isFelix (execution .getPlugin ()) ? FELIX_MANIFEST_GOAL : BND_MANIFEST_GOALS ) + "." );
@@ -120,33 +119,42 @@ public void configure(ProjectConfigurationRequest request, IProgressMonitor moni
120119 PDEProjectHelper .addPDENature (facade .getProject (), metainfPath , monitor );
121120 }
122121
123- private void createWarningMarker (ProjectConfigurationRequest request , MojoExecution execution , String attribute ,
124- String message ) {
125- createWarningMarker (projectManager , markerManager , request , execution , attribute , message );
122+ private void createWarningMarker (ProjectConfigurationRequest request , IMojoExecutionFacade execution ,
123+ String attribute , String message ) {
124+ createWarningMarker (projectManager , markerManager , request , execution . getKey () , attribute , message );
126125 }
127126
128127 static void createWarningMarker (IMavenProjectRegistry projectManager , IMavenMarkerManager markerManager ,
129- ProjectConfigurationRequest request , MojoExecution execution , String attribute , String message ) {
130- SourceLocation location = SourceLocationHelper .findLocation (execution .getPlugin (), attribute );
128+ ProjectConfigurationRequest request , MojoExecutionKey executionKey , String attribute , String message ) {
129+ Plugin plugin = request .mavenProject ().getPlugin (executionKey .groupId () + ":" + executionKey .artifactId ());
130+ SourceLocation location = SourceLocationHelper .findLocation (plugin , attribute );
131131
132132 String [] gav = location .getResourceId ().split (":" );
133133 IMavenProjectFacade facade = projectManager .getMavenProject (gav [0 ], gav [1 ], gav [2 ]);
134134 if (facade == null ) {
135135 // attribute specifying project (probably parent) is not in the workspace.
136136 // The following code returns the location of the project's parent-element.
137- location = SourceLocationHelper .findLocation (request .mavenProject (), new MojoExecutionKey ( execution ) );
137+ location = SourceLocationHelper .findLocation (request .mavenProject (), executionKey );
138138 facade = request .mavenProjectFacade ();
139139 }
140140 MavenProblemInfo problem = new MavenProblemInfo (message , IMarker .SEVERITY_WARNING , location );
141141 markerManager .addErrorMarker (facade .getPom (), IMavenConstants .MARKER_LIFECYCLEMAPPING_ID , problem );
142142 }
143143
144- private boolean isFelixManifestGoal (MojoExecution execution ) {
145- return FELIX_MANIFEST_GOAL . equals (execution .getGoal ());
144+ private boolean isFelixManifestGoal (IMojoExecutionFacade execution ) {
145+ return isFelixManifestGoal (execution .getKey (). goal ());
146146 }
147147
148- private boolean isBNDBundleGoal (MojoExecution execution ) {
149- return BND_MANIFEST_GOALS .contains (execution .getGoal ());
148+ private boolean isFelixManifestGoal (String goal ) {
149+ return FELIX_MANIFEST_GOAL .equals (goal );
150+ }
151+
152+ private boolean isBNDBundleGoal (IMojoExecutionFacade execution ) {
153+ return isBNDBundleGoal (execution .getKey ().goal ());
154+ }
155+
156+ private boolean isBNDBundleGoal (String goal ) {
157+ return BND_MANIFEST_GOALS .contains (goal );
150158 }
151159
152160 @ Override
@@ -159,26 +167,34 @@ public void configureRawClasspath(ProjectConfigurationRequest request, IClasspat
159167 IProgressMonitor monitor ) throws CoreException { // nothing to do
160168 }
161169
162- private IPath getMetainfPath (IMavenProjectFacade facade , List <MojoExecution > executions , IProgressMonitor monitor )
163- throws CoreException {
170+ private IPath getMetainfPath (IMavenProjectFacade facade , List <IMojoExecutionFacade > executions ,
171+ IProgressMonitor monitor ) throws CoreException {
164172 // TODO: warn on multiple executions and prefer the one without classifier (i.e.
165173 // the main artifact or the one for the bnd-process/jar goal??
166- for (MojoExecution execution : executions ) {
167- Plugin plugin = execution .getPlugin ();
174+ for (IMojoExecutionFacade execution : executions ) {
175+ IPluginFacade plugin = execution .getPlugin ();
168176 String manifestParameter = isBND (plugin ) ? BND_PARAM_MANIFESTLOCATION : FELIX_PARAM_MANIFESTLOCATION ;
169- IMojoExecutionFacade executionFacade = IMojoExecutionFacade .wrap (facade , execution );
170- File location = executionFacade .getMojoParameterValue (manifestParameter , File .class , monitor );
177+ File location = execution .getMojoParameterValue (manifestParameter , File .class , monitor );
171178 if (location != null ) {
172179 return facade .getProjectRelativePath (location .getAbsolutePath ());
173180 }
174181 }
175182 return null ;
176183 }
177184
185+ private boolean isBND (IPluginFacade plugin ) {
186+ return plugin != null && "bnd-maven-plugin" .equals (plugin .getArtifactId ());
187+ }
188+
178189 private boolean isBND (Plugin plugin ) {
179190 return plugin != null && "bnd-maven-plugin" .equals (plugin .getArtifactId ());
180191 }
181192
193+ private boolean isFelix (IPluginFacade plugin ) {
194+ return plugin != null && "org.apache.felix" .equals (plugin .getGroupId ())
195+ && "maven-bundle-plugin" .equals (plugin .getArtifactId ());
196+ }
197+
182198 private boolean isFelix (Plugin plugin ) {
183199 return plugin != null && "org.apache.felix" .equals (plugin .getGroupId ())
184200 && "maven-bundle-plugin" .equals (plugin .getArtifactId ());
@@ -194,7 +210,8 @@ public boolean hasConfigurationChanged(IMavenProjectFacade newFacade,
194210 public AbstractBuildParticipant getBuildParticipant (IMavenProjectFacade projectFacade , MojoExecution execution ,
195211 IPluginExecutionMetadata executionMetadata ) {
196212 Plugin plugin = execution .getPlugin ();
197- if ((isFelix (plugin ) && isFelixManifestGoal (execution )) || (isBND (plugin ) && isBNDBundleGoal (execution ))) {
213+ if ((isFelix (plugin ) && isFelixManifestGoal (execution .getGoal ()))
214+ || (isBND (plugin ) && isBNDBundleGoal (execution .getGoal ()))) {
198215 // Run .classpath synchronization on each incremental build in order to consider
199216 // potential changes on the Bundle-ClassPath and the resources recognized by the
200217 // '-includeResource' instruction that are caused by previous mojo executions.
0 commit comments