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  
26  /**
27   *
28   * @author Benjamin Bentmann
29   */
30  public class MavenIT0145ReactorWithIncludesExcludesTest
31      extends AbstractMavenIntegrationTestCase
32  {
33  
34      public MavenIT0145ReactorWithIncludesExcludesTest()
35      {
36          // superseded by make-like reactor mode in 3.x (see also MNG-4260)
37          super( "[2.0,3.0-alpha-1)" );
38      }
39  
40      /**
41       * Test the old-style reactor mode with includes/excludes to locate projects.
42       *
43       * @throws Exception in case of failure
44       */
45      public void testitDefaultIncludesExcludes()
46          throws Exception
47      {
48          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0145" );
49  
50          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
51          verifier.setAutoclean( false );
52          verifier.deleteDirectory( "target" );
53          verifier.deleteDirectory( "mod-a/target" );
54          verifier.deleteDirectory( "mod-b/target" );
55          verifier.addCliOption( "-r" );
56          verifier.setLogFileName( "log-defaults.txt" );
57          verifier.executeGoal( "validate" );
58          verifier.verifyErrorFreeLog();
59          verifier.resetStreams();
60  
61          verifier.assertFileNotPresent( "target/touch.txt" );
62          verifier.assertFilePresent( "mod-a/target/touch-a.txt" );
63          verifier.assertFilePresent( "mod-b/target/touch-b.txt" );
64      }
65  
66      /**
67       * Test the old-style reactor mode with includes/excludes to locate projects.
68       *
69       * @throws Exception in case of failure
70       */
71      public void testitCustomIncludes()
72          throws Exception
73      {
74          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0145" );
75  
76          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
77          verifier.setAutoclean( false );
78          verifier.deleteDirectory( "target" );
79          verifier.deleteDirectory( "mod-a/target" );
80          verifier.deleteDirectory( "mod-b/target" );
81          verifier.addCliOption( "-r" );
82          verifier.addCliOption( "-Dmaven.reactor.includes=mod-a/pom.xml" );
83          verifier.setLogFileName( "log-includes.txt" );
84          verifier.executeGoal( "validate" );
85          verifier.verifyErrorFreeLog();
86          verifier.resetStreams();
87  
88          verifier.assertFileNotPresent( "target/touch.txt" );
89          verifier.assertFilePresent( "mod-a/target/touch-a.txt" );
90          verifier.assertFileNotPresent( "mod-b/target/touch-b.txt" );
91      }
92  
93      /**
94       * Test the old-style reactor mode with includes/excludes to locate projects.
95       *
96       * @throws Exception in case of failure
97       */
98      public void testitCustomExcludes()
99          throws Exception
100     {
101         File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0145" );
102 
103         Verifier verifier = newVerifier( testDir.getAbsolutePath() );
104         verifier.setAutoclean( false );
105         verifier.deleteDirectory( "target" );
106         verifier.deleteDirectory( "mod-a/target" );
107         verifier.deleteDirectory( "mod-b/target" );
108         verifier.addCliOption( "-r" );
109         verifier.addCliOption( "-Dmaven.reactor.excludes=mod-a/pom.xml" );
110         verifier.setLogFileName( "log-excludes.txt" );
111         verifier.executeGoal( "validate" );
112         verifier.verifyErrorFreeLog();
113         verifier.resetStreams();
114 
115         verifier.assertFilePresent( "target/touch.txt" );
116         verifier.assertFileNotPresent( "mod-a/target/touch-a.txt" );
117         verifier.assertFilePresent( "mod-b/target/touch-b.txt" );
118     }
119 
120 }