View Javadoc
1   package org.apache.maven.it;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  import org.apache.maven.it.util.ResourceExtractor;
25  
26  /**
27   * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-3729">MNG-3729</a>.
28   * <p>
29   * Complicated use case, but say
30   * you have an aggregator plugin that forks a lifecycle, and this aggregator is bound to the main lifecycle in a
31   * multimodule build. Further, say you call another plugin directly from the command line for this multimodule build,
32   * which forks a new lifecycle (like assembly:assembly).
33   * </p>
34   * When the directly invoked aggregator forks, it will force the
35   * forked lifecycle phase to be run for each project in the reactor, regardless of whether this causes the bound
36   * aggregator mojo to run multiple times. When the bound aggregator executes for the first project (this will be in an
37   * inner fork, two levels removed from the main lifecycle execution) it will set the executionProject to null for the
38   * current project (which is one of the reactorProjects member instances). On the second pass, as it tries to execute
39   * the inner aggregator's forked lifecycle for the second project in the reactor, one of the reactorProjects'
40   * project.getExecutionProject() results will be null. If any of the mojos in this inner lifecycle fork requires
41   * dependency resolution, it will cause a NullPointerException in the DefaultPluginManager when it tries to resolve the
42   * dependencies for the current project. This happened in 2.0.10-RC11 (which was the predecessor to 2.1.0-RC12, since
43   * the version was renamed while the release process was in mid-execution). It did not happen in 2.0.9, and was fixed in
44   * 2.1.0-RC12.
45   *
46   * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
47   * @author jdcasey
48   */
49  public class MavenITmng3729MultiForkAggregatorsTest
50      extends AbstractMavenIntegrationTestCase
51  {
52      public MavenITmng3729MultiForkAggregatorsTest()
53      {
54          super( "(2.0.8,3.0-alpha-1),[3.0-alpha-3,)" ); // only test in 2.0.9+
55      }
56  
57      public void testitMNG3729 ()
58          throws Exception
59      {
60          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3729" );
61          File pluginDir = new File( testDir, "maven-mng3729-plugin" );
62          File projectDir = new File( testDir, "projects" );
63  
64          Verifier verifier;
65  
66          verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
67  
68          verifier.executeGoal( "install" );
69          verifier.verifyErrorFreeLog();
70          verifier.resetStreams();
71  
72          verifier = newVerifier( projectDir.getAbsolutePath() );
73  
74          verifier.executeGoal( "package" );
75          verifier.verifyErrorFreeLog();
76          verifier.resetStreams();
77      }
78  }