View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.its;
20  
21  import java.io.File;
22  import java.io.IOException;
23  import java.net.URISyntaxException;
24  import java.util.HashSet;
25  import java.util.Set;
26  
27  import org.apache.maven.it.VerificationException;
28  import org.apache.maven.it.Verifier;
29  import org.junit.Test;
30  
31  import static org.apache.its.util.TestUtils.archivePathFromChild;
32  import static org.apache.its.util.TestUtils.archivePathFromProject;
33  import static org.apache.its.util.TestUtils.assertZipContents;
34  import static org.apache.its.util.TestUtils.getTestDir;
35  
36  public class IT_ExcludeSrcDirWithinBuildOutputDir {
37  
38      private static final String BASENAME = "output-dir-contains-src-name";
39      private static final String VERSION = "1";
40  
41      @Test
42      public void execute() throws VerificationException, IOException, URISyntaxException {
43          File testDir = getTestDir(BASENAME);
44  
45          Verifier verifier = new Verifier(testDir.getAbsolutePath());
46  
47          verifier.executeGoal("package");
48  
49          verifier.verifyErrorFreeLog();
50          verifier.resetStreams();
51  
52          File assembly = new File(testDir, "target/" + BASENAME + "-" + VERSION + "-source-release.zip");
53  
54          Set<String> required = new HashSet<String>();
55  
56          required.add(archivePathFromProject(BASENAME, VERSION, "/pom.xml"));
57          required.add(archivePathFromChild(BASENAME, VERSION, "child1", "/pom.xml"));
58          required.add(archivePathFromChild(BASENAME, VERSION, "child2", "/pom.xml"));
59  
60          required.add(archivePathFromProject(
61                  BASENAME, VERSION, "/src/test/resources/project/src/main/resources/test.properties"));
62          required.add(archivePathFromChild(
63                  BASENAME, VERSION, "child1", "/src/test/resources/project/src/main/resources/test.properties"));
64          required.add(archivePathFromChild(
65                  BASENAME, VERSION, "child2", "/src/test/resources/project/src/main/resources/test.properties"));
66  
67          Set<String> banned = new HashSet<String>();
68  
69          banned.add(archivePathFromProject(BASENAME, VERSION, "/target/"));
70          banned.add(archivePathFromProject(
71                  BASENAME, VERSION, "/target/test-classes/project/src/main/resources/test.properties"));
72          banned.add(archivePathFromChild(BASENAME, VERSION, "child1", "/target/"));
73          banned.add(archivePathFromChild(
74                  BASENAME, VERSION, "child1", "/target/test-classes/project/src/main/resources/test.properties"));
75          banned.add(archivePathFromChild(BASENAME, VERSION, "child2", "/target/"));
76          banned.add(archivePathFromChild(
77                  BASENAME, VERSION, "child2", "/target/test-classes/project/src/main/resources/test.properties"));
78  
79          assertZipContents(required, banned, assembly);
80      }
81  }