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.io.IOException;
26  
27  public class MavenITmng7112ProjectsWithNonRecursiveTest
28          extends AbstractMavenIntegrationTestCase
29  {
30      private static final String PROJECT_PATH = "/mng-7112-projects-with-non-recursive";
31  
32      public MavenITmng7112ProjectsWithNonRecursiveTest()
33      {
34          super( "[4.0.0-alpha-1,)" );
35      }
36  
37      public void testAggregatesCanBeBuiltNonRecursively()
38              throws IOException, VerificationException
39      {
40          final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
41          newVerifier( projectDir.getAbsolutePath() ).executeGoal( "clean" );
42  
43          final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
44  
45          verifier.addCliOption( "-pl" );
46          verifier.addCliOption( ":aggregator-a,:aggregator-b" );
47          verifier.addCliOption( "-N" );
48          verifier.setLogFileName( "selected-non-recursive.txt" );
49          verifier.executeGoal( "validate" );
50  
51          verifier.assertFileNotPresent( "target/touch.txt" );
52          verifier.assertFilePresent( "aggregator-a/target/touch.txt" );
53          verifier.assertFileNotPresent( "aggregator-a/module-a/target/touch.txt" );
54          verifier.assertFilePresent( "aggregator-b/target/touch.txt" );
55          verifier.assertFileNotPresent( "aggregator-b/module-b/target/touch.txt" );
56      }
57  
58      public void testAggregatesCanBeDeselectedNonRecursively()
59              throws IOException, VerificationException
60      {
61          final File projectDir = ResourceExtractor.simpleExtractResources( getClass(), PROJECT_PATH );
62          newVerifier( projectDir.getAbsolutePath() ).executeGoal( "clean" );
63  
64          final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
65  
66          verifier.addCliOption( "-pl" );
67          verifier.addCliOption( "!:aggregator-a,!:aggregator-b" );
68          verifier.addCliOption( "-N" );
69          verifier.setLogFileName( "excluded-non-recursive.txt" );
70          verifier.executeGoal( "validate" );
71  
72          verifier.assertFilePresent( "target/touch.txt" );
73          verifier.assertFileNotPresent( "aggregator-a/target/touch.txt" );
74          verifier.assertFilePresent( "aggregator-a/module-a/target/touch.txt" );
75          verifier.assertFileNotPresent( "aggregator-b/target/touch.txt" );
76          verifier.assertFilePresent( "aggregator-b/module-b/target/touch.txt" );
77      }
78  }