1   package org.apache.its;
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 static org.apache.its.util.TestUtils.archivePathFromChild;
23  import static org.apache.its.util.TestUtils.archivePathFromProject;
24  import static org.apache.its.util.TestUtils.assertZipContents;
25  import static org.apache.its.util.TestUtils.getTestDir;
26  
27  import org.apache.maven.it.VerificationException;
28  import org.apache.maven.it.Verifier;
29  import org.junit.Test;
30  
31  import java.io.File;
32  import java.io.IOException;
33  import java.net.URISyntaxException;
34  import java.util.HashSet;
35  import java.util.Set;
36  
37  public class IT_ExcludeSrcDirWithinBuildOutputDir
38  {
39      
40      private static final String BASENAME = "output-dir-contains-src-name";
41      private static final String VERSION = "1";
42      
43      @Test
44      public void execute()
45          throws VerificationException, IOException, URISyntaxException
46      {
47          File testDir = getTestDir( BASENAME );
48          
49          Verifier verifier = new Verifier( testDir.getAbsolutePath() );
50          
51          verifier.executeGoal( "package" );
52          
53          verifier.verifyErrorFreeLog();
54          verifier.resetStreams();
55          
56          File assembly = new File( testDir, "target/" + BASENAME + "-" + VERSION + "-source-release.zip" );
57          
58          Set<String> required = new HashSet<String>();
59          
60          required.add( archivePathFromProject( BASENAME, VERSION, "/pom.xml" ) );
61          required.add( archivePathFromChild( BASENAME, VERSION, "child1", "/pom.xml" ) );
62          required.add( archivePathFromChild( BASENAME, VERSION, "child2", "/pom.xml" ) );
63          
64          required.add( archivePathFromProject( BASENAME, VERSION, "/src/test/resources/project/src/main/resources/test.properties" ) );
65          required.add( archivePathFromChild( BASENAME, VERSION, "child1", "/src/test/resources/project/src/main/resources/test.properties" ) );
66          required.add( archivePathFromChild( BASENAME, VERSION, "child2", "/src/test/resources/project/src/main/resources/test.properties" ) );
67          
68          Set<String> banned = new HashSet<String>();
69          
70          banned.add( archivePathFromProject( BASENAME, VERSION, "/target/" ) );
71          banned.add( archivePathFromProject( BASENAME, VERSION, "/target/test-classes/project/src/main/resources/test.properties" ) );
72          banned.add( archivePathFromChild( BASENAME, VERSION, "child1", "/target/" ) );
73          banned.add( archivePathFromChild( BASENAME, VERSION, "child1", "/target/test-classes/project/src/main/resources/test.properties" ) );
74          banned.add( archivePathFromChild( BASENAME, VERSION, "child2", "/target/" ) );
75          banned.add( archivePathFromChild( BASENAME, VERSION, "child2", "/target/test-classes/project/src/main/resources/test.properties" ) );
76          
77          assertZipContents( required, banned, assembly );
78      }
79  
80  }