Author: gboue Date: Sat Nov 12 23:16:20 2016 New Revision: 1769446 URL: http://svn.apache.org/viewvc?rev=1769446&view=rev Log: [MPH-105] Effective pom aggregation is not triggered
When the plugin is invoked from the command-line, always show all effective POMs for all projects in the reactor. When it is invoked from the lifecycle, only show all effective POMs for the head project in the reactor (see commit 497785 and resolution of MPH-21); otherwise, show the effective POM for the current project only. Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/module/ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/module/pom.xml (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/pom.xml (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/verify.groovy (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/invoker.properties (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/module/ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/module/pom.xml (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/pom.xml (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/verify.groovy (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/invoker.properties (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/module/ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/module/pom.xml (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/pom.xml (with props) maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/verify.groovy (with props) Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/module/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/module/pom.xml?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/module/pom.xml (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/module/pom.xml Sat Nov 12 23:16:20 2016 @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor + license agreements. See the NOTICE file distributed with this work for additional + information regarding copyright ownership. The ASF licenses this file to + you under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of + the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required + by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License. --> + +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.maven.its.help</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + </parent> + <packaging>pom</packaging> + <artifactId>module</artifactId> +</project> Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/module/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/module/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/pom.xml?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/pom.xml (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/pom.xml Sat Nov 12 23:16:20 2016 @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<project> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.its.help</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + <packaging>pom</packaging> + <url>https://issues.apache.org/jira/browse/MPH-21</url> + <description> + Tests that the effective POM goal, bound to a phase of the lifecycle in a project of a multi-module build, prints + all the effective POMs in the reactor for the head project, and only prints their effective POM for the other projects. + </description> + <modules> + <module>module</module> + </modules> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-help-plugin</artifactId> + <version>@project.version@</version> + <executions> + <execution> + <id>print-effective-pom</id> + <phase>package</phase> + <goals> + <goal>effective-pom</goal> + </goals> + <configuration> + <output>result.txt</output> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/verify.groovy?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/verify.groovy (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/verify.groovy Sat Nov 12 23:16:20 2016 @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +String content = new File( basedir, "result.txt" ).text + +assert content.contains( "<projects>" ) +assert content.contains( "org.apache.maven.its.help:test:pom:1.0" ) +assert content.contains( "org.apache.maven.its.help:module:pom:1.0" ) + +content = new File( basedir, "module/result.txt" ).text + +assert !content.contains( "<projects>" ) +assert !content.contains( "org.apache.maven.its.help:test:pom:1.0" ) +assert content.contains( "org.apache.maven.its.help:module:pom:1.0" ) Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/verify.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-from-lifecycle/verify.groovy ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/invoker.properties?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/invoker.properties (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/invoker.properties Sat Nov 12 23:16:20 2016 @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:effective-pom Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/module/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/module/pom.xml?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/module/pom.xml (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/module/pom.xml Sat Nov 12 23:16:20 2016 @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor + license agreements. See the NOTICE file distributed with this work for additional + information regarding copyright ownership. The ASF licenses this file to + you under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of + the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required + by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License. --> + +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.its.help</groupId> + <version>1.0</version> + <packaging>pom</packaging> + <artifactId>module</artifactId> +</project> Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/module/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/module/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/pom.xml?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/pom.xml (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/pom.xml Sat Nov 12 23:16:20 2016 @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<project> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.its.help</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + <packaging>pom</packaging> + <url>https://issues.apache.org/jira/browse/MPH-105</url> + <description> + Tests that the effective POM goal in a multi-module project prints the effective POM of all projects in the reactor, + even when the aggregator POM is not the parent POM for the modules. + </description> + <modules> + <module>module</module> + </modules> + + <build> + <plugins> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/verify.groovy?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/verify.groovy (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/verify.groovy Sat Nov 12 23:16:20 2016 @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +String content = new File( basedir, "build.log" ).text +assert content.indexOf( "<projects>" ) != -1 \ No newline at end of file Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/verify.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule-unlink-parent/verify.groovy ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/invoker.properties?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/invoker.properties (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/invoker.properties Sat Nov 12 23:16:20 2016 @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:effective-pom Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/module/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/module/pom.xml?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/module/pom.xml (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/module/pom.xml Sat Nov 12 23:16:20 2016 @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor + license agreements. See the NOTICE file distributed with this work for additional + information regarding copyright ownership. The ASF licenses this file to + you under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of + the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required + by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License. --> + +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.maven.its.help</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + </parent> + <packaging>pom</packaging> + <artifactId>module</artifactId> +</project> Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/module/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/module/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/pom.xml?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/pom.xml (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/pom.xml Sat Nov 12 23:16:20 2016 @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<project> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.its.help</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + <packaging>pom</packaging> + <url>https://issues.apache.org/jira/browse/MPH-105</url> + <description> + Tests that the effective POM goal in a multi-module project prints the effective POM of all projects in the reactor + </description> + <modules> + <module>module</module> + </modules> + + <build> + <plugins> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/verify.groovy URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/verify.groovy?rev=1769446&view=auto ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/verify.groovy (added) +++ maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/verify.groovy Sat Nov 12 23:16:20 2016 @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +String content = new File( basedir, "build.log" ).text +assert content.indexOf( "<projects>" ) != -1 \ No newline at end of file Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/verify.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-help-plugin/src/it/effective-pom-multimodule/verify.groovy ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java?rev=1769446&r1=1769445&r2=1769446&view=diff ============================================================================== --- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java (original) +++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java Sat Nov 12 23:16:20 2016 @@ -21,6 +21,8 @@ package org.apache.maven.plugins.help; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecution.Source; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -69,7 +71,13 @@ public class EffectivePomMojo */ @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) private List<MavenProject> projects; - + + /** + * This mojo execution, used to determine if it was launched from the lifecycle or the command-line. + */ + @Parameter( defaultValue = "${mojo}", required = true, readonly = true ) + private MojoExecution mojoExecution; + /** * The artifact for which to display the effective POM. * <br> @@ -102,7 +110,7 @@ public class EffectivePomMojo writeHeader( writer ); String effectivePom; - if ( projects.get( 0 ).equals( project ) && projects.size() > 1 ) + if ( shouldWriteAllEffectivePOMsInReactor() ) { // outer root element writer.startElement( "projects" ); @@ -149,6 +157,21 @@ public class EffectivePomMojo } } + /** + * Determines if all effective POMs of all the projects in the reactor should be written. When this goal is started + * on the command-line, it is always the case. However, when it is bound to a phase in the lifecycle, it is only the + * case when the current project being built is the head project in the reactor. + * + * @return <code>true</code> if all effective POMs should be written, <code>false</code> otherwise. + */ + private boolean shouldWriteAllEffectivePOMsInReactor() + { + Source source = mojoExecution.getSource(); + // [MNG-5550] For Maven < 3.2.1, the source is null, instead of LIFECYCLE: only rely on comparisons with CLI + return projects.size() > 1 + && ( source == Source.CLI || source != Source.CLI && projects.get( 0 ).equals( project ) ); + } + // ---------------------------------------------------------------------- // Private methods // ----------------------------------------------------------------------