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.Verifier;
23  import org.apache.maven.it.util.ResourceExtractor;
24  
25  import java.io.File;
26  import java.util.ArrayList;
27  import java.util.Arrays;
28  import java.util.List;
29  
30  /**
31   * 
32   * @author Benjamin Bentmann
33   */
34  public class MavenIT0145ReactorWithIncludesExcludesTest
35      extends AbstractMavenIntegrationTestCase
36  {
37  
38      public MavenIT0145ReactorWithIncludesExcludesTest()
39      {
40          // superseded by make-like reactor mode in 3.x (see also MNG-4260)
41          super( "[2.0,3.0-alpha-1)" );
42      }
43  
44      /**
45       * Test the old-style reactor mode with includes/excludes to locate projects.
46       */
47      public void testitDefaultIncludesExcludes()
48          throws Exception
49      {
50          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0145" );
51  
52          Verifier verifier = newVerifier( testDir.getAbsolutePath() );
53          verifier.setAutoclean( false );
54          verifier.deleteDirectory( "target" );
55          verifier.deleteDirectory( "mod-a/target" );
56          verifier.deleteDirectory( "mod-b/target" );
57          verifier.getCliOptions().add( "-r" );
58          verifier.setLogFileName( "log-defaults.txt" );
59          verifier.executeGoal( "validate" );
60          verifier.verifyErrorFreeLog();
61          verifier.resetStreams();
62  
63          verifier.assertFileNotPresent( "target/touch.txt" );
64          verifier.assertFilePresent( "mod-a/target/touch-a.txt" );
65          verifier.assertFilePresent( "mod-b/target/touch-b.txt" );
66      }
67  
68      /**
69       * Test the old-style reactor mode with includes/excludes to locate projects.
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.getCliOptions().add( "-r" );
82          verifier.getCliOptions().add( "-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      public void testitCustomExcludes()
97          throws Exception
98      {
99          File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/it0145" );
100 
101         Verifier verifier = newVerifier( testDir.getAbsolutePath() );
102         verifier.setAutoclean( false );
103         verifier.deleteDirectory( "target" );
104         verifier.deleteDirectory( "mod-a/target" );
105         verifier.deleteDirectory( "mod-b/target" );
106         verifier.getCliOptions().add( "-r" );
107         verifier.getCliOptions().add( "-Dmaven.reactor.excludes=mod-a/pom.xml" );
108         verifier.setLogFileName( "log-excludes.txt" );
109         verifier.executeGoal( "validate" );
110         verifier.verifyErrorFreeLog();
111         verifier.resetStreams();
112 
113         verifier.assertFilePresent( "target/touch.txt" );
114         verifier.assertFileNotPresent( "mod-a/target/touch-a.txt" );
115         verifier.assertFilePresent( "mod-b/target/touch-b.txt" );
116     }
117 
118 }