Skip to content

Commit b64ef89

Browse files
committed
[MASFRES-69] Also exclude deeply nested target directories
Add single module test Add test already having a target directory (simulating build without clean)
1 parent fd9bcef commit b64ef89

File tree

9 files changed

+286
-2
lines changed

9 files changed

+286
-2
lines changed

source-release/src/main/resources/assemblies/source-shared.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<useDefaultExcludes>true</useDefaultExcludes>
2828
<excludes>
2929
<!-- build output -->
30-
<exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)${project.build.directory}(/.*)?]</exclude>
30+
<exclude>%regex[(?!((?!${project.build.directory}/)[^/]+/)*src/)(.*/)?${project.build.directory}(/.*)?]</exclude>
3131

3232
<!-- NOTE: Most of the following excludes should not be required
3333
if the standard release process is followed. This is because the
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 junit.framework.Assert;
28+
import org.apache.maven.it.VerificationException;
29+
import org.apache.maven.it.Verifier;
30+
import org.junit.Test;
31+
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.createVerifier;
35+
import static org.apache.its.util.TestUtils.getTestDir;
36+
37+
public class IT_SingleModule {
38+
39+
private static final String BASENAME = "single-module";
40+
private static final String VERSION = "1";
41+
42+
@Test
43+
public void execute() throws VerificationException, IOException, URISyntaxException {
44+
File testDir = getTestDir(BASENAME);
45+
46+
Verifier verifier = createVerifier(testDir);
47+
48+
verifier.executeGoal("package");
49+
50+
verifier.verifyErrorFreeLog();
51+
verifier.resetStreams();
52+
53+
File zipAssemblyFile = new File(testDir, "target/" + BASENAME + "-" + VERSION + "-source-release.zip");
54+
Assert.assertTrue("zip assembly should have been created", zipAssemblyFile.exists());
55+
56+
Set<String> required = new HashSet<>();
57+
58+
required.add(archivePathFromProject(BASENAME, VERSION, "/pom.xml"));
59+
60+
required.add(archivePathFromProject(BASENAME, VERSION, "/src/main/java/org/apache/assembly/it/App.java"));
61+
required.add(archivePathFromProject(BASENAME, VERSION, "/src/main/resources/META-INF/plexus/components.xml"));
62+
63+
Set<String> banned = new HashSet<>();
64+
65+
banned.add(archivePathFromProject(BASENAME, VERSION, "/target"));
66+
67+
assertZipContents(required, banned, zipAssemblyFile);
68+
}
69+
}

source-release/src/test/java/org/apache/its/IT_ZipAndTarCreation.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public void execute() throws VerificationException, IOException, URISyntaxExcept
5353
verifier.verifyErrorFreeLog();
5454
verifier.resetStreams();
5555

56-
// make sure the tar did NOT get created by default
5756
File tarAssemblyFile = new File(testDir, "target/" + BASENAME + "-" + VERSION + "-source-release.tar.gz");
5857
Assert.assertTrue("tar assembly should have been created", tarAssemblyFile.exists());
5958

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
!*
2+
target/*
3+
!target/dummy.txt
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
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+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<groupId>org.apache.assembly.it</groupId>
27+
<artifactId>single-module</artifactId>
28+
<version>1</version>
29+
<packaging>jar</packaging>
30+
31+
<properties>
32+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33+
</properties>
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>junit</groupId>
38+
<artifactId>junit</artifactId>
39+
<version>3.8.1</version>
40+
<scope>test</scope>
41+
</dependency>
42+
</dependencies>
43+
44+
<build>
45+
<plugins>
46+
<plugin>
47+
<artifactId>maven-assembly-plugin</artifactId>
48+
<version>@assemblyPluginVersion@</version>
49+
50+
<dependencies>
51+
<dependency>
52+
<groupId>org.apache.apache.resources</groupId>
53+
<artifactId>apache-source-release-assembly-descriptor</artifactId>
54+
<version>@project.version@</version>
55+
</dependency>
56+
</dependencies>
57+
58+
<executions>
59+
<execution>
60+
<id>source-release-assembly</id>
61+
<phase>package</phase>
62+
<goals>
63+
<goal>single</goal>
64+
</goals>
65+
<configuration>
66+
<runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
67+
<descriptorRefs>
68+
<descriptorRef>source-release</descriptorRef>
69+
</descriptorRefs>
70+
</configuration>
71+
</execution>
72+
</executions>
73+
</plugin>
74+
<plugin>
75+
<artifactId>maven-compiler-plugin</artifactId>
76+
<version>3.11.0</version>
77+
<configuration>
78+
<source>1.8</source>
79+
<target>1.8</target>
80+
</configuration>
81+
</plugin>
82+
</plugins>
83+
</build>
84+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.apache.assembly.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+
/**
23+
* Hello world!
24+
*
25+
*/
26+
public class App
27+
{
28+
public static void main( String[] args )
29+
{
30+
System.out.println( "Hello World!" );
31+
}
32+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version='1.0'?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
21+
<component-set>
22+
<components>
23+
</components>
24+
</component-set>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.apache.assembly.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 junit.framework.Test;
23+
import junit.framework.TestCase;
24+
import junit.framework.TestSuite;
25+
26+
/**
27+
* Unit test for simple App.
28+
*/
29+
public class AppTest
30+
extends TestCase
31+
{
32+
/**
33+
* Create the test case
34+
*
35+
* @param testName name of the test case
36+
*/
37+
public AppTest( String testName )
38+
{
39+
super( testName );
40+
}
41+
42+
/**
43+
* @return the suite of tests being tested
44+
*/
45+
public static Test suite()
46+
{
47+
return new TestSuite( AppTest.class );
48+
}
49+
50+
/**
51+
* Rigourous Test :-)
52+
*/
53+
public void testApp()
54+
{
55+
assertTrue( true );
56+
}
57+
}

0 commit comments

Comments
 (0)