This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch bugfix/exclude-nested-target
in repository https://gitbox.apache.org/repos/asf/maven-apache-resources.git

commit 901a8093315d395d561b95638013f2b8576dd54e
Author: Konrad Windszus <k...@apache.org>
AuthorDate: Fri Jul 19 17:15:15 2024 +0200

    [MASFRES-69] Also exclude deeply nested target directories
    
    Add single module test
    Add test already having a target directory (simulating build without
    clean)
---
 .../main/resources/assemblies/source-shared.xml    |  2 +-
 ...ZipAndTarCreation.java => IT_SingleModule.java} | 25 +++-------
 .../java/org/apache/its/IT_ZipAndTarCreation.java  |  1 -
 .../build-output-dir-child1/.gitignore             |  3 ++
 .../build-output-dir-child1/target/dummy.txt       | 16 ++++++
 .../src/test/resources/build-output-dir/pom.xml    |  2 +-
 .../{build-output-dir => single-module}/pom.xml    | 20 +++++---
 .../src/main/java/org/apache/assembly/it/App.java  | 32 ++++++++++++
 .../main/resources/META-INF/plexus/components.xml  | 24 +++++++++
 .../test/java/org/apache/assembly/it/AppTest.java  | 57 ++++++++++++++++++++++
 10 files changed, 152 insertions(+), 30 deletions(-)

diff --git a/source-release/src/main/resources/assemblies/source-shared.xml 
b/source-release/src/main/resources/assemblies/source-shared.xml
index 7fb04d6..7363b74 100644
--- a/source-release/src/main/resources/assemblies/source-shared.xml
+++ b/source-release/src/main/resources/assemblies/source-shared.xml
@@ -27,7 +27,7 @@
       <useDefaultExcludes>true</useDefaultExcludes>
       <excludes>
         <!-- build output -->
-        
<exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)${project.build.directory}(/.*)?]</exclude>
+        
<exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?${project.build.directory}(/.*)?]</exclude>
 
         <!-- NOTE: Most of the following excludes should not be required
              if the standard release process is followed. This is because the
diff --git 
a/source-release/src/test/java/org/apache/its/IT_ZipAndTarCreation.java 
b/source-release/src/test/java/org/apache/its/IT_SingleModule.java
similarity index 63%
copy from source-release/src/test/java/org/apache/its/IT_ZipAndTarCreation.java
copy to source-release/src/test/java/org/apache/its/IT_SingleModule.java
index d415b75..aa75a3b 100644
--- a/source-release/src/test/java/org/apache/its/IT_ZipAndTarCreation.java
+++ b/source-release/src/test/java/org/apache/its/IT_SingleModule.java
@@ -21,7 +21,6 @@ package org.apache.its;
 import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -30,16 +29,14 @@ import org.apache.maven.it.VerificationException;
 import org.apache.maven.it.Verifier;
 import org.junit.Test;
 
-import static org.apache.its.util.TestUtils.archivePathFromChild;
 import static org.apache.its.util.TestUtils.archivePathFromProject;
-import static org.apache.its.util.TestUtils.assertTarContents;
 import static org.apache.its.util.TestUtils.assertZipContents;
 import static org.apache.its.util.TestUtils.createVerifier;
 import static org.apache.its.util.TestUtils.getTestDir;
 
