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.Verifier;
25  import org.apache.maven.it.util.ResourceExtractor;
26  
27  /**
28   * This is a test set for <a href="http://jira.codehaus.org/browse/MNG-3729">MNG-3729</a>.
29   * <br/><br/>
30   * Complicated use case, but say
31   * you have an aggregator plugin that forks a lifecycle, and this aggregator is bound to the main lifecycle in a
32   * multimodule build. Further, say you call another plugin directly from the command line for this multimodule build,
33   * which forks a new lifecycle (like assembly:assembly).
34   * <br/><br/>
35   * When the directly invoked aggregator forks, it will force the
36   * forked lifecycle phase to be run for each project in the reactor, regardless of whether this causes the bound
37   * aggregator mojo to run multiple times. When the bound aggregator executes for the first project (this will be in an
38   * inner fork, two levels removed from the main lifecycle execution) it will set the executionProject to null for the
39   * current project (which is one of the reactorProjects member instances). On the second pass, as it tries to execute
40   * the inner aggregator's forked lifecycle for the second project in the reactor, one of the reactorProjects'
41   * project.getExecutionProject() results will be null. If any of the mojos in this inner lifecycle fork requires
42   * dependency resolution, it will cause a NullPointerException in the DefaultPluginManager when it tries to resolve the
43   * dependencies for the current project. This happened in 2.0.10-RC11 (which was the predecessor to 2.1.0-RC12, since
44   * the version was renamed while the release process was in mid-execution). It did not happen in 2.0.9, and was fixed in
45   * 2.1.0-RC12.
46   * 
47   * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
48   * @author jdcasey
49   */
50  public class MavenITmng3729MultiForkAggregatorsTest
51      extends AbstractMavenIntegrationTestCase
52  {
53      public MavenITmng3729MultiForkAggregatorsTest()
54      {
55          super( "(2.0.8,3.0-alpha-1),[3.0-alpha-3,)" ); // only test in 2.0.9+
56      }
57  
58      public void testitMNG3729 ()
59          throws Exception
60      {
61          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3729" );
62          File pluginDir = new File( testDir, "maven-mng3729-plugin" );
63          File projectDir = new File( testDir, "projects" );
64  
65          Verifier verifier;
66  
67          verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
68  
69          verifier.executeGoal( "install" );
70          verifier.verifyErrorFreeLog();
71          verifier.resetStreams();
72          
73          verifier = newVerifier( projectDir.getAbsolutePath() );
74  
75          verifier.executeGoal( "package" );
76          verifier.verifyErrorFreeLog();
77          verifier.resetStreams();
78      }
79  }