diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 932827c..56062b5 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -25,3 +25,7 @@ jobs: build: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 + with: + ff-maven: "4.0.0-beta-3" # Maven version for fail-fast-build + maven-matrix: '[ "4.0.0-beta-3" ]' + jdk-matrix: '[ "17", "21" ]' diff --git a/pom.xml b/pom.xml index 17c90b2..5a3f894 100644 --- a/pom.xml +++ b/pom.xml @@ -23,12 +23,12 @@ under the License. org.apache.maven.plugins maven-plugins - 41 + 42 maven-source-plugin - 3.3.2-SNAPSHOT + 4.0.0-SNAPSHOT maven-plugin Apache Maven Source Plugin @@ -77,17 +77,33 @@ under the License. - 8 - 3.2.5 + 17 + 4.0.0-beta-3 + + 6.0.0 + 5.10.2 + 4.0.0-SNAPSHOT + 4.0.0-SNAPSHOT + 4.0.0-alpha-3-SNAPSHOT + 5.12.0 + 4.9.2 + ${mavenPluginPluginVersion} + 3.7.0 + 2024-03-30T01:49:10Z - commons-io - commons-io - 2.16.1 + org.apache.commons + commons-compress + 1.26.1 + + + com.google.guava + guava + 32.0.1-jre @@ -95,74 +111,100 @@ under the License. org.apache.maven - maven-model + maven-api-core ${mavenVersion} provided org.apache.maven - maven-plugin-api + maven-api-di ${mavenVersion} provided org.apache.maven - maven-artifact + maven-api-model ${mavenVersion} provided org.apache.maven - maven-core + maven-api-meta ${mavenVersion} provided - - - org.apache.maven.plugin-tools - maven-plugin-annotations - provided - - org.apache.maven maven-archiver - 3.6.2 + ${mavenArchiverVersion} org.codehaus.plexus plexus-archiver - 4.9.2 + ${plexusArchiverVersion} org.codehaus.plexus plexus-utils - 3.5.1 org.apache.maven.plugin-testing maven-plugin-testing-harness - 3.3.0 + ${mavenPluginTestingVersion} + test + + + org.apache.maven + maven-core + ${mavenVersion} test org.apache.maven - maven-compat + maven-api-impl ${mavenVersion} test - junit - junit - 4.13.2 + com.google.inject + guice + ${guiceVersion} + test + + + org.junit.jupiter + junit-jupiter-api + ${junitVersion} + test + + + org.mockito + mockito-core + ${mockitoVersion} test + + com.diffplug.spotless + spotless-maven-plugin + + + + src/**/*.java + + + + + **/pom.xml + + + + org.apache.rat apache-rat-plugin diff --git a/src/it/MSOURCES-121/pom.xml b/src/it/MSOURCES-121/pom.xml index 975b8c2..0a0946c 100644 --- a/src/it/MSOURCES-121/pom.xml +++ b/src/it/MSOURCES-121/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.sources @@ -28,12 +25,11 @@ 1.0-SNAPSHOT Test for multiple attachments of files - This build should fail based on the duplicate + This build should fail based on the duplicate execution with the same configuration. This will erroneously add the classifier/file twice. MSOURCES-121. - update with MSOURCES-141: do not fail but detect and not add twice - + update with MSOURCES-141: do not fail but detect and not add twice UTF-8 diff --git a/src/it/MSOURCES-121/src/main/java/MyClass.java b/src/it/MSOURCES-121/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/MSOURCES-121/src/main/java/MyClass.java +++ b/src/it/MSOURCES-121/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/MSOURCES-121/src/test/java/MyTest.java b/src/it/MSOURCES-121/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/MSOURCES-121/src/test/java/MyTest.java +++ b/src/it/MSOURCES-121/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/MSOURCES-121/verify.groovy b/src/it/MSOURCES-121/verify.groovy index e58ef75..308a3c7 100644 --- a/src/it/MSOURCES-121/verify.groovy +++ b/src/it/MSOURCES-121/verify.groovy @@ -19,4 +19,5 @@ File buildLog = new File( basedir, 'build.log' ) -assert buildLog.text =~ /\[ERROR\] Artifact org.apache.maven.its.sources:jar-no-fork:java-source:sources:1.0-SNAPSHOT already attached to a file target.jar-no-fork-1.0-SNAPSHOT-sources.jar: attach to target.jar-no-fork-1.0-SNAPSHOT-secondary-sources.jar should be done with another classifier/ +var fs = File.separatorChar == '\\' ? "\\\\" : "/" +assert buildLog.text =~ /\[ERROR\] Artifact org.apache.maven.its.sources:jar-no-fork:jar:sources:1.0-SNAPSHOT already attached to a file target${fs}jar-no-fork-1.0-SNAPSHOT-sources.jar: attach to target${fs}jar-no-fork-1.0-SNAPSHOT-secondary-sources.jar should be done with another classifier/ diff --git a/src/it/MSOURCES-140/invoker.properties b/src/it/MSOURCES-140/invoker.properties index 54abe94..cfb882b 100644 --- a/src/it/MSOURCES-140/invoker.properties +++ b/src/it/MSOURCES-140/invoker.properties @@ -16,3 +16,6 @@ # under the License. invoker.buildResult = success invoker.goals = package clean install + +# maven 4.0.0-beta-3 is broken because of https://github.com/apache/maven/pull/1587 +invoker.maven.version = 4.0.0-beta-4+ \ No newline at end of file diff --git a/src/it/MSOURCES-140/pom.xml b/src/it/MSOURCES-140/pom.xml index c22d234..6dba478 100644 --- a/src/it/MSOURCES-140/pom.xml +++ b/src/it/MSOURCES-140/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.sources diff --git a/src/it/MSOURCES-140/src/main/java/MyClass.java b/src/it/MSOURCES-140/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/MSOURCES-140/src/main/java/MyClass.java +++ b/src/it/MSOURCES-140/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/MSOURCES-140/src/test/java/MyTest.java b/src/it/MSOURCES-140/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/MSOURCES-140/src/test/java/MyTest.java +++ b/src/it/MSOURCES-140/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/MSOURCES-140/verify.groovy b/src/it/MSOURCES-140/verify.groovy index 8cc6491..e9b0fd2 100644 --- a/src/it/MSOURCES-140/verify.groovy +++ b/src/it/MSOURCES-140/verify.groovy @@ -19,4 +19,4 @@ File buildLog = new File( basedir, 'build.log' ) -assert buildLog.text =~ /\[INFO\] Artifact org.apache.maven.its.sources:jar-no-fork:java-source:sources:1.0-SNAPSHOT already attached to target.jar-no-fork-1.0-SNAPSHOT-sources.jar: ignoring same re-attach \(same artifact, same file\)/ +assert buildLog.text =~ /\[INFO\] Artifact org.apache.maven.its.sources:jar-no-fork:jar:sources:1.0-SNAPSHOT already attached to target" + File.separator + "jar-no-fork-1.0-SNAPSHOT-sources.jar: ignoring same re-attach \(same artifact, same file\)/ diff --git a/src/it/MSOURCES-62/pom.xml b/src/it/MSOURCES-62/pom.xml index 672b413..1a7f1b6 100644 --- a/src/it/MSOURCES-62/pom.xml +++ b/src/it/MSOURCES-62/pom.xml @@ -17,9 +17,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + 4.0.0 org.apache.maven.its.ejb @@ -41,7 +39,6 @@ under the License. package - true false true diff --git a/src/it/MSOURCES-64/pom.xml b/src/it/MSOURCES-64/pom.xml index 8bd16b7..8875adf 100644 --- a/src/it/MSOURCES-64/pom.xml +++ b/src/it/MSOURCES-64/pom.xml @@ -17,9 +17,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + 4.0.0 org.apache.maven.its.ejb diff --git a/src/it/MSOURCES-95/pom.xml b/src/it/MSOURCES-95/pom.xml index e16d8c6..c817554 100644 --- a/src/it/MSOURCES-95/pom.xml +++ b/src/it/MSOURCES-95/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.source diff --git a/src/it/jar-attached/pom.xml b/src/it/jar-attached/pom.xml index 7610fd5..5c6eb1c 100644 --- a/src/it/jar-attached/pom.xml +++ b/src/it/jar-attached/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb @@ -42,11 +39,10 @@ attach-sources - - jar + diff --git a/src/it/jar-attached/src/main/java/MyClass.java b/src/it/jar-attached/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/jar-attached/src/main/java/MyClass.java +++ b/src/it/jar-attached/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/jar-classifier/pom.xml b/src/it/jar-classifier/pom.xml index 4cf075e..95cc2e2 100644 --- a/src/it/jar-classifier/pom.xml +++ b/src/it/jar-classifier/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb @@ -50,13 +47,13 @@ generated-sources - generate-sources run + generate-sources - + target/generated-sources/ant diff --git a/src/it/jar-classifier/src/main/java/MyClass.java b/src/it/jar-classifier/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/jar-classifier/src/main/java/MyClass.java +++ b/src/it/jar-classifier/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/jar-classifier/src/test/java/MyTest.java b/src/it/jar-classifier/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/jar-classifier/src/test/java/MyTest.java +++ b/src/it/jar-classifier/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/jar-includes-excludes/pom.xml b/src/it/jar-includes-excludes/pom.xml index b0c3f75..f651d95 100644 --- a/src/it/jar-includes-excludes/pom.xml +++ b/src/it/jar-includes-excludes/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb diff --git a/src/it/jar-includes-excludes/src/main/java/MyClass.java b/src/it/jar-includes-excludes/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/jar-includes-excludes/src/main/java/MyClass.java +++ b/src/it/jar-includes-excludes/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/jar-includes-excludes/src/main/java/MyClass2.java b/src/it/jar-includes-excludes/src/main/java/MyClass2.java index 9c66faa..0a27e41 100644 --- a/src/it/jar-includes-excludes/src/main/java/MyClass2.java +++ b/src/it/jar-includes-excludes/src/main/java/MyClass2.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass2 -{ - -} +public class MyClass2 {} diff --git a/src/it/jar-includes-excludes/src/test/java/MyTest.java b/src/it/jar-includes-excludes/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/jar-includes-excludes/src/test/java/MyTest.java +++ b/src/it/jar-includes-excludes/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/jar-includes-excludes/src/test/java/MyTest2.java b/src/it/jar-includes-excludes/src/test/java/MyTest2.java index 6a8440e..f5063f0 100644 --- a/src/it/jar-includes-excludes/src/test/java/MyTest2.java +++ b/src/it/jar-includes-excludes/src/test/java/MyTest2.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest2 -{ - -} +public class MyTest2 {} diff --git a/src/it/jar-no-fork/pom.xml b/src/it/jar-no-fork/pom.xml index 22967cc..9f01a1b 100644 --- a/src/it/jar-no-fork/pom.xml +++ b/src/it/jar-no-fork/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb diff --git a/src/it/jar-no-fork/src/main/java/MyClass.java b/src/it/jar-no-fork/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/jar-no-fork/src/main/java/MyClass.java +++ b/src/it/jar-no-fork/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/jar-no-fork/src/test/java/MyTest.java b/src/it/jar-no-fork/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/jar-no-fork/src/test/java/MyTest.java +++ b/src/it/jar-no-fork/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/jar-with-archive-config/pom.xml b/src/it/jar-with-archive-config/pom.xml index c89d03f..ae9e01f 100644 --- a/src/it/jar-with-archive-config/pom.xml +++ b/src/it/jar-with-archive-config/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb diff --git a/src/it/jar-with-archive-config/src/main/java/MyClass.java b/src/it/jar-with-archive-config/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/jar-with-archive-config/src/main/java/MyClass.java +++ b/src/it/jar-with-archive-config/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/jar-with-archive-config/src/test/java/MyTest.java b/src/it/jar-with-archive-config/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/jar-with-archive-config/src/test/java/MyTest.java +++ b/src/it/jar-with-archive-config/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/jar-without-descriptor-config/pom.xml b/src/it/jar-without-descriptor-config/pom.xml index b2801d9..7806151 100644 --- a/src/it/jar-without-descriptor-config/pom.xml +++ b/src/it/jar-without-descriptor-config/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb diff --git a/src/it/jar-without-descriptor-config/src/main/java/MyClass.java b/src/it/jar-without-descriptor-config/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/jar-without-descriptor-config/src/main/java/MyClass.java +++ b/src/it/jar-without-descriptor-config/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/jar-without-descriptor-config/src/test/java/MyTest.java b/src/it/jar-without-descriptor-config/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/jar-without-descriptor-config/src/test/java/MyTest.java +++ b/src/it/jar-without-descriptor-config/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/jar/pom.xml b/src/it/jar/pom.xml index 5d58b14..d80aec8 100644 --- a/src/it/jar/pom.xml +++ b/src/it/jar/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb @@ -47,13 +44,13 @@ generated-sources - generate-sources run + generate-sources - + target/generated-sources/ant diff --git a/src/it/jar/src/main/java/MyClass.java b/src/it/jar/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/jar/src/main/java/MyClass.java +++ b/src/it/jar/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/jar/src/test/java/MyTest.java b/src/it/jar/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/jar/src/test/java/MyTest.java +++ b/src/it/jar/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/manifest-content/pom.xml b/src/it/manifest-content/pom.xml index f7fcb96..ab8f4b2 100644 --- a/src/it/manifest-content/pom.xml +++ b/src/it/manifest-content/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb diff --git a/src/it/manifest-content/src/main/java/MyClass.java b/src/it/manifest-content/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/manifest-content/src/main/java/MyClass.java +++ b/src/it/manifest-content/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/project-without-sources/pom.xml b/src/it/project-without-sources/pom.xml index f08ace1..7adb6eb 100755 --- a/src/it/project-without-sources/pom.xml +++ b/src/it/project-without-sources/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb diff --git a/src/it/reproducible/pom.xml b/src/it/reproducible/pom.xml index 2945352..d726b19 100644 --- a/src/it/reproducible/pom.xml +++ b/src/it/reproducible/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 diff --git a/src/it/test-jar-classifier/pom.xml b/src/it/test-jar-classifier/pom.xml index 9261396..68e1b91 100644 --- a/src/it/test-jar-classifier/pom.xml +++ b/src/it/test-jar-classifier/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb @@ -50,13 +47,13 @@ generated-sources - generate-sources run + generate-sources - + target/generated-sources/ant diff --git a/src/it/test-jar-classifier/src/main/java/MyClass.java b/src/it/test-jar-classifier/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/test-jar-classifier/src/main/java/MyClass.java +++ b/src/it/test-jar-classifier/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/test-jar-classifier/src/test/java/MyTest.java b/src/it/test-jar-classifier/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/test-jar-classifier/src/test/java/MyTest.java +++ b/src/it/test-jar-classifier/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/test-jar-generated/pom.xml b/src/it/test-jar-generated/pom.xml index 7b75d28..e83a133 100644 --- a/src/it/test-jar-generated/pom.xml +++ b/src/it/test-jar-generated/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb @@ -47,26 +44,26 @@ generated-sources - generate-sources run + generate-sources - + target/generated-sources/ant generate-test-sources - generate-test-sources run + generate-test-sources - + target/generated-sources/ant diff --git a/src/it/test-jar-generated/src/main/java/MyClass.java b/src/it/test-jar-generated/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/test-jar-generated/src/main/java/MyClass.java +++ b/src/it/test-jar-generated/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/test-jar-generated/src/test/java/MyTest.java b/src/it/test-jar-generated/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/test-jar-generated/src/test/java/MyTest.java +++ b/src/it/test-jar-generated/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/test-jar-no-fork/pom.xml b/src/it/test-jar-no-fork/pom.xml index f3d16c9..49e3c87 100644 --- a/src/it/test-jar-no-fork/pom.xml +++ b/src/it/test-jar-no-fork/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb diff --git a/src/it/test-jar-no-fork/src/main/java/MyClass.java b/src/it/test-jar-no-fork/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/test-jar-no-fork/src/main/java/MyClass.java +++ b/src/it/test-jar-no-fork/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/test-jar-no-fork/src/test/java/MyTest.java b/src/it/test-jar-no-fork/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/test-jar-no-fork/src/test/java/MyTest.java +++ b/src/it/test-jar-no-fork/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/test-jar/pom.xml b/src/it/test-jar/pom.xml index 116f387..88fab51 100644 --- a/src/it/test-jar/pom.xml +++ b/src/it/test-jar/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.ejb @@ -47,13 +44,13 @@ generated-sources - generate-sources run + generate-sources - + target/generated-sources/ant diff --git a/src/it/test-jar/src/main/java/MyClass.java b/src/it/test-jar/src/main/java/MyClass.java index 4945381..22ad741 100644 --- a/src/it/test-jar/src/main/java/MyClass.java +++ b/src/it/test-jar/src/main/java/MyClass.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyClass -{ - -} +public class MyClass {} diff --git a/src/it/test-jar/src/test/java/MyTest.java b/src/it/test-jar/src/test/java/MyTest.java index 9d124be..b4eec60 100644 --- a/src/it/test-jar/src/test/java/MyTest.java +++ b/src/it/test-jar/src/test/java/MyTest.java @@ -6,9 +6,9 @@ * 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 @@ -16,8 +16,4 @@ * specific language governing permissions and limitations * under the License. */ - -public class MyTest -{ - -} +public class MyTest {} diff --git a/src/it/verify-parameter-goal-generated-test-jar/pom.xml b/src/it/verify-parameter-goal-generated-test-jar/pom.xml index 4fb98cf..59c5554 100755 --- a/src/it/verify-parameter-goal-generated-test-jar/pom.xml +++ b/src/it/verify-parameter-goal-generated-test-jar/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.source diff --git a/src/it/verify-parameter-goal-jar-no-fork/pom.xml b/src/it/verify-parameter-goal-jar-no-fork/pom.xml index bfec931..d6fae5c 100755 --- a/src/it/verify-parameter-goal-jar-no-fork/pom.xml +++ b/src/it/verify-parameter-goal-jar-no-fork/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.source diff --git a/src/it/verify-parameter-goal-jar/pom.xml b/src/it/verify-parameter-goal-jar/pom.xml index 4bf4173..b898fbb 100755 --- a/src/it/verify-parameter-goal-jar/pom.xml +++ b/src/it/verify-parameter-goal-jar/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.source diff --git a/src/it/verify-parameter-goal-test-jar-no-fork/pom.xml b/src/it/verify-parameter-goal-test-jar-no-fork/pom.xml index 8a8e1ad..ea4ecd8 100755 --- a/src/it/verify-parameter-goal-test-jar-no-fork/pom.xml +++ b/src/it/verify-parameter-goal-test-jar-no-fork/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.source diff --git a/src/it/verify-parameter-goal-test-jar/pom.xml b/src/it/verify-parameter-goal-test-jar/pom.xml index 8591932..26e60aa 100755 --- a/src/it/verify-parameter-goal-test-jar/pom.xml +++ b/src/it/verify-parameter-goal-test-jar/pom.xml @@ -17,10 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - + 4.0.0 org.apache.maven.its.source diff --git a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java index 284d2f1..d8f1747 100644 --- a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java @@ -19,30 +19,32 @@ package org.apache.maven.plugins.source; import java.io.File; -import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; +import org.apache.maven.api.Artifact; +import org.apache.maven.api.Project; +import org.apache.maven.api.Session; +import org.apache.maven.api.Type; +import org.apache.maven.api.di.Inject; +import org.apache.maven.api.model.Resource; +import org.apache.maven.api.plugin.Log; +import org.apache.maven.api.plugin.Mojo; +import org.apache.maven.api.plugin.MojoException; +import org.apache.maven.api.plugin.annotations.Parameter; +import org.apache.maven.api.services.ArtifactManager; +import org.apache.maven.api.services.ProjectManager; import org.apache.maven.archiver.MavenArchiveConfiguration; import org.apache.maven.archiver.MavenArchiver; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DependencyResolutionRequiredException; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectHelper; import org.codehaus.plexus.archiver.Archiver; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.jar.JarArchiver; -import org.codehaus.plexus.archiver.jar.ManifestException; import org.codehaus.plexus.archiver.util.DefaultFileSet; import org.codehaus.plexus.util.FileUtils; @@ -51,7 +53,7 @@ * * @since 2.0.3 */ -public abstract class AbstractSourceJarMojo extends AbstractMojo { +public abstract class AbstractSourceJarMojo implements Mojo { private static final String[] DEFAULT_INCLUDES = new String[] {"**/**"}; private static final String[] DEFAULT_EXCLUDES = new String[] {}; @@ -63,7 +65,7 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { * @since 2.1 */ @Parameter - private String[] includes; + protected String[] includes; /** * List of files to exclude. Specified as fileset patterns which are relative to the input directory whose contents @@ -72,7 +74,7 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { * @since 2.1 */ @Parameter - private String[] excludes; + protected String[] excludes; /** * Exclude commonly excluded files such as SCM configuration. These are defined in the plexus @@ -81,19 +83,19 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { * @since 2.1 */ @Parameter(property = "maven.source.useDefaultExcludes", defaultValue = "true") - private boolean useDefaultExcludes; + protected boolean useDefaultExcludes; /** * The Maven Project Object */ - @Parameter(defaultValue = "${project}", readonly = true, required = true) - private MavenProject project; + @Inject + protected Project project; /** * The Jar archiver. */ - @Component(role = Archiver.class, hint = "jar") - private JarArchiver jarArchiver; + @Inject + protected JarArchiver jarArchiver; /** * The archive configuration to use. See Maven @@ -105,7 +107,7 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { * @since 2.1 */ @Parameter - private MavenArchiveConfiguration archive = new MavenArchiveConfiguration(); + protected MavenArchiveConfiguration archive = new MavenArchiveConfiguration(); /** * Path to the default MANIFEST file to use. It will be used if useDefaultManifestFile is set to @@ -119,7 +121,7 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { readonly = false, required = true) // CHECKSTYLE_ON: LineLength - private File defaultManifestFile; + protected Path defaultManifestFile; /** * Set this to true to enable the use of the defaultManifestFile.
@@ -127,16 +129,16 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { * @since 2.1 */ @Parameter(property = "maven.source.useDefaultManifestFile", defaultValue = "false") - private boolean useDefaultManifestFile; + protected boolean useDefaultManifestFile; /** - * Specifies whether or not to attach the artifact to the project + * Specifies whether to attach the artifact to the project */ @Parameter(property = "maven.source.attach", defaultValue = "true") - private boolean attach; + protected boolean attach; /** - * Specifies whether or not to exclude resources from the sources-jar. This can be convenient if your project + * Specifies whether to exclude resources from the sources-jar. This can be convenient if your project * includes large resources, such as images, and you don't want to include them in the sources-jar. * * @since 2.0.4 @@ -145,24 +147,18 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { protected boolean excludeResources; /** - * Specifies whether or not to include the POM file in the sources-jar. + * Specifies whether to include the POM file in the sources-jar. * * @since 2.1 */ @Parameter(property = "maven.source.includePom", defaultValue = "false") protected boolean includePom; - /** - * Used for attaching the source jar to the project. - */ - @Component - private MavenProjectHelper projectHelper; - /** * The directory where the generated archive file will be put. */ @Parameter(defaultValue = "${project.build.directory}") - protected File outputDirectory; + protected Path outputDirectory; /** * The filename to be used for the generated archive file. For the source:jar goal, "-sources" is appended to this @@ -174,8 +170,8 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { /** * Contains the full list of projects in the reactor. */ - @Parameter(defaultValue = "${reactorProjects}", readonly = true) - protected List reactorProjects; + @Parameter(defaultValue = "${session.projects}", readonly = true) + protected List reactorProjects; /** * Whether creating the archive should be forced. If set to true, the jar will always be created. If set to false, @@ -184,7 +180,7 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { * @since 2.1 */ @Parameter(property = "maven.source.forceCreation", defaultValue = "false") - private boolean forceCreation; + protected boolean forceCreation; /** * A flag used to disable the source procedure. This is primarily intended for usage from the command line to @@ -193,13 +189,13 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { * @since 2.2 */ @Parameter(property = "maven.source.skip", defaultValue = "false") - private boolean skipSource; + protected boolean skipSource; /** * The Maven session. */ - @Parameter(defaultValue = "${session}", readonly = true, required = true) - private MavenSession session; + @Inject + protected Session session; /** * Timestamp for reproducible output archive entries, either formatted as ISO 8601 @@ -209,21 +205,38 @@ public abstract class AbstractSourceJarMojo extends AbstractMojo { * @since 3.2.0 */ @Parameter(defaultValue = "${project.build.outputTimestamp}") - private String outputTimestamp; + protected String outputTimestamp; + + @Inject + protected Log log; + + /** + * Used for attaching the source jar to the project. + */ + protected ProjectManager projectManager; // ---------------------------------------------------------------------- // Public methods // ---------------------------------------------------------------------- + public Log getLog() { + return log; + } + /** * {@inheritDoc} */ - public void execute() throws MojoExecutionException { + public void execute() throws MojoException { if (skipSource) { getLog().info("Skipping source per configuration."); return; } + projectManager = session.getService(ProjectManager.class); + doExecute(); + } + + protected void doExecute() { packageSources(project); } @@ -237,48 +250,51 @@ public void execute() throws MojoExecutionException { protected abstract String getClassifier(); /** - * @param p {@link MavenProject} not null + * @param p {@link Project} not null * @return the compile or test sources - * @throws MojoExecutionException in case of an error. + * @throws MojoException in case of an error. */ - protected abstract List getSources(MavenProject p) throws MojoExecutionException; + protected abstract List getSources(Project p) throws MojoException; /** - * @param p {@link MavenProject} not null + * @param p {@link Project} not null * @return the compile or test resources - * @throws MojoExecutionException in case of an error. + * @throws MojoException in case of an error. */ - protected abstract List getResources(MavenProject p) throws MojoExecutionException; + protected abstract List getResources(Project p) throws MojoException; /** - * @param p {@link MavenProject} - * @throws MojoExecutionException in case of an error. + * @param p {@link Project} + * @throws MojoException in case of an error. */ - protected void packageSources(MavenProject p) throws MojoExecutionException { - if (!"pom".equals(p.getPackaging())) { + protected void packageSources(Project p) throws MojoException { + String type = p.getPackaging().type().id(); + if (!Type.POM.equals(type) && !Type.BOM.equals(type)) { packageSources(Collections.singletonList(p)); } } /** - * @param theProjects {@link MavenProject} - * @throws MojoExecutionException in case of an error. + * @param theProjects {@link Project} + * @throws MojoException in case of an error. */ - protected void packageSources(List theProjects) throws MojoExecutionException { - if (project.getArtifact().getClassifier() != null) { + protected void packageSources(List theProjects) throws MojoException { + Artifact currentProjectArtifact = project.getMainArtifact().get(); + if (!currentProjectArtifact.getClassifier().isEmpty()) { getLog().warn("NOT adding sources to artifacts with classifier as Maven only supports one classifier " - + "per artifact. Current artifact [" + project.getArtifact().getId() + "] has a [" - + project.getArtifact().getClassifier() + "] classifier."); + + "per artifact. Current artifact [" + currentProjectArtifact.key() + "] has a [" + + currentProjectArtifact.getClassifier() + "] classifier."); return; } MavenArchiver archiver = createArchiver(); - for (MavenProject pItem : theProjects) { - MavenProject subProject = getProject(pItem); + for (Project pItem : theProjects) { + Project subProject = getProject(pItem); - if ("pom".equals(subProject.getPackaging())) { + String type = subProject.getPackaging().type().id(); + if (Type.POM.equals(type) || Type.BOM.equals(type)) { continue; } @@ -287,46 +303,52 @@ protected void packageSources(List theProjects) throws MojoExecuti if (archiver.getArchiver().getResources().hasNext() || forceCreation) { - if (useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile() == null) { - getLog().info("Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath()); + if (useDefaultManifestFile && Files.exists(defaultManifestFile) && archive.getManifestFile() == null) { + getLog().info("Adding existing MANIFEST to archive. Found under: " + defaultManifestFile); archive.setManifestFile(defaultManifestFile); } - File outputFile = new File(outputDirectory, finalName + "-" + getClassifier() + getExtension()); + Path outputFile = outputDirectory.resolve(finalName + "-" + getClassifier() + getExtension()); try { - archiver.setOutputFile(outputFile); + archiver.setOutputFile(outputFile.toFile()); archive.setForced(forceCreation); getLog().debug("create archive " + outputFile); archiver.createArchive(session, project, archive); - } catch (IOException | ArchiverException | DependencyResolutionRequiredException | ManifestException e) { - throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e); + } catch (ArchiverException e) { + throw new MojoException("Error creating source archive: " + e.getMessage(), e); } if (attach) { + Artifact artifact = session.createArtifact( + project.getGroupId(), + project.getArtifactId(), + project.getVersion(), + getClassifier(), + null, + getType()); boolean requiresAttach = true; - for (Artifact attachedArtifact : project.getAttachedArtifacts()) { - Artifact previouslyAttachedArtifact = - getPreviouslyAttached(attachedArtifact, project, getClassifier()); - if (previouslyAttachedArtifact != null) { - File previouslyAttachedFile = previouslyAttachedArtifact.getFile(); - // trying to attache the same file/path or not? - if (!outputFile.equals(previouslyAttachedFile)) { - getLog().error("Artifact " + previouslyAttachedArtifact.getId() - + " already attached to a file " + relative(previouslyAttachedFile) + ": attach to " + for (Artifact attachedArtifact : projectManager.getAttachedArtifacts(project)) { + if (Objects.equals(artifact.key(), attachedArtifact.key())) { + Path attachedFile = session.getService(ArtifactManager.class) + .getPath(attachedArtifact) + .orElse(null); + if (attachedFile != null && !outputFile.equals(attachedFile)) { + getLog().error("Artifact " + attachedArtifact.key() + + " already attached to a file " + relative(attachedFile) + ": attach to " + relative(outputFile) + " should be done with another classifier"); - throw new MojoExecutionException("Presumably you have configured maven-source-plugin " + throw new MojoException("Presumably you have configured maven-source-plugin " + "to execute twice in your build to different output files. " + "You have to configure a classifier for at least one of them."); } requiresAttach = false; - getLog().info("Artifact " + previouslyAttachedArtifact.getId() + " already attached to " + getLog().info("Artifact " + attachedArtifact.key() + " already attached to " + relative(outputFile) + ": ignoring same re-attach (same artifact, same file)"); } } if (requiresAttach) { - projectHelper.attachArtifact(project, getType(), getClassifier(), outputFile); + projectManager.attachArtifact(project, artifact, outputFile); } } else { getLog().info("NOT adding java-sources to attached artifacts list."); @@ -336,50 +358,48 @@ protected void packageSources(List theProjects) throws MojoExecuti } } - private String relative(File to) { - Path basedir = project.getBasedir().getAbsoluteFile().toPath(); - return basedir.relativize(to.getAbsoluteFile().toPath()).toString(); + private String relative(Path to) { + Path basedir = project.getBasedir().toAbsolutePath(); + return basedir.relativize(to.toAbsolutePath()).toString(); } - private Artifact getPreviouslyAttached(Artifact artifact, MavenProject checkProject, String classifier) { - return artifact.getType().equals(getType()) + private Artifact getPreviouslyAttached(Artifact artifact, Project checkProject, String classifier) { + return artifact.getExtension().equals(getExtension()) && artifact.getGroupId().equals(checkProject.getGroupId()) && artifact.getArtifactId().equals(checkProject.getArtifactId()) - && artifact.getVersion().equals(checkProject.getVersion()) + && artifact.getVersion().toString().equals(checkProject.getVersion()) && Objects.equals(artifact.getClassifier(), classifier) ? artifact : null; } /** - * @param p {@link MavenProject} + * @param project {@link Project} * @param archiver {@link Archiver} - * @throws MojoExecutionException in case of an error. + * @throws MojoException in case of an error. */ - protected void archiveProjectContent(MavenProject p, Archiver archiver) throws MojoExecutionException { + protected void archiveProjectContent(Project project, Archiver archiver) throws MojoException { if (includePom) { try { - archiver.addFile(p.getFile(), p.getFile().getName()); + File pom = project.getPomPath().toFile(); + archiver.addFile(pom, pom.getName()); } catch (ArchiverException e) { - throw new MojoExecutionException("Error adding POM file to target jar file.", e); + throw new MojoException("Error adding POM file to target jar file.", e); } } - for (String s : getSources(p)) { - - File sourceDirectory = new File(s); - - if (sourceDirectory.exists()) { + for (Path sourceDirectory : getSources(project)) { + if (Files.exists(sourceDirectory)) { addDirectory(archiver, sourceDirectory, getCombinedIncludes(null), getCombinedExcludes(null)); } } // MAPI: this should be taken from the resources plugin - for (Resource resource : getResources(p)) { + for (Resource resource : getResources(project)) { - File sourceDirectory = new File(resource.getDirectory()); + Path sourceDirectory = Paths.get(resource.getDirectory()); - if (!sourceDirectory.exists()) { + if (!Files.exists(sourceDirectory)) { continue; } @@ -405,9 +425,9 @@ protected void archiveProjectContent(MavenProject p, Archiver archiver) throws M /** * @return {@link MavenArchiver} - * @throws MojoExecutionException in case of an error. + * @throws MojoException in case of an error. */ - protected MavenArchiver createArchiver() throws MojoExecutionException { + protected MavenArchiver createArchiver() throws MojoException { MavenArchiver archiver = new MavenArchiver(); archiver.setArchiver(jarArchiver); archiver.setCreatedBy("Maven Source Plugin", "org.apache.maven.plugins", "maven-source-plugin"); @@ -417,13 +437,14 @@ protected MavenArchiver createArchiver() throws MojoExecutionException { archiver.configureReproducibleBuild(outputTimestamp); if (project.getBuild() != null) { - List resources = project.getBuild().getResources(); + List resources = + project.getBuild().getResources(); - for (Resource r : resources) { + for (org.apache.maven.api.model.Resource r : resources) { if (r.getDirectory().endsWith("maven-shared-archive-resources")) { addDirectory( archiver.getArchiver(), - new File(r.getDirectory()), + Paths.get(r.getDirectory()), getCombinedIncludes(null), getCombinedExcludes(null)); } @@ -435,38 +456,39 @@ protected MavenArchiver createArchiver() throws MojoExecutionException { /** * @param archiver {@link Archiver} - * @param sourceDirectory {@link File} + * @param sourceDirectory {@link Path} * @param pIncludes The list of includes. * @param pExcludes The list of excludes. - * @throws MojoExecutionException in case of an error. + * @throws MojoException in case of an error. */ - protected void addDirectory(Archiver archiver, File sourceDirectory, String[] pIncludes, String[] pExcludes) - throws MojoExecutionException { + protected void addDirectory(Archiver archiver, Path sourceDirectory, String[] pIncludes, String[] pExcludes) + throws MojoException { try { getLog().debug("add directory " + sourceDirectory + " to archiver"); - archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory).includeExclude(pIncludes, pExcludes)); + archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory.toFile()).includeExclude(pIncludes, pExcludes)); } catch (ArchiverException e) { - throw new MojoExecutionException("Error adding directory to source archive.", e); + throw new MojoException("Error adding directory to source archive.", e); } } /** * @param archiver {@link Archiver} - * @param sourceDirectory {@link File} + * @param sourceDirectory {@link Path} * @param prefix The prefix. * @param pIncludes the includes. * @param pExcludes the excludes. - * @throws MojoExecutionException in case of an error. + * @throws MojoException in case of an error. */ protected void addDirectory( - Archiver archiver, File sourceDirectory, String prefix, String[] pIncludes, String[] pExcludes) - throws MojoExecutionException { + Archiver archiver, Path sourceDirectory, String prefix, String[] pIncludes, String[] pExcludes) + throws MojoException { try { getLog().debug("add directory " + sourceDirectory + " to archiver with prefix " + prefix); - archiver.addFileSet( - DefaultFileSet.fileSet(sourceDirectory).prefixed(prefix).includeExclude(pIncludes, pExcludes)); + archiver.addFileSet(DefaultFileSet.fileSet(sourceDirectory.toFile()) + .prefixed(prefix) + .includeExclude(pIncludes, pExcludes)); } catch (ArchiverException e) { - throw new MojoExecutionException("Error adding directory to source archive.", e); + throw new MojoException("Error adding directory to source archive.", e); } } @@ -478,15 +500,11 @@ protected String getExtension() { } /** - * @param p {@link MavenProject} + * @param p {@link Project} * @return The execution projet. */ - protected MavenProject getProject(MavenProject p) { - if (p.getExecutionProject() != null) { - return p.getExecutionProject(); - } - - return p; + protected Project getProject(Project p) { + return projectManager.getExecutionProject(p).orElse(p); } /** @@ -554,14 +572,14 @@ private String[] getCombinedExcludes(List additionalExcludes) { /** * @return The current project. */ - protected MavenProject getProject() { + protected Project getProject() { return project; } /** - * @param project {@link MavenProject} + * @param project {@link Project} */ - protected void setProject(MavenProject project) { + protected void setProject(Project project) { this.project = project; } } diff --git a/src/main/java/org/apache/maven/plugins/source/AggregatorSourceJarMojo.java b/src/main/java/org/apache/maven/plugins/source/AggregatorSourceJarMojo.java index 2186bad..329e0a1 100644 --- a/src/main/java/org/apache/maven/plugins/source/AggregatorSourceJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/source/AggregatorSourceJarMojo.java @@ -18,25 +18,25 @@ */ package org.apache.maven.plugins.source; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Execute; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.api.Type; +import org.apache.maven.api.plugin.MojoException; +import org.apache.maven.api.plugin.annotations.Execute; +import org.apache.maven.api.plugin.annotations.Mojo; /** * Aggregate sources for all modules in an aggregator project. * * @since 2.0.3 */ -@Mojo(name = "aggregate", defaultPhase = LifecyclePhase.PACKAGE, aggregator = true, threadSafe = true) -@Execute(phase = LifecyclePhase.GENERATE_SOURCES) +@Mojo(name = "aggregate", defaultPhase = "package", aggregator = true) +@Execute(phase = "generate-sources") public class AggregatorSourceJarMojo extends SourceJarMojo { /** * {@inheritDoc} */ @Override - public void execute() throws MojoExecutionException { - if ("pom".equals(getProject().getPackaging())) { + protected void doExecute() throws MojoException { + if (Type.POM.equals(getProject().getPackaging().type().id())) { packageSources(reactorProjects); } } diff --git a/src/main/java/org/apache/maven/plugins/source/Archivers.java b/src/main/java/org/apache/maven/plugins/source/Archivers.java new file mode 100644 index 0000000..a4a7f33 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/source/Archivers.java @@ -0,0 +1,35 @@ +/* + * 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. + */ +package org.apache.maven.plugins.source; + +import org.apache.maven.api.di.Named; +import org.apache.maven.api.di.Provides; +import org.apache.maven.api.di.Singleton; +import org.codehaus.plexus.archiver.jar.JarArchiver; + +@Named +public class Archivers { + + @Provides + @Singleton + @Named("jar") + static JarArchiver createJarArchiver() { + return new JarArchiver(); + } +} diff --git a/src/main/java/org/apache/maven/plugins/source/SourceJarMojo.java b/src/main/java/org/apache/maven/plugins/source/SourceJarMojo.java index 10dac7e..c40772a 100644 --- a/src/main/java/org/apache/maven/plugins/source/SourceJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/source/SourceJarMojo.java @@ -18,9 +18,8 @@ */ package org.apache.maven.plugins.source; -import org.apache.maven.plugins.annotations.Execute; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.api.plugin.annotations.Execute; +import org.apache.maven.api.plugin.annotations.Mojo; /** * This plugin bundles all the sources into a jar archive. @@ -28,8 +27,8 @@ * @author
Trygve Laugstøl * @since 2.0.3 */ -@Mojo(name = "jar", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true) -@Execute(phase = LifecyclePhase.GENERATE_SOURCES) +@Mojo(name = "jar", defaultPhase = "package") +@Execute(phase = "generate-sources") public class SourceJarMojo extends SourceJarNoForkMojo { // no op } diff --git a/src/main/java/org/apache/maven/plugins/source/SourceJarNoForkMojo.java b/src/main/java/org/apache/maven/plugins/source/SourceJarNoForkMojo.java index e621c74..8495998 100644 --- a/src/main/java/org/apache/maven/plugins/source/SourceJarNoForkMojo.java +++ b/src/main/java/org/apache/maven/plugins/source/SourceJarNoForkMojo.java @@ -18,14 +18,15 @@ */ package org.apache.maven.plugins.source; +import java.nio.file.Path; import java.util.Collections; import java.util.List; -import org.apache.maven.model.Resource; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; +import org.apache.maven.api.Project; +import org.apache.maven.api.ProjectScope; +import org.apache.maven.api.model.Resource; +import org.apache.maven.api.plugin.annotations.Mojo; +import org.apache.maven.api.plugin.annotations.Parameter; /** * This goal bundles all the sources into a jar archive. This goal functions the same as the jar goal but does not fork @@ -34,7 +35,7 @@ * @author pgier * @since 2.1 */ -@Mojo(name = "jar-no-fork", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true) +@Mojo(name = "jar-no-fork", defaultPhase = "package") public class SourceJarNoForkMojo extends AbstractSourceJarMojo { /** * @since 2.2 @@ -45,19 +46,19 @@ public class SourceJarNoForkMojo extends AbstractSourceJarMojo { /** * {@inheritDoc} */ - protected List getSources(MavenProject p) { - return p.getCompileSourceRoots(); + protected List getSources(Project p) { + return projectManager.getCompileSourceRoots(p, ProjectScope.MAIN); } /** * {@inheritDoc} */ - protected List getResources(MavenProject p) { + protected List getResources(Project p) { if (excludeResources) { return Collections.emptyList(); } - return p.getResources(); + return projectManager.getResources(p, ProjectScope.MAIN); } /** diff --git a/src/main/java/org/apache/maven/plugins/source/TestSourceGeneratedJarMojo.java b/src/main/java/org/apache/maven/plugins/source/TestSourceGeneratedJarMojo.java index b04022d..eb42b83 100644 --- a/src/main/java/org/apache/maven/plugins/source/TestSourceGeneratedJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/source/TestSourceGeneratedJarMojo.java @@ -18,17 +18,16 @@ */ package org.apache.maven.plugins.source; -import org.apache.maven.plugins.annotations.Execute; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.api.plugin.annotations.Execute; +import org.apache.maven.api.plugin.annotations.Mojo; /** * This plugin bundles all the test sources into a jar archive. * * @since 2.2 */ -@Mojo(name = "generated-test-jar", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true) -@Execute(phase = LifecyclePhase.GENERATE_TEST_SOURCES) +@Mojo(name = "generated-test-jar", defaultPhase = "package") +@Execute(phase = "generate-test-sources") public class TestSourceGeneratedJarMojo extends TestSourceJarNoForkMojo { // no op } diff --git a/src/main/java/org/apache/maven/plugins/source/TestSourceJarMojo.java b/src/main/java/org/apache/maven/plugins/source/TestSourceJarMojo.java index 5e4de06..dd281dd 100644 --- a/src/main/java/org/apache/maven/plugins/source/TestSourceJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/source/TestSourceJarMojo.java @@ -18,17 +18,16 @@ */ package org.apache.maven.plugins.source; -import org.apache.maven.plugins.annotations.Execute; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.api.plugin.annotations.Execute; +import org.apache.maven.api.plugin.annotations.Mojo; /** * This plugin bundles all the test sources into a jar archive. * * @since 2.0.3 */ -@Mojo(name = "test-jar", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true) -@Execute(phase = LifecyclePhase.GENERATE_SOURCES) +@Mojo(name = "test-jar", defaultPhase = "package") +@Execute(phase = "generate-sources") public class TestSourceJarMojo extends TestSourceJarNoForkMojo { // no op } diff --git a/src/main/java/org/apache/maven/plugins/source/TestSourceJarNoForkMojo.java b/src/main/java/org/apache/maven/plugins/source/TestSourceJarNoForkMojo.java index f9126c6..7763e83 100644 --- a/src/main/java/org/apache/maven/plugins/source/TestSourceJarNoForkMojo.java +++ b/src/main/java/org/apache/maven/plugins/source/TestSourceJarNoForkMojo.java @@ -18,14 +18,15 @@ */ package org.apache.maven.plugins.source; +import java.nio.file.Path; import java.util.Collections; import java.util.List; -import org.apache.maven.model.Resource; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; +import org.apache.maven.api.Project; +import org.apache.maven.api.ProjectScope; +import org.apache.maven.api.model.Resource; +import org.apache.maven.api.plugin.annotations.Mojo; +import org.apache.maven.api.plugin.annotations.Parameter; /** * This goal bundles all the test sources into a jar archive. This goal functions the same @@ -34,7 +35,7 @@ * * @since 2.1 */ -@Mojo(name = "test-jar-no-fork", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true) +@Mojo(name = "test-jar-no-fork", defaultPhase = "package") public class TestSourceJarNoForkMojo extends AbstractSourceJarMojo { /** * @since 2.2 @@ -45,19 +46,19 @@ public class TestSourceJarNoForkMojo extends AbstractSourceJarMojo { /** * {@inheritDoc} */ - protected List getSources(MavenProject p) { - return p.getTestCompileSourceRoots(); + protected List getSources(Project p) { + return projectManager.getCompileSourceRoots(p, ProjectScope.TEST); } /** * {@inheritDoc} */ - protected List getResources(MavenProject p) { + protected List getResources(Project p) { if (excludeResources) { return Collections.emptyList(); } - return p.getTestResources(); + return projectManager.getResources(p, ProjectScope.TEST); } /** diff --git a/src/test/java/org/apache/maven/plugins/source/AbstractSourcePluginTestCase.java b/src/test/java/org/apache/maven/plugins/source/AbstractSourcePluginTestCase.java index 19d9e99..2605fd8 100644 --- a/src/test/java/org/apache/maven/plugins/source/AbstractSourcePluginTestCase.java +++ b/src/test/java/org/apache/maven/plugins/source/AbstractSourcePluginTestCase.java @@ -27,110 +27,27 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Stephane Nicoll */ -public abstract class AbstractSourcePluginTestCase extends AbstractMojoTestCase { +public abstract class AbstractSourcePluginTestCase { protected static final String FINAL_NAME_PREFIX = "maven-source-plugin-test-"; protected static final String FINAL_NAME_SUFFIX = "-99.0"; - protected abstract String getGoal(); - - /** - * Execute the source plugin for the specified project. - * - * @param projectName the name of the project - * @param classifier The classifier. - * @throws Exception if an error occurred - */ - protected void executeMojo(final String projectName, String classifier) throws Exception { - File testPom = new File(getBasedir(), getTestDir(projectName) + "/pom.xml"); - AbstractSourceJarMojo mojo = (AbstractSourceJarMojo) lookupMojo(getGoal(), testPom); - - // Without the following line the tests will fail, cause the project.getFile() will result with null. - mojo.getProject().setFile(testPom); - - setVariableValueToObject(mojo, "classifier", classifier); - - mojo.execute(); - } - - /** - * Executes the specified projects and asserts the given artifacts. - * - * @param projectName the project to test - * @param expectSourceArchive if a source archive is expected - * @param expectTestSourceArchive if a test source archive is expected - * @param expectedSourceFiles the expected files in the source archive, if any - * @param expectedTestSourceFiles the expected files in the test source archive, if any - * @param classifier the classifier. - * @return the base directory of the project - * @throws Exception if any error occurs - */ - protected File doTestProject( - final String projectName, - boolean expectSourceArchive, - boolean expectTestSourceArchive, - final String[] expectedSourceFiles, - final String[] expectedTestSourceFiles, - String classifier) - throws Exception { - executeMojo(projectName, classifier); - final File testTargetDir = getTestTargetDir(projectName); - - if (expectSourceArchive) { - assertSourceArchive(testTargetDir, projectName); - assertJarContent(getSourceArchive(testTargetDir, projectName), expectedSourceFiles); - } - - if (expectTestSourceArchive) { - assertTestSourceArchive(testTargetDir, projectName); - assertJarContent(getTestSourceArchive(testTargetDir, projectName), expectedTestSourceFiles); - } - - return testTargetDir; - } - - /** - * Executes the specified projects and asserts the given artifacts for a source archive. - * - * @param projectName the project to test - * @param expectedSourceFiles the expected files in the source archive, if any - * @param classifier the classifier. - * @return the base directory of the project - * @throws Exception if any error occurs - */ - protected File doTestProjectWithSourceArchive( - final String projectName, final String[] expectedSourceFiles, String classifier) throws Exception { - return doTestProject(projectName, true, false, expectedSourceFiles, null, classifier); - } - - /** - * Executes the specified projects and asserts the given artifacts for a test source archive. - * - * @param projectName the project to test - * @param expectedTestSourceFiles the expected files in the test source archive, if any - * @param classifier the classifier. - * @return the base directory of the project - * @throws Exception if any error occurs - */ - protected File doTestProjectWithTestSourceArchive( - final String projectName, final String[] expectedTestSourceFiles, String classifier) throws Exception { - return doTestProject(projectName, false, true, null, expectedTestSourceFiles, classifier); - } - protected void assertSourceArchive(final File testTargetDir, final String projectName) { final File expectedFile = getSourceArchive(testTargetDir, projectName); - assertTrue("Source archive does not exist[" + expectedFile.getAbsolutePath() + "]", expectedFile.exists()); + assertTrue(expectedFile.exists(), "Source archive does not exist[" + expectedFile.getAbsolutePath() + "]"); } protected void assertTestSourceArchive(final File testTargetDir, final String projectName) { final File expectedFile = getTestSourceArchive(testTargetDir, projectName); - assertTrue("Test source archive does not exist[" + expectedFile.getAbsolutePath() + "]", expectedFile.exists()); + assertTrue(expectedFile.exists(), "Test source archive does not exist[" + expectedFile.getAbsolutePath() + "]"); } protected File getSourceArchive(final File testTargetDir, final String projectName) { @@ -149,20 +66,12 @@ protected String buildFinalTestSourceName(final String projectName) { return FINAL_NAME_PREFIX + projectName + FINAL_NAME_SUFFIX + "-test-sources"; } - protected File getTestDir(String projectName) throws IOException { - File f = new File("target/test-classes/unit/" + projectName); - if (!new File(f, "pom.xml").exists()) { - throw new IllegalStateException("No pom file found in " + f.getPath()); - } - return f; - } - protected void assertJarContent(final File jarFile, final String[] expectedFiles) throws IOException { ZipFile jar = new ZipFile(jarFile); Enumeration entries = jar.entries(); if (expectedFiles.length == 0) { - assertFalse("Jar file should not contain any entry", entries.hasMoreElements()); + assertFalse(entries.hasMoreElements(), "Jar file should not contain any entry"); } else { assertTrue(entries.hasMoreElements()); @@ -171,16 +80,16 @@ protected void assertJarContent(final File jarFile, final String[] expectedFiles while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); - assertTrue("Not expecting " + entry.getName() + " in " + jarFile, expected.remove(entry.getName())); + assertTrue(expected.remove(entry.getName()), "Not expecting " + entry.getName() + " in " + jarFile); } - assertTrue("Missing entries " + expected.toString() + " in " + jarFile, expected.isEmpty()); + assertTrue(expected.isEmpty(), "Missing entries " + expected + " in " + jarFile); } jar.close(); } protected File getTestTargetDir(String projectName) { - return new File(getBasedir(), "target/test/unit/" + projectName + "/target"); + return new File(getBasedir(), "target/test-classes/unit/" + projectName + "/target"); } } diff --git a/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java b/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java index d585f2f..58e170e 100644 --- a/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java @@ -19,106 +19,181 @@ package org.apache.maven.plugins.source; import java.io.File; +import java.nio.file.Paths; +import java.util.Collections; + +import org.apache.maven.api.Project; +import org.apache.maven.api.ProjectScope; +import org.apache.maven.api.di.Provides; +import org.apache.maven.api.plugin.testing.Basedir; +import org.apache.maven.api.plugin.testing.InjectMojo; +import org.apache.maven.api.plugin.testing.MojoParameter; +import org.apache.maven.api.plugin.testing.MojoTest; +import org.apache.maven.api.plugin.testing.stubs.SessionMock; +import org.apache.maven.api.services.ProjectManager; +import org.apache.maven.internal.impl.InternalSession; +import org.junit.jupiter.api.Test; + +import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * @author Maria Odea Ching */ +@MojoTest public class SourceJarMojoTest extends AbstractSourcePluginTestCase { - protected String getGoal() { - return "jar"; - } - private String[] addMavenDescriptor(String project, String[] listOfElements) { + private String[] addMavenDescriptor(String project, String... listOfElements) { final String METAINF = "META-INF/"; final String MAVENSOURCE = "maven/source/maven-source-plugin-test-"; - String[] result = new String[listOfElements.length + 5]; - System.arraycopy(listOfElements, 0, result, 0, listOfElements.length); - result[listOfElements.length] = METAINF + "maven/"; - result[listOfElements.length + 1] = METAINF + "maven/source/"; - result[listOfElements.length + 2] = METAINF + MAVENSOURCE + project + "/"; - result[listOfElements.length + 3] = METAINF + MAVENSOURCE + project + "/pom.properties"; - result[listOfElements.length + 4] = METAINF + MAVENSOURCE + project + "/pom.xml"; + int length = listOfElements.length; + String[] result = new String[length + 5]; + System.arraycopy(listOfElements, 0, result, 0, length); + result[length] = METAINF + "maven/"; + result[length + 1] = METAINF + "maven/source/"; + result[length + 2] = METAINF + MAVENSOURCE + project + "/"; + result[length + 3] = METAINF + MAVENSOURCE + project + "/pom.properties"; + result[length + 4] = METAINF + MAVENSOURCE + project + "/pom.xml"; return result; } - public void testDefaultConfiguration() throws Exception { - doTestProjectWithSourceArchive( - "project-001", - addMavenDescriptor("project-001", new String[] { - "default-configuration.properties", - "foo/project001/App.java", - "foo/project001/", - "foo/", - "META-INF/MANIFEST.MF", - "META-INF/" - }), - "sources"); + @Test + @InjectMojo(goal = "jar") + @Basedir("${basedir}/target/test-classes/unit/project-001") + @MojoParameter(name = "classifier", value = "sources") + void testDefaultConfiguration(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); + + File target = new File(getBasedir(), "target"); + assertSourceArchive(target, "project-001"); + assertJarContent( + getSourceArchive(target, "project-001"), + addMavenDescriptor( + "project-001", + "default-configuration.properties", + "foo/project001/App.java", + "foo/project001/", + "foo/", + "META-INF/MANIFEST.MF", + "META-INF/")); } - public void testExcludes() throws Exception { - doTestProjectWithSourceArchive( - "project-003", - addMavenDescriptor("project-003", new String[] { - "default-configuration.properties", - "foo/project003/App.java", - "foo/project003/", - "foo/", - "META-INF/MANIFEST.MF", - "META-INF/" - }), - "sources"); + @Test + @InjectMojo(goal = "jar") + @Basedir("${basedir}/target/test-classes/unit/project-003") + public void testExcludes(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); + + File target = new File(getBasedir(), "target"); + assertSourceArchive(target, "project-003"); + assertJarContent( + getSourceArchive(target, "project-003"), + addMavenDescriptor( + "project-003", + "default-configuration.properties", + "foo/project003/App.java", + "foo/project003/", + "foo/", + "META-INF/MANIFEST.MF", + "META-INF/")); } - public void testNoSources() throws Exception { - executeMojo("project-005", "sources"); + @Test + @InjectMojo(goal = "jar") + @Basedir("${basedir}/target/test-classes/unit/project-005") + public void testNoSources(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); + // Now make sure that no archive got created final File expectedFile = getTestTargetDir("project-005"); assertFalse( - "Source archive should not have been created[" + expectedFile.getAbsolutePath() + "]", - expectedFile.exists()); + expectedFile.exists(), + "Source archive should not have been created[" + expectedFile.getAbsolutePath() + "]"); } - public void testIncludes() throws Exception { - doTestProjectWithSourceArchive( - "project-007", - addMavenDescriptor("project-007", new String[] { - "templates/configuration-template.properties", - "foo/project007/App.java", - "templates/", - "foo/project007/", - "foo/", - "META-INF/MANIFEST.MF", - "META-INF/" - }), - "sources"); + @Test + @InjectMojo(goal = "jar") + @Basedir("${basedir}/target/test-classes/unit/project-007") + public void testIncludes(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); + + File target = new File(getBasedir(), "target"); + assertSourceArchive(target, "project-007"); + assertJarContent( + getSourceArchive(target, "project-007"), + addMavenDescriptor( + "project-007", + "templates/configuration-template.properties", + "foo/project007/App.java", + "templates/", + "foo/project007/", + "foo/", + "META-INF/MANIFEST.MF", + "META-INF/")); } - public void testIncludePom() throws Exception { - doTestProjectWithSourceArchive( - "project-009", - addMavenDescriptor("project-009", new String[] { - "default-configuration.properties", - "pom.xml", - "foo/project009/App.java", - "foo/project009/", - "foo/", - "META-INF/MANIFEST.MF", - "META-INF/" - }), - "sources"); + @Test + @InjectMojo(goal = "jar") + @Basedir("${basedir}/target/test-classes/unit/project-009") + public void testIncludePom(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); + + File target = new File(getBasedir(), "target"); + assertSourceArchive(target, "project-009"); + assertJarContent( + getSourceArchive(target, "project-009"), + addMavenDescriptor( + "project-009", + "default-configuration.properties", + "pom.xml", + "foo/project009/App.java", + "foo/project009/", + "foo/", + "META-INF/MANIFEST.MF", + "META-INF/")); + } + + @Test + @InjectMojo(goal = "jar") + @Basedir("${basedir}/target/test-classes/unit/project-010") + public void testIncludeMavenDescriptorWhenExplicitlyConfigured(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); + + File target = new File(getBasedir(), "target"); + assertSourceArchive(target, "project-010"); + assertJarContent( + getSourceArchive(target, "project-010"), + addMavenDescriptor( + "project-010", + "default-configuration.properties", + "foo/project010/App.java", + "foo/project010/", + "foo/", + "META-INF/MANIFEST.MF", + "META-INF/")); } - public void testIncludeMavenDescriptorWhenExplicitlyConfigured() throws Exception { - doTestProjectWithSourceArchive( - "project-010", - addMavenDescriptor("project-010", new String[] { - "default-configuration.properties", - "foo/project010/App.java", - "foo/project010/", - "foo/", - "META-INF/MANIFEST.MF", - "META-INF/" - }), - "sources"); + @Provides + InternalSession createSession() { + InternalSession session = SessionMock.getMockSession("target/local-repo"); + ProjectManager projectManager = mock(ProjectManager.class); + when(session.getService(ProjectManager.class)).thenReturn(projectManager); + when(projectManager.getCompileSourceRoots(any(), eq(ProjectScope.MAIN))).thenAnswer(iom -> { + Project p = iom.getArgument(0, Project.class); + return Collections.singletonList( + Paths.get(getBasedir()).resolve(p.getModel().getBuild().getSourceDirectory())); + }); + when(projectManager.getResources(any(), eq(ProjectScope.MAIN))).thenAnswer(iom -> { + Project p = iom.getArgument(0, Project.class); + return p.getBuild().getResources().stream() + .map(r -> r.withDirectory( + Paths.get(getBasedir()).resolve(r.getDirectory()).toString())) + .toList(); + }); + return session; } } diff --git a/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java b/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java index bcb7b34..e0bc5fe 100644 --- a/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java @@ -19,80 +19,137 @@ package org.apache.maven.plugins.source; import java.io.File; +import java.nio.file.Paths; +import java.util.Collections; + +import org.apache.maven.api.Project; +import org.apache.maven.api.ProjectScope; +import org.apache.maven.api.di.Provides; +import org.apache.maven.api.plugin.testing.Basedir; +import org.apache.maven.api.plugin.testing.InjectMojo; +import org.apache.maven.api.plugin.testing.MojoParameter; +import org.apache.maven.api.plugin.testing.MojoTest; +import org.apache.maven.api.plugin.testing.stubs.SessionMock; +import org.apache.maven.api.services.ProjectManager; +import org.apache.maven.internal.impl.InternalSession; +import org.junit.jupiter.api.Test; + +import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * @author Maria Odea Ching */ +@MojoTest public class TestSourceJarMojoTest extends AbstractSourcePluginTestCase { - protected String getGoal() { - return "test-jar"; - } + @Test + @InjectMojo(goal = "test-jar") + @Basedir("${basedir}/target/test-classes/unit/project-001") + @MojoParameter(name = "classifier", value = "test-sources") + public void testDefaultConfiguration(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); - public void testDefaultConfiguration() throws Exception { - doTestProjectWithTestSourceArchive( - "project-001", - new String[] { - "test-default-configuration.properties", - "foo/project001/AppTest.java", - "foo/project001/", - "foo/", - "META-INF/MANIFEST.MF", - "META-INF/", - "META-INF/maven/", - "META-INF/maven/source/", - "META-INF/maven/source/maven-source-plugin-test-project-001/", - "META-INF/maven/source/maven-source-plugin-test-project-001/pom.properties", - "META-INF/maven/source/maven-source-plugin-test-project-001/pom.xml" - }, - "test-sources"); + File target = new File(getBasedir(), "target"); + assertTestSourceArchive(target, "project-001"); + assertJarContent(getTestSourceArchive(target, "project-001"), new String[] { + "test-default-configuration.properties", + "foo/project001/AppTest.java", + "foo/project001/", + "foo/", + "META-INF/MANIFEST.MF", + "META-INF/", + "META-INF/maven/", + "META-INF/maven/source/", + "META-INF/maven/source/maven-source-plugin-test-project-001/", + "META-INF/maven/source/maven-source-plugin-test-project-001/pom.properties", + "META-INF/maven/source/maven-source-plugin-test-project-001/pom.xml" + }); } - public void testExcludes() throws Exception { - doTestProjectWithTestSourceArchive( - "project-003", - new String[] { - "test-default-configuration.properties", - "foo/project003/AppTest.java", - "foo/project003/", - "foo/", - "META-INF/MANIFEST.MF", - "META-INF/", - "META-INF/maven/", - "META-INF/maven/source/", - "META-INF/maven/source/maven-source-plugin-test-project-003/", - "META-INF/maven/source/maven-source-plugin-test-project-003/pom.properties", - "META-INF/maven/source/maven-source-plugin-test-project-003/pom.xml" - }, - "test-sources"); + @Test + @InjectMojo(goal = "test-jar") + @Basedir("${basedir}/target/test-classes/unit/project-003") + @MojoParameter(name = "classifier", value = "test-sources") + public void testExcludes(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); + + File target = new File(getBasedir(), "target"); + assertTestSourceArchive(target, "project-003"); + assertJarContent(getTestSourceArchive(target, "project-003"), new String[] { + "test-default-configuration.properties", + "foo/project003/AppTest.java", + "foo/project003/", + "foo/", + "META-INF/MANIFEST.MF", + "META-INF/", + "META-INF/maven/", + "META-INF/maven/source/", + "META-INF/maven/source/maven-source-plugin-test-project-003/", + "META-INF/maven/source/maven-source-plugin-test-project-003/pom.properties", + "META-INF/maven/source/maven-source-plugin-test-project-003/pom.xml" + }); } - public void testNoSources() throws Exception { - executeMojo("project-005", "test-sources"); + @Test + @InjectMojo(goal = "test-jar") + @Basedir("${basedir}/target/test-classes/unit/project-005") + @MojoParameter(name = "classifier", value = "test-sources") + public void testNoSources(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); // Now make sure that no archive got created final File expectedFile = getTestTargetDir("project-005"); assertFalse( - "Test source archive should not have been created[" + expectedFile.getAbsolutePath() + "]", - expectedFile.exists()); + expectedFile.exists(), + "Test source archive should not have been created[" + expectedFile.getAbsolutePath() + "]"); + } + + @Test + @InjectMojo(goal = "test-jar") + @Basedir("${basedir}/target/test-classes/unit/project-010") + @MojoParameter(name = "classifier", value = "test-sources") + public void testIncludeMavenDescriptorWhenExplicitlyConfigured(AbstractSourceJarMojo mojo) throws Exception { + mojo.execute(); + + File target = new File(getBasedir(), "target"); + assertTestSourceArchive(target, "project-010"); + assertJarContent(getTestSourceArchive(target, "project-010"), new String[] { + "test-default-configuration.properties", + "foo/project010/AppTest.java", + "foo/project010/", + "foo/", + "META-INF/MANIFEST.MF", + "META-INF/", + "META-INF/maven/", + "META-INF/maven/source/", + "META-INF/maven/source/maven-source-plugin-test-project-010/", + "META-INF/maven/source/maven-source-plugin-test-project-010/pom.xml", + "META-INF/maven/source/maven-source-plugin-test-project-010/pom" + ".properties" + }); } - public void testIncludeMavenDescriptorWhenExplicitlyConfigured() throws Exception { - doTestProjectWithTestSourceArchive( - "project-010", - new String[] { - "test-default-configuration.properties", - "foo/project010/AppTest.java", - "foo/project010/", - "foo/", - "META-INF/MANIFEST.MF", - "META-INF/", - "META-INF/maven/", - "META-INF/maven/source/", - "META-INF/maven/source/maven-source-plugin-test-project-010/", - "META-INF/maven/source/maven-source-plugin-test-project-010/pom.xml", - "META-INF/maven/source/maven-source-plugin-test-project-010/pom" + ".properties" - }, - "test-sources"); + @Provides + InternalSession createSession() { + InternalSession session = SessionMock.getMockSession("target/local-repo"); + ProjectManager projectManager = mock(ProjectManager.class); + when(session.getService(ProjectManager.class)).thenReturn(projectManager); + when(projectManager.getCompileSourceRoots(any(), eq(ProjectScope.TEST))).thenAnswer(iom -> { + Project p = iom.getArgument(0, Project.class); + return Collections.singletonList( + Paths.get(getBasedir()).resolve(p.getModel().getBuild().getTestSourceDirectory())); + }); + when(projectManager.getResources(any(), eq(ProjectScope.TEST))).thenAnswer(iom -> { + Project p = iom.getArgument(0, Project.class); + return p.getBuild().getTestResources().stream() + .map(r -> r.withDirectory( + Paths.get(getBasedir()).resolve(r.getDirectory()).toString())) + .toList(); + }); + return session; } } diff --git a/src/test/java/org/apache/maven/plugins/source/stubs/DefaultArtifactHandlerStub.java b/src/test/java/org/apache/maven/plugins/source/stubs/DefaultArtifactHandlerStub.java deleted file mode 100755 index 506f23a..0000000 --- a/src/test/java/org/apache/maven/plugins/source/stubs/DefaultArtifactHandlerStub.java +++ /dev/null @@ -1,59 +0,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. - */ -package org.apache.maven.plugins.source.stubs; - -/* - * 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 org.apache.maven.artifact.handler.DefaultArtifactHandler; - -/** - * @author pgier - */ -public class DefaultArtifactHandlerStub extends DefaultArtifactHandler { - private String language; - - public String getLanguage() { - if (language == null) { - language = "java"; - } - - return language; - } - - public void setLanguage(String language) { - this.language = language; - } -} diff --git a/src/test/java/org/apache/maven/plugins/source/stubs/Project001Stub.java b/src/test/java/org/apache/maven/plugins/source/stubs/Project001Stub.java deleted file mode 100644 index 773eeb9..0000000 --- a/src/test/java/org/apache/maven/plugins/source/stubs/Project001Stub.java +++ /dev/null @@ -1,126 +0,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. - */ -package org.apache.maven.plugins.source.stubs; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Model; -import org.apache.maven.model.Resource; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.XmlStreamReader; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -/** - * @author Maria Odea Ching - */ -public class Project001Stub extends MavenProjectStub { - private Build build; - - private List resources; - - private List testResources; - - public Project001Stub() { - Model model; - - try { - model = readModelFromFile(new File(getBasedir(), "target/test-classes/unit/project-001/pom.xml")); - setModel(model); - - setGroupId(model.getGroupId()); - setArtifactId(model.getArtifactId()); - setVersion(model.getVersion()); - setName(model.getName()); - setUrl(model.getUrl()); - setPackaging(model.getPackaging()); - - Build build = new Build(); - build.setFinalName(getArtifactId() + "-" + getVersion()); - build.setDirectory(getBasedir() + "/target/test/unit/project-001/target"); - setBuild(build); - - String basedir = getBasedir().getAbsolutePath(); - List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add(basedir + "/target/test-classes/unit/project-001/src/main/java"); - setCompileSourceRoots(compileSourceRoots); - - List testCompileSourceRoots = new ArrayList<>(); - testCompileSourceRoots.add(basedir + "/target/test-classes/unit/project-001/src/test/java"); - setTestCompileSourceRoots(testCompileSourceRoots); - - setResources(model.getBuild().getResources()); - setTestResources(model.getBuild().getTestResources()); - - SourcePluginArtifactStub artifact = - new SourcePluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging(), null); - artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); - artifact.setType("jar"); - artifact.setBaseVersion("1.0-SNAPSHOT"); - setArtifact(artifact); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - public Build getBuild() { - return build; - } - - public void setBuild(Build build) { - this.build = build; - } - - public List getResources() { - return this.resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getTestResources() { - return testResources; - } - - public void setTestResources(List testResources) { - this.testResources = testResources; - } - - static Model readModelFromFile(File file) throws IOException, XmlPullParserException { - MavenXpp3Reader pomReader = new MavenXpp3Reader(); - XmlStreamReader reader = null; - try { - reader = ReaderFactory.newXmlReader(file); - final Model model = pomReader.read(reader); - reader.close(); - reader = null; - return model; - } finally { - IOUtil.close(reader); - } - } -} diff --git a/src/test/java/org/apache/maven/plugins/source/stubs/Project003Stub.java b/src/test/java/org/apache/maven/plugins/source/stubs/Project003Stub.java deleted file mode 100644 index c010351..0000000 --- a/src/test/java/org/apache/maven/plugins/source/stubs/Project003Stub.java +++ /dev/null @@ -1,108 +0,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. - */ -package org.apache.maven.plugins.source.stubs; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Model; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; - -import static org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile; - -/** - * @author Maria Odea Ching - */ -public class Project003Stub extends MavenProjectStub { - private Build build; - - private List resources; - - private List testResources; - - public Project003Stub() { - Model model; - - try { - model = readModelFromFile(new File(getBasedir(), "target/test-classes/unit/project-003/pom.xml")); - setModel(model); - - setGroupId(model.getGroupId()); - setArtifactId(model.getArtifactId()); - setVersion(model.getVersion()); - setName(model.getName()); - setUrl(model.getUrl()); - setPackaging(model.getPackaging()); - - Build build = new Build(); - build.setFinalName(getArtifactId() + "-" + getVersion()); - build.setDirectory(getBasedir() + "/target/test/unit/project-003/target"); - setBuild(build); - - String basedir = getBasedir().getAbsolutePath(); - List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add(basedir + "/target/test-classes/unit/project-003/src/main/java"); - setCompileSourceRoots(compileSourceRoots); - - List testCompileSourceRoots = new ArrayList<>(); - testCompileSourceRoots.add(basedir + "/target/test-classes/unit/project-003/src/test/java"); - setTestCompileSourceRoots(testCompileSourceRoots); - - setResources(model.getBuild().getResources()); - setTestResources(model.getBuild().getTestResources()); - - SourcePluginArtifactStub artifact = - new SourcePluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging(), null); - artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); - artifact.setType("jar"); - artifact.setBaseVersion("1.0-SNAPSHOT"); - setArtifact(artifact); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - public Build getBuild() { - return build; - } - - public void setBuild(Build build) { - this.build = build; - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getTestResources() { - return testResources; - } - - public void setTestResources(List testResources) { - this.testResources = testResources; - } -} diff --git a/src/test/java/org/apache/maven/plugins/source/stubs/Project005Stub.java b/src/test/java/org/apache/maven/plugins/source/stubs/Project005Stub.java deleted file mode 100644 index ee00cf6..0000000 --- a/src/test/java/org/apache/maven/plugins/source/stubs/Project005Stub.java +++ /dev/null @@ -1,94 +0,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. - */ -package org.apache.maven.plugins.source.stubs; - -import java.io.File; -import java.util.List; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Model; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; - -import static org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile; - -/** - * @author Maria Odea Ching - */ -public class Project005Stub extends MavenProjectStub { - private Build build; - - private List resources; - - private List testResources; - - public Project005Stub() { - Model model; - try { - model = readModelFromFile(new File(getBasedir(), "target/test-classes/unit/project-005/pom.xml")); - setModel(model); - - setGroupId(model.getGroupId()); - setArtifactId(model.getArtifactId()); - setVersion(model.getVersion()); - setName(model.getName()); - setUrl(model.getUrl()); - setPackaging(model.getPackaging()); - - Build build = new Build(); - build.setFinalName(getArtifactId() + "-" + getVersion()); - build.setDirectory(getBasedir() + "/target/test/unit/project-005/target"); - setBuild(build); - - SourcePluginArtifactStub artifact = - new SourcePluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging(), null); - artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); - artifact.setType("jar"); - artifact.setBaseVersion("1.0-SNAPSHOT"); - setArtifact(artifact); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - public Build getBuild() { - return build; - } - - public void setBuild(Build build) { - this.build = build; - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getTestResources() { - return testResources; - } - - public void setTestResources(List testResources) { - this.testResources = testResources; - } -} diff --git a/src/test/java/org/apache/maven/plugins/source/stubs/Project007Stub.java b/src/test/java/org/apache/maven/plugins/source/stubs/Project007Stub.java deleted file mode 100644 index 120cc5b..0000000 --- a/src/test/java/org/apache/maven/plugins/source/stubs/Project007Stub.java +++ /dev/null @@ -1,107 +0,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. - */ -package org.apache.maven.plugins.source.stubs; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Model; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; - -import static org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile; - -/** - * @author Maria Odea Ching - */ -public class Project007Stub extends MavenProjectStub { - private Build build; - - private List resources; - - private List testResources; - - public Project007Stub() { - Model model; - try { - model = readModelFromFile(new File(getBasedir(), "target/test-classes/unit/project-007/pom.xml")); - setModel(model); - - setGroupId(model.getGroupId()); - setArtifactId(model.getArtifactId()); - setVersion(model.getVersion()); - setName(model.getName()); - setUrl(model.getUrl()); - setPackaging(model.getPackaging()); - - Build build = new Build(); - build.setFinalName(getArtifactId() + "-" + getVersion()); - build.setDirectory(getBasedir() + "/target/test/unit/project-007/target"); - setBuild(build); - - String basedir = getBasedir().getAbsolutePath(); - List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add(basedir + "/target/test-classes/unit/project-007/src/main/java"); - setCompileSourceRoots(compileSourceRoots); - - List testCompileSourceRoots = new ArrayList<>(); - testCompileSourceRoots.add(basedir + "/target/test-classes/unit/project-007/src/test/java"); - setTestCompileSourceRoots(testCompileSourceRoots); - - setResources(model.getBuild().getResources()); - setTestResources(model.getBuild().getTestResources()); - - SourcePluginArtifactStub artifact = - new SourcePluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging(), null); - artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); - artifact.setType("jar"); - artifact.setBaseVersion("1.0-SNAPSHOT"); - setArtifact(artifact); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - public Build getBuild() { - return build; - } - - public void setBuild(Build build) { - this.build = build; - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getTestResources() { - return testResources; - } - - public void setTestResources(List testResources) { - this.testResources = testResources; - } -} diff --git a/src/test/java/org/apache/maven/plugins/source/stubs/Project009Stub.java b/src/test/java/org/apache/maven/plugins/source/stubs/Project009Stub.java deleted file mode 100644 index 3955a2e..0000000 --- a/src/test/java/org/apache/maven/plugins/source/stubs/Project009Stub.java +++ /dev/null @@ -1,109 +0,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. - */ -package org.apache.maven.plugins.source.stubs; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Model; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; - -import static org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile; - -/** - * @author Dennis Lundberg - */ -public class Project009Stub extends MavenProjectStub { - private Build build; - - private List resources; - - private List testResources; - - public Project009Stub() { - Model model; - - try { - final File pomFile = new File(getBasedir(), "target/test-classes/unit/project-009/pom.xml"); - model = readModelFromFile(pomFile); - setModel(model); - setFile(pomFile); - - setGroupId(model.getGroupId()); - setArtifactId(model.getArtifactId()); - setVersion(model.getVersion()); - setName(model.getName()); - setUrl(model.getUrl()); - setPackaging(model.getPackaging()); - - Build build = new Build(); - build.setFinalName(getArtifactId() + "-" + getVersion()); - build.setDirectory(getBasedir() + "/target/test/unit/project-009/target"); - setBuild(build); - - String basedir = getBasedir().getAbsolutePath(); - List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add(basedir + "/target/test-classes/unit/project-009/src/main/java"); - setCompileSourceRoots(compileSourceRoots); - - List testCompileSourceRoots = new ArrayList<>(); - testCompileSourceRoots.add(basedir + "/target/test-classes/unit/project-009/src/test/java"); - setTestCompileSourceRoots(testCompileSourceRoots); - - setResources(model.getBuild().getResources()); - setTestResources(model.getBuild().getTestResources()); - - SourcePluginArtifactStub artifact = - new SourcePluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging(), null); - artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); - artifact.setType("jar"); - artifact.setBaseVersion("1.0-SNAPSHOT"); - setArtifact(artifact); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public Build getBuild() { - return build; - } - - public void setBuild(Build build) { - this.build = build; - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getTestResources() { - return testResources; - } - - public void setTestResources(List testResources) { - this.testResources = testResources; - } -} diff --git a/src/test/java/org/apache/maven/plugins/source/stubs/Project010Stub.java b/src/test/java/org/apache/maven/plugins/source/stubs/Project010Stub.java deleted file mode 100644 index 90a5a4a..0000000 --- a/src/test/java/org/apache/maven/plugins/source/stubs/Project010Stub.java +++ /dev/null @@ -1,108 +0,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. - */ -package org.apache.maven.plugins.source.stubs; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Model; -import org.apache.maven.model.Resource; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; - -import static org.apache.maven.plugins.source.stubs.Project001Stub.readModelFromFile; - -public class Project010Stub extends MavenProjectStub { - private Build build; - - private List resources; - - private List testResources; - - public Project010Stub() { - Model model; - - try { - model = readModelFromFile(new File(getBasedir(), "target/test-classes/unit/project-010/pom.xml")); - setModel(model); - - setFile(new File(getBasedir(), "target/test-classes/unit/project-010/pom.xml")); - - setGroupId(model.getGroupId()); - setArtifactId(model.getArtifactId()); - setVersion(model.getVersion()); - setName(model.getName()); - setUrl(model.getUrl()); - setPackaging(model.getPackaging()); - - Build build = new Build(); - build.setFinalName(getArtifactId() + "-" + getVersion()); - build.setDirectory(getBasedir() + "/target/test/unit/project-010/target"); - - setBuild(build); - - String basedir = getBasedir().getAbsolutePath(); - List compileSourceRoots = new ArrayList<>(); - compileSourceRoots.add(basedir + "/target/test-classes/unit/project-010/src/main/java"); - setCompileSourceRoots(compileSourceRoots); - - List testCompileSourceRoots = new ArrayList<>(); - testCompileSourceRoots.add(basedir + "/target/test-classes/unit/project-010/src/test/java"); - setTestCompileSourceRoots(testCompileSourceRoots); - - setResources(model.getBuild().getResources()); - setTestResources(model.getBuild().getTestResources()); - - SourcePluginArtifactStub artifact = - new SourcePluginArtifactStub(getGroupId(), getArtifactId(), getVersion(), getPackaging(), null); - artifact.setArtifactHandler(new DefaultArtifactHandlerStub()); - artifact.setType("jar"); - artifact.setBaseVersion("1.0-SNAPSHOT"); - setArtifact(artifact); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - public Build getBuild() { - return build; - } - - public void setBuild(Build build) { - this.build = build; - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getTestResources() { - return testResources; - } - - public void setTestResources(List testResources) { - this.testResources = testResources; - } -} diff --git a/src/test/java/org/apache/maven/plugins/source/stubs/SourcePluginArtifactStub.java b/src/test/java/org/apache/maven/plugins/source/stubs/SourcePluginArtifactStub.java deleted file mode 100644 index b758a17..0000000 --- a/src/test/java/org/apache/maven/plugins/source/stubs/SourcePluginArtifactStub.java +++ /dev/null @@ -1,134 +0,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. - */ -package org.apache.maven.plugins.source.stubs; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.plugin.testing.stubs.ArtifactStub; - -/** - * @author Maria Odea Ching - */ -public class SourcePluginArtifactStub extends ArtifactStub { - - private String groupId; - - private String artifactId; - - private String version; - - private String type; - - private String classifier; - - private String baseVersion; - - private VersionRange versionRange; - - private ArtifactHandler handler; - - public SourcePluginArtifactStub(String groupId, String artifactId, String version, String type, String classifier) { - this.groupId = groupId; - this.artifactId = artifactId; - this.version = version; - this.type = type; - this.classifier = classifier; - versionRange = VersionRange.createFromVersion(version); - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public String getGroupId() { - return groupId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public String getArtifactId() { - return artifactId; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getVersion() { - return version; - } - - public void setType(String packaging) { - this.type = packaging; - } - - public String getType() { - return type; - } - - public void setClassifier(String classifier) { - this.classifier = classifier; - } - - public String getClassifier() { - return classifier; - } - - public boolean hasClassifier() { - return classifier != null; - } - - public String getId() { - String id = groupId + ":" + artifactId + ":" + type + ":"; - - if (hasClassifier()) { - id = id + getClassifier() + ":"; - } - - id = id + version; - - return id; - } - - public VersionRange getVersionRange() { - return versionRange; - } - - public void setVersionRange(VersionRange versionRange) { - this.versionRange = versionRange; - } - - public String getBaseVersion() { - return baseVersion; - } - - public void setBaseVersion(String baseVersion) { - this.baseVersion = baseVersion; - } - - public ArtifactHandler getArtifactHandler() { - return handler; - } - - public void setArtifactHandler(ArtifactHandler handler) { - this.handler = handler; - } -} diff --git a/src/test/resources/unit/project-001/pom.xml b/src/test/resources/unit/project-001/pom.xml index d1c659b..c726e61 100644 --- a/src/test/resources/unit/project-001/pom.xml +++ b/src/test/resources/unit/project-001/pom.xml @@ -17,15 +17,13 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + 4.0.0 source maven-source-plugin-test-project-001 99.0 - Maven jar + Maven http://maven.apache.org @@ -38,12 +36,12 @@ under the License. - target/test-classes/unit/project-001/src/main/resources + src/main/resources - target/test-classes/unit/project-001/src/test/resources + src/test/resources @@ -51,10 +49,8 @@ under the License. org.apache.maven.plugins maven-source-plugin - - ${basedir}/target/test/unit/project-001/target maven-source-plugin-test-project-001-99.0 - + diff --git a/src/test/resources/unit/project-001/src/main/java/foo/project001/App.java b/src/test/resources/unit/project-001/src/main/java/foo/project001/App.java index 10053c9..dec027b 100644 --- a/src/test/resources/unit/project-001/src/main/java/foo/project001/App.java +++ b/src/test/resources/unit/project-001/src/main/java/foo/project001/App.java @@ -1,3 +1,21 @@ +/* + * 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. + */ package foo.project001; /* @@ -23,10 +41,8 @@ * Hello world! * */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); +public class App { + public static void main(String[] args) { + System.out.println("Hello World!"); } } diff --git a/src/test/resources/unit/project-001/src/test/java/foo/project001/AppTest.java b/src/test/resources/unit/project-001/src/test/java/foo/project001/AppTest.java index d5a0e00..63db293 100644 --- a/src/test/resources/unit/project-001/src/test/java/foo/project001/AppTest.java +++ b/src/test/resources/unit/project-001/src/test/java/foo/project001/AppTest.java @@ -1,3 +1,21 @@ +/* + * 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. + */ package foo.project001; /* @@ -26,32 +44,27 @@ /** * Unit test for simple App. */ -public class AppTest - extends TestCase -{ +public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ - public AppTest( String testName ) - { - super( testName ); + public AppTest(String testName) { + super(testName); } /** * @return the suite of tests being tested */ - public static Test suite() - { - return new TestSuite( AppTest.class ); + public static Test suite() { + return new TestSuite(AppTest.class); } /** * Rigourous Test :-) */ - public void testApp() - { - assertTrue( true ); + public void testApp() { + assertTrue(true); } } diff --git a/src/test/resources/unit/project-003/pom.xml b/src/test/resources/unit/project-003/pom.xml index e10189e..fe73a62 100644 --- a/src/test/resources/unit/project-003/pom.xml +++ b/src/test/resources/unit/project-003/pom.xml @@ -17,15 +17,13 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + 4.0.0 source maven-source-plugin-test-project-003 99.0 - Maven jar + Maven junit @@ -37,15 +35,15 @@ under the License. - target/test-classes/unit/project-003/src/main/resources + src/main/resources excluded-file.txt - + - target/test-classes/unit/project-003/src/test/resources + src/test/resources excluded-file.txt @@ -56,10 +54,8 @@ under the License. org.apache.maven.plugins maven-source-plugin - - ${basedir}/target/test/unit/project-003/target maven-source-plugin-test-project-003-99.0 - +
diff --git a/src/test/resources/unit/project-003/src/main/java/foo/project003/App.java b/src/test/resources/unit/project-003/src/main/java/foo/project003/App.java index 2d341ae..8a6c866 100644 --- a/src/test/resources/unit/project-003/src/main/java/foo/project003/App.java +++ b/src/test/resources/unit/project-003/src/main/java/foo/project003/App.java @@ -1,3 +1,21 @@ +/* + * 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. + */ package foo.project003; /* @@ -23,10 +41,8 @@ * Hello world! * */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); +public class App { + public static void main(String[] args) { + System.out.println("Hello World!"); } } diff --git a/src/test/resources/unit/project-003/src/test/java/foo/project003/AppTest.java b/src/test/resources/unit/project-003/src/test/java/foo/project003/AppTest.java index 06acafc..55c4ed5 100644 --- a/src/test/resources/unit/project-003/src/test/java/foo/project003/AppTest.java +++ b/src/test/resources/unit/project-003/src/test/java/foo/project003/AppTest.java @@ -1,3 +1,21 @@ +/* + * 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. + */ package foo.project003; /* @@ -26,32 +44,27 @@ /** * Unit test for simple App. */ -public class AppTest - extends TestCase -{ +public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ - public AppTest( String testName ) - { - super( testName ); + public AppTest(String testName) { + super(testName); } /** * @return the suite of tests being tested */ - public static Test suite() - { - return new TestSuite( AppTest.class ); + public static Test suite() { + return new TestSuite(AppTest.class); } /** * Rigourous Test :-) */ - public void testApp() - { - assertTrue( true ); + public void testApp() { + assertTrue(true); } } diff --git a/src/test/resources/unit/project-005/pom.xml b/src/test/resources/unit/project-005/pom.xml index d54018b..0a80fce 100644 --- a/src/test/resources/unit/project-005/pom.xml +++ b/src/test/resources/unit/project-005/pom.xml @@ -17,16 +17,14 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + 4.0.0 source maven-source-plugin-test-project-005 99.0 - Maven pom + Maven junit @@ -41,10 +39,8 @@ under the License. org.apache.maven.plugins maven-source-plugin - - ${basedir}/target/test/unit/project-005/target maven-source-plugin-test-project-005-99.0 - + diff --git a/src/test/resources/unit/project-007/pom.xml b/src/test/resources/unit/project-007/pom.xml index f1dfb40..ddb1311 100644 --- a/src/test/resources/unit/project-007/pom.xml +++ b/src/test/resources/unit/project-007/pom.xml @@ -17,15 +17,13 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + 4.0.0 source maven-source-plugin-test-project-007 99.0 - Maven jar + Maven junit @@ -37,7 +35,7 @@ under the License. - target/test-classes/unit/project-007/src/main/resources + src/main/resources templates/** @@ -48,10 +46,8 @@ under the License. org.apache.maven.plugins maven-source-plugin - - ${basedir}/target/test/unit/project-007/target maven-source-plugin-test-project-007-99.0 - + diff --git a/src/test/resources/unit/project-007/src/main/java/foo/project007/App.java b/src/test/resources/unit/project-007/src/main/java/foo/project007/App.java index 4958ba9..f882eba 100644 --- a/src/test/resources/unit/project-007/src/main/java/foo/project007/App.java +++ b/src/test/resources/unit/project-007/src/main/java/foo/project007/App.java @@ -1,3 +1,21 @@ +/* + * 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. + */ package foo.project007; /* @@ -23,10 +41,8 @@ * Hello world! * */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); +public class App { + public static void main(String[] args) { + System.out.println("Hello World!"); } } diff --git a/src/test/resources/unit/project-009/pom.xml b/src/test/resources/unit/project-009/pom.xml index 2562083..1e95f69 100644 --- a/src/test/resources/unit/project-009/pom.xml +++ b/src/test/resources/unit/project-009/pom.xml @@ -17,15 +17,13 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + 4.0.0 source maven-source-plugin-test-project-009 99.0 - Maven jar + Maven junit @@ -37,7 +35,7 @@ under the License. - target/test-classes/unit/project-009/src/main/resources + src/main/resources @@ -46,10 +44,8 @@ under the License. maven-source-plugin true - - ${basedir}/target/test/unit/project-009/target maven-source-plugin-test-project-009-99.0 - + diff --git a/src/test/resources/unit/project-009/src/main/java/foo/project009/App.java b/src/test/resources/unit/project-009/src/main/java/foo/project009/App.java index 66522e4..8505312 100644 --- a/src/test/resources/unit/project-009/src/main/java/foo/project009/App.java +++ b/src/test/resources/unit/project-009/src/main/java/foo/project009/App.java @@ -1,3 +1,21 @@ +/* + * 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. + */ package foo.project009; /* @@ -23,10 +41,8 @@ * Hello world! * */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); +public class App { + public static void main(String[] args) { + System.out.println("Hello World!"); } } diff --git a/src/test/resources/unit/project-010/pom.xml b/src/test/resources/unit/project-010/pom.xml index 9972cea..d984dc9 100644 --- a/src/test/resources/unit/project-010/pom.xml +++ b/src/test/resources/unit/project-010/pom.xml @@ -17,15 +17,13 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - - + 4.0.0 source maven-source-plugin-test-project-010 99.0 - Maven jar + Maven http://maven.apache.org @@ -38,12 +36,12 @@ under the License. - target/test-classes/unit/project-010/src/main/resources + src/main/resources - target/test-classes/unit/project-010/src/test/resources + src/test/resources @@ -51,10 +49,8 @@ under the License. org.apache.maven.plugins maven-source-plugin - - ${basedir}/target/test/unit/project-010/target maven-source-plugin-test-project-010-99.0 - + true diff --git a/src/test/resources/unit/project-010/src/main/java/foo/project010/App.java b/src/test/resources/unit/project-010/src/main/java/foo/project010/App.java index 1c93f39..9a8a17f 100644 --- a/src/test/resources/unit/project-010/src/main/java/foo/project010/App.java +++ b/src/test/resources/unit/project-010/src/main/java/foo/project010/App.java @@ -1,3 +1,21 @@ +/* + * 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. + */ package foo.project010; /* @@ -23,10 +41,8 @@ * Hello world! * */ -public class App -{ - public static void main( String[] args ) - { - System.out.println( "Hello World!" ); +public class App { + public static void main(String[] args) { + System.out.println("Hello World!"); } } diff --git a/src/test/resources/unit/project-010/src/test/java/foo/project010/AppTest.java b/src/test/resources/unit/project-010/src/test/java/foo/project010/AppTest.java index 06b6a16..28a94db 100644 --- a/src/test/resources/unit/project-010/src/test/java/foo/project010/AppTest.java +++ b/src/test/resources/unit/project-010/src/test/java/foo/project010/AppTest.java @@ -1,3 +1,21 @@ +/* + * 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. + */ package foo.project010; /* @@ -26,32 +44,27 @@ /** * Unit test for simple App. */ -public class AppTest - extends TestCase -{ +public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ - public AppTest( String testName ) - { - super( testName ); + public AppTest(String testName) { + super(testName); } /** * @return the suite of tests being tested */ - public static Test suite() - { - return new TestSuite( AppTest.class ); + public static Test suite() { + return new TestSuite(AppTest.class); } /** * Rigourous Test :-) */ - public void testApp() - { - assertTrue( true ); + public void testApp() { + assertTrue(true); } }