-public class IT_ZipAndTarCreation {
+public class IT_SingleModule {
 
-    private static final String BASENAME = "zip-and-tar";
+    private static final String BASENAME = "single-module";
     private static final String VERSION = "1";
 
     @Test
@@ -53,30 +50,20 @@ public class IT_ZipAndTarCreation {
         verifier.verifyErrorFreeLog();
         verifier.resetStreams();
 
-        // make sure the tar did NOT get created by default
-        File tarAssemblyFile = new File(testDir, "target/" + BASENAME + "-" + 
VERSION + "-source-release.tar.gz");
-        Assert.assertTrue("tar assembly should  have been created", 
tarAssemblyFile.exists());
-
         File zipAssemblyFile = new File(testDir, "target/" + BASENAME + "-" + 
VERSION + "-source-release.zip");
         Assert.assertTrue("zip assembly should  have been created", 
zipAssemblyFile.exists());
 
         Set<String> required = new HashSet<>();
 
         required.add(archivePathFromProject(BASENAME, VERSION, "/pom.xml"));
-        required.add(archivePathFromChild(BASENAME, VERSION, "child1", 
"pom.xml"));
-        required.add(archivePathFromChild(BASENAME, VERSION, "child2", 
"/pom.xml"));
 
-        required.add(
-                archivePathFromChild(BASENAME, VERSION, "child1", 
"/src/main/java/org/apache/assembly/it/App.java"));
-        required.add(archivePathFromChild(
-                BASENAME, VERSION, "child1", 
"/src/main/resources/META-INF/plexus/components.xml"));
+        required.add(archivePathFromProject(BASENAME, VERSION, 
"/src/main/java/org/apache/assembly/it/App.java"));
+        required.add(archivePathFromProject(BASENAME, VERSION, 
"/src/main/resources/META-INF/plexus/components.xml"));
 
-        required.add(
-                archivePathFromChild(BASENAME, VERSION, "child2", 
"/src/main/java/org/apache/assembly/it/App.java"));
+        Set<String> banned = new HashSet<>();
 
-        Set<String> banned = Collections.emptySet();
+        banned.add(archivePathFromProject(BASENAME, VERSION, "/target"));
 
         assertZipContents(required, banned, zipAssemblyFile);
-        assertTarContents(required, banned, tarAssemblyFile);
     }
 }
diff --git 
a/source-release/src/test/java/org/apache/its/IT_ZipAndTarCreation.java 
b/source-release/src/test/java/org/apache/its/IT_ZipAndTarCreation.java
index d415b75..258cecc 100644
--- a/source-release/src/test/java/org/apache/its/IT_ZipAndTarCreation.java
+++ b/source-release/src/test/java/org/apache/its/IT_ZipAndTarCreation.java
@@ -53,7 +53,6 @@ public class IT_ZipAndTarCreation {
         verifier.verifyErrorFreeLog();
         verifier.resetStreams();
 
-        // make sure the tar did NOT get created by default
         File tarAssemblyFile = new File(testDir, "target/" + BASENAME + "-" + 
VERSION + "-source-release.tar.gz");
         Assert.assertTrue("tar assembly should  have been created", 
tarAssemblyFile.exists());
 
diff --git 
a/source-release/src/test/resources/build-output-dir/build-output-dir-child1/.gitignore
 
b/source-release/src/test/resources/build-output-dir/build-output-dir-child1/.gitignore
new file mode 100644
index 0000000..b97970d
--- /dev/null
+++ 
b/source-release/src/test/resources/build-output-dir/build-output-dir-child1/.gitignore
@@ -0,0 +1,3 @@
+!*
+target/*
+!target/dummy.txt
\ No newline at end of file
diff --git 
a/source-release/src/test/resources/build-output-dir/build-output-dir-child1/target/dummy.txt
 
b/source-release/src/test/resources/build-output-dir/build-output-dir-child1/target/dummy.txt
new file mode 100644
index 0000000..287f9b1
--- /dev/null
+++ 
b/source-release/src/test/resources/build-output-dir/build-output-dir-child1/target/dummy.txt
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
\ No newline at end of file
diff --git a/source-release/src/test/resources/build-output-dir/pom.xml 
b/source-release/src/test/resources/build-output-dir/pom.xml
index 4fb644b..c180c95 100644
--- a/source-release/src/test/resources/build-output-dir/pom.xml
+++ b/source-release/src/test/resources/build-output-dir/pom.xml
@@ -59,7 +59,7 @@ under the License.
               <goal>single</goal>
             </goals>
             <configuration>
-              <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
+              <!--<runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>-->
               <descriptorRefs>
                 <descriptorRef>source-release</descriptorRef>
               </descriptorRefs>
diff --git a/source-release/src/test/resources/build-output-dir/pom.xml 
b/source-release/src/test/resources/single-module/pom.xml
similarity index 90%
copy from source-release/src/test/resources/build-output-dir/pom.xml
copy to source-release/src/test/resources/single-module/pom.xml
index 4fb644b..0015403 100644
--- a/source-release/src/test/resources/build-output-dir/pom.xml
+++ b/source-release/src/test/resources/single-module/pom.xml
@@ -24,19 +24,23 @@ under the License.
   <modelVersion>4.0.0</modelVersion>
 
   <groupId>org.apache.assembly.it</groupId>
-  <artifactId>build-output-dir</artifactId>
+  <artifactId>single-module</artifactId>
   <version>1</version>
-  <packaging>pom</packaging>
+  <packaging>jar</packaging>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
-  
-  <modules>
-    <module>build-output-dir-child1</module>
-    <module>build-output-dir-child2</module>
-  </modules>
-  
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
   <build>
     <plugins>
       <plugin>
diff --git 
a/source-release/src/test/resources/single-module/src/main/java/org/apache/assembly/it/App.java
 
b/source-release/src/test/resources/single-module/src/main/java/org/apache/assembly/it/App.java
new file mode 100644
index 0000000..02b2fdf
--- /dev/null
+++ 
b/source-release/src/test/resources/single-module/src/main/java/org/apache/assembly/it/App.java
@@ -0,0 +1,32 @@
+package org.apache.assembly.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Hello world!
+ *
+ */
+public class App 
+{
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello World!" );
+    }
+}
diff --git 
a/source-release/src/test/resources/single-module/src/main/resources/META-INF/plexus/components.xml
 
b/source-release/src/test/resources/single-module/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 0000000..047058a
--- /dev/null
+++ 
b/source-release/src/test/resources/single-module/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,24 @@
+<?xml version='1.0'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<component-set>
+  <components>
+  </components>
+</component-set>
\ No newline at end of file
diff --git 
a/source-release/src/test/resources/single-module/src/test/java/org/apache/assembly/it/AppTest.java
 
b/source-release/src/test/resources/single-module/src/test/java/org/apache/assembly/it/AppTest.java
new file mode 100644
index 0000000..c6b11d0
--- /dev/null
+++ 
b/source-release/src/test/resources/single-module/src/test/java/org/apache/assembly/it/AppTest.java
@@ -0,0 +1,57 @@
+package org.apache.assembly.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest 
+    extends TestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertTrue( true );
+    }
+}

Reply via email to