diff --git a/.asf.yaml b/.asf.yaml index 5feedc51dbe65332d84ede8a83a5801a64e5ae08..699735c51f817fc3b1f552d99270993a491a1f64 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -8,3 +8,9 @@ github: - apache-maven - maven-plugins - maven-deploy-plugin + enabled_merge_buttons: + squash: true + merge: false + rebase: true + autolink_jira: + - MDEPLOY \ No newline at end of file diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000000000000000000000000000000000..517a2a3907219245e06e32d8eee5f0c5e9b73140 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +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. +# + +# Change maven code style - parent 39 +27026fb9d50f2ccf008387d562e9dc7800bfb975 diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b9b9dde8ccdb694baaf6bcf7b42bef51b7abe2dd..7f4ebfaa8064da5d540d73e6358d993622eb3af5 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,13 +1,13 @@ Following this checklist to help us incorporate your contribution quickly and easily: - - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MPH) filed + - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MDEPLOY) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - - [ ] Format the pull request title like `[MPH-XXX] - Fixes bug in ApproximateQuantiles`, - where you replace `MPH-XXX` with the appropriate JIRA issue. Best practice + - [ ] Format the pull request title like `[MDEPLOY-XXX] - Fixes bug in ApproximateQuantiles`, + where you replace `MDEPLOY-XXX` with the appropriate JIRA issue. Best practice is to use the JIRA issue title in the pull request title and in the first line of the commit message. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000000000000000000000000000000000000..387b9ca278c7e330bbdaa1f676f4101e68b9939c --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,18 @@ +# 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. + +_extends: maven-gh-actions-shared diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index bbd7786537798db666d603d132187f7aee63f5e9..4d67fdcf92465f742bb17b846f2cd76c13284add 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -24,4 +24,4 @@ on: jobs: build: name: Verify - uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v2 + uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000000000000000000000000000000000000..b44872cff796aec5dcd8cbebd67f882f570a0224 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,25 @@ +# 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. + +name: Release Drafter +on: + push: + branches: + - master +jobs: + update_release_draft: + uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v3 diff --git a/README.md b/README.md index 0cf6df0877044644371aa1b6139481a13e7402af..52b7b0fd90bcc71409ba2c01c93e59f6c84a7758 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Contributing to [Apache Maven Deploy Plugin](https://maven.apache.org/plugins/ma [][jira] [][license] [](https://search.maven.org/artifact/org.apache.maven.plugins/maven-deploy-plugin) +[](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/plugins/maven-deploy-plugin/README.md) [][build] [][test-results] diff --git a/pom.xml b/pom.xml index f53476855506baca865e5c2f037ecb624b141730..be639a3f4561f62bd77cb99eca3cc336859c5af4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ -<?xml version='1.0' encoding='UTF-8'?> - +<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -18,25 +17,31 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugins</artifactId> - <version>36</version> + <version>39</version> <relativePath /> </parent> <artifactId>maven-deploy-plugin</artifactId> - <version>3.0.0</version> + <version>3.1.0</version> <packaging>maven-plugin</packaging> <name>Apache Maven Deploy Plugin</name> <description>Uploads the project artifacts to the internal remote repository.</description> <inceptionYear>2004</inceptionYear> + <contributors> + <!-- alphabetic order --> + <contributor> + <name>Hermann Josef Hill</name> + </contributor> + </contributors> + <prerequisites> <maven>${mavenVersion}</maven> </prerequisites> @@ -44,8 +49,8 @@ under the License. <scm> <connection>scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git</connection> <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git</developerConnection> + <tag>maven-deploy-plugin-3.1.0</tag> <url>https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag}</url> - <tag>maven-deploy-plugin-3.0.0</tag> </scm> <issueManagement> <system>JIRA</system> @@ -63,11 +68,27 @@ under the License. </distributionManagement> <properties> - <javaVersion>7</javaVersion> + <javaVersion>8</javaVersion> <mavenVersion>3.2.5</mavenVersion> - <slf4jVersion>1.7.5</slf4jVersion> <!-- Keep in sync with resolver used in maven above --> - <resolverVersion>1.0.0.v20140518</resolverVersion> <!-- Keep in sync with resolver used in maven above --> - <project.build.outputTimestamp>2022-07-16T16:14:02Z</project.build.outputTimestamp> + <!-- Keep in sync with resolver used in maven above --> + <slf4jVersion>1.7.5</slf4jVersion> + <!-- Keep in sync with resolver used in maven above --> + <resolverVersion>1.0.0.v20140518</resolverVersion> + + <!-- plugins version used in IT tests --> + <mavenAntrunPluginVersion>3.1.0</mavenAntrunPluginVersion> + <mavenCompilerPluginVersion>3.10.1</mavenCompilerPluginVersion> + <mavenEnforcerPluginVersion>3.1.0</mavenEnforcerPluginVersion> + <mavenInstallPluginVersion>3.1.0</mavenInstallPluginVersion> + <mavenJarPluginVersion>3.3.0</mavenJarPluginVersion> + <mavenJavadocPluginVersion>3.4.1</mavenJavadocPluginVersion> + <mavenPluginToolsVersion>${maven.plugin.tools.version}</mavenPluginToolsVersion> + <mavenResourcesPluginVersion>3.3.0</mavenResourcesPluginVersion> + <mavenSourcePluginVersion>3.2.1</mavenSourcePluginVersion> + <mavenSurefirePluginVersion>${surefire.version}</mavenSurefirePluginVersion> + <mavenWarPluginVersion>3.3.2</mavenWarPluginVersion> + + <project.build.outputTimestamp>2023-02-06T12:43:17Z</project.build.outputTimestamp> </properties> <dependencies> @@ -105,7 +126,6 @@ under the License. <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>3.3.1</version> </dependency> <dependency> <groupId>org.eclipse.aether</groupId> @@ -117,7 +137,8 @@ under the License. <groupId>org.eclipse.aether</groupId> <artifactId>aether-util</artifactId> <version>${resolverVersion}</version> - <scope>compile</scope> <!-- To work in Maven versions older than 3.9.0 --> + <!-- To work in Maven versions older than 3.9.0 --> + <scope>compile</scope> </dependency> <!-- dependencies to annotations --> @@ -134,7 +155,8 @@ under the License. <version>3.3.0</version> <scope>test</scope> </dependency> - <dependency> <!-- used by maven-plugin-testing-harness, don't give it compile scope! --> + <dependency> + <!-- used by maven-plugin-testing-harness, don't give it compile scope! --> <groupId>org.apache.maven</groupId> <artifactId>maven-compat</artifactId> <version>${mavenVersion}</version> @@ -182,30 +204,9 @@ under the License. <version>${slf4jVersion}</version> <scope>test</scope> </dependency> - - </dependencies> - <contributors> - <!-- alphabetic order --> - <contributor> - <name>Hermann Josef Hill</name> - </contributor> - </contributors> + </dependencies> - <build> - <plugins> - <!-- https://issues.apache.org/jira/browse/MPOM-226 --> - <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - <configuration> - <excludes combine.children="append"> - <exclude>.asf.yaml</exclude><!-- Can be removed with upgrade to maven-plugins:34 --> - </excludes> - </configuration> - </plugin> - </plugins> - </build> <profiles> <profile> <id>run-its</id> @@ -228,14 +229,15 @@ under the License. <postBuildHookScript>verify</postBuildHookScript> <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> <settingsFile>src/it/settings.xml</settingsFile> - <addTestClassPath>true</addTestClassPath> + <scriptVariables> + <remoteRepo>${project.build.directory}/remote-repo</remoteRepo> + </scriptVariables> + <filterProperties> + <remoteRepo>${project.build.directory}/remote-repo</remoteRepo> + </filterProperties> <goals> <goal>deploy</goal> </goals> - <properties> - <!-- e.g. ensure that Java7 picks up TLSv1.2 when connecting with Central --> - <https.protocols>${https.protocols}</https.protocols> - </properties> </configuration> </plugin> </plugins> diff --git a/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties b/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties index 18efa761e319b596d5c476c3f036c7f99b038785..50360fc0c300f8d51b73343468c6df40b9314a35 100644 --- a/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties +++ b/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties @@ -1,18 +1,17 @@ -# 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. -invoker.goals = clean deploy -T2 -invoker.maven.version = 3.0+ \ No newline at end of file +# 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. +invoker.goals = clean deploy -T2 diff --git a/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml b/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml index 576847dd96273d6333c3f05001a305be4a69fe5c..af8d8c2bf1234d26c95363a7c5399c708fda28c3 100644 --- a/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml +++ b/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -60,22 +60,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.0.4</version> + <version>@mavenSourcePluginVersion@</version> <executions> <execution> <id>attach-sources</id> @@ -88,7 +88,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/MDEPLOY-170_deploy-at-end-configperproject/pom.xml b/src/it/MDEPLOY-170_deploy-at-end-configperproject/pom.xml index 42f53daf729958035b1d8c1c6bf6ceb414a52655..8884e1385741b2d5c7d4df2486164943ddac5faa 100644 --- a/src/it/MDEPLOY-170_deploy-at-end-configperproject/pom.xml +++ b/src/it/MDEPLOY-170_deploy-at-end-configperproject/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -60,22 +60,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.0.4</version> + <version>@mavenSourcePluginVersion@</version> <executions> <execution> <id>attach-sources</id> @@ -88,7 +88,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/MDEPLOY-212/pom.xml b/src/it/MDEPLOY-212/pom.xml index c6376ff44234a2e03e2f39b138784e190f6d09f0..8bca65b140c5fbb6b69295d4ae7678b031c8acb8 100644 --- a/src/it/MDEPLOY-212/pom.xml +++ b/src/it/MDEPLOY-212/pom.xml @@ -38,7 +38,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.0.1</version> + <version>@mavenJavadocPluginVersion@</version> <executions> <execution> <id>attach-javadoc</id> diff --git a/src/it/MDEPLOY-213/pom.xml b/src/it/MDEPLOY-213/pom.xml index 36e6d23ab79f42a1f619e0ff798b40f5cdf15398..ff4574d6728e96e619ad8aa4a9935a1507c5b9a6 100644 --- a/src/it/MDEPLOY-213/pom.xml +++ b/src/it/MDEPLOY-213/pom.xml @@ -46,7 +46,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.0.1</version> + <version>@mavenJavadocPluginVersion@</version> <executions> <execution> <id>attach-javadoc</id> diff --git a/src/it/MDEPLOY-224_deploy-at-end-only-modules/module1/pom.xml b/src/it/MDEPLOY-224_deploy-at-end-only-modules/module1/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..9f2550859ed6a8bdecfd9510ba8e0ce0354d8d30 --- /dev/null +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/module1/pom.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- 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. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.mdeploy-224</groupId> + <artifactId>parent</artifactId> + <version>1.0</version> + </parent> + <artifactId>module1</artifactId> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <deployAtEnd>true</deployAtEnd> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/MDEPLOY-224_deploy-at-end-only-modules/module2/pom.xml b/src/it/MDEPLOY-224_deploy-at-end-only-modules/module2/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..081edc5ab10a953f1450b1ad1e4ebb31cc3fb5ca --- /dev/null +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/module2/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- 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. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.mdeploy-224</groupId> + <artifactId>parent</artifactId> + <version>1.0</version> + </parent> + <artifactId>module2</artifactId> + <packaging>pom</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <deployAtEnd>true</deployAtEnd> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/attach-jar-checksum-snapshot/pom.xml b/src/it/MDEPLOY-224_deploy-at-end-only-modules/pom.xml similarity index 62% rename from src/it/attach-jar-checksum-snapshot/pom.xml rename to src/it/MDEPLOY-224_deploy-at-end-only-modules/pom.xml index 89ddce7884583d0b7960b900a46ad3fa0fea441b..f40c64acda6d1caab12fc2a6f883e88ea5e86e3a 100644 --- a/src/it/attach-jar-checksum-snapshot/pom.xml +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/pom.xml @@ -19,26 +19,26 @@ specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven.its.deploy.ajc</groupId> - <artifactId>test</artifactId> - <version>1.0-SNAPSHOT</version> - <packaging>jar</packaging> + <groupId>org.apache.maven.its.mdeploy-224</groupId> + <artifactId>parent</artifactId> + <version>1.0</version> + <packaging>pom</packaging> <description> - Tests the deployment of a simple SNAPSHOT JAR with an attached artifact and checksums + Tests deployment at end only in modules. </description> <properties> <maven.test.skip>true</maven.test.skip> </properties> + <distributionManagement> <repository> <id>it</id> - <url>file:///${basedir}/target/remoterepo</url> + <url>file:///${basedir}/target/repo</url> </repository> </distributionManagement> @@ -47,56 +47,41 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>@project.version@</version> + <configuration> + <deployAtEnd>false</deployAtEnd> + </configuration> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> - </plugin> - <!-- - ! This is intentionally the old version which - ! will not create checksums by default. - ! We want to make sure that only maven-deploy-plugin - ! will generate the checksums. - --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.5.2</version> - <configuration> - <createChecksum>false</createChecksum> - </configuration> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <artifactId>maven-jar-plugin</artifactId> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>2.0.4</version> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> + <artifactId>maven-resources-plugin</artifactId> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> + <modules> + <module>module1</module> + <module>module2</module> + </modules> </project> diff --git a/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy b/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy new file mode 100644 index 0000000000000000000000000000000000000000..063f2aeede6bc57fd59155ddf026f6eb600cd26b --- /dev/null +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy @@ -0,0 +1,29 @@ +/* + * 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. + */ + +assert new File( basedir, "target/repo/org/apache/maven/its/mdeploy-224/parent/1.0/parent-1.0.pom" ).exists() +assert new File( basedir, "module1/target/repo/org/apache/maven/its/mdeploy-224/module1/1.0/module1-1.0.pom" ).exists() +assert new File( basedir, "module2/target/repo/org/apache/maven/its/mdeploy-224/module2/1.0/module2-1.0.pom" ).exists() + +def buildLog = new File ( basedir, "build.log").text + +assert ! buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:parent:1.0 at end') +assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module1:1.0 at end') +// Last module does not emit this misleading message, as it IS "the end", not deferring anymore +// assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module2:1.0 at end') diff --git a/src/it/MDEPLOY-225_deploy-at-end-skip-root/module1/pom.xml b/src/it/MDEPLOY-225_deploy-at-end-skip-root/module1/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..325a6342867391030c903b7f3ca4a9c06462585d --- /dev/null +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/module1/pom.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- 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. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.mdeploy-225</groupId> + <artifactId>parent</artifactId> + <version>1.0</version> + </parent> + <artifactId>module1</artifactId> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <skip>false</skip> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/MDEPLOY-225_deploy-at-end-skip-root/module2/pom.xml b/src/it/MDEPLOY-225_deploy-at-end-skip-root/module2/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..5bb4f62a1480f10fc5c05348833c6bb37d31ac2b --- /dev/null +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/module2/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- 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. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.mdeploy-225</groupId> + <artifactId>parent</artifactId> + <version>1.0</version> + </parent> + <artifactId>module2</artifactId> + <packaging>pom</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <skip>false</skip> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/attach-jar-checksum-release/pom.xml b/src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml similarity index 62% rename from src/it/attach-jar-checksum-release/pom.xml rename to src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml index bda659d4464f20286e205e9060e9104d2e35bfee..8ac0f8201a5c565d5c5b5c03b0b9b3502b5106a6 100644 --- a/src/it/attach-jar-checksum-release/pom.xml +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml @@ -19,27 +19,26 @@ specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven.its.deploy.ajc</groupId> - <artifactId>test</artifactId> + <groupId>org.apache.maven.its.mdeploy-225</groupId> + <artifactId>parent</artifactId> <version>1.0</version> - <packaging>jar</packaging> + <packaging>pom</packaging> <description> - This test has been moved from maven-install-plugin to maven-deploy-plugin. - Tests the installation of a simple snapshot JAR with an attached artifact and checksums + Tests deployment at end with skipped root project. </description> <properties> <maven.test.skip>true</maven.test.skip> </properties> + <distributionManagement> <repository> <id>it</id> - <url>file:///${basedir}/target/remoterepo</url> + <url>file:///${basedir}/target/repo</url> </repository> </distributionManagement> @@ -48,56 +47,42 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>@project.version@</version> + <configuration> + <deployAtEnd>true</deployAtEnd> + <skip>true</skip> + </configuration> </plugin> - <!-- - ! This is intentionally the old version which - ! will not create checksums by default. - ! We want to make sure that only maven-deploy-plugin - ! will generate the checksums. - --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.5.2</version> - <configuration> - <createChecksum>false</createChecksum> - </configuration> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>2.0.4</version> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> + <modules> + <module>module1</module> + <module>module2</module> + </modules> </project> diff --git a/src/it/attach-jar-checksum-snapshot/setup.bsh b/src/it/MDEPLOY-225_deploy-at-end-skip-root/verify.groovy similarity index 72% rename from src/it/attach-jar-checksum-snapshot/setup.bsh rename to src/it/MDEPLOY-225_deploy-at-end-skip-root/verify.groovy index 7d54f90eecbb28c8c3a33a96620d2d45e6d2b474..edcc0b97d3600573efa3156e7ccae31d9cb2f572 100644 --- a/src/it/attach-jar-checksum-snapshot/setup.bsh +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/verify.groovy @@ -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 @@ -17,13 +17,6 @@ * under the License. */ -import java.io.*; -import java.util.*; - -import org.codehaus.plexus.util.*; - -File file = new File( basedir, "target/remoterepo/org/apache/maven/its/deploy/ajc" ); -System.out.println( "Deleting " + file ); -FileUtils.deleteDirectory( file ); - -return true; +assert ! new File( basedir, "target/repo" ).exists() +assert new File( basedir, "module1/target/repo/org/apache/maven/its/mdeploy-225/module1/1.0/module1-1.0.pom" ).exists() +assert new File( basedir, "module2/target/repo/org/apache/maven/its/mdeploy-225/module2/1.0/module2-1.0.pom" ).exists() diff --git a/src/it/alt-deploy-repo-with-dist-mgmt-snapshot/pom.xml b/src/it/alt-deploy-repo-with-dist-mgmt-snapshot/pom.xml index ac1f97eb43c54c868e39e0a92608c79d601601a3..cd943815942fa9d84da705845afbc78d90fb9c1a 100644 --- a/src/it/alt-deploy-repo-with-dist-mgmt-snapshot/pom.xml +++ b/src/it/alt-deploy-repo-with-dist-mgmt-snapshot/pom.xml @@ -48,7 +48,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -58,22 +58,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/alt-deploy-repo-with-dist-mgmt/pom.xml b/src/it/alt-deploy-repo-with-dist-mgmt/pom.xml index aa1dd73685531771ea27f8fda9184f0c58a91db9..e29e00f474ffac90ee6f2756922f005608e391a3 100644 --- a/src/it/alt-deploy-repo-with-dist-mgmt/pom.xml +++ b/src/it/alt-deploy-repo-with-dist-mgmt/pom.xml @@ -48,7 +48,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -58,22 +58,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/alt-deploy-repo-without-dist-mgmt/pom.xml b/src/it/alt-deploy-repo-without-dist-mgmt/pom.xml index a6826e95ca93ac1fa4f2a948cdb60fa72290dd94..185d92d749cf2f246d7e01da3a648d9220bd3f71 100644 --- a/src/it/alt-deploy-repo-without-dist-mgmt/pom.xml +++ b/src/it/alt-deploy-repo-without-dist-mgmt/pom.xml @@ -41,7 +41,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -51,22 +51,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/attach-jar-checksum-release/verify.groovy b/src/it/attach-jar-checksum-release/verify.groovy deleted file mode 100644 index ac362f812dc4c31c7158b596c55c47213372e84d..0000000000000000000000000000000000000000 --- a/src/it/attach-jar-checksum-release/verify.groovy +++ /dev/null @@ -1,64 +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. - */ - -import java.io.*; -import java.util.*; - -import org.apache.maven.plugins.deploy.Utils; - -def paths = -[ - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0.pom", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0.pom.md5", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0.pom.sha1", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0.jar", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0.jar.md5", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0.jar.sha1", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0-sources.jar", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0-sources.jar.md5", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0-sources.jar.sha1", - "org/apache/maven/its/deploy/ajc/test/maven-metadata.xml", - "org/apache/maven/its/deploy/ajc/test/maven-metadata.xml.md5", - "org/apache/maven/its/deploy/ajc/test/maven-metadata.xml.sha1", -] - -def cksumToCheckPaths = [ - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0.pom", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0.jar", - "org/apache/maven/its/deploy/ajc/test/1.0/test-1.0-sources.jar" -] - -// Check if artifacts have been uploaded to remote with checksums -def repository = new File (basedir, "target/remoterepo" ) -paths.each { path -> - //File file = new File( localRepositoryPath, path ); - File file = new File( repository, path ); - println "Checking for existence of ${file}" - if ( !file.isFile() ) - { - throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() ); - } - if ( cksumToCheckPaths.contains( path ) ) - { - println "Verifying ${file}" - Utils.verifyChecksum( file ); - } -} - -return true; diff --git a/src/it/attach-jar-checksum-snapshot/verify.groovy b/src/it/attach-jar-checksum-snapshot/verify.groovy deleted file mode 100644 index 0a4a14f9e1e77d1c6b86fa66fbf291b8e945f739..0000000000000000000000000000000000000000 --- a/src/it/attach-jar-checksum-snapshot/verify.groovy +++ /dev/null @@ -1,95 +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. - */ - -import org.apache.maven.plugins.deploy.Utils; - -def pathsInTargetDirectory = [ - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\.pom", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\.pom\\.md5", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\.pom\\.sha1", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\.jar", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\.jar\\.md5", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\.jar\\.sha1", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\-sources\\.jar", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\-sources\\.jar\\.md5", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\-sources\\.jar\\.sha1", - //The following files will be generated. But they can't be check for the checksums - //cause they contain timestamps which means they change everytime. - "maven\\-metadata\\.xml", - "maven\\-metadata\\.xml\\.md5", - "maven\\-metadata\\.xml\\.sha1", -] - -def checkSumsToCheckPaths = [ - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\.pom", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\.jar", - "test\\-1\\.0\\-\\d{8}\\.\\d{6}\\-\\d{1}\\-sources\\.jar", -] - -// All files are being deployed to that location. See pom.xml -def repository = new File (basedir, "target/remoterepo/org/apache/maven/its/deploy/ajc/test/1.0-SNAPSHOT" ) - -// Read all files from the target directory. -def filesInDirectory = [] -repository.eachFile() { file -> - filesInDirectory << file.getName() -} - -println "Size: ${filesInDirectory.size()} / ${pathsInTargetDirectory.size()}" - -// First Step is to check the number of files found in directory against -// the number of files we expect to find. -if (filesInDirectory.size() != pathsInTargetDirectory.size()) { - throw new Exception( "The number of files in filesInDirectory and the number of files in pathsInTargetDirectory are not equal" ); -} - -// The following will check for the existence of all given -// files based on the given regular expressions. -// This is needed cause the time stamp in the file name -// changes each time this test will be running. -filesInDirectory.each { existingFile -> - def result = false - pathsInTargetDirectory.each { searchItem -> - def expected = existingFile ==~ searchItem - println "existingFile: ${existingFile} ${searchItem} expeced:${expected}" - if (expected) { - result = true - } - } - - if (!result) { - throw new FileNotFoundException ( "Missing: ${existingFile}" ) - } -} - -// The following will check the existing checksums. -filesInDirectory.each { existingFile -> - def result = false - checkSumsToCheckPaths.each { searchItem -> - //search for the file name pattern.. - def expected = existingFile ==~ searchItem - if (expected) { - println "Verifying ${existingFile}" - Utils.verifyChecksum( new File(repository, existingFile) ); - } - } -} - -return true; - diff --git a/src/it/attach-release-jar/pom.xml b/src/it/attach-release-jar/pom.xml index 4557d2229dddd1025eb6928004d5b5aae8d9b88e..916f24626b35c94ac0db7639a6262a7b49776a84 100644 --- a/src/it/attach-release-jar/pom.xml +++ b/src/it/attach-release-jar/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -57,22 +57,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.0.4</version> + <version>@mavenSourcePluginVersion@</version> <executions> <execution> <id>attach-sources</id> @@ -81,11 +81,14 @@ under the License. </goals> </execution> </executions> + <configuration> + <forceCreation>true</forceCreation> + </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/deploy-at-end-fail/module1/pom.xml b/src/it/deploy-at-end-fail/module1/pom.xml index 7b48b486fdc00b3bc58de4ec873b6b6b6b75b31b..ba919db50d512094e19b802c4d442407bbb0ac9d 100644 --- a/src/it/deploy-at-end-fail/module1/pom.xml +++ b/src/it/deploy-at-end-fail/module1/pom.xml @@ -27,7 +27,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> - <version>1.2</version> + <version>@mavenEnforcerPluginVersion@</version> <executions> <execution> <id>enforce</id> diff --git a/src/it/deploy-at-end-fail/pom.xml b/src/it/deploy-at-end-fail/pom.xml index be9ef50c526e942a0e6f7e8e6c6837c29d3e11a1..ed5f9ba004b9ba5c387000ddf33ddd2e92a5c1fe 100644 --- a/src/it/deploy-at-end-fail/pom.xml +++ b/src/it/deploy-at-end-fail/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -60,22 +60,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.0.4</version> + <version>@mavenSourcePluginVersion@</version> <executions> <execution> <id>attach-sources</id> @@ -88,7 +88,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/deploy-at-end-pass/module1/pom.xml b/src/it/deploy-at-end-pass/module1/pom.xml index 1a91fc5627a5fa4af735d14f386b7ca6c4f71ffe..602a8f5c97d4362d4956302345c65b604f186dd0 100644 --- a/src/it/deploy-at-end-pass/module1/pom.xml +++ b/src/it/deploy-at-end-pass/module1/pom.xml @@ -22,27 +22,4 @@ </parent> <artifactId>module1</artifactId> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-enforcer-plugin</artifactId> - <version>1.2</version> - <executions> - <execution> - <id>enforce</id> - <goals> - <goal>enforce</goal> - </goals> - <configuration> - <rules> - <AlwaysPass /> - </rules> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </project> diff --git a/src/it/deploy-at-end-pass/module2/pom.xml b/src/it/deploy-at-end-pass/module2/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..827396feb35a7e55fff751dec9180e1ecb76df37 --- /dev/null +++ b/src/it/deploy-at-end-pass/module2/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- 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. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.deploy.dae.pass</groupId> + <artifactId>dae</artifactId> + <version>1.0</version> + </parent> + <artifactId>module2</artifactId> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <executions> + <execution> + <id>default-deploy</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/deploy-at-end-pass/module3/pom.xml b/src/it/deploy-at-end-pass/module3/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..48c9caa072c65d6c16af9603afc042368bb407fd --- /dev/null +++ b/src/it/deploy-at-end-pass/module3/pom.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- 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. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.deploy.dae.pass</groupId> + <artifactId>dae</artifactId> + <version>1.0</version> + </parent> + <artifactId>module3</artifactId> + +</project> diff --git a/src/it/deploy-at-end-pass/module4/pom.xml b/src/it/deploy-at-end-pass/module4/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..05f07629b78b5f3d9a983c006630b10367ccc8c6 --- /dev/null +++ b/src/it/deploy-at-end-pass/module4/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- 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. --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.deploy.dae.pass</groupId> + <artifactId>dae</artifactId> + <version>1.0</version> + </parent> + <artifactId>module4</artifactId> + + <!-- packaging without deploy plugin --> + <packaging>without-deploy</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.its.deploy.mock</groupId> + <artifactId>mock-phase-maven-plugin</artifactId> + <version>1.0</version> + <extensions>true</extensions> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/deploy-at-end-pass/pom.xml b/src/it/deploy-at-end-pass/pom.xml index ecf739a8b57e23af3ac6b3b92b19a12a8cc13657..90ed655c3c05bdbdddfc2e83e26cd3bd6b7536a4 100644 --- a/src/it/deploy-at-end-pass/pom.xml +++ b/src/it/deploy-at-end-pass/pom.xml @@ -38,7 +38,7 @@ under the License. <distributionManagement> <repository> <id>it</id> - <url>file:///${basedir}/target/repo</url> + <url>file:///@remoteRepo@/deploy-at-end-pass</url> </repository> </distributionManagement> @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -60,22 +60,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.0.4</version> + <version>@mavenSourcePluginVersion@</version> <executions> <execution> <id>attach-sources</id> @@ -88,12 +88,15 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> <modules> <module>module1</module> + <module>module2</module> + <module>module3</module> + <module>module4</module> </modules> </project> diff --git a/src/it/deploy-at-end-pass/verify.groovy b/src/it/deploy-at-end-pass/verify.groovy index 634808a555ca020a70de380d03c2a253fe765a68..8db44909a159e414c0c6225f6533bd5272715387 100644 --- a/src/it/deploy-at-end-pass/verify.groovy +++ b/src/it/deploy-at-end-pass/verify.groovy @@ -17,10 +17,16 @@ * under the License. */ -assert new File( basedir, "target/repo/org/apache/maven/its/deploy/dae/pass/dae/1.0/dae-1.0.pom" ).exists() -assert new File( basedir, "module1/target/repo/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/dae/1.0/dae-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.jar" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module3/1.0/module3-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module3/1.0/module3-1.0.jar" ).exists() File buildLog = new File( basedir, 'build.log' ) assert buildLog.exists() assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:dae:1.0 at end" ) +assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module1:1.0 at end" ) +// Last module does not emit this misleading message, as it IS "the end", not deferring anymore +//assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module3:1.0 at end" ) diff --git a/src/it/deploy-attached-sources/pom.xml b/src/it/deploy-attached-sources/pom.xml index 43a2e22ec0ca95b092def3285a80f1921e72e7f3..01a48240b8067a760f7c1c74a0c5684b55a1a9e1 100644 --- a/src/it/deploy-attached-sources/pom.xml +++ b/src/it/deploy-attached-sources/pom.xml @@ -49,7 +49,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.1.2</version> + <version>@mavenSourcePluginVersion@</version> <executions> <execution> <id>attach-sources</id> @@ -62,7 +62,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>3.0.1</version> + <version>@mavenJavadocPluginVersion@</version> <executions> <execution> <id>attach-javadoc</id> diff --git a/src/it/deploy-default-packaging/pom.xml b/src/it/deploy-default-packaging/pom.xml index 9764c8b82a05b64f13b15150b6994ea3e0311add..9440f68f025d620800b57b75fc2a8d2f472306fa 100644 --- a/src/it/deploy-default-packaging/pom.xml +++ b/src/it/deploy-default-packaging/pom.xml @@ -49,7 +49,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.1.2</version> + <version>@mavenSourcePluginVersion@</version> <executions> <execution> <id>attach-sources</id> @@ -62,7 +62,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>2.7</version> + <version>@mavenJavadocPluginVersion@</version> <executions> <execution> <id>attach-javadoc</id> diff --git a/src/it/deployfile-release-skip-fail/invoker.properties b/src/it/deployfile-release-skip-fail/invoker.properties new file mode 100644 index 0000000000000000000000000000000000000000..44aca986f8342ca740c0d112e48da70fdd113e64 --- /dev/null +++ b/src/it/deployfile-release-skip-fail/invoker.properties @@ -0,0 +1,17 @@ +# 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. +invoker.goals=package deploy:deploy-file diff --git a/src/it/deployfile-release-skip-fail/pom.xml b/src/it/deployfile-release-skip-fail/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ab4e9cb73f8e2f2c2f0dc76c0a236001c9f06b0f --- /dev/null +++ b/src/it/deployfile-release-skip-fail/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.deploy.its</groupId> + <artifactId>deployfile-release-skip-fail</artifactId> + <version>1.0</version> + + <description> + Test to verify that skip stops artifact deployment + </description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <version>1.0</version> + <skip>snapshots</skip> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/deployfile-release-skip-fail/test.properties b/src/it/deployfile-release-skip-fail/test.properties new file mode 100644 index 0000000000000000000000000000000000000000..4b138a5c53ea40abdd8b4850733b913fc627f2e8 --- /dev/null +++ b/src/it/deployfile-release-skip-fail/test.properties @@ -0,0 +1,18 @@ +# 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. +file=target/deployfile-release-skip-fail-1.0.jar +url=file:target/repo \ No newline at end of file diff --git a/src/it/deployfile-release-skip-fail/verify.groovy b/src/it/deployfile-release-skip-fail/verify.groovy new file mode 100644 index 0000000000000000000000000000000000000000..17fe4366ff3062756ff9bd8521badd63dcde23ed --- /dev/null +++ b/src/it/deployfile-release-skip-fail/verify.groovy @@ -0,0 +1,26 @@ +/* + * 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. + */ + +assert new File(basedir, "target/repo/org/apache/maven/plugins/deploy/its/deployfile-release-skip-fail/1.0/deployfile-release-skip-fail-1.0.jar").exists() +File deployedPom = new File(basedir, "target/repo/org/apache/maven/plugins/deploy/its/deployfile-release-skip-fail/1.0/deployfile-release-skip-fail-1.0.pom") +assert deployedPom.exists() + +File buildLog = new File(basedir, 'build.log') +assert buildLog.exists() +assert buildLog.text.contains("[DEBUG] Using META-INF/maven/org.apache.maven.plugins.deploy.its/deployfile-release-skip-fail/pom.xml as pomFile") diff --git a/src/it/deployfile-release-skip/invoker.properties b/src/it/deployfile-release-skip/invoker.properties new file mode 100644 index 0000000000000000000000000000000000000000..44aca986f8342ca740c0d112e48da70fdd113e64 --- /dev/null +++ b/src/it/deployfile-release-skip/invoker.properties @@ -0,0 +1,17 @@ +# 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. +invoker.goals=package deploy:deploy-file diff --git a/src/it/deployfile-release-skip/pom.xml b/src/it/deployfile-release-skip/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..3a02d9afd13aa90ea094a4bc311f8e53821f3575 --- /dev/null +++ b/src/it/deployfile-release-skip/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.deploy.its</groupId> + <artifactId>deployfile-release-skip</artifactId> + <version>1.0</version> + + <description> + Test to verify that skip stops artifact deployment + </description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <version>1.0</version> + <skip>releases</skip> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/deployfile-release-skip/test.properties b/src/it/deployfile-release-skip/test.properties new file mode 100644 index 0000000000000000000000000000000000000000..2895346471993088759807ddd9eb087624a7c70f --- /dev/null +++ b/src/it/deployfile-release-skip/test.properties @@ -0,0 +1,18 @@ +# 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. +file=target/deployfile-release-skip-1.0.jar +url=file:target/repo \ No newline at end of file diff --git a/src/it/deployfile-release-skip/verify.groovy b/src/it/deployfile-release-skip/verify.groovy new file mode 100644 index 0000000000000000000000000000000000000000..c476e408b42d6f2d391ca86be746e7ce62fcd13a --- /dev/null +++ b/src/it/deployfile-release-skip/verify.groovy @@ -0,0 +1,24 @@ +/* + * 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. + */ + +assert !new File(basedir, "target/repo/org/apache/maven/plugins/deploy/its/deployfile-release-skip").exists() + +File buildLog = new File(basedir, 'build.log') +assert buildLog.exists() +assert !buildLog.text.contains("[DEBUG] Using META-INF/maven/org.apache.maven.plugins.deploy.its/deployfile-release-skip/pom.xml as pomFile") diff --git a/src/it/deployfile-skip-fail/invoker.properties b/src/it/deployfile-skip-fail/invoker.properties new file mode 100644 index 0000000000000000000000000000000000000000..44aca986f8342ca740c0d112e48da70fdd113e64 --- /dev/null +++ b/src/it/deployfile-skip-fail/invoker.properties @@ -0,0 +1,17 @@ +# 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. +invoker.goals=package deploy:deploy-file diff --git a/src/it/deployfile-skip-fail/pom.xml b/src/it/deployfile-skip-fail/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ae7aa257b65fbeea75a1e840df52a54ade8db69e --- /dev/null +++ b/src/it/deployfile-skip-fail/pom.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.deploy.its</groupId> + <artifactId>deployfile-skip-fail</artifactId> + <version>1.0</version> + + <description> + Test to verify that skip stops artifact deployment + </description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <skip>false</skip> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/deployfile-skip-fail/test.properties b/src/it/deployfile-skip-fail/test.properties new file mode 100644 index 0000000000000000000000000000000000000000..f93ace8d84b9e12590a726fa80868d1663a2ec44 --- /dev/null +++ b/src/it/deployfile-skip-fail/test.properties @@ -0,0 +1,18 @@ +# 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. +file=target/deployfile-skip-fail-1.0.jar +url=file:target/repo \ No newline at end of file diff --git a/src/it/deployfile-skip-fail/verify.groovy b/src/it/deployfile-skip-fail/verify.groovy new file mode 100644 index 0000000000000000000000000000000000000000..35e8db1f9b4937105fddc98897625f88149eefb4 --- /dev/null +++ b/src/it/deployfile-skip-fail/verify.groovy @@ -0,0 +1,26 @@ +/* + * 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. + */ + +assert new File(basedir, "target/repo/org/apache/maven/plugins/deploy/its/deployfile-skip-fail/1.0/deployfile-skip-fail-1.0.jar").exists() +File deployedPom = new File(basedir, "target/repo/org/apache/maven/plugins/deploy/its/deployfile-skip-fail/1.0/deployfile-skip-fail-1.0.pom") +assert deployedPom.exists() + +File buildLog = new File(basedir, 'build.log') +assert buildLog.exists() +assert buildLog.text.contains("[DEBUG] Using META-INF/maven/org.apache.maven.plugins.deploy.its/deployfile-skip-fail/pom.xml as pomFile") diff --git a/src/it/deployfile-skip/invoker.properties b/src/it/deployfile-skip/invoker.properties new file mode 100644 index 0000000000000000000000000000000000000000..44aca986f8342ca740c0d112e48da70fdd113e64 --- /dev/null +++ b/src/it/deployfile-skip/invoker.properties @@ -0,0 +1,17 @@ +# 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. +invoker.goals=package deploy:deploy-file diff --git a/src/it/deployfile-skip/pom.xml b/src/it/deployfile-skip/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..530a84ec30eadd89f77ad31def83bad792239a9f --- /dev/null +++ b/src/it/deployfile-skip/pom.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.deploy.its</groupId> + <artifactId>deployfile-skip</artifactId> + <version>1.0</version> + + <description> + Test to verify that skip stops artifact deployment + </description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/deployfile-skip/test.properties b/src/it/deployfile-skip/test.properties new file mode 100644 index 0000000000000000000000000000000000000000..b1cd01111c5277458abb5522fe1e617137c24044 --- /dev/null +++ b/src/it/deployfile-skip/test.properties @@ -0,0 +1,18 @@ +# 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. +file=target/deployfile-skip-1.0.jar +url=file:target/repo \ No newline at end of file diff --git a/src/it/attach-jar-checksum-release/setup.bsh b/src/it/deployfile-skip/verify.groovy similarity index 71% rename from src/it/attach-jar-checksum-release/setup.bsh rename to src/it/deployfile-skip/verify.groovy index 4d7397155d212acf7cf8f2f55bb665972096f602..618ff5e405c5460a0200fff9d4647234ac9f5f0d 100644 --- a/src/it/attach-jar-checksum-release/setup.bsh +++ b/src/it/deployfile-skip/verify.groovy @@ -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 @@ -17,13 +17,8 @@ * under the License. */ -import java.io.*; -import java.util.*; +assert !new File(basedir, "target/repo/org/apache/maven/plugins/deploy/its/deployfile-skip").exists() -import org.codehaus.plexus.util.*; - -File file = new File( basedir, "org/apache/maven/its/deploy/ajc" ); -System.out.println( "Deleting " + file ); -FileUtils.deleteDirectory( file ); - -return true; +File buildLog = new File(basedir, 'build.log') +assert buildLog.exists() +assert !buildLog.text.contains("[DEBUG] Using META-INF/maven/org.apache.maven.plugins.deploy.its/deployfile-skip/pom.xml as pomFile") diff --git a/src/it/deployfile-snapshot-skip-fail/invoker.properties b/src/it/deployfile-snapshot-skip-fail/invoker.properties new file mode 100644 index 0000000000000000000000000000000000000000..44aca986f8342ca740c0d112e48da70fdd113e64 --- /dev/null +++ b/src/it/deployfile-snapshot-skip-fail/invoker.properties @@ -0,0 +1,17 @@ +# 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. +invoker.goals=package deploy:deploy-file diff --git a/src/it/deployfile-snapshot-skip-fail/pom.xml b/src/it/deployfile-snapshot-skip-fail/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..aba1a40df82da0f61612df5dc8cfd08d3336fca8 --- /dev/null +++ b/src/it/deployfile-snapshot-skip-fail/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.deploy.its</groupId> + <artifactId>deployfile-snapshot-skip-fail</artifactId> + <version>1.0</version> + + <description> + Test to verify that skip stops artifact deployment + </description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <version>1.0-SNAPSHOT</version> + <skip>releases</skip> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/deployfile-snapshot-skip-fail/test.properties b/src/it/deployfile-snapshot-skip-fail/test.properties new file mode 100644 index 0000000000000000000000000000000000000000..24b71939779c94517290043bd9c5e815d185353b --- /dev/null +++ b/src/it/deployfile-snapshot-skip-fail/test.properties @@ -0,0 +1,18 @@ +# 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. +file=target/deployfile-snapshot-skip-fail-1.0.jar +url=file:target/repo \ No newline at end of file diff --git a/src/it/deployfile-snapshot-skip-fail/verify.groovy b/src/it/deployfile-snapshot-skip-fail/verify.groovy new file mode 100644 index 0000000000000000000000000000000000000000..21ef0c72f3d0ecca58496b17860cf88d1fef6ce6 --- /dev/null +++ b/src/it/deployfile-snapshot-skip-fail/verify.groovy @@ -0,0 +1,28 @@ +/* + * 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. + */ + +File deployedDir = new File(basedir, "target/repo/org/apache/maven/plugins/deploy/its/deployfile-snapshot-skip-fail/1.0-SNAPSHOT") +assert deployedDir.exists() +assert deployedDir.isDirectory() +assert deployedDir.listFiles({ File file, String name -> name.matches("deployfile-snapshot-skip-fail-1\\.0-.*\\.jar") } as FilenameFilter).length == 1 +assert deployedDir.listFiles({ File file, String name -> name.matches("deployfile-snapshot-skip-fail-1\\.0-.*\\.pom") } as FilenameFilter).length == 1 + +File buildLog = new File(basedir, 'build.log') +assert buildLog.exists() +assert buildLog.text.contains("[DEBUG] Using META-INF/maven/org.apache.maven.plugins.deploy.its/deployfile-snapshot-skip-fail/pom.xml as pomFile") diff --git a/src/it/deployfile-snapshot-skip/invoker.properties b/src/it/deployfile-snapshot-skip/invoker.properties new file mode 100644 index 0000000000000000000000000000000000000000..44aca986f8342ca740c0d112e48da70fdd113e64 --- /dev/null +++ b/src/it/deployfile-snapshot-skip/invoker.properties @@ -0,0 +1,17 @@ +# 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. +invoker.goals=package deploy:deploy-file diff --git a/src/it/deployfile-snapshot-skip/pom.xml b/src/it/deployfile-snapshot-skip/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..cbedfd8cf45d2045c7b1337818d872f9a4df8bd0 --- /dev/null +++ b/src/it/deployfile-snapshot-skip/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.deploy.its</groupId> + <artifactId>deployfile-snapshot-skip</artifactId> + <version>1.0</version> + + <description> + Test to verify that skip stops artifact deployment + </description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <version>1.0-SNAPSHOT</version> + <skip>snapshots</skip> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/deployfile-snapshot-skip/test.properties b/src/it/deployfile-snapshot-skip/test.properties new file mode 100644 index 0000000000000000000000000000000000000000..b33c818126d9fcd1af1ad2d1023d4409a9b6022a --- /dev/null +++ b/src/it/deployfile-snapshot-skip/test.properties @@ -0,0 +1,18 @@ +# 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. +file=target/deployfile-snapshot-skip-1.0.jar +url=file:target/repo \ No newline at end of file diff --git a/src/it/deployfile-snapshot-skip/verify.groovy b/src/it/deployfile-snapshot-skip/verify.groovy new file mode 100644 index 0000000000000000000000000000000000000000..ab46c5907a3d3bcd4bfef6b881a93c7845ab1d96 --- /dev/null +++ b/src/it/deployfile-snapshot-skip/verify.groovy @@ -0,0 +1,24 @@ +/* + * 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. + */ + +assert !new File(basedir, "target/repo/org/apache/maven/plugins/deploy/its/deployfile-snapshot-skip").exists() + +File buildLog = new File(basedir, 'build.log') +assert buildLog.exists() +assert !buildLog.text.contains("[DEBUG] Using META-INF/maven/org.apache.maven.plugins.deploy.its/deployfile-snapshot-skip/pom.xml as pomFile") diff --git a/src/it/mdeploy-45-test/pom.xml b/src/it/mdeploy-45-test/pom.xml index 2447705a4f6754a4d0d439d124bb2cd3d1fad1d4..cdefaade0ef16ecf988c86f4162912d4523e15ca 100644 --- a/src/it/mdeploy-45-test/pom.xml +++ b/src/it/mdeploy-45-test/pom.xml @@ -54,7 +54,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.5</version> + <version>@mavenResourcesPluginVersion@</version> <executions> <execution> <goals> @@ -66,7 +66,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenWarPluginVersion@</version> <executions> <execution> <goals> diff --git a/src/it/no-main-artifact-1/pom.xml b/src/it/no-main-artifact-1/pom.xml index a9a7c2bb9fc2936ea9926be9a8e6e63a0cbbdf44..18944b6766c4d163153477525b4876fb62c57bec 100644 --- a/src/it/no-main-artifact-1/pom.xml +++ b/src/it/no-main-artifact-1/pom.xml @@ -49,14 +49,14 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> - <version>1.1</version> + <version>@mavenAntrunPluginVersion@</version> <configuration> - <tasks> + <target> <!-- NOTE: The Compiler Plugin sets this as the main artifact file, should be non-existent for this test. --> <delete dir="target/classes"/> - </tasks> + </target> </configuration> <executions> <execution> @@ -71,7 +71,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -81,7 +81,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> <configuration> <classifier>it</classifier> </configuration> @@ -89,17 +89,17 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.3</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/no-main-artifact-2/pom.xml b/src/it/no-main-artifact-2/pom.xml index e063973c9b9e06dfec377eb0b70df7ed9fb21b65..f9644f9be9b3b1a8dd1875b37b9eef7f5f320f76 100644 --- a/src/it/no-main-artifact-2/pom.xml +++ b/src/it/no-main-artifact-2/pom.xml @@ -48,14 +48,14 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> - <version>1.1</version> + <version>@mavenAntrunPluginVersion@</version> <configuration> - <tasks> + <target> <!-- NOTE: The Compiler Plugin sets this as the main artifact file, should be existent for this test. --> <mkdir dir="target/classes"/> - </tasks> + </target> </configuration> <executions> <execution> @@ -70,7 +70,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -80,7 +80,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> <configuration> <classifier>it</classifier> </configuration> @@ -88,17 +88,17 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/no-main-artifact-snapshot/pom.xml b/src/it/no-main-artifact-snapshot/pom.xml index cb9061068d11c3c1ff095e4dd33ec8b87f53e3d9..89c4fc99470145b92f5afbc9f9cd2f60ae509e8c 100644 --- a/src/it/no-main-artifact-snapshot/pom.xml +++ b/src/it/no-main-artifact-snapshot/pom.xml @@ -48,7 +48,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> <executions> <execution> <goals> @@ -65,7 +65,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> <executions> <execution> <goals> @@ -80,12 +80,12 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.3</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> <executions> <execution> <goals> diff --git a/src/it/non-default-pom/non-default-pom.xml b/src/it/non-default-pom/non-default-pom.xml index 231a7c13ab951d6060da34ebec2d69d88bb31643..e97b2b9b9a44a5eb6de2e00d633daf7296174ab7 100644 --- a/src/it/non-default-pom/non-default-pom.xml +++ b/src/it/non-default-pom/non-default-pom.xml @@ -52,12 +52,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <version>2.0-beta-5</version> + <version>@mavenInstallPluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/offline/pom.xml b/src/it/offline/pom.xml index 32e53ec274a62d233c9f10522eee1194b8ecd2c9..cdad63cf42af3593d06e121bdf26e5d405365a6a 100644 --- a/src/it/offline/pom.xml +++ b/src/it/offline/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -57,22 +57,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/release-jar/pom.xml b/src/it/release-jar/pom.xml index af72e7d724809acd45c9036197e6fbe407eb3ea8..1d275c9c5006861d12b0be8ca29c7a668b1b48d1 100644 --- a/src/it/release-jar/pom.xml +++ b/src/it/release-jar/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -57,22 +57,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/release-pom/pom.xml b/src/it/release-pom/pom.xml index d7bff31b71518f8e76057cd27c97cbf919176564..fe9c110e02c1d1e7008aed0049e6d8ce940358f1 100644 --- a/src/it/release-pom/pom.xml +++ b/src/it/release-pom/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -57,22 +57,17 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <version>2.0-beta-5</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/setup-mock-phase-maven-plugin/invoker.properties b/src/it/setup-mock-phase-maven-plugin/invoker.properties new file mode 100644 index 0000000000000000000000000000000000000000..d5d6ca5db81e9d298be91991d92bf5a463aff9c6 --- /dev/null +++ b/src/it/setup-mock-phase-maven-plugin/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = install diff --git a/src/it/setup-mock-phase-maven-plugin/pom.xml b/src/it/setup-mock-phase-maven-plugin/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..4ebb8af5a874caa20f1689532e5db8f372887ee5 --- /dev/null +++ b/src/it/setup-mock-phase-maven-plugin/pom.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.its.deploy.mock</groupId> + <artifactId>mock-phase-maven-plugin</artifactId> + <version>1.0</version> + <packaging>maven-plugin</packaging> + + <prerequisites> + <maven>@mavenVersion@</maven> + </prerequisites> + + <description>plugin with Maven phase without m-deploy-p</description> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-install-plugin</artifactId> + <version>@mavenInstallPluginVersion@</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>@mavenPluginToolsVersion@</version> + <configuration> + <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + +</project> diff --git a/src/it/setup-mock-phase-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/src/it/setup-mock-phase-maven-plugin/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 0000000000000000000000000000000000000000..93e017cacb4e9efbe96f3c955ca99f57a9a51a55 --- /dev/null +++ b/src/it/setup-mock-phase-maven-plugin/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<component-set> + <components> + <component> + <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role> + <role-hint>without-deploy</role-hint> + <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation> + <configuration> + <lifecycles> + <lifecycle> + <id>default</id> + <phases> + <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources> + </phases> + </lifecycle> + </lifecycles> + </configuration> + </component> + </components> +</component-set> diff --git a/src/it/skip-release-jar/pom.xml b/src/it/skip-release-jar/pom.xml index 3e57a45e51e4cac6573676940f6aa4a5ea25bee3..2774462e688304663b308a860b5ea409a9d07892 100644 --- a/src/it/skip-release-jar/pom.xml +++ b/src/it/skip-release-jar/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -60,22 +60,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/skip-snapshot-jar/pom.xml b/src/it/skip-snapshot-jar/pom.xml index a58a66fafefd9a18d7f8d1016a30ae9359601798..a009904146da0cd9083fd6b04569b86d1bd175dc 100644 --- a/src/it/skip-snapshot-jar/pom.xml +++ b/src/it/skip-snapshot-jar/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -60,22 +60,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/skip/pom.xml b/src/it/skip/pom.xml index 0b50d3876ab08bd7f7149014d6061b0d89336e21..652b3080eded3d3ba2e5cf0921cdf6bcb3931882 100644 --- a/src/it/skip/pom.xml +++ b/src/it/skip/pom.xml @@ -42,7 +42,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -55,22 +55,17 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <version>2.0-beta-5</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/snapshot-jar/pom.xml b/src/it/snapshot-jar/pom.xml index bd215e05434442070b1c26c48bc35096bd26d3a6..899b58320deb3109a368c990405e09660687b411 100644 --- a/src/it/snapshot-jar/pom.xml +++ b/src/it/snapshot-jar/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -57,22 +57,22 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>2.1</version> + <version>@mavenJarPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/it/snapshot-pom/pom.xml b/src/it/snapshot-pom/pom.xml index 735559d7bab19a4c7dd0a6745a301f09422777ff..5ff795c71511e43f28fdbc87700c1ce0e45bc44b 100644 --- a/src/it/snapshot-pom/pom.xml +++ b/src/it/snapshot-pom/pom.xml @@ -47,7 +47,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>@mavenCompilerPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -57,22 +57,17 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> - <version>2.2</version> + <version>@mavenInstallPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> - <version>2.2</version> + <version>@mavenResourcesPluginVersion@</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.3.1</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <version>2.0-beta-5</version> + <version>@mavenSurefirePluginVersion@</version> </plugin> </plugins> </build> diff --git a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java index 4a66ecd8906ba569ea673b1e34e11b77c1f68988..2c5c1d9cd9cc847706be0136a24e76bcbb6d04b5 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy; * "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 + * 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 @@ -18,6 +16,7 @@ package org.apache.maven.plugins.deploy; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; @@ -27,7 +26,6 @@ import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.rtinfo.RuntimeInformation; import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.deployment.DeployRequest; import org.eclipse.aether.deployment.DeploymentException; import org.eclipse.aether.repository.RemoteRepository; @@ -38,13 +36,11 @@ import org.eclipse.aether.version.Version; /** * Abstract class for Deploy mojo's. */ -public abstract class AbstractDeployMojo - extends AbstractMojo -{ +public abstract class AbstractDeployMojo extends AbstractMojo { /** * Flag whether Maven is currently in online/offline mode. */ - @Parameter( defaultValue = "${settings.offline}", readonly = true ) + @Parameter(defaultValue = "${settings.offline}", readonly = true) private boolean offline; /** @@ -53,13 +49,13 @@ public abstract class AbstractDeployMojo * * @since 2.7 */ - @Parameter( property = "retryFailedDeploymentCount", defaultValue = "1" ) + @Parameter(property = "retryFailedDeploymentCount", defaultValue = "1") private int retryFailedDeploymentCount; @Component private RuntimeInformation runtimeInformation; - @Parameter( defaultValue = "${session}", readonly = true, required = true ) + @Parameter(defaultValue = "${session}", readonly = true, required = true) protected MavenSession session; @Component @@ -71,38 +67,29 @@ public abstract class AbstractDeployMojo /* Setters and Getters */ - void failIfOffline() - throws MojoFailureException - { - if ( offline ) - { - throw new MojoFailureException( "Cannot deploy artifacts when Maven is in offline mode" ); + void failIfOffline() throws MojoFailureException { + if (offline) { + throw new MojoFailureException("Cannot deploy artifacts when Maven is in offline mode"); } } /** * If this plugin used in pre-3.9.0 Maven, the packaging {@code maven-plugin} will not deploy G level metadata. */ - protected void warnIfAffectedPackagingAndMaven( final String packaging ) - { - if ( AFFECTED_MAVEN_PACKAGING.equals( packaging ) ) - { - try - { + protected void warnIfAffectedPackagingAndMaven(final String packaging) { + if (AFFECTED_MAVEN_PACKAGING.equals(packaging)) { + try { GenericVersionScheme versionScheme = new GenericVersionScheme(); - Version fixedMavenVersion = versionScheme.parseVersion( FIXED_MAVEN_VERSION ); - Version currentMavenVersion = versionScheme.parseVersion( runtimeInformation.getMavenVersion() ); - if ( fixedMavenVersion.compareTo( currentMavenVersion ) > 0 ) - { - getLog().warn( "" ); - getLog().warn( "You are about to deploy a maven-plugin using Maven " + currentMavenVersion + "." ); - getLog().warn( "This plugin should be used ONLY with Maven 3.9.0 and newer, as MNG-7055" ); - getLog().warn( "is fixed in those versions of Maven only!" ); - getLog().warn( "" ); + Version fixedMavenVersion = versionScheme.parseVersion(FIXED_MAVEN_VERSION); + Version currentMavenVersion = versionScheme.parseVersion(runtimeInformation.getMavenVersion()); + if (fixedMavenVersion.compareTo(currentMavenVersion) > 0) { + getLog().warn(""); + getLog().warn("You are about to deploy a maven-plugin using Maven " + currentMavenVersion + "."); + getLog().warn("This plugin should be used ONLY with Maven 3.9.0 and newer, as MNG-7055"); + getLog().warn("is fixed in those versions of Maven only!"); + getLog().warn(""); } - } - catch ( InvalidVersionSpecificationException e ) - { + } catch (InvalidVersionSpecificationException e) { // skip it: Generic does not throw, only API contains this exception } } @@ -111,23 +98,21 @@ public abstract class AbstractDeployMojo /** * Creates resolver {@link RemoteRepository} equipped with needed whistles and bells. */ - protected RemoteRepository getRemoteRepository( final String repositoryId, final String url ) - { - RemoteRepository result = new RemoteRepository.Builder( repositoryId, "default", url ).build(); - - if ( result.getAuthentication() == null || result.getProxy() == null ) - { - RemoteRepository.Builder builder = new RemoteRepository.Builder( result ); - - if ( result.getAuthentication() == null ) - { - builder.setAuthentication( session.getRepositorySession().getAuthenticationSelector() - .getAuthentication( result ) ); + protected RemoteRepository getRemoteRepository(final String repositoryId, final String url) { + RemoteRepository result = new RemoteRepository.Builder(repositoryId, "default", url).build(); + + if (result.getAuthentication() == null || result.getProxy() == null) { + RemoteRepository.Builder builder = new RemoteRepository.Builder(result); + + if (result.getAuthentication() == null) { + builder.setAuthentication(session.getRepositorySession() + .getAuthenticationSelector() + .getAuthentication(result)); } - if ( result.getProxy() == null ) - { - builder.setProxy( session.getRepositorySession().getProxySelector().getProxy( result ) ); + if (result.getProxy() == null) { + builder.setProxy( + session.getRepositorySession().getProxySelector().getProxy(result)); } result = builder.build(); @@ -136,43 +121,36 @@ public abstract class AbstractDeployMojo return result; } - /** - * Handles high level retries (this was buried into MAT). - */ - protected void deploy( RepositorySystemSession session, DeployRequest deployRequest ) throws MojoExecutionException - { - int retryFailedDeploymentCounter = Math.max( 1, Math.min( 10, retryFailedDeploymentCount ) ); + // I'm not sure if retries will work with deploying on client level ... + // Most repository managers block a duplicate artifacts. + + // Eg, when we have an artifact list, even simple pom and jar in one request with released version, + // next try can fail due to duplicate. + + protected void deploy(DeployRequest deployRequest) throws MojoExecutionException { + int retryFailedDeploymentCounter = Math.max(1, Math.min(10, retryFailedDeploymentCount)); DeploymentException exception = null; - for ( int count = 0; count < retryFailedDeploymentCounter; count++ ) - { - try - { - if ( count > 0 ) - { - getLog().info( "Retrying deployment attempt " + ( count + 1 ) + " of " - + retryFailedDeploymentCounter ); + for (int count = 0; count < retryFailedDeploymentCounter; count++) { + try { + if (count > 0) { + getLog().info("Retrying deployment attempt " + (count + 1) + " of " + retryFailedDeploymentCounter); } - repositorySystem.deploy( session, deployRequest ); + repositorySystem.deploy(session.getRepositorySession(), deployRequest); exception = null; break; - } - catch ( DeploymentException e ) - { - if ( count + 1 < retryFailedDeploymentCounter ) - { - getLog().warn( "Encountered issue during deployment: " + e.getLocalizedMessage() ); - getLog().debug( e ); + } catch (DeploymentException e) { + if (count + 1 < retryFailedDeploymentCounter) { + getLog().warn("Encountered issue during deployment: " + e.getLocalizedMessage()); + getLog().debug(e); } - if ( exception == null ) - { + if (exception == null) { exception = e; } } } - if ( exception != null ) - { - throw new MojoExecutionException( exception.getMessage(), exception ); + if (exception != null) { + throw new MojoExecutionException(exception.getMessage(), exception); } } } diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java index 5d950438b3726c13036f49f8330eddf3bc1013c4..c6c875b1d83c9b903fcb2b58a3dd8ce33f93900d 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy; * "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 + * 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 @@ -18,21 +16,23 @@ package org.apache.maven.plugins.deploy; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; +import java.nio.file.Files; import java.util.Enumeration; import java.util.Objects; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.regex.Pattern; +import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; @@ -58,29 +58,27 @@ import org.eclipse.aether.util.artifact.SubArtifact; /** * Installs the artifact in the remote repository. - * + * * @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a> */ -@Mojo( name = "deploy-file", requiresProject = false, threadSafe = true ) -public class DeployFileMojo - extends AbstractDeployMojo -{ +@Mojo(name = "deploy-file", requiresProject = false, threadSafe = true) +public class DeployFileMojo extends AbstractDeployMojo { /** * GroupId of the artifact to be deployed. Retrieved from POM file if specified. */ - @Parameter( property = "groupId" ) + @Parameter(property = "groupId") private String groupId; /** * ArtifactId of the artifact to be deployed. Retrieved from POM file if specified. */ - @Parameter( property = "artifactId" ) + @Parameter(property = "artifactId") private String artifactId; /** * Version of the artifact to be deployed. Retrieved from POM file if specified. */ - @Parameter( property = "version" ) + @Parameter(property = "version") private String version; /** @@ -89,374 +87,297 @@ public class DeployFileMojo * Maven uses two terms to refer to this datum: the <packaging> element for the entire POM, and the * <type> element in a dependency specification. */ - @Parameter( property = "packaging" ) + @Parameter(property = "packaging") private String packaging; /** * Description passed to a generated POM file (in case of generatePom=true) */ - @Parameter( property = "generatePom.description" ) + @Parameter(property = "generatePom.description") private String description; /** * File to be deployed. */ - @Parameter( property = "file", required = true ) + @Parameter(property = "file", required = true) private File file; /** * The bundled API docs for the artifact. - * + * * @since 2.6 */ - @Parameter( property = "javadoc" ) + @Parameter(property = "javadoc") private File javadoc; /** * The bundled sources for the artifact. - * + * * @since 2.6 */ - @Parameter( property = "sources" ) + @Parameter(property = "sources") private File sources; /** * Server Id to map on the <id> under <server> section of settings.xml In most cases, this parameter * will be required for authentication. */ - @Parameter( property = "repositoryId", defaultValue = "remote-repository", required = true ) + @Parameter(property = "repositoryId", defaultValue = "remote-repository", required = true) private String repositoryId; /** * URL where the artifact will be deployed. <br/> * ie ( file:///C:/m2-repo or scp://host.com/path/to/repo ) */ - @Parameter( property = "url", required = true ) + @Parameter(property = "url", required = true) private String url; /** * Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter. */ - @Parameter( property = "pomFile" ) + @Parameter(property = "pomFile") private File pomFile; /** * Upload a POM for this artifact. Will generate a default POM if none is supplied with the pomFile argument. */ - @Parameter( property = "generatePom", defaultValue = "true" ) + @Parameter(property = "generatePom", defaultValue = "true") private boolean generatePom; /** * Add classifier to the artifact */ - @Parameter( property = "classifier" ) + @Parameter(property = "classifier") private String classifier; /** * A comma separated list of types for each of the extra side artifacts to deploy. If there is a mis-match in the * number of entries in {@link #files} or {@link #classifiers}, then an error will be raised. */ - @Parameter( property = "types" ) + @Parameter(property = "types") private String types; /** * A comma separated list of classifiers for each of the extra side artifacts to deploy. If there is a mis-match in * the number of entries in {@link #files} or {@link #types}, then an error will be raised. */ - @Parameter( property = "classifiers" ) + @Parameter(property = "classifiers") private String classifiers; /** * A comma separated list of files for each of the extra side artifacts to deploy. If there is a mis-match in the * number of entries in {@link #types} or {@link #classifiers}, then an error will be raised. */ - @Parameter( property = "files" ) + @Parameter(property = "files") private String files; - void initProperties() - throws MojoExecutionException - { - if ( pomFile == null ) - { - boolean foundPom = false; - - JarFile jarFile = null; - try - { - Pattern pomEntry = Pattern.compile( "META-INF/maven/.*/pom\\.xml" ); - - jarFile = new JarFile( file ); + /** + * Set this to 'true' to bypass artifact deploy + * It's not a real boolean as it can have more than 2 values: + * <ul> + * <li><code>true</code>: will skip as usual</li> + * <li><code>releases</code>: will skip if current version of the project is a release</li> + * <li><code>snapshots</code>: will skip if current version of the project is a snapshot</li> + * <li>any other values will be considered as <code>false</code></li> + * </ul> + * @since 3.1.0 + */ + @Parameter(property = "maven.deploy.file.skip", defaultValue = "false") + private String skip = Boolean.FALSE.toString(); + void initProperties() throws MojoExecutionException { + if (pomFile == null) { + boolean foundPom = false; + try (JarFile jarFile = new JarFile(file)) { + Pattern pomEntry = Pattern.compile("META-INF/maven/.*/pom\\.xml"); Enumeration<JarEntry> jarEntries = jarFile.entries(); - while ( jarEntries.hasMoreElements() ) - { + while (jarEntries.hasMoreElements()) { JarEntry entry = jarEntries.nextElement(); - if ( pomEntry.matcher( entry.getName() ).matches() ) - { - getLog().debug( "Using " + entry.getName() + " as pomFile" ); - + if (pomEntry.matcher(entry.getName()).matches()) { + getLog().debug("Using " + entry.getName() + " as pomFile"); foundPom = true; + String base = file.getName(); + if (base.indexOf('.') > 0) { + base = base.substring(0, base.lastIndexOf('.')); + } + pomFile = new File(file.getParentFile(), base + ".pom"); - InputStream pomInputStream = null; - OutputStream pomOutputStream = null; - - try - { - pomInputStream = jarFile.getInputStream( entry ); - - String base = file.getName(); - if ( base.indexOf( '.' ) > 0 ) - { - base = base.substring( 0, base.lastIndexOf( '.' ) ); + try (InputStream pomInputStream = jarFile.getInputStream(entry)) { + try (OutputStream pomOutputStream = Files.newOutputStream(pomFile.toPath())) { + IOUtil.copy(pomInputStream, pomOutputStream); } - pomFile = new File( file.getParentFile(), base + ".pom" ); - - pomOutputStream = new FileOutputStream( pomFile ); - - IOUtil.copy( pomInputStream, pomOutputStream ); - - pomOutputStream.close(); - pomOutputStream = null; - pomInputStream.close(); - pomInputStream = null; - - processModel( readModel( pomFile ) ); - + processModel(readModel(pomFile)); break; } - finally - { - IOUtil.close( pomInputStream ); - IOUtil.close( pomOutputStream ); - } } } - if ( !foundPom ) - { - getLog().info( "pom.xml not found in " + file.getName() ); + if (!foundPom) { + getLog().info("pom.xml not found in " + file.getName()); } - } - catch ( IOException e ) - { + } catch (IOException e) { // ignore, artifact not packaged by Maven } - finally - { - if ( jarFile != null ) - { - try - { - jarFile.close(); - } - catch ( IOException e ) - { - // we did our best - } - } - } - } - else - { - processModel( readModel( pomFile ) ); + } else { + processModel(readModel(pomFile)); } - if ( packaging == null && file != null ) - { - packaging = getExtension( file ); + if (packaging == null && file != null) { + packaging = getExtension(file); } } - public void execute() - throws MojoExecutionException, MojoFailureException - { - if ( !file.exists() ) - { - throw new MojoExecutionException( file.getPath() + " not found." ); + public void execute() throws MojoExecutionException, MojoFailureException { + if (Boolean.parseBoolean(skip) + || ("releases".equals(skip) && !ArtifactUtils.isSnapshot(version)) + || ("snapshots".equals(skip) && ArtifactUtils.isSnapshot(version))) { + getLog().info("Skipping artifact deployment"); + return; + } + + if (!file.exists()) { + throw new MojoExecutionException(file.getPath() + " not found."); } initProperties(); - RemoteRepository remoteRepository = getRemoteRepository( repositoryId, url ); + RemoteRepository remoteRepository = getRemoteRepository(repositoryId, url); - if ( StringUtils.isEmpty( remoteRepository.getProtocol() ) ) - { - throw new MojoExecutionException( "No transfer protocol found." ); + if (StringUtils.isEmpty(remoteRepository.getProtocol())) { + throw new MojoExecutionException("No transfer protocol found."); } - if ( groupId == null || artifactId == null || version == null || packaging == null ) - { - throw new MojoExecutionException( "The artifact information is incomplete: 'groupId', 'artifactId', " - + "'version' and 'packaging' are required." ); + if (groupId == null || artifactId == null || version == null || packaging == null) { + throw new MojoExecutionException("The artifact information is incomplete: 'groupId', 'artifactId', " + + "'version' and 'packaging' are required."); } - if ( !isValidId( groupId ) - || !isValidId( artifactId ) - || !isValidVersion( version ) ) - { - throw new MojoExecutionException( "The artifact information is not valid: uses invalid characters." ); + if (!isValidId(groupId) || !isValidId(artifactId) || !isValidVersion(version)) { + throw new MojoExecutionException("The artifact information is not valid: uses invalid characters."); } failIfOffline(); - warnIfAffectedPackagingAndMaven( packaging ); + warnIfAffectedPackagingAndMaven(packaging); DeployRequest deployRequest = new DeployRequest(); - deployRequest.setRepository( remoteRepository ); - - boolean isFilePom = classifier == null && "pom".equals( packaging ); - if ( !isFilePom ) - { - ArtifactType artifactType = session.getRepositorySession().getArtifactTypeRegistry().get( packaging ); - if ( artifactType != null - && StringUtils.isEmpty( classifier ) - && !StringUtils.isEmpty( artifactType.getClassifier() ) ) - { + deployRequest.setRepository(remoteRepository); + + boolean isFilePom = classifier == null && "pom".equals(packaging); + if (!isFilePom) { + ArtifactType artifactType = + session.getRepositorySession().getArtifactTypeRegistry().get(packaging); + if (artifactType != null + && StringUtils.isEmpty(classifier) + && !StringUtils.isEmpty(artifactType.getClassifier())) { classifier = artifactType.getClassifier(); } } Artifact mainArtifact = new DefaultArtifact( - groupId, - artifactId, - classifier, - isFilePom ? "pom" : getExtension( file ), - version - ).setFile( file ); - deployRequest.addArtifact( mainArtifact ); - - File artifactLocalFile = getLocalRepositoryFile( session.getRepositorySession(), mainArtifact ); - - if ( file.equals( artifactLocalFile ) ) - { - throw new MojoFailureException( "Cannot deploy artifact from the local repository: " + file ); + groupId, artifactId, classifier, isFilePom ? "pom" : getExtension(file), version) + .setFile(file); + deployRequest.addArtifact(mainArtifact); + + File artifactLocalFile = getLocalRepositoryFile(session.getRepositorySession(), mainArtifact); + + if (file.equals(artifactLocalFile)) { + throw new MojoFailureException("Cannot deploy artifact from the local repository: " + file); } File temporaryPom = null; - if ( !"pom".equals( packaging ) ) - { - if ( pomFile != null ) - { - deployRequest.addArtifact( new SubArtifact( mainArtifact, "", "pom", pomFile ) ); - } - else if ( generatePom ) - { + if (!"pom".equals(packaging)) { + if (pomFile != null) { + deployRequest.addArtifact(new SubArtifact(mainArtifact, "", "pom", pomFile)); + } else if (generatePom) { temporaryPom = generatePomFile(); - getLog().debug( "Deploying generated POM" ); - deployRequest.addArtifact( new SubArtifact( mainArtifact, "", "pom", temporaryPom ) ); - } - else - { - getLog().debug( "Skipping deploying POM" ); + getLog().debug("Deploying generated POM"); + deployRequest.addArtifact(new SubArtifact(mainArtifact, "", "pom", temporaryPom)); + } else { + getLog().debug("Skipping deploying POM"); } } - if ( sources != null ) - { - deployRequest.addArtifact( new SubArtifact( mainArtifact, "sources", "jar", sources ) ); + if (sources != null) { + deployRequest.addArtifact(new SubArtifact(mainArtifact, "sources", "jar", sources)); } - if ( javadoc != null ) - { - deployRequest.addArtifact( new SubArtifact( mainArtifact, "javadoc", "jar", javadoc ) ); + if (javadoc != null) { + deployRequest.addArtifact(new SubArtifact(mainArtifact, "javadoc", "jar", javadoc)); } - if ( files != null ) - { - if ( types == null ) - { - throw new MojoExecutionException( "You must specify 'types' if you specify 'files'" ); + if (files != null) { + if (types == null) { + throw new MojoExecutionException("You must specify 'types' if you specify 'files'"); } - if ( classifiers == null ) - { - throw new MojoExecutionException( "You must specify 'classifiers' if you specify 'files'" ); + if (classifiers == null) { + throw new MojoExecutionException("You must specify 'classifiers' if you specify 'files'"); } - int filesLength = StringUtils.countMatches( files, "," ); - int typesLength = StringUtils.countMatches( types, "," ); - int classifiersLength = StringUtils.countMatches( classifiers, "," ); - if ( typesLength != filesLength ) - { - throw new MojoExecutionException( "You must specify the same number of entries in 'files' and " - + "'types' (respectively " + filesLength + " and " + typesLength + " entries )" ); + int filesLength = StringUtils.countMatches(files, ","); + int typesLength = StringUtils.countMatches(types, ","); + int classifiersLength = StringUtils.countMatches(classifiers, ","); + if (typesLength != filesLength) { + throw new MojoExecutionException("You must specify the same number of entries in 'files' and " + + "'types' (respectively " + filesLength + " and " + typesLength + " entries )"); } - if ( classifiersLength != filesLength ) - { - throw new MojoExecutionException( "You must specify the same number of entries in 'files' and " - + "'classifiers' (respectively " + filesLength + " and " + classifiersLength + " entries )" ); + if (classifiersLength != filesLength) { + throw new MojoExecutionException("You must specify the same number of entries in 'files' and " + + "'classifiers' (respectively " + filesLength + " and " + classifiersLength + " entries )"); } int fi = 0; int ti = 0; int ci = 0; - for ( int i = 0; i <= filesLength; i++ ) - { - int nfi = files.indexOf( ',', fi ); - if ( nfi == -1 ) - { + for (int i = 0; i <= filesLength; i++) { + int nfi = files.indexOf(',', fi); + if (nfi == -1) { nfi = files.length(); } - int nti = types.indexOf( ',', ti ); - if ( nti == -1 ) - { + int nti = types.indexOf(',', ti); + if (nti == -1) { nti = types.length(); } - int nci = classifiers.indexOf( ',', ci ); - if ( nci == -1 ) - { + int nci = classifiers.indexOf(',', ci); + if (nci == -1) { nci = classifiers.length(); } - File file = new File( files.substring( fi, nfi ) ); - if ( !file.isFile() ) - { + File file = new File(files.substring(fi, nfi)); + if (!file.isFile()) { // try relative to the project basedir just in case - file = new File( files.substring( fi, nfi ) ); + file = new File(files.substring(fi, nfi)); } - if ( file.isFile() ) - { - String extension = getExtension( file ); - ArtifactType artifactType = session.getRepositorySession().getArtifactTypeRegistry() - .get( types.substring( ti, nti ).trim() ); - if ( artifactType != null && !Objects.equals( extension, artifactType.getExtension() ) ) - { + if (file.isFile()) { + String extension = getExtension(file); + ArtifactType artifactType = session.getRepositorySession() + .getArtifactTypeRegistry() + .get(types.substring(ti, nti).trim()); + if (artifactType != null && !Objects.equals(extension, artifactType.getExtension())) { extension = artifactType.getExtension(); } - deployRequest.addArtifact( - new SubArtifact( mainArtifact, classifiers.substring( ci, nci ).trim(), extension, file ) - ); - } - else - { - throw new MojoExecutionException( "Specified side artifact " + file + " does not exist" ); + deployRequest.addArtifact(new SubArtifact( + mainArtifact, classifiers.substring(ci, nci).trim(), extension, file)); + } else { + throw new MojoExecutionException("Specified side artifact " + file + " does not exist"); } fi = nfi + 1; ti = nti + 1; ci = nci + 1; } - } - else - { - if ( types != null ) - { - throw new MojoExecutionException( "You must specify 'files' if you specify 'types'" ); + } else { + if (types != null) { + throw new MojoExecutionException("You must specify 'files' if you specify 'types'"); } - if ( classifiers != null ) - { - throw new MojoExecutionException( "You must specify 'files' if you specify 'classifiers'" ); + if (classifiers != null) { + throw new MojoExecutionException("You must specify 'files' if you specify 'classifiers'"); } } - try - { - repositorySystem.deploy( session.getRepositorySession(), deployRequest ); - } - catch ( DeploymentException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } - finally - { - if ( temporaryPom != null ) - { + try { + repositorySystem.deploy(session.getRepositorySession(), deployRequest); + } catch (DeploymentException e) { + throw new MojoExecutionException(e.getMessage(), e); + } finally { + if (temporaryPom != null) { // noinspection ResultOfMethodCallIgnored temporaryPom.delete(); } @@ -467,198 +388,159 @@ public class DeployFileMojo * Gets the path of the specified artifact within the local repository. Note that the returned path need not exist * (yet). */ - private File getLocalRepositoryFile( RepositorySystemSession session, Artifact artifact ) - { - String path = session.getLocalRepositoryManager().getPathForLocalArtifact( artifact ); - return new File( session.getLocalRepository().getBasedir(), path ); + private File getLocalRepositoryFile(RepositorySystemSession session, Artifact artifact) { + String path = session.getLocalRepositoryManager().getPathForLocalArtifact(artifact); + return new File(session.getLocalRepository().getBasedir(), path); } /** * Process the supplied pomFile to get groupId, artifactId, version, and packaging - * + * * @param model The POM to extract missing artifact coordinates from, must not be <code>null</code>. */ - private void processModel( Model model ) - { + private void processModel(Model model) { Parent parent = model.getParent(); - if ( this.groupId == null ) - { + if (this.groupId == null) { this.groupId = model.getGroupId(); - if ( this.groupId == null && parent != null ) - { + if (this.groupId == null && parent != null) { this.groupId = parent.getGroupId(); } } - if ( this.artifactId == null ) - { + if (this.artifactId == null) { this.artifactId = model.getArtifactId(); } - if ( this.version == null ) - { + if (this.version == null) { this.version = model.getVersion(); - if ( this.version == null && parent != null ) - { + if (this.version == null && parent != null) { this.version = parent.getVersion(); } } - if ( this.packaging == null ) - { + if (this.packaging == null) { this.packaging = model.getPackaging(); } } /** * Extract the model from the specified POM file. - * + * * @param pomFile The path of the POM file to parse, must not be <code>null</code>. * @return The model from the POM file, never <code>null</code>. * @throws MojoExecutionException If the file doesn't exist of cannot be read. */ - Model readModel( File pomFile ) - throws MojoExecutionException - { + Model readModel(File pomFile) throws MojoExecutionException { Reader reader = null; - try - { - reader = ReaderFactory.newXmlReader( pomFile ); - final Model model = new MavenXpp3Reader().read( reader ); + try { + reader = ReaderFactory.newXmlReader(pomFile); + final Model model = new MavenXpp3Reader().read(reader); reader.close(); reader = null; return model; - } - catch ( FileNotFoundException e ) - { - throw new MojoExecutionException( "POM not found " + pomFile, e ); - } - catch ( IOException e ) - { - throw new MojoExecutionException( "Error reading POM " + pomFile, e ); - } - catch ( XmlPullParserException e ) - { - throw new MojoExecutionException( "Error parsing POM " + pomFile, e ); - } - finally - { - IOUtil.close( reader ); + } catch (FileNotFoundException e) { + throw new MojoExecutionException("POM not found " + pomFile, e); + } catch (IOException e) { + throw new MojoExecutionException("Error reading POM " + pomFile, e); + } catch (XmlPullParserException e) { + throw new MojoExecutionException("Error parsing POM " + pomFile, e); + } finally { + IOUtil.close(reader); } } /** * Generates a minimal POM from the user-supplied artifact information. - * + * * @return The path to the generated POM file, never <code>null</code>. * @throws MojoExecutionException If the generation failed. */ - private File generatePomFile() - throws MojoExecutionException - { + private File generatePomFile() throws MojoExecutionException { Model model = generateModel(); Writer fw = null; - try - { - File tempFile = File.createTempFile( "mvndeploy", ".pom" ); + try { + File tempFile = File.createTempFile("mvndeploy", ".pom"); tempFile.deleteOnExit(); - fw = WriterFactory.newXmlWriter( tempFile ); + fw = WriterFactory.newXmlWriter(tempFile); - new MavenXpp3Writer().write( fw, model ); + new MavenXpp3Writer().write(fw, model); fw.close(); fw = null; return tempFile; - } - catch ( IOException e ) - { - throw new MojoExecutionException( "Error writing temporary pom file: " + e.getMessage(), e ); - } - finally - { - IOUtil.close( fw ); + } catch (IOException e) { + throw new MojoExecutionException("Error writing temporary pom file: " + e.getMessage(), e); + } finally { + IOUtil.close(fw); } } /** * Generates a minimal model from the user-supplied artifact information. - * + * * @return The generated model, never <code>null</code>. */ - private Model generateModel() - { + private Model generateModel() { Model model = new Model(); - model.setModelVersion( "4.0.0" ); + model.setModelVersion("4.0.0"); - model.setGroupId( groupId ); - model.setArtifactId( artifactId ); - model.setVersion( version ); - model.setPackaging( packaging ); + model.setGroupId(groupId); + model.setArtifactId(artifactId); + model.setVersion(version); + model.setPackaging(packaging); - model.setDescription( description ); + model.setDescription(description); return model; } - void setGroupId( String groupId ) - { + void setGroupId(String groupId) { this.groupId = groupId; } - void setArtifactId( String artifactId ) - { + void setArtifactId(String artifactId) { this.artifactId = artifactId; } - void setVersion( String version ) - { + void setVersion(String version) { this.version = version; } - void setPackaging( String packaging ) - { + void setPackaging(String packaging) { this.packaging = packaging; } - void setPomFile( File pomFile ) - { + void setPomFile(File pomFile) { this.pomFile = pomFile; } - String getGroupId() - { + String getGroupId() { return groupId; } - String getArtifactId() - { + String getArtifactId() { return artifactId; } - String getVersion() - { + String getVersion() { return version; } - String getPackaging() - { + String getPackaging() { return packaging; } - File getFile() - { + File getFile() { return file; } - String getClassifier() - { + String getClassifier() { return classifier; } - void setClassifier( String classifier ) - { + void setClassifier(String classifier) { this.classifier = classifier; } @@ -667,34 +549,30 @@ public class DeployFileMojo /** * Specialization of {@link FileUtils#getExtension(String)} that honors various {@code tar.xxx} combinations. */ - private String getExtension( final File file ) - { + private String getExtension(final File file) { String filename = file.getName(); - if ( filename.contains( ".tar." ) ) - { - return "tar." + FileUtils.getExtension( filename ); - } - else - { - return FileUtils.getExtension( filename ); + if (filename.contains(".tar.")) { + return "tar." + FileUtils.getExtension(filename); + } else { + return FileUtils.getExtension(filename); } } /** * Returns {@code true} if passed in string is "valid Maven ID" (groupId or artifactId). */ - private boolean isValidId( String id ) - { - if ( id == null ) - { + private boolean isValidId(String id) { + if (id == null) { return false; } - for ( int i = 0; i < id.length(); i++ ) - { - char c = id.charAt( i ); - if ( !( c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' - || c >= '0' && c <= '9' || c == '-' || c == '_' || c == '.' ) ) - { + for (int i = 0; i < id.length(); i++) { + char c = id.charAt(i); + if (!(c >= 'a' && c <= 'z' + || c >= 'A' && c <= 'Z' + || c >= '0' && c <= '9' + || c == '-' + || c == '_' + || c == '.')) { return false; } } @@ -706,16 +584,12 @@ public class DeployFileMojo /** * Returns {@code true} if passed in string is "valid Maven (simple. non range, expression, etc) version". */ - private boolean isValidVersion( String version ) - { - if ( version == null ) - { + private boolean isValidVersion(String version) { + if (version == null) { return false; } - for ( int i = version.length() - 1; i >= 0; i-- ) - { - if ( ILLEGAL_VERSION_CHARS.indexOf( version.charAt( i ) ) >= 0 ) - { + for (int i = version.length() - 1; i >= 0; i--) { + if (ILLEGAL_VERSION_CHARS.indexOf(version.charAt(i)) >= 0) { return false; } } diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java index d169ab8aa7214c65fefbb393b4ae7cb4ff795ef9..4e317acfb0d80f98e12f17607c3e35c60048b1c4 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy; * "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 + * 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 @@ -18,8 +16,11 @@ package org.apache.maven.plugins.deploy; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy; import java.io.File; +import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -27,6 +28,8 @@ import java.util.regex.Pattern; import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.descriptor.PluginDescriptor; @@ -35,42 +38,37 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifact; -import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.eclipse.aether.deployment.DeployRequest; import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.util.artifact.SubArtifact; /** * Deploys an artifact to remote repository. - * + * * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> * @author <a href="mailto:jdcasey@apache.org">John Casey (refactoring only)</a> */ -@Mojo( name = "deploy", defaultPhase = LifecyclePhase.DEPLOY, threadSafe = true ) -public class DeployMojo - extends AbstractDeployMojo -{ - private static final Pattern ALT_LEGACY_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+?)::(.+?)::(.+)" ); +@Mojo(name = "deploy", defaultPhase = LifecyclePhase.DEPLOY, threadSafe = true) +public class DeployMojo extends AbstractDeployMojo { + private static final Pattern ALT_LEGACY_REPO_SYNTAX_PATTERN = Pattern.compile("(.+?)::(.+?)::(.+)"); - private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+?)::(.+)" ); + private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile("(.+?)::(.+)"); - @Parameter( defaultValue = "${project}", readonly = true, required = true ) + @Parameter(defaultValue = "${project}", readonly = true, required = true) private MavenProject project; - @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) + @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true) private List<MavenProject> reactorProjects; - @Parameter( defaultValue = "${plugin}", required = true, readonly = true ) + @Parameter(defaultValue = "${plugin}", required = true, readonly = true) private PluginDescriptor pluginDescriptor; /** * Whether every project should be deployed during its own deploy-phase or at the end of the multimodule build. If * set to {@code true} and the build fails, none of the reactor projects is deployed. - * <strong>(experimental)</strong> - * + * * @since 2.8 */ - @Parameter( defaultValue = "false", property = "deployAtEnd" ) + @Parameter(defaultValue = "false", property = "deployAtEnd") private boolean deployAtEnd; /** @@ -87,7 +85,7 @@ public class DeployMojo * could be <code>default</code> (ie. Maven 2) or <code>legacy</code> (ie. Maven 1), but since 3.0.0 the layout part * has been removed because Maven 3 only supports Maven 2 repository layout. */ - @Parameter( property = "altDeploymentRepository" ) + @Parameter(property = "altDeploymentRepository") private String altDeploymentRepository; /** @@ -99,7 +97,7 @@ public class DeployMojo * @since 2.8 * @see DeployMojo#altDeploymentRepository */ - @Parameter( property = "altSnapshotDeploymentRepository" ) + @Parameter(property = "altSnapshotDeploymentRepository") private String altSnapshotDeploymentRepository; /** @@ -111,7 +109,7 @@ public class DeployMojo * @since 2.8 * @see DeployMojo#altDeploymentRepository */ - @Parameter( property = "altReleaseDeploymentRepository" ) + @Parameter(property = "altReleaseDeploymentRepository") private String altReleaseDeploymentRepository; /** @@ -125,284 +123,255 @@ public class DeployMojo * </ul> * @since 2.4 */ - @Parameter( property = "maven.deploy.skip", defaultValue = "false" ) + @Parameter(property = "maven.deploy.skip", defaultValue = "false") private String skip = Boolean.FALSE.toString(); - private enum State - { - SKIPPED, DEPLOYED, TO_BE_DEPLOYED + private enum State { + SKIPPED, + DEPLOYED, + TO_BE_DEPLOYED } private static final String DEPLOY_PROCESSED_MARKER = DeployMojo.class.getName() + ".processed"; private static final String DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY = - DeployMojo.class.getName() + ".altReleaseDeploymentRepository"; + DeployMojo.class.getName() + ".altReleaseDeploymentRepository"; private static final String DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY = - DeployMojo.class.getName() + ".altSnapshotDeploymentRepository"; + DeployMojo.class.getName() + ".altSnapshotDeploymentRepository"; private static final String DEPLOY_ALT_DEPLOYMENT_REPOSITORY = - DeployMojo.class.getName() + ".altDeploymentRepository"; + DeployMojo.class.getName() + ".altDeploymentRepository"; - private void putState( State state ) - { - getPluginContext().put( DEPLOY_PROCESSED_MARKER, state.name() ); + private void putState(State state) { + getPluginContext().put(DEPLOY_PROCESSED_MARKER, state.name()); } - private void putPluginContextValue( String key, String value ) - { - if ( value != null ) - { - getPluginContext().put( key, value ); + private void putPluginContextValue(String key, String value) { + if (value != null) { + getPluginContext().put(key, value); } } - private String getPluginContextValue( Map<String, Object> pluginContext, String key ) - { - return (String) pluginContext.get( key ); + private String getPluginContextValue(Map<String, Object> pluginContext, String key) { + return (String) pluginContext.get(key); } - private State getState( Map<String, Object> pluginContext ) - { - return State.valueOf( getPluginContextValue( pluginContext, DEPLOY_PROCESSED_MARKER ) ); + private State getState(Map<String, Object> pluginContext) { + return State.valueOf(getPluginContextValue(pluginContext, DEPLOY_PROCESSED_MARKER)); } - private boolean hasState( MavenProject project ) - { - Map<String, Object> pluginContext = session.getPluginContext( pluginDescriptor, project ); - return pluginContext.containsKey( DEPLOY_PROCESSED_MARKER ); + private boolean hasState(MavenProject project) { + Map<String, Object> pluginContext = session.getPluginContext(pluginDescriptor, project); + return pluginContext.containsKey(DEPLOY_PROCESSED_MARKER); } - public void execute() - throws MojoExecutionException, MojoFailureException - { - if ( Boolean.parseBoolean( skip ) - || ( "releases".equals( skip ) && !ArtifactUtils.isSnapshot( project.getVersion() ) ) - || ( "snapshots".equals( skip ) && ArtifactUtils.isSnapshot( project.getVersion() ) ) - ) - { - getLog().info( "Skipping artifact deployment" ); - putState( State.SKIPPED ); - } - else - { + public void execute() throws MojoExecutionException, MojoFailureException { + State state; + if (Boolean.parseBoolean(skip) + || ("releases".equals(skip) && !ArtifactUtils.isSnapshot(project.getVersion())) + || ("snapshots".equals(skip) && ArtifactUtils.isSnapshot(project.getVersion()))) { + getLog().info("Skipping artifact deployment"); + state = State.SKIPPED; + } else { failIfOffline(); - warnIfAffectedPackagingAndMaven( project.getPackaging() ); - - if ( !deployAtEnd ) - { - deploy( session.getRepositorySession(), - processProject( project, - altSnapshotDeploymentRepository, altReleaseDeploymentRepository, altDeploymentRepository ) ); - putState( State.DEPLOYED ); - } - else - { - putPluginContextValue( DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository ); - putPluginContextValue( DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY, altSnapshotDeploymentRepository ); - putPluginContextValue( DEPLOY_ALT_DEPLOYMENT_REPOSITORY, altDeploymentRepository ); - putState( State.TO_BE_DEPLOYED ); - getLog().info( "Deferring deploy for " + project.getGroupId() - + ":" + project.getArtifactId() + ":" + project.getVersion() + " at end" ); + warnIfAffectedPackagingAndMaven(project.getPackaging()); + + if (!deployAtEnd) { + + RemoteRepository deploymentRepository = getDeploymentRepository( + project, + altSnapshotDeploymentRepository, + altReleaseDeploymentRepository, + altDeploymentRepository); + + DeployRequest request = new DeployRequest(); + request.setRepository(deploymentRepository); + processProject(project, request); + deploy(request); + state = State.DEPLOYED; + } else { + putPluginContextValue(DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY, altSnapshotDeploymentRepository); + putPluginContextValue(DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository); + putPluginContextValue(DEPLOY_ALT_DEPLOYMENT_REPOSITORY, altDeploymentRepository); + state = State.TO_BE_DEPLOYED; } } - if ( allProjectsMarked() ) - { - for ( MavenProject reactorProject : reactorProjects ) - { - Map<String, Object> pluginContext = session.getPluginContext( pluginDescriptor, reactorProject ); - State state = getState( pluginContext ); - if ( state == State.TO_BE_DEPLOYED ) - { - String altReleaseDeploymentRepository = - getPluginContextValue( pluginContext, DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY ); - String altSnapshotDeploymentRepository = - getPluginContextValue( pluginContext, DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY ); - String altDeploymentRepository = - getPluginContextValue( pluginContext, DEPLOY_ALT_DEPLOYMENT_REPOSITORY ); - - deploy( session.getRepositorySession(), - processProject( reactorProject, - altSnapshotDeploymentRepository, altReleaseDeploymentRepository, altDeploymentRepository ) - ); - } + putState(state); + + List<MavenProject> allProjectsUsingPlugin = getAllProjectsUsingPlugin(); + + if (allProjectsMarked(allProjectsUsingPlugin)) { + deployAllAtOnce(allProjectsUsingPlugin); + } else if (state == State.TO_BE_DEPLOYED) { + getLog().info("Deferring deploy for " + project.getGroupId() + ":" + project.getArtifactId() + ":" + + project.getVersion() + " at end"); + } + } + + private void deployAllAtOnce(List<MavenProject> allProjectsUsingPlugin) throws MojoExecutionException { + Map<RemoteRepository, DeployRequest> requests = new LinkedHashMap<>(); + + // collect all arifacts from all modules to deploy + // requests are grouped by used remote repository + for (MavenProject reactorProject : allProjectsUsingPlugin) { + Map<String, Object> pluginContext = session.getPluginContext(pluginDescriptor, reactorProject); + State state = getState(pluginContext); + if (state == State.TO_BE_DEPLOYED) { + + RemoteRepository deploymentRepository = getDeploymentRepository( + reactorProject, + getPluginContextValue(pluginContext, DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY), + getPluginContextValue(pluginContext, DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY), + getPluginContextValue(pluginContext, DEPLOY_ALT_DEPLOYMENT_REPOSITORY)); + + DeployRequest request = requests.computeIfAbsent(deploymentRepository, repo -> { + DeployRequest newRequest = new DeployRequest(); + newRequest.setRepository(repo); + return newRequest; + }); + processProject(reactorProject, request); } } + // finally execute all deployments request, lets resolver to optimize deployment + for (DeployRequest request : requests.values()) { + deploy(request); + } } - private boolean allProjectsMarked() - { - for ( MavenProject reactorProject : reactorProjects ) - { - if ( !hasState( reactorProject ) ) - { + private boolean allProjectsMarked(List<MavenProject> allProjectsUsingPlugin) { + for (MavenProject reactorProject : allProjectsUsingPlugin) { + if (!hasState(reactorProject)) { return false; } } return true; } - private DeployRequest processProject( final MavenProject project, - final String altSnapshotDeploymentRepository, - final String altReleaseDeploymentRepository, - final String altDeploymentRepository ) - throws MojoExecutionException, MojoFailureException - { - DeployRequest request = new DeployRequest(); - request.setRepository( getDeploymentRepository( project, - altSnapshotDeploymentRepository, altReleaseDeploymentRepository, altDeploymentRepository ) ); - - org.apache.maven.artifact.Artifact mavenMainArtifact = project.getArtifact(); - String packaging = project.getPackaging(); - File pomFile = project.getFile(); - boolean isPomArtifact = "pom".equals( packaging ); - boolean pomArtifactAttached = false; - - if ( pomFile != null ) - { - request.addArtifact( RepositoryUtils.toArtifact( new ProjectArtifact( project ) ) ); - pomArtifactAttached = true; + private List<MavenProject> getAllProjectsUsingPlugin() { + ArrayList<MavenProject> result = new ArrayList<>(); + for (MavenProject reactorProject : reactorProjects) { + if (hasExecution(reactorProject.getPlugin("org.apache.maven.plugins:maven-deploy-plugin"))) { + result.add(reactorProject); + } } + return result; + } - if ( !isPomArtifact ) - { - File file = mavenMainArtifact.getFile(); - if ( file != null && file.isFile() ) - { - org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( mavenMainArtifact ); - request.addArtifact( mainArtifact ); - - if ( !pomArtifactAttached ) - { - for ( Object metadata : mavenMainArtifact.getMetadataList() ) - { - if ( metadata instanceof ProjectArtifactMetadata ) - { - request.addArtifact( new SubArtifact( - mainArtifact, - "", - "pom" - ).setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ) ); - pomArtifactAttached = true; - } - } - } - } - else if ( !project.getAttachedArtifacts().isEmpty() ) - { - throw new MojoExecutionException( "The packaging plugin for this project did not assign " - + "a main file to the project but it has attachments. Change packaging to 'pom'." ); - } - else - { - throw new MojoExecutionException( "The packaging for this project did not assign " - + "a file to the build artifact" ); + private boolean hasExecution(Plugin plugin) { + if (plugin == null) { + return false; + } + + for (PluginExecution execution : plugin.getExecutions()) { + if (!execution.getGoals().isEmpty() && !"none".equalsIgnoreCase(execution.getPhase())) { + return true; } } + return false; + } - if ( !pomArtifactAttached ) - { - throw new MojoExecutionException( "The POM could not be attached" ); + private void processProject(final MavenProject project, DeployRequest request) throws MojoExecutionException { + + if (isFile(project.getFile())) { + request.addArtifact(RepositoryUtils.toArtifact(new ProjectArtifact(project))); + } else { + throw new MojoExecutionException("The project POM could not be attached"); } - for ( org.apache.maven.artifact.Artifact attached : project.getAttachedArtifacts() ) - { - getLog().debug( "Attaching for install: " + attached.getId() ); - request.addArtifact( RepositoryUtils.toArtifact( attached ) ); + if (!"pom".equals(project.getPackaging())) { + org.apache.maven.artifact.Artifact mavenMainArtifact = project.getArtifact(); + if (isFile(mavenMainArtifact.getFile())) { + request.addArtifact(RepositoryUtils.toArtifact(mavenMainArtifact)); + } else if (!project.getAttachedArtifacts().isEmpty()) { + throw new MojoExecutionException("The packaging plugin for this project did not assign " + + "a main file to the project but it has attachments. Change packaging to 'pom'."); + } else { + throw new MojoExecutionException( + "The packaging for this project did not assign a file to the build artifact"); + } } - return request; + for (org.apache.maven.artifact.Artifact attached : project.getAttachedArtifacts()) { + getLog().debug("Attaching for deploy: " + attached.getId()); + request.addArtifact(RepositoryUtils.toArtifact(attached)); + } + } + + private boolean isFile(File file) { + return file != null && file.isFile(); } /** * Visible for testing. */ - RemoteRepository getDeploymentRepository( final MavenProject project, - final String altSnapshotDeploymentRepository, - final String altReleaseDeploymentRepository, - final String altDeploymentRepository ) - - throws MojoExecutionException, MojoFailureException - { + RemoteRepository getDeploymentRepository( + final MavenProject project, + final String altSnapshotDeploymentRepository, + final String altReleaseDeploymentRepository, + final String altDeploymentRepository) + throws MojoExecutionException { RemoteRepository repo = null; String altDeploymentRepo; - if ( ArtifactUtils.isSnapshot( project.getVersion() ) && altSnapshotDeploymentRepository != null ) - { + if (ArtifactUtils.isSnapshot(project.getVersion()) && altSnapshotDeploymentRepository != null) { altDeploymentRepo = altSnapshotDeploymentRepository; - } - else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploymentRepository != null ) - { + } else if (!ArtifactUtils.isSnapshot(project.getVersion()) && altReleaseDeploymentRepository != null) { altDeploymentRepo = altReleaseDeploymentRepository; - } - else - { + } else { altDeploymentRepo = altDeploymentRepository; } - if ( altDeploymentRepo != null ) - { - getLog().info( "Using alternate deployment repository " + altDeploymentRepo ); + if (altDeploymentRepo != null) { + getLog().info("Using alternate deployment repository " + altDeploymentRepo); - Matcher matcher = ALT_LEGACY_REPO_SYNTAX_PATTERN.matcher( altDeploymentRepo ); + Matcher matcher = ALT_LEGACY_REPO_SYNTAX_PATTERN.matcher(altDeploymentRepo); - if ( matcher.matches() ) - { - String id = matcher.group( 1 ).trim(); - String layout = matcher.group( 2 ).trim(); - String url = matcher.group( 3 ).trim(); + if (matcher.matches()) { + String id = matcher.group(1).trim(); + String layout = matcher.group(2).trim(); + String url = matcher.group(3).trim(); - if ( "default".equals( layout ) ) - { - getLog().warn( "Using legacy syntax for alternative repository. " - + "Use \"" + id + "::" + url + "\" instead." ); - repo = getRemoteRepository( id, url ); - } - else - { - throw new MojoFailureException( altDeploymentRepo, + if ("default".equals(layout)) { + getLog().warn("Using legacy syntax for alternative repository. " + "Use \"" + id + "::" + url + + "\" instead."); + repo = getRemoteRepository(id, url); + } else { + throw new MojoExecutionException( + altDeploymentRepo, "Invalid legacy syntax and layout for repository.", - "Invalid legacy syntax and layout for alternative repository. Use \"" - + id + "::" + url + "\" instead, and only default layout is supported." - ); + "Invalid legacy syntax and layout for alternative repository. Use \"" + id + "::" + url + + "\" instead, and only default layout is supported."); } - } - else - { - matcher = ALT_REPO_SYNTAX_PATTERN.matcher( altDeploymentRepo ); + } else { + matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altDeploymentRepo); - if ( !matcher.matches() ) - { - throw new MojoFailureException( altDeploymentRepo, + if (!matcher.matches()) { + throw new MojoExecutionException( + altDeploymentRepo, "Invalid syntax for repository.", - "Invalid syntax for alternative repository. Use \"id::url\"." - ); - } - else - { - String id = matcher.group( 1 ).trim(); - String url = matcher.group( 2 ).trim(); + "Invalid syntax for alternative repository. Use \"id::url\"."); + } else { + String id = matcher.group(1).trim(); + String url = matcher.group(2).trim(); - repo = getRemoteRepository( id, url ); + repo = getRemoteRepository(id, url); } } } - if ( repo == null ) - { - repo = RepositoryUtils.toRepo( project.getDistributionManagementArtifactRepository() ); + if (repo == null) { + repo = RepositoryUtils.toRepo(project.getDistributionManagementArtifactRepository()); } - if ( repo == null ) - { + if (repo == null) { String msg = "Deployment failed: repository element was not specified in the POM inside" - + " distributionManagement element or in -DaltDeploymentRepository=id::url parameter"; + + " distributionManagement element or in -DaltDeploymentRepository=id::url parameter"; - throw new MojoExecutionException( msg ); + throw new MojoExecutionException(msg); } return repo; } - } diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 81515002dfe7559f59dd5906d051248a9a111365..262e90a112bcfd26a504b7475d157c400ca428f7 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -75,25 +75,6 @@ ${project.name} [] -* Major Version Upgrade to version 3.0.0 - - Please note that the following parameter has been completely removed from the plugin configuration: - - * uniqueVersion - - * The syntax of the following parameters for the plugin has been changed: - - * altDeploymentRepository - * altReleaseDeploymentRepository - * altSnapshotDeploymentRepository - - The old format was: <<<id::layout::url>>> - The new format is: <<<id::url>>> - - [] - - As of Maven 3, snapshot artifacts will always be deployed using a timestamped version. - * Usage General instructions on how to use the Deploy Plugin can be found on the {{{./usage.html}usage page}}. Some more diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index f1cd28ed4deede53362b6999057e0cef065994eb..8f28f053a73aea2470df0466042f9685b9f20134 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -23,102 +23,51 @@ under the License. <properties> <title>Download ${project.name} Source</title> </properties> + <body> <section name="Download ${project.name} ${project.version} Source"> - <p>${project.name} ${project.version} is distributed in source format. Use a source archive if you intend to build - ${project.name} yourself. Otherwise, simply use the ready-made binary artifacts from central repository.</p> - - <p>You will be prompted for a mirror - if the file is not found on yours, please be patient, as it may take 24 - hours to reach all mirrors.<p/> - - <p>In order to guard against corrupted downloads/installations, it is highly recommended to - <a href="https://www.apache.org/dev/release-signing#verifying-signature">verify the signature</a> - of the release bundles against the public <a href="https://www.apache.org/dist/maven/KEYS">KEYS</a> used by the Apache Maven - developers.</p> + <p><strong>${project.name} ${project.version}</strong> is distributed in source format.</p> - <p>${project.name} is distributed under the <a href="https://www.apache.org/licenses/">Apache License, version 2.0</a>.</p> + <p>Use a source archive if you intend to build <strong>${project.name}</strong> yourself.</p> - <p></p>We <b>strongly</b> encourage our users to configure a Maven repository mirror closer to their location, please read <a href="/guides/mini/guide-mirror-settings.html">How to Use Mirrors for Repositories</a>.</p> - - <a name="mirror"/> - <subsection name="Mirror"> - - <p> - [if-any logo] - <a href="[link]"> - <img align="right" src="[logo]" border="0" - alt="logo"/> - </a> - [end] - The currently selected mirror is - <b>[preferred]</b>. - If you encounter a problem with this mirror, - please select another mirror. - If all mirrors are failing, there are - <i>backup</i> - mirrors - (at the end of the mirrors list) that should be available. - </p> + <p>Otherwise, simply use the ready-made binary artifacts from <strong>central repository</strong>.</p> - <form action="[location]" method="get" id="SelectMirror"> - Other mirrors: - <select name="Preferred"> - [if-any http] - [for http] - <option value="[http]">[http]</option> - [end] - [end] - [if-any ftp] - [for ftp] - <option value="[ftp]">[ftp]</option> - [end] - [end] - [if-any backup] - [for backup] - <option value="[backup]">[backup] (backup)</option> - [end] - [end] - </select> - <input type="submit" value="Change"/> - </form> + <p><strong>${project.name}</strong> is distributed under the <a href="https://www.apache.org/licenses/">Apache License, version 2.0</a>.</p> - <p> - You may also consult the - <a href="https://www.apache.org/mirrors/">complete list of - mirrors.</a> + <subsection name="Files"> + + <p>This is the current stable version of <strong>${project.name}</strong>.</p> + + <table> + <thead> + <tr> + <th></th> + <th>Link</th> + <th>Checksum</th> + <th>Signature</th> + </tr> + </thead> + <tbody> + <tr> + <td>${project.name} ${project.version} (Source zip)</td> + <td><a href="https://dlcdn.apache.org/maven/plugins/${project.artifactId}-${project.version}-source-release.zip">${project.artifactId}-${project.version}-source-release.zip</a></td> + <td><a href="https://downloads.apache.org/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512">${project.artifactId}-${project.version}-source-release.zip.sha512</a></td> + <td><a href="https://downloads.apache.org/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc">${project.artifactId}-${project.version}-source-release.zip.asc</a></td> + </tr> + </tbody> + </table> + + <p>It is essential that you <a href="https://www.apache.org/info/verification.html">verify the integrity</a> of the downloaded file + using the checksum (.sha512 file) + or using the signature (.asc file) against the public <a href="https://downloads.apache.org/maven/KEYS">KEYS</a> used by the Apache Maven developers. </p> </subsection> - - <subsection name="${project.name} ${project.version}"> - - <p>This is the current stable version of ${project.name}.</p> - - <table> - <thead> - <tr> - <th></th> - <th>Link</th> - <th>Checksum</th> - <th>Signature</th> - </tr> - </thead> - <tbody> - <tr> - <td>${project.name} ${project.version} (Source zip)</td> - <td><a href="[preferred]maven/plugins/${project.artifactId}-${project.version}-source-release.zip">maven/plugins/${project.artifactId}-${project.version}-source-release.zip</a></td> - <td><a href="https://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512</a></td> - <td><a href="https://www.apache.org/dist/maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc">maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc</a></td> - </tr> - </tbody> - </table> - </subsection> <subsection name="Previous Versions"> - - <p>Older non-recommended releases can be found on our <a href="https://archive.apache.org/dist/maven/plugins/">archive site</a>.</p> - + <p>It is strongly recommended to use the latest release version of <strong>${project.name}</strong> to take advantage of the newest features and bug fixes.</p> + <p>Older non-recommended releases can be found on our <a href="https://archive.apache.org/dist/maven/plugins/">archive site</a>.</p> </subsection> </section> </body> diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java index d8538705d3034196c59802ed5b8a2797a2ef971c..f36e6892cf03e3cb764d38d572ba35d5af543bad 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy; * "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 + * 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 @@ -18,33 +16,33 @@ package org.apache.maven.plugins.deploy; * specific language governing permissions and limitations * under the License. */ - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +package org.apache.maven.plugins.deploy; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.ProjectBuildingRequest; import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a> */ -public class DeployFileMojoTest - extends AbstractMojoTestCase -{ - private String LOCAL_REPO = getBasedir() + "/target/local-repo"; - +public class DeployFileMojoTest extends AbstractMojoTestCase { + private final String LOCAL_REPO = getBasedir() + "/target/local-repo"; + private List<String> expectedFiles; private List<String> fileList; @@ -53,259 +51,253 @@ public class DeployFileMojoTest @Mock private MavenSession session; - + @InjectMocks private DeployFileMojo mojo; - - public void setUp() - throws Exception - { + + public void setUp() throws Exception { super.setUp(); - remoteRepo = new File( getBasedir(), "target/remote-repo" ); + remoteRepo = new File(getBasedir(), "target/remote-repo"); - if ( !remoteRepo.exists() ) - { + if (!remoteRepo.exists()) { remoteRepo.mkdirs(); } } - public void testDeployTestEnvironment() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml" ); + public void testDeployTestEnvironment() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml"); - AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom ); + AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo("deploy-file", testPom); - assertNotNull( mojo ); + assertNotNull(mojo); } - public void testBasicDeployFile() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml" ); + public void testBasicDeployFile() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml"); - mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + mojo = (DeployFileMojo) lookupMojo("deploy-file", testPom); - MockitoAnnotations.initMocks( this ); - - assertNotNull( mojo ); - - ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); - when( buildingRequest.getRepositoryMerging() ).thenReturn( ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT ); - when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MockitoAnnotations.initMocks(this); + + assertNotNull(mojo); + + ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); + when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT); + when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); - when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - when( session.getRepositorySession() ).thenReturn( repositorySession ); + repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); + + String groupId = (String) getVariableValueFromObject(mojo, "groupId"); + + String artifactId = (String) getVariableValueFromObject(mojo, "artifactId"); - String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); + String version = (String) getVariableValueFromObject(mojo, "version"); - String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" ); + String packaging = (String) getVariableValueFromObject(mojo, "packaging"); - String version = (String) getVariableValueFromObject( mojo, "version" ); + File file = (File) getVariableValueFromObject(mojo, "file"); - String packaging = (String) getVariableValueFromObject( mojo, "packaging" ); + String repositoryId = (String) getVariableValueFromObject(mojo, "repositoryId"); - File file = (File) getVariableValueFromObject( mojo, "file" ); + String url = (String) getVariableValueFromObject(mojo, "url"); - String repositoryId = (String) getVariableValueFromObject( mojo, "repositoryId" ); + String skip = (String) getVariableValueFromObject(mojo, "skip"); - String url = (String) getVariableValueFromObject( mojo, "url" ); + assertEquals("org.apache.maven.test", groupId); - assertEquals( "org.apache.maven.test", groupId ); + assertEquals("maven-deploy-file-test", artifactId); - assertEquals( "maven-deploy-file-test", artifactId ); + assertEquals("1.0", version); - assertEquals( "1.0", version ); + assertEquals("jar", packaging); - assertEquals( "jar", packaging ); + assertEquals("snapshots", skip); - assertTrue( file.exists() ); + assertTrue(file.exists()); - assertEquals( "deploy-test", repositoryId ); + assertEquals("deploy-test", repositoryId); + + assertEquals("file://" + getBasedir() + "/target/remote-repo/deploy-file-test", url); - assertEquals( "file://" + getBasedir() + "/target/remote-repo/deploy-file-test", url ); - mojo.execute(); - //check the generated pom - File pom = new File( remoteRepo, "deploy-file-test/" + groupId.replace( '.', '/' ) + - "/" + artifactId + "/" + version + "/" + artifactId + - "-" + version + ".pom" ); + // check the generated pom + File pom = new File( + remoteRepo, + "deploy-file-test/" + groupId.replace('.', '/') + "/" + + artifactId + "/" + version + "/" + artifactId + "-" + + version + ".pom"); - assertTrue( pom.exists() ); + assertTrue(pom.exists()); - Model model = mojo.readModel( pom ); + Model model = mojo.readModel(pom); - assertEquals( "4.0.0", model.getModelVersion() ); + assertEquals("4.0.0", model.getModelVersion()); - assertEquals( groupId, model.getGroupId() ); + assertEquals(groupId, model.getGroupId()); - assertEquals( artifactId, model.getArtifactId() ); + assertEquals(artifactId, model.getArtifactId()); - assertEquals( version, model.getVersion() ); + assertEquals(version, model.getVersion()); - assertEquals( packaging, model.getPackaging() ); + assertEquals(packaging, model.getPackaging()); - assertEquals( "POM was created from deploy:deploy-file", model.getDescription() ); + assertEquals("POM was created from deploy:deploy-file", model.getDescription()); - //check the remote-repo - expectedFiles = new ArrayList<String>(); - fileList = new ArrayList<String>(); + // check the remote-repo + expectedFiles = new ArrayList<>(); + fileList = new ArrayList<>(); - File repo = new File( remoteRepo, "deploy-file-test" ); + File repo = new File(remoteRepo, "deploy-file-test"); File[] files = repo.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull(files)) { addFileToList(file1, fileList); } - expectedFiles.add( "org" ); - expectedFiles.add( "apache" ); - expectedFiles.add( "maven" ); - expectedFiles.add( "test" ); - expectedFiles.add( "maven-deploy-file-test" ); - expectedFiles.add( "1.0" ); - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - expectedFiles.add( "maven-deploy-file-test-1.0.jar" ); - expectedFiles.add( "maven-deploy-file-test-1.0.jar.md5" ); - expectedFiles.add( "maven-deploy-file-test-1.0.jar.sha1" ); - expectedFiles.add( "maven-deploy-file-test-1.0.pom" ); - expectedFiles.add( "maven-deploy-file-test-1.0.pom.md5" ); - expectedFiles.add( "maven-deploy-file-test-1.0.pom.sha1" ); - - assertEquals( expectedFiles.size(), fileList.size() ); - - assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); + expectedFiles.add("org"); + expectedFiles.add("apache"); + expectedFiles.add("maven"); + expectedFiles.add("test"); + expectedFiles.add("maven-deploy-file-test"); + expectedFiles.add("1.0"); + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + expectedFiles.add("maven-deploy-file-test-1.0.jar"); + expectedFiles.add("maven-deploy-file-test-1.0.jar.md5"); + expectedFiles.add("maven-deploy-file-test-1.0.jar.sha1"); + expectedFiles.add("maven-deploy-file-test-1.0.pom"); + expectedFiles.add("maven-deploy-file-test-1.0.pom.md5"); + expectedFiles.add("maven-deploy-file-test-1.0.pom.sha1"); + + assertEquals(expectedFiles.size(), fileList.size()); + + assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); } - public void testDeployIfClassifierIsSet() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-classifier/plugin-config.xml" ); + public void testDeployIfClassifierIsSet() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/deploy-file-classifier/plugin-config.xml"); + + mojo = (DeployFileMojo) lookupMojo("deploy-file", testPom); + + MockitoAnnotations.initMocks(this); - mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + assertNotNull(mojo); - MockitoAnnotations.initMocks( this ); - - assertNotNull( mojo ); - - ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); - when( buildingRequest.getRepositoryMerging() ).thenReturn( ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT ); - when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); + when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT); + when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); - when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - when( session.getRepositorySession() ).thenReturn( repositorySession ); + repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); - String classifier = ( String ) getVariableValueFromObject( mojo, "classifier" ); + String classifier = (String) getVariableValueFromObject(mojo, "classifier"); - String groupId = ( String ) getVariableValueFromObject( mojo, "groupId" ); + String groupId = (String) getVariableValueFromObject(mojo, "groupId"); - String artifactId = ( String ) getVariableValueFromObject( mojo, "artifactId" ); + String artifactId = (String) getVariableValueFromObject(mojo, "artifactId"); - String version = ( String ) getVariableValueFromObject( mojo, "version" ); + String version = (String) getVariableValueFromObject(mojo, "version"); - assertEquals( "bin", classifier ); + assertEquals("bin", classifier); mojo.execute(); - File deployedArtifact = new File( remoteRepo, "deploy-file-classifier/" + groupId.replace( '.', '/' ) + - "/" + artifactId + "/" + version + "/" + artifactId + - "-" + version + "-" + classifier + ".jar"); + File deployedArtifact = new File( + remoteRepo, + "deploy-file-classifier/" + groupId.replace('.', '/') + "/" + + artifactId + "/" + version + "/" + artifactId + "-" + + version + "-" + classifier + ".jar"); - assertTrue( deployedArtifact.exists() ); + assertTrue(deployedArtifact.exists()); - mojo.setClassifier( "prod" ); + mojo.setClassifier("prod"); - assertEquals( "prod", mojo.getClassifier() ); + assertEquals("prod", mojo.getClassifier()); mojo.execute(); - File prodDeployedArtifact = new File( remoteRepo, "deploy-file-classifier/" + groupId.replace( '.', '/' ) + - "/" + artifactId + "/" + version + "/" + artifactId + - "-" + version + "-" + mojo.getClassifier() + ".jar"); + File prodDeployedArtifact = new File( + remoteRepo, + "deploy-file-classifier/" + groupId.replace('.', '/') + "/" + + artifactId + "/" + version + "/" + artifactId + "-" + + version + "-" + mojo.getClassifier() + ".jar"); - assertTrue( prodDeployedArtifact.exists() ); + assertTrue(prodDeployedArtifact.exists()); } - public void testDeployIfArtifactIsNotJar() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-artifact-not-jar/plugin-config.xml" ); + public void testDeployIfArtifactIsNotJar() throws Exception { + File testPom = + new File(getBasedir(), "target/test-classes/unit/deploy-file-artifact-not-jar/plugin-config.xml"); - mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + mojo = (DeployFileMojo) lookupMojo("deploy-file", testPom); - MockitoAnnotations.initMocks( this ); - - assertNotNull( mojo ); - - ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); - when( buildingRequest.getRepositoryMerging() ).thenReturn( ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT ); - when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MockitoAnnotations.initMocks(this); + + assertNotNull(mojo); + + ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); + when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT); + when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); - when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - when( session.getRepositorySession() ).thenReturn( repositorySession ); + repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); - String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); + String groupId = (String) getVariableValueFromObject(mojo, "groupId"); - String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" ); + String artifactId = (String) getVariableValueFromObject(mojo, "artifactId"); - String version = (String) getVariableValueFromObject( mojo, "version" ); + String version = (String) getVariableValueFromObject(mojo, "version"); - assertEquals( "org.apache.maven.test", groupId ); + assertEquals("org.apache.maven.test", groupId); - assertEquals( "maven-deploy-file-test", artifactId ); + assertEquals("maven-deploy-file-test", artifactId); - assertEquals( "1.0", version ); + assertEquals("1.0", version); mojo.execute(); - File file = new File( remoteRepo, "deploy-file-artifact-not-jar/" + groupId.replace( '.', '/' ) + - "/" + artifactId + "/" + version + "/" + artifactId + - "-" + version + ".zip"); + File file = new File( + remoteRepo, + "deploy-file-artifact-not-jar/" + groupId.replace('.', '/') + "/" + + artifactId + "/" + version + "/" + artifactId + "-" + + version + ".zip"); - assertTrue( file.exists() ); + assertTrue(file.exists()); } - private void addFileToList( File file, List<String> fileList ) - { - if ( !file.isDirectory() ) - { - fileList.add( file.getName() ); - } - else - { - fileList.add( file.getName() ); + private void addFileToList(File file, List<String> fileList) { + if (!file.isDirectory()) { + fileList.add(file.getName()); + } else { + fileList.add(file.getName()); File[] files = file.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull(files)) { addFileToList(file1, fileList); } } } - private int getSizeOfExpectedFiles( List<String> fileList, List<String> expectedFiles ) - { - for ( String fileName : fileList ) - { - if ( expectedFiles.contains( fileName ) ) - { - expectedFiles.remove( fileName ); - } - else - { - fail( fileName + " is not included in the expected files" ); + private int getSizeOfExpectedFiles(List<String> fileList, List<String> expectedFiles) { + for (String fileName : fileList) { + if (expectedFiles.contains(fileName)) { + expectedFiles.remove(fileName); + } else { + fail(fileName + " is not included in the expected files"); } } return expectedFiles.size(); } - } - diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java index a7bbd8b709b26714e4a7f5d68e44b5e82fe28f20..c368b36576eadaa821269bdb84fff1d7c92f6352 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy; * "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 + * 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 @@ -18,6 +16,9 @@ package org.apache.maven.plugins.deploy; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy; + +import java.io.File; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; @@ -26,36 +27,31 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.io.File; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** * @author <a href="jerome@coffeebreaks.org">Jerome Lacoste</a> */ -public class DeployFileMojoUnitTest -{ +public class DeployFileMojoUnitTest { MockDeployFileMojo mojo; Parent parent; @Before - public void setUp() - { + public void setUp() { Model pomModel = new Model(); - pomModel.setPackaging( null ); + pomModel.setPackaging(null); parent = new Parent(); - parent.setGroupId( "parentGroup" ); - parent.setArtifactId( "parentArtifact" ); - parent.setVersion( "parentVersion" ); + parent.setGroupId("parentGroup"); + parent.setArtifactId("parentArtifact"); + parent.setVersion("parentVersion"); - mojo = new MockDeployFileMojo( pomModel ); + mojo = new MockDeployFileMojo(pomModel); } @After - public void tearDown() - { + public void tearDown() { mojo = null; } @@ -70,63 +66,58 @@ public class DeployFileMojoUnitTest this.model = model; } - protected Model readModel(File pomFile) throws MojoExecutionException { + protected Model readModel(File pomFile) { return model; } } @Test - public void testProcessPomFromPomFileWithParent1() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); + public void testProcessPomFromPomFileWithParent1() { + mojo.setPomFile(new File("foo.bar")); - setMojoModel( mojo.model, null, null, null, null, parent ); + setMojoModel(mojo.model, null, null, null, null, parent); try { mojo.initProperties(); } catch (MojoExecutionException expected) { - assertTrue( true ); // missing artifactId and packaging + assertTrue(true); // missing artifactId and packaging } checkMojoProperties("parentGroup", null, "parentVersion", null); } @Test - public void testProcessPomFromPomFileWithParent2() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, null, "artifact", null, null, parent ); + public void testProcessPomFromPomFileWithParent2() { + mojo.setPomFile(new File("foo.bar")); + setMojoModel(mojo.model, null, "artifact", null, null, parent); try { mojo.initProperties(); } catch (MojoExecutionException expected) { - assertTrue( true ); // missing packaging + assertTrue(true); // missing packaging } - checkMojoProperties("parentGroup", "artifact", "parentVersion", null ); - + checkMojoProperties("parentGroup", "artifact", "parentVersion", null); } @Test - public void testProcessPomFromPomFileWithParent3() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, null, "artifact", "version", null, parent ); + public void testProcessPomFromPomFileWithParent3() { + mojo.setPomFile(new File("foo.bar")); + setMojoModel(mojo.model, null, "artifact", "version", null, parent); try { mojo.initProperties(); } catch (MojoExecutionException expected) { - assertTrue( true ); // missing version and packaging + assertTrue(true); // missing version and packaging } - checkMojoProperties( "parentGroup", "artifact", "version", null ); + checkMojoProperties("parentGroup", "artifact", "version", null); } @Test - public void testProcessPomFromPomFileWithParent4() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, null, "artifact", "version", "packaging", parent ); + public void testProcessPomFromPomFileWithParent4() throws MojoExecutionException { + mojo.setPomFile(new File("foo.bar")); + setMojoModel(mojo.model, null, "artifact", "version", "packaging", parent); mojo.initProperties(); @@ -134,10 +125,9 @@ public class DeployFileMojoUnitTest } @Test - public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, "group", "artifact", "version", "packaging", parent ); + public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException { + mojo.setPomFile(new File("foo.bar")); + setMojoModel(mojo.model, "group", "artifact", "version", "packaging", parent); mojo.initProperties(); @@ -145,46 +135,47 @@ public class DeployFileMojoUnitTest } @Test - public void testProcessPomFromPomFileWithParent6() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, "group", "artifact", "version", "packaging", null ); + public void testProcessPomFromPomFileWithParent6() throws MojoExecutionException { + mojo.setPomFile(new File("foo.bar")); + setMojoModel(mojo.model, "group", "artifact", "version", "packaging", null); mojo.initProperties(); checkMojoProperties("group", "artifact", "version", "packaging"); - } @Test - public void testProcessPomFromPomFileWithOverrides() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, "group", "artifact", "version", "packaging", null ); + public void testProcessPomFromPomFileWithOverrides() throws MojoExecutionException { + mojo.setPomFile(new File("foo.bar")); + setMojoModel(mojo.model, "group", "artifact", "version", "packaging", null); - mojo.setGroupId( "groupO" ); - mojo.setArtifactId( "artifactO" ); - mojo.setVersion( "versionO" ); - mojo.setPackaging( "packagingO" ); + mojo.setGroupId("groupO"); + mojo.setArtifactId("artifactO"); + mojo.setVersion("versionO"); + mojo.setPackaging("packagingO"); mojo.initProperties(); checkMojoProperties("groupO", "artifactO", "versionO", "packagingO"); } - private void checkMojoProperties(final String expectedGroup, final String expectedArtifact, final String expectedVersion, final String expectedPackaging) { - assertEquals( expectedGroup, mojo.getGroupId() ); - assertEquals( expectedArtifact, mojo.getArtifactId() ); - assertEquals( expectedVersion, mojo.getVersion() ); - assertEquals( expectedPackaging, mojo.getPackaging() ); + private void checkMojoProperties( + final String expectedGroup, + final String expectedArtifact, + final String expectedVersion, + final String expectedPackaging) { + assertEquals(expectedGroup, mojo.getGroupId()); + assertEquals(expectedArtifact, mojo.getArtifactId()); + assertEquals(expectedVersion, mojo.getVersion()); + assertEquals(expectedPackaging, mojo.getPackaging()); } - private void setMojoModel(Model model, String group, String artifact, String version, String packaging, Parent parent ) { - model.setGroupId( group ); - model.setArtifactId( artifact ); - model.setVersion( version ); - model.setPackaging( packaging ); - model.setParent( parent ); + private void setMojoModel( + Model model, String group, String artifact, String version, String packaging, Parent parent) { + model.setGroupId(group); + model.setArtifactId(artifact); + model.setVersion(version); + model.setPackaging(packaging); + model.setParent(parent); } - } diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java index f34abd06d3b869fcbfe942b5a8d2521e82c74f69..c43bdf5c02e17bd64ab6b0fe2475dd61d9057923 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy; * "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 + * 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 @@ -18,23 +16,18 @@ package org.apache.maven.plugins.deploy; * specific language governing permissions and limitations * under the License. */ - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; +package org.apache.maven.plugins.deploy; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; @@ -45,707 +38,671 @@ import org.apache.maven.project.ProjectBuildingRequest; import org.codehaus.plexus.util.FileUtils; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; import org.junit.Ignore; import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; -import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a> */ -public class DeployMojoTest - extends AbstractMojoTestCase -{ +public class DeployMojoTest extends AbstractMojoTestCase { private File remoteRepo; - + private File localRepo; - - private String LOCAL_REPO = getBasedir() + "/target/local-repo"; - - private String REMOTE_REPO = getBasedir() + "/target/remote-repo"; - + + private final String LOCAL_REPO = getBasedir() + "/target/local-repo"; + + private final String REMOTE_REPO = getBasedir() + "/target/remote-repo"; + DeployArtifactStub artifact; - - MavenProjectStub project = new MavenProjectStub(); + + final MavenProjectStub project = new MavenProjectStub(); private MavenSession session; - + @InjectMocks private DeployMojo mojo; - public void setUp() - throws Exception - { + public void setUp() throws Exception { super.setUp(); - session = mock( MavenSession.class ); - when( session.getPluginContext(any(PluginDescriptor.class), any(MavenProject.class))) - .thenReturn( new ConcurrentHashMap<String, Object>() ); + session = mock(MavenSession.class); + when(session.getPluginContext(any(PluginDescriptor.class), any(MavenProject.class))) + .thenReturn(new ConcurrentHashMap<String, Object>()); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); - when( session.getRepositorySession() ).thenReturn( repositorySession ); - - remoteRepo = new File( REMOTE_REPO ); - - remoteRepo.mkdirs(); - - localRepo = new File( LOCAL_REPO ); - - if ( localRepo.exists() ) - { - FileUtils.deleteDirectory( localRepo ); + repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(session.getRepositorySession()).thenReturn(repositorySession); + + remoteRepo = new File(REMOTE_REPO); + + remoteRepo.mkdirs(); + + localRepo = new File(LOCAL_REPO); + + if (localRepo.exists()) { + FileUtils.deleteDirectory(localRepo); } - if ( remoteRepo.exists() ) - { - FileUtils.deleteDirectory( remoteRepo ); + if (remoteRepo.exists()) { + FileUtils.deleteDirectory(remoteRepo); } } - public void tearDown() - throws Exception - { + public void tearDown() throws Exception { super.tearDown(); - - if( remoteRepo.exists() ) - { - //FileUtils.deleteDirectory( remoteRepo ); + + if (remoteRepo.exists()) { + // FileUtils.deleteDirectory( remoteRepo ); } } - - public void testDeployTestEnvironment() - throws Exception - { - File testPom = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-test/plugin-config.xml" ); - - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - assertNotNull( mojo ); + + public void testDeployTestEnvironment() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml"); + + DeployMojo mojo = (DeployMojo) lookupMojo("deploy", testPom); + + assertNotNull(mojo); } - - public void testBasicDeploy() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml" ); - - mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - MockitoAnnotations.initMocks( this ); - - assertNotNull( mojo ); - - ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); - when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + + public void testBasicDeploy() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml"); + + mojo = (DeployMojo) lookupMojo("deploy", testPom); + + MockitoAnnotations.initMocks(this); + + assertNotNull(mojo); + + ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); + when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); - when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - when( session.getRepositorySession() ).thenReturn( repositorySession ); + repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); - File file = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-test/target/" + - "deploy-test-file-1.0-SNAPSHOT.jar" ); + File file = new File( + getBasedir(), + "target/test-classes/unit/basic-deploy-test/target/" + "deploy-test-file-1.0-SNAPSHOT.jar"); - assertTrue( file.exists() ); + assertTrue(file.exists()); - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - project.setGroupId( "org.apache.maven.test" ); - project.setArtifactId( "maven-deploy-test" ); - project.setVersion( "1.0-SNAPSHOT" ); + MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); + project.setGroupId("org.apache.maven.test"); + project.setArtifactId("maven-deploy-test"); + project.setVersion("1.0-SNAPSHOT"); - setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); - - artifact = ( DeployArtifactStub ) project.getArtifact(); + setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); + + artifact = (DeployArtifactStub) project.getArtifact(); String packaging = project.getPackaging(); - - assertEquals( "jar", packaging ); - - artifact.setFile( file ); - - ArtifactRepositoryStub repo = getRepoStub( mojo ); - - assertNotNull( repo ); - - repo.setAppendToUrl( "basic-deploy-test" ); - - assertEquals( "deploy-test", repo.getId() ); - assertEquals( "deploy-test", repo.getKey() ); - assertEquals( "file", repo.getProtocol() ); - assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() ); - + + assertEquals("jar", packaging); + + artifact.setFile(file); + + ArtifactRepositoryStub repo = getRepoStub(mojo); + + assertNotNull(repo); + + repo.setAppendToUrl("basic-deploy-test"); + + assertEquals("deploy-test", repo.getId()); + assertEquals("deploy-test", repo.getKey()); + assertEquals("file", repo.getProtocol()); + assertEquals("file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl()); + mojo.execute(); - //check the artifact in local repository - List<String> expectedFiles = new ArrayList<String>(); - List<String> fileList = new ArrayList<String>(); - - expectedFiles.add( "org" ); - expectedFiles.add( "apache" ); - expectedFiles.add( "maven" ); - expectedFiles.add( "test" ); - expectedFiles.add( "maven-deploy-test" ); - expectedFiles.add( "1.0-SNAPSHOT" ); - expectedFiles.add( "maven-metadata-deploy-test.xml" ); + // check the artifact in local repository + List<String> expectedFiles = new ArrayList<>(); + List<String> fileList = new ArrayList<>(); + + expectedFiles.add("org"); + expectedFiles.add("apache"); + expectedFiles.add("maven"); + expectedFiles.add("test"); + expectedFiles.add("maven-deploy-test"); + expectedFiles.add("1.0-SNAPSHOT"); + expectedFiles.add("maven-metadata-deploy-test.xml"); // expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar" ); // expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" ); // as we are in SNAPSHOT the file is here twice - expectedFiles.add( "maven-metadata-deploy-test.xml" ); + expectedFiles.add("maven-metadata-deploy-test.xml"); // extra Aether files - expectedFiles.add( "resolver-status.properties" ); - expectedFiles.add( "resolver-status.properties" ); - - File localRepo = new File( LOCAL_REPO, "" ); - + expectedFiles.add("resolver-status.properties"); + expectedFiles.add("resolver-status.properties"); + + File localRepo = new File(LOCAL_REPO, ""); + File[] files = localRepo.listFiles(); - for (File file2 : files) { + for (File file2 : Objects.requireNonNull(files)) { addFileToList(file2, fileList); } - - assertEquals( expectedFiles.size(), fileList.size() ); - - assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); - - //check the artifact in remote repository - expectedFiles = new ArrayList<String>(); - fileList = new ArrayList<String>(); - - expectedFiles.add( "org" ); - expectedFiles.add( "apache" ); - expectedFiles.add( "maven" ); - expectedFiles.add( "test" ); - expectedFiles.add( "maven-deploy-test" ); - expectedFiles.add( "1.0-SNAPSHOT" ); - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.md5" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.sha1" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.md5" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.sha1" ); + + assertEquals(expectedFiles.size(), fileList.size()); + + assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); + + // check the artifact in remote repository + expectedFiles = new ArrayList<>(); + fileList = new ArrayList<>(); + + expectedFiles.add("org"); + expectedFiles.add("apache"); + expectedFiles.add("maven"); + expectedFiles.add("test"); + expectedFiles.add("maven-deploy-test"); + expectedFiles.add("1.0-SNAPSHOT"); + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar.md5"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar.sha1"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.md5"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.sha1"); // as we are in SNAPSHOT the file is here twice - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - - remoteRepo = new File( remoteRepo, "basic-deploy-test" ); - + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + + remoteRepo = new File(remoteRepo, "basic-deploy-test"); + files = remoteRepo.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull(files)) { addFileToList(file1, fileList); } - - assertEquals( expectedFiles.size(), fileList.size() ); - assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); + assertEquals(expectedFiles.size(), fileList.size()); + + assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); } - public void testSkippingDeploy() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml" ); + public void testSkippingDeploy() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml"); - DeployMojo mojo = (DeployMojo) lookupMojo( "deploy", testPom ); + DeployMojo mojo = (DeployMojo) lookupMojo("deploy", testPom); - assertNotNull( mojo ); + assertNotNull(mojo); - File file = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/target/" - + "deploy-test-file-1.0-SNAPSHOT.jar" ); + File file = new File( + getBasedir(), + "target/test-classes/unit/basic-deploy-test/target/" + "deploy-test-file-1.0-SNAPSHOT.jar"); - assertTrue( file.exists() ); + assertTrue(file.exists()); - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); + MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - setVariableValueToObject( mojo, "pluginDescriptor", new PluginDescriptor() ); - setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); - setVariableValueToObject( mojo, "session", session ); + setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); + setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); + setVariableValueToObject(mojo, "session", session); artifact = (DeployArtifactStub) project.getArtifact(); String packaging = project.getPackaging(); - assertEquals( "jar", packaging ); + assertEquals("jar", packaging); + + artifact.setFile(file); - artifact.setFile( file ); + ArtifactRepositoryStub repo = getRepoStub(mojo); - ArtifactRepositoryStub repo = getRepoStub( mojo ); + assertNotNull(repo); - assertNotNull( repo ); + repo.setAppendToUrl("basic-deploy-test"); - repo.setAppendToUrl( "basic-deploy-test" ); + assertEquals("deploy-test", repo.getId()); + assertEquals("deploy-test", repo.getKey()); + assertEquals("file", repo.getProtocol()); + assertEquals("file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl()); - assertEquals( "deploy-test", repo.getId() ); - assertEquals( "deploy-test", repo.getKey() ); - assertEquals( "file", repo.getProtocol() ); - assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() ); + setVariableValueToObject(mojo, "skip", Boolean.TRUE.toString()); - setVariableValueToObject( mojo, "skip", Boolean.TRUE.toString() ); - mojo.execute(); - File localRepo = new File( LOCAL_REPO, "" ); + File localRepo = new File(LOCAL_REPO, ""); File[] files = localRepo.listFiles(); - assertNull( files ); - - remoteRepo = new File( remoteRepo, "basic-deploy-test" ); + assertNull(files); + + remoteRepo = new File(remoteRepo, "basic-deploy-test"); files = remoteRepo.listFiles(); - assertNull( files ); - } - - public void testBasicDeployWithPackagingAsPom() - throws Exception - { - File testPom = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-pom/plugin-config.xml" ); - - mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - MockitoAnnotations.initMocks( this ); - - assertNotNull( mojo ); - - ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); - when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + assertNull(files); + } + + public void testBasicDeployWithPackagingAsPom() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-pom/plugin-config.xml"); + + mojo = (DeployMojo) lookupMojo("deploy", testPom); + + MockitoAnnotations.initMocks(this); + + assertNotNull(mojo); + + ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); + when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); - when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - when( session.getRepositorySession() ).thenReturn( repositorySession ); - - File pomFile = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-pom/target/" + - "deploy-test-file-1.0-SNAPSHOT.pom" ); - - assertTrue( pomFile.exists() ); - - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - project.setGroupId( "org.apache.maven.test" ); - project.setArtifactId( "maven-deploy-test" ); - project.setVersion( "1.0-SNAPSHOT" ); - - setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); + repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); + + File pomFile = new File( + getBasedir(), + "target/test-classes/unit/basic-deploy-pom/target/" + "deploy-test-file-1.0-SNAPSHOT.pom"); + + assertTrue(pomFile.exists()); + + MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); + project.setGroupId("org.apache.maven.test"); + project.setArtifactId("maven-deploy-test"); + project.setVersion("1.0-SNAPSHOT"); + + setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); artifact = (DeployArtifactStub) project.getArtifact(); - - artifact.setArtifactHandlerExtension( project.getPackaging() ); - - artifact.setFile( pomFile ); - - ArtifactRepositoryStub repo = getRepoStub( mojo ); - - repo.setAppendToUrl( "basic-deploy-pom" ); - + + artifact.setArtifactHandlerExtension(project.getPackaging()); + + artifact.setFile(pomFile); + + ArtifactRepositoryStub repo = getRepoStub(mojo); + + repo.setAppendToUrl("basic-deploy-pom"); + mojo.execute(); - - List<String> expectedFiles = new ArrayList<String>(); - List<String> fileList = new ArrayList<String>(); - - expectedFiles.add( "org" ); - expectedFiles.add( "apache" ); - expectedFiles.add( "maven" ); - expectedFiles.add( "test" ); - expectedFiles.add( "maven-deploy-test" ); - expectedFiles.add( "1.0-SNAPSHOT" ); - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.md5" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.sha1" ); + + List<String> expectedFiles = new ArrayList<>(); + List<String> fileList = new ArrayList<>(); + + expectedFiles.add("org"); + expectedFiles.add("apache"); + expectedFiles.add("maven"); + expectedFiles.add("test"); + expectedFiles.add("maven-deploy-test"); + expectedFiles.add("1.0-SNAPSHOT"); + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.md5"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.sha1"); // as we are in SNAPSHOT the file is here twice - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - remoteRepo = new File( remoteRepo, "basic-deploy-pom" ); - + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + remoteRepo = new File(remoteRepo, "basic-deploy-pom"); + File[] files = remoteRepo.listFiles(); - for (File file : files) { + for (File file : Objects.requireNonNull(files)) { addFileToList(file, fileList); } - - assertEquals( expectedFiles.size(), fileList.size() ); - assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); + assertEquals(expectedFiles.size(), fileList.size()); + + assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); } - public void testDeployIfArtifactFileIsNull() - throws Exception - { - File testPom = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-test/plugin-config.xml" ); - - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - MockitoAnnotations.initMocks( this ); - - ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); - when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); - - setVariableValueToObject( mojo, "session", session ); - - assertNotNull( mojo ); - - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - project.setGroupId( "org.apache.maven.test" ); - project.setArtifactId( "maven-deploy-test" ); - project.setVersion( "1.0-SNAPSHOT" ); - - setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); + public void testDeployIfArtifactFileIsNull() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml"); + + DeployMojo mojo = (DeployMojo) lookupMojo("deploy", testPom); + + MockitoAnnotations.initMocks(this); + + ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); + when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); + + setVariableValueToObject(mojo, "session", session); + + assertNotNull(mojo); + + MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); + project.setGroupId("org.apache.maven.test"); + project.setArtifactId("maven-deploy-test"); + project.setVersion("1.0-SNAPSHOT"); + + setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); artifact = (DeployArtifactStub) project.getArtifact(); - - artifact.setFile( null ); - - assertNull( artifact.getFile() ); - - try - { + + artifact.setFile(null); + + assertNull(artifact.getFile()); + + try { mojo.execute(); - fail( "Did not throw mojo execution exception" ); - } - catch( MojoExecutionException e ) - { - //expected + fail("Did not throw mojo execution exception"); + } catch (MojoExecutionException e) { + // expected } } - - public void testDeployWithAttachedArtifacts() - throws Exception - { - File testPom = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-with-attached-artifacts/" + - "plugin-config.xml" ); - - mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - MockitoAnnotations.initMocks( this ); - - assertNotNull( mojo ); - - ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); - when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + + public void testDeployWithAttachedArtifacts() throws Exception { + File testPom = new File( + getBasedir(), "target/test-classes/unit/basic-deploy-with-attached-artifacts/" + "plugin-config.xml"); + + mojo = (DeployMojo) lookupMojo("deploy", testPom); + + MockitoAnnotations.initMocks(this); + + assertNotNull(mojo); + + ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); + when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); - when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - when( session.getRepositorySession() ).thenReturn( repositorySession ); + repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - project.setGroupId( "org.apache.maven.test" ); - project.setArtifactId( "maven-deploy-test" ); - project.setVersion( "1.0-SNAPSHOT" ); + MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); + project.setGroupId("org.apache.maven.test"); + project.setArtifactId("maven-deploy-test"); + project.setVersion("1.0-SNAPSHOT"); - setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); + setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); artifact = (DeployArtifactStub) project.getArtifact(); - - File file = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-with-attached-artifacts/target/" + - "deploy-test-file-1.0-SNAPSHOT.jar" ); - - artifact.setFile( file ); - - ArtifactRepositoryStub repo = getRepoStub( mojo ); - - repo.setAppendToUrl( "basic-deploy-with-attached-artifacts" ); - + + File file = new File( + getBasedir(), + "target/test-classes/unit/basic-deploy-with-attached-artifacts/target/" + + "deploy-test-file-1.0-SNAPSHOT.jar"); + + artifact.setFile(file); + + ArtifactRepositoryStub repo = getRepoStub(mojo); + + repo.setAppendToUrl("basic-deploy-with-attached-artifacts"); + mojo.execute(); - //check the artifacts in remote repository - List<String> expectedFiles = new ArrayList<String>(); - List<String> fileList = new ArrayList<String>(); - - expectedFiles.add( "org" ); - expectedFiles.add( "apache" ); - expectedFiles.add( "maven" ); - expectedFiles.add( "test" ); - expectedFiles.add( "maven-deploy-test" ); - expectedFiles.add( "1.0-SNAPSHOT" ); - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.md5" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.sha1" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.md5" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.sha1" ); + // check the artifacts in remote repository + List<String> expectedFiles = new ArrayList<>(); + List<String> fileList = new ArrayList<>(); + + expectedFiles.add("org"); + expectedFiles.add("apache"); + expectedFiles.add("maven"); + expectedFiles.add("test"); + expectedFiles.add("maven-deploy-test"); + expectedFiles.add("1.0-SNAPSHOT"); + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar.md5"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar.sha1"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.md5"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.sha1"); // as we are in SNAPSHOT the file is here twice - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - expectedFiles.add( "attached-artifact-test-0" ); - expectedFiles.add( "1.0-SNAPSHOT" ); - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - expectedFiles.add( "attached-artifact-test-0-1.0-SNAPSHOT.jar" ); - expectedFiles.add( "attached-artifact-test-0-1.0-SNAPSHOT.jar.md5" ); - expectedFiles.add( "attached-artifact-test-0-1.0-SNAPSHOT.jar.sha1" ); + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + expectedFiles.add("attached-artifact-test-0"); + expectedFiles.add("1.0-SNAPSHOT"); + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + expectedFiles.add("attached-artifact-test-0-1.0-SNAPSHOT.jar"); + expectedFiles.add("attached-artifact-test-0-1.0-SNAPSHOT.jar.md5"); + expectedFiles.add("attached-artifact-test-0-1.0-SNAPSHOT.jar.sha1"); // as we are in SNAPSHOT the file is here twice - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - - remoteRepo = new File( remoteRepo, "basic-deploy-with-attached-artifacts" ); - + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + + remoteRepo = new File(remoteRepo, "basic-deploy-with-attached-artifacts"); + File[] files = remoteRepo.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull(files)) { addFileToList(file1, fileList); } - - assertEquals( expectedFiles.size(), fileList.size() ); - assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); + assertEquals(expectedFiles.size(), fileList.size()); + + assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); } - - @Ignore( "SCP is not part of Maven3 distribution. Aether handles transport extensions." ) - public void _testBasicDeployWithScpAsProtocol() - throws Exception - { - String originalUserHome = System.getProperty( "user.home" ); - + + @Ignore("SCP is not part of Maven3 distribution. Aether handles transport extensions.") + public void _testBasicDeployWithScpAsProtocol() throws Exception { + String originalUserHome = System.getProperty("user.home"); + // FIX THE DAMN user.home BEFORE YOU DELETE IT!!! - File altHome = new File( getBasedir(), "target/ssh-user-home" ); + File altHome = new File(getBasedir(), "target/ssh-user-home"); altHome.mkdirs(); - - System.out.println( "Testing user.home value for .ssh dir: " + altHome.getCanonicalPath() ); - + + System.out.println("Testing user.home value for .ssh dir: " + altHome.getCanonicalPath()); + Properties props = System.getProperties(); - props.setProperty( "user.home", altHome.getCanonicalPath() ); - - System.setProperties( props ); - - File testPom = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-scp/plugin-config.xml" ); - - mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - assertNotNull( mojo ); - - RepositorySystem repositorySystem = mock( RepositorySystem.class ); - - setVariableValueToObject( mojo, "repositorySystem", repositorySystem ); - - File file = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-scp/target/" + - "deploy-test-file-1.0-SNAPSHOT.jar" ); - - assertTrue( file.exists() ); - - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - - setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); + props.setProperty("user.home", altHome.getCanonicalPath()); + + System.setProperties(props); + + File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-scp/plugin-config.xml"); + + mojo = (DeployMojo) lookupMojo("deploy", testPom); + + assertNotNull(mojo); + + RepositorySystem repositorySystem = mock(RepositorySystem.class); + + setVariableValueToObject(mojo, "repositorySystem", repositorySystem); + + File file = new File( + getBasedir(), + "target/test-classes/unit/basic-deploy-scp/target/" + "deploy-test-file-1.0-SNAPSHOT.jar"); + + assertTrue(file.exists()); + + MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); + + setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); artifact = (DeployArtifactStub) project.getArtifact(); - - artifact.setFile( file ); - - String altUserHome = System.getProperty( "user.home" ); - - if ( altUserHome.equals( originalUserHome ) ) - { + + artifact.setFile(file); + + String altUserHome = System.getProperty("user.home"); + + if (altUserHome.equals(originalUserHome)) { // this is *very* bad! - throw new IllegalStateException( "Setting 'user.home' system property to alternate value did NOT work. Aborting test." ); + throw new IllegalStateException( + "Setting 'user.home' system property to alternate value did NOT work. Aborting test."); } - - File sshFile = new File( altUserHome, ".ssh" ); - - System.out.println( "Testing .ssh dir: " + sshFile.getCanonicalPath() ); - - //delete first the .ssh folder if existing before executing the mojo - if( sshFile.exists() ) - { - FileUtils.deleteDirectory( sshFile ); + + File sshFile = new File(altUserHome, ".ssh"); + + System.out.println("Testing .ssh dir: " + sshFile.getCanonicalPath()); + + // delete first the .ssh folder if existing before executing the mojo + if (sshFile.exists()) { + FileUtils.deleteDirectory(sshFile); } mojo.execute(); - - assertTrue( sshFile.exists() ); - - FileUtils.deleteDirectory( sshFile ); + + assertTrue(sshFile.exists()); + + FileUtils.deleteDirectory(sshFile); } - public void testLegacyAltDeploymentRepositoryWithDefaultLayout() - throws Exception - { + public void testLegacyAltDeploymentRepositoryWithDefaultLayout() throws Exception { DeployMojo mojo = new DeployMojo(); - setVariableValueToObject( mojo, "project", project ); - setVariableValueToObject( mojo, "session", session ); - setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::default::http://localhost" ); - - project.setVersion( "1.0-SNAPSHOT" ); + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject(mojo, "altDeploymentRepository", "altDeploymentRepository::default::http://localhost"); - assertEquals( new RemoteRepository.Builder( "altDeploymentRepository", "default", "http://localhost" ).build(), - mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::default::http://localhost") ); + project.setVersion("1.0-SNAPSHOT"); + assertEquals( + new RemoteRepository.Builder("altDeploymentRepository", "default", "http://localhost").build(), + mojo.getDeploymentRepository( + project, null, null, "altDeploymentRepository::default::http://localhost")); } - public void testLegacyAltDeploymentRepositoryWithLegacyLayout() - throws Exception - { + public void testLegacyAltDeploymentRepositoryWithLegacyLayout() throws Exception { DeployMojo mojo = new DeployMojo(); - setVariableValueToObject( mojo, "project", project ); - setVariableValueToObject( mojo, "session", session ); - setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::http://localhost" ); - - project.setVersion( "1.0-SNAPSHOT" ); - try - { - mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::legacy::http://localhost" ); - fail( "Should throw: Invalid legacy syntax and layout for repository." ); - } - catch( MojoFailureException e ) - { - assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository."); - assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported."); + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject(mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::http://localhost"); + + project.setVersion("1.0-SNAPSHOT"); + try { + mojo.getDeploymentRepository(project, null, null, "altDeploymentRepository::legacy::http://localhost"); + fail("Should throw: Invalid legacy syntax and layout for repository."); + } catch (MojoExecutionException e) { + assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); + assertEquals( + e.getLongMessage(), + "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported."); } } - public void testInsaneAltDeploymentRepository() - throws Exception - { + public void testInsaneAltDeploymentRepository() throws Exception { DeployMojo mojo = new DeployMojo(); - setVariableValueToObject( mojo, "project", project ); - setVariableValueToObject( mojo, "session", session ); - setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::hey::wow::foo::http://localhost" ); - - project.setVersion( "1.0-SNAPSHOT" ); - try - { - mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::hey::wow::foo::http://localhost" ); - fail( "Should throw: Invalid legacy syntax and layout for repository." ); - } - catch( MojoFailureException e ) - { - assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository."); - assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported."); + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject( + mojo, "altDeploymentRepository", "altDeploymentRepository::hey::wow::foo::http://localhost"); + + project.setVersion("1.0-SNAPSHOT"); + try { + mojo.getDeploymentRepository( + project, null, null, "altDeploymentRepository::hey::wow::foo::http://localhost"); + fail("Should throw: Invalid legacy syntax and layout for repository."); + } catch (MojoExecutionException e) { + assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); + assertEquals( + e.getLongMessage(), + "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported."); } } - public void testDefaultScmSvnAltDeploymentRepository() - throws Exception - { + public void testDefaultScmSvnAltDeploymentRepository() throws Exception { DeployMojo mojo = new DeployMojo(); - setVariableValueToObject( mojo, "project", project ); - setVariableValueToObject( mojo, "session", session ); - setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::default::scm:svn:http://localhost" ); + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject( + mojo, "altDeploymentRepository", "altDeploymentRepository::default::scm:svn:http://localhost"); - project.setVersion( "1.0-SNAPSHOT" ); + project.setVersion("1.0-SNAPSHOT"); - assertEquals( new RemoteRepository.Builder( "altDeploymentRepository", "default", "scm:svn:http://localhost" ).build(), - mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::default::scm:svn:http://localhost" ) ); + assertEquals( + new RemoteRepository.Builder("altDeploymentRepository", "default", "scm:svn:http://localhost").build(), + mojo.getDeploymentRepository( + project, null, null, "altDeploymentRepository::default::scm:svn:http://localhost")); } - public void testLegacyScmSvnAltDeploymentRepository() - throws Exception - { - DeployMojo mojo = new DeployMojo(); - setVariableValueToObject( mojo, "project", project ); - setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::scm:svn:http://localhost" ); + public void testLegacyScmSvnAltDeploymentRepository() throws Exception { + DeployMojo mojo = new DeployMojo(); - project.setVersion( "1.0-SNAPSHOT" ); - try - { - mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::legacy::scm:svn:http://localhost" ); - fail( "Should throw: Invalid legacy syntax and layout for repository." ); - } - catch( MojoFailureException e ) - { - assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository."); - assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported."); + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject( + mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::scm:svn:http://localhost"); + + project.setVersion("1.0-SNAPSHOT"); + try { + mojo.getDeploymentRepository( + project, null, null, "altDeploymentRepository::legacy::scm:svn:http://localhost"); + fail("Should throw: Invalid legacy syntax and layout for repository."); + } catch (MojoExecutionException e) { + assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); + assertEquals( + e.getLongMessage(), + "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported."); } } - public void testAltSnapshotDeploymentRepository() - throws Exception - { + public void testAltSnapshotDeploymentRepository() throws Exception { DeployMojo mojo = new DeployMojo(); - setVariableValueToObject( mojo, "project", project ); - setVariableValueToObject( mojo, "session", session ); - setVariableValueToObject( mojo, "altSnapshotDeploymentRepository", "altSnapshotDeploymentRepository::http://localhost" ); + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject( + mojo, "altSnapshotDeploymentRepository", "altSnapshotDeploymentRepository::http://localhost"); - project.setVersion( "1.0-SNAPSHOT" ); + project.setVersion("1.0-SNAPSHOT"); - assertEquals( new RemoteRepository.Builder( "altSnapshotDeploymentRepository", "default", "http://localhost" ).build(), - mojo.getDeploymentRepository( project, "altSnapshotDeploymentRepository::http://localhost", null, null )); + assertEquals( + new RemoteRepository.Builder("altSnapshotDeploymentRepository", "default", "http://localhost").build(), + mojo.getDeploymentRepository(project, "altSnapshotDeploymentRepository::http://localhost", null, null)); } - public void testAltReleaseDeploymentRepository() - throws Exception - { + public void testAltReleaseDeploymentRepository() throws Exception { DeployMojo mojo = new DeployMojo(); - setVariableValueToObject( mojo, "project", project ); - setVariableValueToObject( mojo, "session", session ); - setVariableValueToObject( mojo, "altReleaseDeploymentRepository", "altReleaseDeploymentRepository::http://localhost" ); + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject( + mojo, "altReleaseDeploymentRepository", "altReleaseDeploymentRepository::http://localhost"); - project.setVersion( "1.0" ); + project.setVersion("1.0"); - assertEquals( new RemoteRepository.Builder("altReleaseDeploymentRepository", "default", "http://localhost").build(), - mojo.getDeploymentRepository( project, null, "altReleaseDeploymentRepository::http://localhost", null )); + assertEquals( + new RemoteRepository.Builder("altReleaseDeploymentRepository", "default", "http://localhost").build(), + mojo.getDeploymentRepository(project, null, "altReleaseDeploymentRepository::http://localhost", null)); } - - private void addFileToList( File file, List<String> fileList ) - { - if( !file.isDirectory() ) - { - fileList.add( file.getName() ); - } - else - { - fileList.add( file.getName() ); + + private void addFileToList(File file, List<String> fileList) { + if (!file.isDirectory()) { + fileList.add(file.getName()); + } else { + fileList.add(file.getName()); File[] files = file.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull(files)) { addFileToList(file1, fileList); } } - } - - private int getSizeOfExpectedFiles( List<String> fileList, List<String> expectedFiles ) - { - for( String fileName : fileList ) - { - // translate uniqueVersion to -SNAPSHOT - fileName = fileName.replaceFirst( "-\\d{8}\\.\\d{6}-\\d+", "-SNAPSHOT" ); - - if( !expectedFiles.remove( fileName ) ) - { - fail( fileName + " is not included in the expected files" ); + } + + private int getSizeOfExpectedFiles(List<String> fileList, List<String> expectedFiles) { + for (String fileName : fileList) { + // translate uniqueVersion to -SNAPSHOT + fileName = fileName.replaceFirst("-\\d{8}\\.\\d{6}-\\d+", "-SNAPSHOT"); + + if (!expectedFiles.remove(fileName)) { + fail(fileName + " is not included in the expected files"); } } return expectedFiles.size(); - } + } - private ArtifactRepositoryStub getRepoStub( Object mojo ) - throws Exception - { - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); + private ArtifactRepositoryStub getRepoStub(Object mojo) throws Exception { + MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); return (ArtifactRepositoryStub) project.getDistributionManagementArtifactRepository(); } - } diff --git a/src/test/java/org/apache/maven/plugins/deploy/Utils.java b/src/test/java/org/apache/maven/plugins/deploy/Utils.java deleted file mode 100644 index f4acbc9dc1a3eb5fc87ebdeeb68d9b31791a9398..0000000000000000000000000000000000000000 --- a/src/test/java/org/apache/maven/plugins/deploy/Utils.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.apache.maven.plugins.deploy; - -/* - * 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 java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.apache.maven.plugin.MojoExecutionException; -import org.eclipse.aether.util.ChecksumUtils; - -/** - * A utility class to assist testing. - * - * @author Benjamin Bentmann - */ -public class Utils -{ - - public static final List<String> CHECKSUM_ALGORITHMS = Arrays.asList( "MD5", "SHA-1" ); - - /** - * Verifies the checksum files in the local repo for the given file. - * - * @param file The file to verify its checksum with, must not be <code>null</code>. - * @throws MojoExecutionException In case the checksums were incorrect. - * @throws IOException If the files couldn't be read. - */ - public static void verifyChecksum( File file ) - throws MojoExecutionException, IOException - { - Map<String, Object> checksums = ChecksumUtils.calc( file, CHECKSUM_ALGORITHMS ); - for ( Map.Entry<String, Object> entry : checksums.entrySet() ) - { - File cksumFile = new File( file + "." + entry.getKey().toLowerCase().replace( "-", "" ) ); - String actualChecksum = ChecksumUtils.read( cksumFile ); - if ( !actualChecksum.equals( entry.getValue() ) ) - { - throw new MojoExecutionException( "Incorrect " + entry.getKey() + " checksum for file: " + file ); - } - } - } - -} diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java index 92db6c19d483477cbca5f6e57b1446f678b93422..9dd95400392f6a700fa5ce445890dd1568475f58 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy.stubs; * "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 + * 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 @@ -18,6 +16,7 @@ package org.apache.maven.plugins.deploy.stubs; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy.stubs; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; @@ -27,120 +26,94 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; -public class ArtifactRepositoryStub - extends StubArtifactRepository -{ +public class ArtifactRepositoryStub extends StubArtifactRepository { private boolean blacklisted; - + private ArtifactRepositoryLayout layout; - + private String url; - - private String basedir = System.getProperty( "basedir" ); - - public ArtifactRepositoryStub() - { - super( null ); - } - - public ArtifactRepositoryStub( String dir ) - { - super( dir ); - } - - public String pathOf( Artifact artifact ) - { - return getLayout().pathOf( artifact ); - } - - public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata ) - { - return getLayout().pathOfRemoteRepositoryMetadata( artifactMetadata ); - } - - public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository ) - { - return getLayout().pathOfLocalRepositoryMetadata( metadata, repository ); - } - - public String getUrl() - { + + private final String basedir = System.getProperty("basedir"); + + public ArtifactRepositoryStub() { + super(null); + } + + public ArtifactRepositoryStub(String dir) { + super(dir); + } + + public String pathOf(Artifact artifact) { + return getLayout().pathOf(artifact); + } + + public String pathOfRemoteRepositoryMetadata(ArtifactMetadata artifactMetadata) { + return getLayout().pathOfRemoteRepositoryMetadata(artifactMetadata); + } + + public String pathOfLocalRepositoryMetadata(ArtifactMetadata metadata, ArtifactRepository repository) { + return getLayout().pathOfLocalRepositoryMetadata(metadata, repository); + } + + public String getUrl() { return url; } - - public void setAppendToUrl( String dir ) - { + + public void setAppendToUrl(String dir) { this.url = "file://" + basedir + "/target/remote-repo/" + dir; } - - public String getBasedir() - { + + public String getBasedir() { return basedir; } - - public String getProtocol() - { + + public String getProtocol() { return "file"; } - - public String getId() - { + + public String getId() { return "deploy-test"; } - - public ArtifactRepositoryPolicy getSnapshots() - { - return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); - } - - public ArtifactRepositoryPolicy getReleases() - { - return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE ); - } - - public ArtifactRepositoryLayout getLayout() - { - if( layout != null ) - { + + public ArtifactRepositoryPolicy getSnapshots() { + return new ArtifactRepositoryPolicy( + true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE); + } + + public ArtifactRepositoryPolicy getReleases() { + return new ArtifactRepositoryPolicy( + true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE); + } + + public ArtifactRepositoryLayout getLayout() { + if (layout != null) { return layout; - } - else - { + } else { return new DefaultRepositoryLayout(); } } - - public String getKey() - { + + public String getKey() { return getId(); } - public boolean isUniqueVersion() - { + public boolean isUniqueVersion() { return false; } - - public void setBlacklisted( boolean blackListed ) - { + + public void setBlacklisted(boolean blackListed) { this.blacklisted = blackListed; } - public boolean isBlacklisted() - { + public boolean isBlacklisted() { return blacklisted; } // @Override - public boolean isBlocked() - { + public boolean isBlocked() { return false; } // @Override - public void setBlocked( boolean b ) - { - - } + public void setBlocked(boolean b) {} } diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java index 0e3338fcfce3e1029a31b270d8bbda8c1666c50c..96d43bb961a09826616ac1447277551c702d3c50 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy.stubs; * "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 + * 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 @@ -18,43 +16,35 @@ package org.apache.maven.plugins.deploy.stubs; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy.stubs; -public class ArtifactRepositoryStub2 - extends ArtifactRepositoryStub -{ +public class ArtifactRepositoryStub2 extends ArtifactRepositoryStub { private String protocol; - - public ArtifactRepositoryStub2() - { + + public ArtifactRepositoryStub2() { super(); } - - public ArtifactRepositoryStub2( String dir ) - { - super( dir ); + + public ArtifactRepositoryStub2(String dir) { + super(dir); } - public String getUrl() - { - return "file://" + System.getProperty( "basedir" ) + "/target/remote-repo/basic-deploy-scp"; + public String getUrl() { + return "file://" + System.getProperty("basedir") + "/target/remote-repo/basic-deploy-scp"; } - - public String getBasedir() - { - return System.getProperty( "basedir" ); + + public String getBasedir() { + return System.getProperty("basedir"); } - - public String getProtocol() - { - if( this.protocol == null || this.protocol.equals("") ) - { + + public String getProtocol() { + if (this.protocol == null || this.protocol.equals("")) { this.protocol = "scp"; } return this.protocol; } - - public void setProtocol( String protocol ) - { + + public void setProtocol(String protocol) { this.protocol = protocol; } } diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java index 0419a85ca82fad6214a1bfd77142fe9f8d40fb06..9226bdcf8a8def17c4086f446e5fd1fb199e150d 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy.stubs; * "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 + * 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 @@ -18,21 +16,19 @@ package org.apache.maven.plugins.deploy.stubs; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy.stubs; import java.io.File; -public class AttachedArtifactStub - extends DeployArtifactStub -{ - public String getArtifactId() - { +public class AttachedArtifactStub extends DeployArtifactStub { + public String getArtifactId() { return "attached-artifact-test-0"; } - - public File getFile() - { - return new File( System.getProperty( "basedir" ), - "target/test-classes/unit/basic-deploy-with-attached-artifacts/" + - "target/deploy-test-file-1.0-SNAPSHOT.jar" ); - } + + public File getFile() { + return new File( + System.getProperty("basedir"), + "target/test-classes/unit/basic-deploy-with-attached-artifacts/" + + "target/deploy-test-file-1.0-SNAPSHOT.jar"); + } } diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java index 24f31d5813fbc6b600497186774460f9350eb989..7218fdf71215f9447f4f4a8ea03a6a7d2cf51668 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy.stubs; * "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 + * 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 @@ -18,6 +16,7 @@ package org.apache.maven.plugins.deploy.stubs; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy.stubs; import java.io.File; import java.util.Collection; @@ -30,103 +29,81 @@ import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.plugin.testing.stubs.ArtifactStub; -public class DeployArtifactStub - extends ArtifactStub -{ +public class DeployArtifactStub extends ArtifactStub { private Map<Object, ArtifactMetadata> metadataMap; - + private File file; - + private boolean release; - + private String extension; - - public String getArtifactId() - { + + public String getArtifactId() { return "maven-deploy-test"; } - public String getGroupId() - { + public String getGroupId() { return "org.apache.maven.test"; } - public String getVersion() - { + public String getVersion() { return "1.0-SNAPSHOT"; } - - public String getBaseVersion() - { + + public String getBaseVersion() { return getVersion(); } - + @Override - public String getType() - { + public String getType() { return "jar"; } - - public void setFile( File file ) - { + + public void setFile(File file) { this.file = file; } - - public File getFile() - { + + public File getFile() { return file; } - - public ArtifactHandler getArtifactHandler() - { - return new DefaultArtifactHandler() - { - public String getExtension() - { - if( extension == null ) - { + + public ArtifactHandler getArtifactHandler() { + return new DefaultArtifactHandler() { + public String getExtension() { + if (extension == null) { extension = "jar"; } return extension; } }; } - - public void setArtifactHandlerExtension( String extension ) - { + + public void setArtifactHandlerExtension(String extension) { this.extension = extension; } - - public void addMetadata( ArtifactMetadata metadata ) - { - if ( metadataMap == null ) - { - metadataMap = new HashMap<Object, ArtifactMetadata>(); - } - ArtifactMetadata m = metadataMap.get( metadata.getKey() ); - if ( m != null ) - { - m.merge( metadata ); + public void addMetadata(ArtifactMetadata metadata) { + if (metadataMap == null) { + metadataMap = new HashMap<>(); } - else - { - metadataMap.put( metadata.getKey(), metadata ); + + ArtifactMetadata m = metadataMap.get(metadata.getKey()); + if (m != null) { + m.merge(metadata); + } else { + metadataMap.put(metadata.getKey(), metadata); } } - - public Collection<ArtifactMetadata> getMetadataList() - { - return metadataMap == null ? Collections.<ArtifactMetadata>emptyList() : metadataMap.values(); + + public Collection<ArtifactMetadata> getMetadataList() { + return metadataMap == null ? Collections.emptyList() : metadataMap.values(); } - public boolean isRelease() - { + public boolean isRelease() { return release; } - public void setRelease( boolean release ) - { + public void setRelease(boolean release) { this.release = release; } diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java index 91709a360ec747935a52764eada27694d67637bb..646e09adfd78d78f6fe9cd735d325c584846dcb2 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java @@ -1,5 +1,3 @@ -package org.apache.maven.plugins.deploy.stubs; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -9,7 +7,7 @@ package org.apache.maven.plugins.deploy.stubs; * "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 + * 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 @@ -18,18 +16,27 @@ package org.apache.maven.plugins.deploy.stubs; * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy.stubs; + +import java.util.Collections; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.model.Build; +import org.apache.maven.model.Plugin; -public class MavenProjectStub - extends org.apache.maven.plugin.testing.stubs.MavenProjectStub -{ +public class MavenProjectStub extends org.apache.maven.plugin.testing.stubs.MavenProjectStub { private ArtifactRepositoryStub deploymentRepository; - public ArtifactRepository getDistributionManagementArtifactRepository() - { + public ArtifactRepository getDistributionManagementArtifactRepository() { return deploymentRepository; } + @Override + public Build getBuild() { + Plugin plugin = new Plugin(); + Build build = new Build(); + build.setPlugins(Collections.singletonList(plugin)); + return build; + } } diff --git a/src/test/resources/unit/deploy-file-test/plugin-config.xml b/src/test/resources/unit/deploy-file-test/plugin-config.xml index 67b98a17aa907606c14abe9071dcd37a25b61d10..9f5225536da6b09f219afdbbe899e2236eb23e71 100644 --- a/src/test/resources/unit/deploy-file-test/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-test/plugin-config.xml @@ -32,6 +32,7 @@ under the License. <url>file://${basedir}/target/remote-repo/deploy-file-test</url> <description>POM was created from deploy:deploy-file</description> <generatePom>true</generatePom> + <skip>snapshots</skip> </configuration> </plugin> </plugins>