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 org.apache.maven.it.util.ResourceExtractor;
23  
24  import java.io.File;
25  import java.util.Arrays;
26  
27  /**
28   * The usage of a <code>${revision}</code> for the version in the pom file and furthermore
29   * defining the property in the pom file and overwrite it via command line and
30   * try to build a partial reactor via <code>mvn -pl ..</code>
31   * <a href="https://issues.apache.org/jira/browse/MNG-6090">MNG-6090</a>.
32   *
33   * @author Karl Heinz Marbaise khmarbaise@apache.org
34   */
35  public class MavenITmng6090CIFriendlyTest
36      extends AbstractMavenIntegrationTestCase
37  {
38  
39      public MavenITmng6090CIFriendlyTest()
40      {
41          // The first version which contains the fix for the MNG-issue.
42          // TODO: Think about it!
43          super( "[3.5.0-alpha-2,)" );
44      }
45  
46      /**
47       * Check that the resulting run will not fail in case
48       * of defining the property via command line and
49       * install the projects and afterwards just build
50       * a part of the whole reactor.
51       *
52       * @throws Exception in case of failure
53       */
54      public void testitShouldResolveTheDependenciesWithoutBuildConsumer()
55          throws Exception
56      {
57          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6090-ci-friendly" );
58  
59          Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
60          verifier.setMavenDebug( false );
61          verifier.setAutoclean( false );
62  
63          verifier.addCliOption( "-Drevision=1.2" );
64          verifier.addCliOption( "-Dmaven.experimental.buildconsumer=false" );
65          verifier.setLogFileName( "install-log.txt" );
66          verifier.executeGoals( Arrays.asList( "clean", "install" ) );
67          verifier.verifyErrorFreeLog();
68          verifier.resetStreams();
69  
70          verifier = newVerifier( testDir.getAbsolutePath(), false );
71          verifier.setMavenDebug( false );
72          verifier.setAutoclean( false );
73  
74          verifier.addCliOption( "-Drevision=1.2" );
75          verifier.addCliOption( "-pl module-3" );
76          verifier.executeGoal( "package" );
77          verifier.verifyErrorFreeLog();
78          verifier.resetStreams();
79      }
80  
81      public void testitShouldResolveTheDependenciesWithBuildConsumer()
82                      throws Exception
83      {
84          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-6090-ci-friendly" );
85  
86          Verifier verifier = newVerifier( testDir.getAbsolutePath(), false );
87          verifier.setMavenDebug( false );
88          verifier.setAutoclean( false );
89          verifier.setForkJvm(true);
90  
91          verifier.addCliOption( "-Drevision=1.2" );
92          verifier.addCliOption( "-Dmaven.experimental.buildconsumer=true" );
93          verifier.setLogFileName( "install-log.txt" );
94          verifier.executeGoals( Arrays.asList( "clean", "install" ) );
95          verifier.verifyErrorFreeLog();
96          verifier.resetStreams();
97  
98          verifier = newVerifier( testDir.getAbsolutePath(), false );
99          verifier.setMavenDebug( false );
100         verifier.setAutoclean( false );
101         verifier.setForkJvm(true);
102 
103         verifier.addCliOption( "-Drevision=1.2" );
104         verifier.addCliOption( "-pl module-3" );
105         verifier.executeGoal( "package" );
106         verifier.verifyErrorFreeLog();
107         verifier.resetStreams();
108     }
109 
110 }