From 82b8d79fd601d44a6263db4879b3c049235a9106 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 27 Aug 2014 20:16:35 +0000 Subject: [PATCH 001/153] [maven-release-plugin] prepare for next development iteration git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1620972 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 03b2d9c3..68aab5c7 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-deploy-plugin - 2.8.2 + 2.8.3-SNAPSHOT maven-plugin Apache Maven Deploy Plugin @@ -42,9 +42,9 @@ under the License. - scm:svn:http://svn.apache.org/repos/asf/maven/plugins/tags/maven-deploy-plugin-2.8.2 - scm:svn:https://svn.apache.org/repos/asf/maven/plugins/tags/maven-deploy-plugin-2.8.2 - http://svn.apache.org/viewvc/maven/plugins/tags/maven-deploy-plugin-2.8.2 + scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-deploy-plugin/ + scm:svn:https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-deploy-plugin/ + http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/ JIRA From 3cbf6a6a578aa5a1aedc50569888fac31b303cd4 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Thu, 9 Oct 2014 09:49:32 +0000 Subject: [PATCH 002/153] - Added to all plugins LICENSE file - Added to all plugins NOTICE file with copyright year 2007-2014 git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1630358 13f79535-47bb-0310-9956-ffa450edef68 --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NOTICE | 5 ++ 2 files changed, 207 insertions(+) create mode 100644 LICENSE create mode 100644 NOTICE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..0e827cb7 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache Maven Deploy Plugin +Copyright 2007-2014 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). From fa2ee59319c011f3f9aafdf1ee54d726cce5d9b6 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Thu, 9 Oct 2014 20:40:31 +0000 Subject: [PATCH 003/153] - Undone the commit r1630358 which means to remove all LICENSE/NOTICE files until the ASF is clear about what to do. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1630593 13f79535-47bb-0310-9956-ffa450edef68 --- LICENSE | 202 -------------------------------------------------------- NOTICE | 5 -- 2 files changed, 207 deletions(-) delete mode 100644 LICENSE delete mode 100644 NOTICE diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d6456956..00000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. diff --git a/NOTICE b/NOTICE deleted file mode 100644 index 0e827cb7..00000000 --- a/NOTICE +++ /dev/null @@ -1,5 +0,0 @@ -Apache Maven Deploy Plugin -Copyright 2007-2014 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). From 9503f3a3e76c28930caa23397ef44742c58d0e9d Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sat, 18 Oct 2014 19:47:32 +0000 Subject: [PATCH 004/153] [MDEPLOY-188] - Upgrade plexus-utils from 3.0.15 to 3.0.18 git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1632832 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 68aab5c7..448cca97 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.0.15 + 3.0.18 org.apache.maven.plugin-testing From fbe851ca2484f6d38637025408d0ab737d0685fe Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sat, 18 Oct 2014 20:17:34 +0000 Subject: [PATCH 005/153] [MDEPLOY-171] - Removed deprecated marked entries. artifact, packaging, pomFile, attachedArtifacts fixed unit tests accordingly. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1632838 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/deploy/DeployMojo.java | 41 ++++-------------- .../plugin/deploy/DeployFileMojoTest.java | 24 ---------- .../maven/plugin/deploy/DeployMojoTest.java | 7 +-- .../unit/basic-deploy-pom/plugin-config.xml | 6 --- .../unit/basic-deploy-scp/plugin-config.xml | 6 --- .../unit/basic-deploy-test/plugin-config.xml | Bin 4128 -> 3490 bytes .../plugin-config.xml | 8 ---- .../plugin-config.xml | 1 - 8 files changed, 9 insertions(+), 84 deletions(-) diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java index a70b3db6..a12de010 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java @@ -19,6 +19,14 @@ * under the License. */ +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; @@ -27,21 +35,12 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * Deploys an artifact to remote repository. * @@ -82,24 +81,6 @@ public class DeployMojo @Parameter( defaultValue = "false", property = "deployAtEnd" ) private boolean deployAtEnd; - /** - * @deprecated either use project.getArtifact() or reactorProjects.get(i).getArtifact() - */ - @Parameter( defaultValue = "${project.artifact}", required = true, readonly = true ) - private Artifact artifact; - - /** - * @deprecated either use project.getPackaging() or reactorProjects.get(i).getPackaging() - */ - @Parameter( defaultValue = "${project.packaging}", required = true, readonly = true ) - private String packaging; - - /** - * @deprecated either use project.getFile() or reactorProjects.get(i).getFile() - */ - @Parameter( defaultValue = "${project.file}", required = true, readonly = true ) - private File pomFile; - /** * Specifies an alternative repository to which the project artifacts should be deployed ( other than those * specified in <distributionManagement> ).
@@ -135,12 +116,6 @@ public class DeployMojo @Parameter( property = "altReleaseDeploymentRepository" ) private String altReleaseDeploymentRepository; - /** - * @deprecated either use project.getAttachedArtifacts() or reactorProjects.get(i).getAttachedArtifacts() - */ - @Parameter( defaultValue = "${project.attachedArtifacts}", required = true, readonly = true ) - private List attachedArtifacts; - /** * Set this to 'true' to bypass artifact deploy * diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java index ef62a80b..ccf8775d 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java @@ -162,26 +162,6 @@ public void testBasicDeployFile() assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); } - public void testDeployIfPomFileParamIsSet() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-pom-file/plugin-config.xml" ); - - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); - - assertNotNull( mojo ); - - setVariableValueToObject( mojo, "project", projectStub ); - - File pomFile = ( File ) getVariableValueFromObject( mojo, "pomFile" ); - - assertNotNull( pomFile ); - - mojo.execute(); - - assertTrue( pomFile.exists() ); - } - public void testDeployIfClassifierIsSet() throws Exception { @@ -241,16 +221,12 @@ public void testDeployIfArtifactIsNotJar() String version = (String) getVariableValueFromObject( mojo, "version" ); - String packaging = (String) getVariableValueFromObject( mojo, "packaging" ); - assertEquals( "org.apache.maven.test", groupId ); assertEquals( "maven-deploy-file-test", artifactId ); assertEquals( "1.0", version ); - assertEquals( "zip", packaging ); - mojo.execute(); File file = new File( remoteRepo, "deploy-file-artifact-not-jar/" + groupId.replace( '.', '/' ) + diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java index 26f76ee2..c2562ce4 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java @@ -31,7 +31,6 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.deploy.stubs.ArtifactDeployerStub; import org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub; @@ -274,17 +273,13 @@ public void testBasicDeployWithPackagingAsPom() assertNotNull( mojo ); - String packaging = ( String ) getVariableValueFromObject( mojo, "packaging" ); - - assertEquals( "pom", packaging ); - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); artifact = (DeployArtifactStub) project.getArtifact(); - artifact.setArtifactHandlerExtension( packaging ); + artifact.setArtifactHandlerExtension( project.getPackaging() ); ArtifactRepositoryStub repo = getRepoStub( mojo ); diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml index 798927fa..706ae344 100644 --- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml @@ -23,12 +23,6 @@ under the License. maven-deploy-plugin - - ${basedir}/src/test/resources/unit/basic-deploy-pom/plugin-config.xml - pom - - - ${localRepository} ${basedir}/src/test/resources/unit/basic-deploy-pom/plugin-config.xml diff --git a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml index 9fecd38d..0d785501 100644 --- a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml @@ -23,12 +23,6 @@ under the License. maven-deploy-plugin - - ${basedir}/src/test/resources/unit/basic-deploy-scp/plugin-config.xml - jar - - - ${localRepository} ${basedir}/src/test/resources/unit/basic-deploy-scp/plugin-config.xml diff --git a/src/test/resources/unit/basic-deploy-test/plugin-config.xml b/src/test/resources/unit/basic-deploy-test/plugin-config.xml index 45f82a3778645324ba307c1381596162cf2d0d9d..708190083f1dd6cf0b030567577cc6fe8b87cc3d 100644 GIT binary patch delta 12 TcmZ3Wut<8tH1^FRTs&+59s&cd delta 106 zcmZ1^y+C2ZGyIsTx-R diff --git a/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml b/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml index 3d54491c..4e234f2d 100644 --- a/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml @@ -23,14 +23,6 @@ under the License. maven-deploy-plugin - - ${basedir}/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml - jar - - - - - ${localRepository} ${basedir}/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml diff --git a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml b/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml index e193f5c2..5ec690ce 100644 --- a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml @@ -26,7 +26,6 @@ under the License. org.apache.maven.test maven-deploy-file-test 1.0 - zip ${basedir}/src/test/resources/unit/deploy-file-artifact-not-jar/target/deploy-test-file.zip deploy-test file://${basedir}/target/remote-repo/deploy-file-artifact-not-jar From 312793a84cb326cea2c165130203fdf59276f8be Mon Sep 17 00:00:00 2001 From: Kristian Rosenvold Date: Sun, 19 Oct 2014 07:02:32 +0000 Subject: [PATCH 006/153] Updated to p-u .20 git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1632876 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 448cca97..7734a9fb 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.0.18 + 3.0.20 org.apache.maven.plugin-testing From 1211506c1495b0f6931faf4c2e9c6e7d9dccef6e Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Tue, 18 Nov 2014 22:28:56 +0000 Subject: [PATCH 007/153] [MDEPLOY-191] Upgrade to maven-plugins parent version 27 - Cleaned up pom accordingly to let the parent do it's work. - Fixed checkstyle reported issues. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1640441 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 35 +------------------ .../plugin/deploy/AbstractDeployMojo.java | 7 ++-- .../maven/plugin/deploy/DeployFileMojo.java | 3 +- .../maven/plugin/deploy/DeployMojo.java | 19 +++++----- .../maven/plugin/deploy/DeployRequest.java | 4 +-- 5 files changed, 20 insertions(+), 48 deletions(-) diff --git a/pom.xml b/pom.xml index 7734a9fb..1f9117b8 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 25 + 27 ../maven-plugins/pom.xml @@ -59,7 +59,6 @@ under the License. 2.2.1 - 3.2 @@ -87,7 +86,6 @@ under the License. org.apache.maven.plugin-tools maven-plugin-annotations - ${mavenPluginPluginVersion} provided @@ -122,37 +120,6 @@ under the License. - - - - - - org.apache.maven.plugins - maven-plugin-plugin - ${mavenPluginPluginVersion} - - true - - - - mojo-descriptor - process-classes - - descriptor - - - - help-goal - - helpmojo - - - - - - - - run-its diff --git a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java index 33478746..06532d07 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java @@ -138,12 +138,12 @@ boolean isUpdateReleaseInfo() { return updateReleaseInfo; } - + int getRetryFailedDeploymentCount() { return retryFailedDeploymentCount; } - + /** * Deploy an artifact from a particular file. * @@ -166,7 +166,8 @@ protected void deploy( File source, Artifact artifact, ArtifactRepository deploy { if ( count > 0 ) { - getLog().info( "Retrying deployment attempt " + ( count + 1 ) + " of " + retryFailedDeploymentCounter ); + getLog().info( "Retrying deployment attempt " + ( count + 1 ) + " of " + + retryFailedDeploymentCounter ); } getDeployer().deploy( source, artifact, deploymentRepository, localRepository ); exception = null; diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java index 719e530b..59468325 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java @@ -383,7 +383,8 @@ else if ( generatePom ) { try { - deploy( attached.getFile(), attached, deploymentRepository, getLocalRepository(), getRetryFailedDeploymentCount() ); + deploy( attached.getFile(), attached, deploymentRepository, getLocalRepository(), + getRetryFailedDeploymentCount() ); } catch ( ArtifactDeploymentException e ) { diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java index a12de010..7cf73378 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java @@ -59,9 +59,9 @@ public class DeployMojo * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready * to be deployed */ - private static final AtomicInteger readyProjectsCounter = new AtomicInteger(); + private static final AtomicInteger READYPROJECTSCOUNTER = new AtomicInteger(); - private static final List deployRequests = + private static final List DEPLOYREQUESTS = Collections.synchronizedList( new ArrayList() ); /** @@ -74,7 +74,8 @@ public class DeployMojo /** * 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. (experimental) + * set to {@code true} and the build fails, none of the reactor projects is deployed. + * (experimental) * * @since 2.8 */ @@ -136,8 +137,10 @@ public void execute() { failIfOffline(); + // CHECKSTYLE_OFF: LineLength DeployRequest currentExecutionDeployRequest = new DeployRequest().setProject( project ).setUpdateReleaseInfo( isUpdateReleaseInfo() ).setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ).setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ).setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ).setAltDeploymentRepository( altDeploymentRepository ); + // CHECKSTYLE_ON: LineLength if ( !deployAtEnd ) { @@ -145,19 +148,19 @@ public void execute() } else { - deployRequests.add( currentExecutionDeployRequest ); + DEPLOYREQUESTS.add( currentExecutionDeployRequest ); addedDeployRequest = true; } } - boolean projectsReady = readyProjectsCounter.incrementAndGet() == reactorProjects.size(); + boolean projectsReady = READYPROJECTSCOUNTER.incrementAndGet() == reactorProjects.size(); if ( projectsReady ) { - synchronized ( deployRequests ) + synchronized ( DEPLOYREQUESTS ) { - while ( !deployRequests.isEmpty() ) + while ( !DEPLOYREQUESTS.isEmpty() ) { - deployProject( deployRequests.remove( 0 ) ); + deployProject( DEPLOYREQUESTS.remove( 0 ) ); } } } diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java b/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java index 02e96858..b5505d92 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java @@ -1,7 +1,5 @@ package org.apache.maven.plugin.deploy; -import org.apache.maven.project.MavenProject; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -21,6 +19,8 @@ * under the License. */ +import org.apache.maven.project.MavenProject; + /** * * @author Robert Scholte From a1b15eb70c9d14b6d86ab5985bb71f26c47bee57 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 26 Nov 2014 22:10:07 +0000 Subject: [PATCH 008/153] [MDEPLOY-192] Upgrade maven-plugin-testing-harness to 1.3 git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1641951 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f9117b8..2626ddbc 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ under the License. org.apache.maven.plugin-testing maven-plugin-testing-harness - 1.2 + 1.3 test From 932eff341b1fe9b6d8dbcf962c3b9778c8fa1cb4 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 27 Dec 2014 16:55:13 +0000 Subject: [PATCH 009/153] [MDEPLOY-194] Deploy SSH external: copy and paste failure in POM snippet comment git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1648069 13f79535-47bb-0310-9956-ffa450edef68 --- src/site/apt/examples/deploy-ssh-external.apt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/apt/examples/deploy-ssh-external.apt b/src/site/apt/examples/deploy-ssh-external.apt index 65f3f45d..e424a748 100644 --- a/src/site/apt/examples/deploy-ssh-external.apt +++ b/src/site/apt/examples/deploy-ssh-external.apt @@ -45,7 +45,7 @@ Deployment of artifacts in an external SSH command - + org.apache.maven.wagon wagon-ssh-external From e6152ec54ac7436ab768ad2f2bc5d3c0ed5d6a16 Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Sat, 3 Jan 2015 14:49:38 +0000 Subject: [PATCH 010/153] [MDEPLOY-178] Use information provided in pom.xml of JAR git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1649209 13f79535-47bb-0310-9956-ffa450edef68 --- .../invoker.properties | 18 ++++ .../pom.xml | 46 ++++++++++ .../test.properties | 19 ++++ .../verify.groovy | 29 +++++++ .../maven/plugin/deploy/DeployFileMojo.java | 87 ++++++++++++++++++- 5 files changed, 195 insertions(+), 4 deletions(-) create mode 100644 src/it/MDEPLOY-178_deployfile-with-embedded-pom/invoker.properties create mode 100644 src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml create mode 100644 src/it/MDEPLOY-178_deployfile-with-embedded-pom/test.properties create mode 100644 src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/invoker.properties b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/invoker.properties new file mode 100644 index 00000000..dd84d096 --- /dev/null +++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/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 = package deploy:deploy-file \ No newline at end of file diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml new file mode 100644 index 00000000..aa089934 --- /dev/null +++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml @@ -0,0 +1,46 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.deploy.its + mdeploy178 + 1.0 + + + Test to verify that the pom inside the jar in used when deploying the file + + + https://jira.codehaus.org/browse/MDEPLOY-178 + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + + + diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/test.properties b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/test.properties new file mode 100644 index 00000000..992a650f --- /dev/null +++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/test.properties @@ -0,0 +1,19 @@ +# 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/mdeploy178-1.0.jar +url = file:target/repo \ No newline at end of file diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy new file mode 100644 index 00000000..2c6701ad --- /dev/null +++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/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/plugins/deploy/its/mdeploy178/1.0/mdeploy178-1.0.jar" ).exists() +File deployedPom = new File( basedir, "target/repo/org/apache/maven/plugins/deploy/its/mdeploy178/1.0/mdeploy178-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/mdeploy178/pom.xml as pomFile" ) + +def pomProject = new XmlSlurper().parse( deployedPom ) +assert "https://jira.codehaus.org/browse/MDEPLOY-178".equals( pomProject.url.text() ) \ No newline at end of file diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java index 59468325..db134b42 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java @@ -21,10 +21,17 @@ 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.util.Enumeration; import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.deployer.ArtifactDeploymentException; @@ -202,14 +209,86 @@ public class DeployFileMojo void initProperties() throws MojoExecutionException { - // Process the supplied POM (if there is one) if ( pomFile != null ) { - generatePom = false; + processModel( readModel( pomFile ) ); + } + else + { + boolean foundPom = false; + + JarFile jarFile = null; + try + { + Pattern pomEntry = Pattern.compile( "META-INF/maven/.*/pom\\.xml" ); + + jarFile = new JarFile( file ); - Model model = readModel( pomFile ); + Enumeration jarEntries = jarFile.entries(); + + while ( jarEntries.hasMoreElements() ) + { + JarEntry entry = jarEntries.nextElement(); + + if ( pomEntry.matcher( entry.getName() ).matches() ) + { + getLog().debug( "Using " + entry.getName() + " as pomFile" ); + + foundPom = true; + + 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( '.' ) ); + } + pomFile = new File( file.getParentFile(), base + ".pom" ); + + pomOutputStream = new FileOutputStream( pomFile ); + + IOUtil.copy( pomInputStream, pomOutputStream ); + + processModel( readModel( pomFile ) ); + + break; + } + finally + { + IOUtil.close( pomInputStream ); + IOUtil.close( pomOutputStream ); + } + } + } - processModel( model ); + if ( !foundPom ) + { + getLog().info( "pom.xml not found in " + file.getName() ); + } + } + catch ( IOException e ) + { + // ignore, artifact not packaged by Maven + } + finally + { + if ( jarFile != null ) + { + try + { + jarFile.close(); + } + catch ( IOException e ) + { + // we did our best + } + } + } } if ( packaging == null && file != null ) From aa4b86c83d6ce619cd8c59b26b4b2f8c5c1d855f Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Mon, 30 Mar 2015 22:54:42 +0000 Subject: [PATCH 011/153] changed svnpubsub url from /content to /components git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1670209 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2626ddbc..2401cf30 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ under the License. apache.website - scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/${maven.site.path} + scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path} From 92d7ed3858f1568eb0fab14e0ce27ba413c7cac0 Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Mon, 6 Apr 2015 01:19:34 +0000 Subject: [PATCH 012/153] moved Jira from Codehaus to Apache git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1671465 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2401cf30..dc430f62 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ under the License. JIRA - http://jira.codehaus.org/browse/MDEPLOY + https://issues.apache.org/jira/browse/MDEPLOY From 5ff429c5dac68c8fe8928909d809c0826a53b9be Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Fri, 19 Jun 2015 22:37:34 +0000 Subject: [PATCH 013/153] [MNGSITE-243] Fixed link to How to use Mirros for Repositories git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1686511 13f79535-47bb-0310-9956-ffa450edef68 --- src/site/xdoc/download.xml.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index 7186d93a..09d4f421 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -39,7 +39,7 @@ under the License.

${project.name} is distributed under the Apache License, version 2.0.

-

We strongly encourage our users to configure a Maven repository mirror closer to their location, please read How to Use Mirrors for Repositories.

+

We strongly encourage our users to configure a Maven repository mirror closer to their location, please read How to Use Mirrors for Repositories.

From 89980bf81879217ef0f6c71ee4d80eb28d8e05ef Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Thu, 24 Sep 2015 21:12:20 +0000 Subject: [PATCH 014/153] Result of mvn versions:update-child-modules -DallowSnapshots -N git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1705152 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc430f62..9911e74f 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 27 + 28-SNAPSHOT ../maven-plugins/pom.xml From 9b2c32c5d81f1463b4f14d249cdcd6b1a7d36886 Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Sun, 11 Oct 2015 19:00:45 +0000 Subject: [PATCH 015/153] Merge with 3.0-branch git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1708010 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 31 +++- .../plugin/deploy/AbstractDeployMojo.java | 47 +++--- .../maven/plugin/deploy/DeployFileMojo.java | 96 ++++++++--- .../maven/plugin/deploy/DeployMojo.java | 36 +++- .../plugin/deploy/DeployFileMojoTest.java | 93 ++++++----- .../maven/plugin/deploy/DeployMojoTest.java | 157 ++++++++++++------ .../deploy/stubs/ArtifactDeployerStub.java | 23 +-- .../deploy/stubs/ArtifactRepositoryStub.java | 13 +- .../deploy/stubs/ArtifactRepositoryStub2.java | 10 ++ .../deploy/stubs/DeployArtifactStub.java | 6 + .../target/deploy-test-file-1.0-SNAPSHOT.jar | 1 - .../target/deploy-test-file-1.0-SNAPSHOT.pom | 28 ++++ 12 files changed, 379 insertions(+), 162 deletions(-) delete mode 100644 src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.jar create mode 100644 src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.pom diff --git a/pom.xml b/pom.xml index 9911e74f..426395bc 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-deploy-plugin - 2.8.3-SNAPSHOT + 3.0-SNAPSHOT maven-plugin Apache Maven Deploy Plugin @@ -58,7 +58,9 @@ under the License.
- 2.2.1 + 3.0 + 1.6 + 1.6 @@ -69,7 +71,7 @@ under the License.
org.apache.maven - maven-project + maven-core ${mavenVersion} @@ -82,6 +84,13 @@ under the License. maven-artifact ${mavenVersion} + + + org.apache.maven.shared + maven-artifact-transfer + 3.0-SNAPSHOT + + org.apache.maven.plugin-tools @@ -96,7 +105,13 @@ under the License. org.apache.maven.plugin-testing maven-plugin-testing-harness - 1.3 + 2.1 + test + + + org.apache.maven + maven-compat + ${mavenVersion} test @@ -108,7 +123,13 @@ under the License. junit junit - 3.8.2 + 4.11 + test + + + org.sonatype.aether + aether-connector-file + 1.7 test
diff --git a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java index 06532d07..d8d29f87 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java @@ -19,21 +19,23 @@ * under the License. */ -import java.io.File; +import java.util.Collection; import java.util.Map; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.deployer.ArtifactDeployer; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; +import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; +import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; /** * @version $Id$ @@ -52,12 +54,6 @@ public abstract class AbstractDeployMojo @Component protected ArtifactFactory artifactFactory; - /** - * Component used to create a repository. - */ - @Component - ArtifactRepositoryFactory repositoryFactory; - /** * Map that contains the layouts. */ @@ -90,6 +86,9 @@ public abstract class AbstractDeployMojo @Parameter( property = "retryFailedDeploymentCount", defaultValue = "1" ) private int retryFailedDeploymentCount; + @Parameter( defaultValue = "${session}", readonly = true, required = true ) + private MavenSession session; + /* Setters and Getters */ public ArtifactDeployer getDeployer() @@ -146,20 +145,21 @@ int getRetryFailedDeploymentCount() /** * Deploy an artifact from a particular file. - * - * @param source the file to deploy - * @param artifact the artifact definition + * @param artifacts the artifact definitions * @param deploymentRepository the repository to deploy to * @param localRepository the local repository to install into * @param retryFailedDeploymentCount TODO - * @throws ArtifactDeploymentException if an error occurred deploying the artifact + * + * @throws ArtifactDeployerException if an error occurred deploying the artifact */ - protected void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, + protected void deploy( Collection artifacts, ArtifactRepository deploymentRepository, ArtifactRepository localRepository, int retryFailedDeploymentCount ) - throws ArtifactDeploymentException + throws ArtifactDeployerException { + + // for now retry means redeploy the complete artifacts collection int retryFailedDeploymentCounter = Math.max( 1, Math.min( 10, retryFailedDeploymentCount ) ); - ArtifactDeploymentException exception = null; + ArtifactDeployerException exception = null; for ( int count = 0; count < retryFailedDeploymentCounter; count++ ) { try @@ -169,11 +169,12 @@ protected void deploy( File source, Artifact artifact, ArtifactRepository deploy getLog().info( "Retrying deployment attempt " + ( count + 1 ) + " of " + retryFailedDeploymentCounter ); } - getDeployer().deploy( source, artifact, deploymentRepository, localRepository ); + + getDeployer().deploy( session.getProjectBuildingRequest(), artifacts ); exception = null; break; } - catch ( ArtifactDeploymentException e ) + catch ( ArtifactDeployerException e ) { if ( count + 1 < retryFailedDeploymentCounter ) { @@ -191,4 +192,12 @@ protected void deploy( File source, Artifact artifact, ArtifactRepository deploy throw exception; } } + + protected ArtifactRepository createDeploymentArtifactRepository( String id, String url, + ArtifactRepositoryLayout layout, + boolean uniqueVersion2 ) + { + return new MavenArtifactRepository( id, url, layout, new ArtifactRepositoryPolicy(), + new ArtifactRepositoryPolicy() ); + } } diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java index db134b42..1b6fd977 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java @@ -27,6 +27,7 @@ import java.io.OutputStream; import java.io.Reader; import java.io.Writer; +import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; @@ -34,14 +35,19 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.model.InputLocation; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; +import org.apache.maven.model.building.DefaultModelBuildingRequest; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; +import org.apache.maven.model.validation.ModelValidator; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; @@ -50,8 +56,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import org.apache.maven.project.validation.ModelValidationResult; -import org.apache.maven.project.validation.ModelValidator; +import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; @@ -145,6 +150,7 @@ public class DeployFileMojo /** * The type of remote repository layout to deploy to. Try legacy for a Maven 1.x-style repository layout. */ + @Deprecated @Parameter( property = "repositoryLayout", defaultValue = "default" ) private String repositoryLayout; @@ -314,7 +320,7 @@ public void execute() ArtifactRepositoryLayout layout = getLayout( repositoryLayout ); ArtifactRepository deploymentRepository = - repositoryFactory.createDeploymentArtifactRepository( repositoryId, url, layout, uniqueVersion ); + createDeploymentArtifactRepository( repositoryId, url, layout, uniqueVersion ); String protocol = deploymentRepository.getProtocol(); @@ -354,14 +360,13 @@ else if ( generatePom ) project.setArtifact( artifact ); - try - { - deploy( file, artifact, deploymentRepository, getLocalRepository(), getRetryFailedDeploymentCount() ); - } - catch ( ArtifactDeploymentException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } + artifact.setFile( file ); + + artifact.setRepository( deploymentRepository ); + + List deployableArtifacts = new ArrayList(); + + deployableArtifacts.add( artifact ); if ( sources != null ) { @@ -455,23 +460,21 @@ else if ( generatePom ) } } - @SuppressWarnings( "unchecked" ) List attachedArtifacts = project.getAttachedArtifacts(); for ( Artifact attached : attachedArtifacts ) { - try - { - deploy( attached.getFile(), attached, deploymentRepository, getLocalRepository(), - getRetryFailedDeploymentCount() ); - } - catch ( ArtifactDeploymentException e ) - { - throw new MojoExecutionException( "Error deploying attached artifact " + attached.getFile() + ": " - + e.getMessage(), e ); - } + deployableArtifacts.add( attached ); } + try + { + deploy( deployableArtifacts, deploymentRepository, getLocalRepository(), getRetryFailedDeploymentCount() ); + } + catch ( ArtifactDeployerException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } } /** @@ -598,12 +601,16 @@ private void validateArtifactInformation() { Model model = generateModel(); - ModelValidationResult result = modelValidator.validate( model ); + ModelBuildingRequest buildingRequest = new DefaultModelBuildingRequest(); - if ( result.getMessageCount() > 0 ) + DeployModelProblemCollector problemCollector = new DeployModelProblemCollector(); + + modelValidator.validateEffectiveModel( model, buildingRequest, problemCollector ); + + if ( problemCollector.getMessageCount() > 0 ) { throw new MojoExecutionException( "The artifact information is incomplete or not valid:\n" - + result.render( " " ) ); + + problemCollector.render( " " ) ); } } @@ -687,4 +694,41 @@ void setClassifier( String classifier ) { this.classifier = classifier; } + + private static class DeployModelProblemCollector implements ModelProblemCollector + { + /** */ + private static final String NEWLINE = System.getProperty( "line.separator" ); + + /** */ + private List messages = new ArrayList(); + + @Override + public void add( Severity severity, String message, InputLocation location, Exception cause ) + { + messages.add( message ); + } + + public int getMessageCount() + { + return messages.size(); + } + + public String render( String indentation ) + { + if ( messages.size() == 0 ) + { + return indentation + "There were no validation errors."; + } + + StringBuilder message = new StringBuilder(); + + for ( int i = 0; i < messages.size(); i++ ) + { + message.append( indentation + "[" + i + "] " + messages.get( i ).toString() + NEWLINE ); + } + + return message.toString(); + } + }; } diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java index 7cf73378..4dd03099 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java @@ -29,7 +29,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; @@ -40,6 +39,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifactMetadata; +import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; /** * Deploys an artifact to remote repository. @@ -174,11 +174,12 @@ else if ( addedDeployRequest ) private void deployProject( DeployRequest request ) throws MojoExecutionException, MojoFailureException { + List deployableArtifacts = new ArrayList(); + Artifact artifact = request.getProject().getArtifact(); String packaging = request.getProject().getPackaging(); File pomFile = request.getProject().getFile(); - @SuppressWarnings( "unchecked" ) List attachedArtifacts = request.getProject().getAttachedArtifacts(); ArtifactRepository repo = @@ -205,19 +206,25 @@ private void deployProject( DeployRequest request ) ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); artifact.addMetadata( metadata ); } + else + { + artifact.setFile( pomFile ); + } if ( request.isUpdateReleaseInfo() ) { artifact.setRelease( true ); } + artifact.setRepository( repo ); + int retryFailedDeploymentCount = request.getRetryFailedDeploymentCount(); try { if ( isPomArtifact ) { - deploy( pomFile, artifact, repo, getLocalRepository(), retryFailedDeploymentCount ); + deployableArtifacts.add( artifact ); } else { @@ -225,7 +232,7 @@ private void deployProject( DeployRequest request ) if ( file != null && file.isFile() ) { - deploy( file, artifact, repo, getLocalRepository(), retryFailedDeploymentCount ); + deployableArtifacts.add( artifact ); } else if ( !attachedArtifacts.isEmpty() ) { @@ -240,7 +247,7 @@ else if ( !attachedArtifacts.isEmpty() ) pomArtifact.setRelease( true ); } - deploy( pomFile, pomArtifact, repo, getLocalRepository(), retryFailedDeploymentCount ); + deployableArtifacts.add( pomArtifact ); // propagate the timestamped version to the main artifact for the attached artifacts to pick it up artifact.setResolvedVersion( pomArtifact.getVersion() ); @@ -254,10 +261,23 @@ else if ( !attachedArtifacts.isEmpty() ) for ( Artifact attached : attachedArtifacts ) { - deploy( attached.getFile(), attached, repo, getLocalRepository(), retryFailedDeploymentCount ); + // This is here when AttachedArtifact is used, like m-sources-plugin:2.0.4 + try + { + attached.setRepository( repo ); + } + catch ( UnsupportedOperationException e ) + { + getLog().warn( attached.getId() + " has been attached with deprecated code, " + + "try to upgrade the responsible plugin" ); + } + + deployableArtifacts.add( attached ); } + + deploy( deployableArtifacts, repo, getLocalRepository(), retryFailedDeploymentCount ); } - catch ( ArtifactDeploymentException e ) + catch ( ArtifactDeployerException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -303,7 +323,7 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym ArtifactRepositoryLayout repoLayout = getLayout( layout ); - repo = repositoryFactory.createDeploymentArtifactRepository( id, url, repoLayout, true ); + repo = createDeploymentArtifactRepository( id, url, repoLayout, true ); } } diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java index ccf8775d..e3e4c40e 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java @@ -19,14 +19,25 @@ * under the License. */ +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.io.File; import java.util.ArrayList; import java.util.List; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; +import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; /** * @author Allan Ramirez @@ -34,6 +45,8 @@ public class DeployFileMojoTest extends AbstractMojoTestCase { + private String LOCAL_REPO = getBasedir() + "/target/local-repo"; + private List expectedFiles; private List fileList; @@ -42,6 +55,12 @@ public class DeployFileMojoTest MavenProjectStub projectStub = new MavenProjectStub(); + @Mock + private MavenSession session; + + @InjectMocks + private DeployFileMojo mojo; + public void setUp() throws Exception { @@ -62,7 +81,7 @@ public void testDeployTestEnvironment() { File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml" ); - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom ); assertNotNull( mojo ); } @@ -72,10 +91,18 @@ public void testBasicDeployFile() { File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml" ); - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + MockitoAnnotations.initMocks( this ); + assertNotNull( mojo ); + ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); + setVariableValueToObject( mojo, "project", projectStub ); String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); @@ -167,9 +194,17 @@ public void testDeployIfClassifierIsSet() { File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-classifier/plugin-config.xml" ); - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + MockitoAnnotations.initMocks( this ); + assertNotNull( mojo ); + + ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); setVariableValueToObject( mojo, "project", projectStub ); @@ -209,9 +244,17 @@ public void testDeployIfArtifactIsNotJar() { File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-artifact-not-jar/plugin-config.xml" ); - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + MockitoAnnotations.initMocks( this ); + assertNotNull( mojo ); + + ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); setVariableValueToObject( mojo, "project", projectStub ); @@ -241,7 +284,7 @@ public void testDeployIfRepositoryLayoutIsLegacy() { File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-legacy-repository-layout/plugin-config.xml" ); - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); + AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom ); assertNotNull( mojo ); @@ -257,40 +300,16 @@ public void testDeployIfRepositoryLayoutIsLegacy() assertEquals( "legacy", repositoryLayout ); - mojo.execute(); - - File artifactFile = new File( remoteRepo, "deploy-file-legacy-repository-layout/" + groupId + "/jars/" + artifactId + "-" + version + ".jar" ); - - assertTrue( artifactFile.exists() ); - - //check the remote-repo - expectedFiles = new ArrayList(); - fileList = new ArrayList(); - - File repo = new File( remoteRepo, "deploy-file-legacy-repository-layout" ); - - File[] files = repo.listFiles(); - - for (File file : files) { - addFileToList(file, fileList); + try + { + mojo.execute(); + fail( "legacy is not supported anymore" ); + } + catch ( MojoExecutionException e ) + { + assertEquals( "Invalid repository layout: legacy", e.getMessage() ); } - expectedFiles.add( "org.apache.maven.test" ); - expectedFiles.add( "jars" ); - 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( "poms" ); - 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" ); - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - - assertEquals( expectedFiles.size(), fileList.size() ); - - assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); } private void addFileToList( File file, List fileList ) diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java index c2562ce4..738e00b6 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java @@ -20,6 +20,7 @@ */ import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import java.io.File; @@ -28,18 +29,31 @@ import java.util.List; import java.util.Properties; +import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.deploy.stubs.ArtifactDeployerStub; import org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub; -import org.apache.maven.plugin.deploy.stubs.AttachedArtifactStub; import org.apache.maven.plugin.deploy.stubs.DeployArtifactStub; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; import org.codehaus.plexus.util.FileUtils; +import org.junit.Assume; +import org.junit.Ignore; +import org.junit.internal.builders.IgnoredBuilder; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.sonatype.aether.RepositorySystemSession; +import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; +import org.sonatype.aether.repository.LocalRepositoryManager; /** * @author Allan Ramirez @@ -58,7 +72,13 @@ public class DeployMojoTest DeployArtifactStub artifact; MavenProjectStub project = new MavenProjectStub(); + + @Mock + private MavenSession session; + @InjectMocks + private DeployMojo mojo; + public void setUp() throws Exception { @@ -79,6 +99,8 @@ public void setUp() { FileUtils.deleteDirectory( remoteRepo ); } + + } public void tearDown() @@ -106,13 +128,20 @@ public void testDeployTestEnvironment() public void testBasicDeploy() throws Exception { - File testPom = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-test/plugin-config.xml" ); + File testPom = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml" ); - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); + mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); + + MockitoAnnotations.initMocks( this ); assertNotNull( mojo ); + ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); + File file = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/target/" + "deploy-test-file-1.0-SNAPSHOT.jar" ); @@ -155,10 +184,13 @@ public void testBasicDeploy() 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" ); + // 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" ); + // extra Aether files + expectedFiles.add( "resolver-status.properties" ); + expectedFiles.add( "resolver-status.properties" ); File localRepo = new File( LOCAL_REPO, "" ); @@ -269,10 +301,24 @@ public void testBasicDeployWithPackagingAsPom() File testPom = new File( getBasedir(), "target/test-classes/unit/basic-deploy-pom/plugin-config.xml" ); - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); + mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); + + MockitoAnnotations.initMocks( this ); assertNotNull( mojo ); + ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + when( buildingRequest.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" ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); @@ -281,6 +327,8 @@ public void testBasicDeployWithPackagingAsPom() artifact.setArtifactHandlerExtension( project.getPackaging() ); + artifact.setFile( pomFile ); + ArtifactRepositoryStub repo = getRepoStub( mojo ); repo.setAppendToUrl( "basic-deploy-pom" ); @@ -324,11 +372,18 @@ public void testUpdateReleaseParamSetToTrue() { File testPom = new File( getBasedir(), "target/test-classes/unit/basic-deploy-pom/plugin-config.xml" ); + mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); + MockitoAnnotations.initMocks( this ); assertNotNull( mojo ); + ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); + boolean updateReleaseInfo = (Boolean) getVariableValueFromObject(mojo, "updateReleaseInfo"); assertTrue( updateReleaseInfo ); @@ -389,9 +444,17 @@ public void testDeployWithAttachedArtifacts() "target/test-classes/unit/basic-deploy-with-attached-artifacts/" + "plugin-config.xml" ); - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - + mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); + + MockitoAnnotations.initMocks( this ); + assertNotNull( mojo ); + + ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); + MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); @@ -405,28 +468,16 @@ public void testDeployWithAttachedArtifacts() artifact.setFile( file ); + for( Artifact attachment :project.getAttachedArtifacts() ) + {} + - @SuppressWarnings( "unchecked" ) - List attachedArtifacts = project.getAttachedArtifacts(); - ArtifactRepositoryStub repo = getRepoStub( mojo ); repo.setAppendToUrl( "basic-deploy-with-attached-artifacts" ); mojo.execute(); - String packaging = project.getPackaging(); - - for( AttachedArtifactStub attachedArtifact : attachedArtifacts ) - { - File deployedArtifact = new File( remoteRepo, "basic-deploy-with-attached-artifacts" + "/" + - attachedArtifact.getGroupId().replace( '.', '/' ) + "/" + - attachedArtifact.getArtifactId() + "/" + - attachedArtifact.getVersion() + "/" + attachedArtifact.getArtifactId() + "-" + - attachedArtifact.getVersion() + "." + packaging ); - assertTrue( deployedArtifact.exists() ); - } - //check the artifacts in remote repository List expectedFiles = new ArrayList(); List fileList = new ArrayList(); @@ -476,8 +527,8 @@ public void testDeployWithAttachedArtifacts() assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); } - - public void testBasicDeployWithScpAsProtocol() + @Ignore( "SCP is not part of Maven3 distribution. Aether handles transport extensions." ) + public void _testBasicDeployWithScpAsProtocol() throws Exception { String originalUserHome = System.getProperty( "user.home" ); @@ -496,7 +547,7 @@ public void testBasicDeployWithScpAsProtocol() File testPom = new File( getBasedir(), "target/test-classes/unit/basic-deploy-scp/plugin-config.xml" ); - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); + mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); assertNotNull( mojo ); @@ -543,40 +594,45 @@ public void testBasicDeployWithScpAsProtocol() FileUtils.deleteDirectory( sshFile ); } - public void testAltSnapshotDeploymentRepository() throws Exception + public void testAltSnapshotDeploymentRepository() + throws Exception { - DeployMojo mojo = new DeployMojo(); - + DeployMojo mojo = spy( new DeployMojo() ); + ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class ); setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) ); - ArtifactRepositoryFactory repositoryFactory = mock( ArtifactRepositoryFactory.class ); - ArtifactRepository repository = mock( ArtifactRepository.class); - when( repositoryFactory.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost", repositoryLayout, true ) ).thenReturn( repository ); - setVariableValueToObject( mojo, "repositoryFactory", repositoryFactory ); - + ArtifactRepository repository = mock( ArtifactRepository.class ); + when( + mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost", + repositoryLayout, true ) ).thenReturn( repository ); + project.setVersion( "1.0-SNAPSHOT" ); - - assertEquals( repository, mojo.getDeploymentRepository( project, null, null, "altSnapshotDeploymentRepository::default::http://localhost" ) ); + + assertEquals( repository, + mojo.getDeploymentRepository( project, null, null, + "altSnapshotDeploymentRepository::default::http://localhost" ) ); } - public void testAltReleaseDeploymentRepository() throws Exception + public void testAltReleaseDeploymentRepository() + throws Exception { - DeployMojo mojo = new DeployMojo(); - + DeployMojo mojo = spy( new DeployMojo() ); + ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class ); setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) ); - ArtifactRepositoryFactory repositoryFactory = mock( ArtifactRepositoryFactory.class ); - ArtifactRepository repository = mock( ArtifactRepository.class); - when( repositoryFactory.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost", repositoryLayout, true ) ).thenReturn( repository ); - setVariableValueToObject( mojo, "repositoryFactory", repositoryFactory ); - + ArtifactRepository repository = mock( ArtifactRepository.class ); + when( + mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost", + repositoryLayout, true ) ).thenReturn( repository ); + project.setVersion( "1.0" ); - - assertEquals( repository, mojo.getDeploymentRepository( project, null, "altReleaseDeploymentRepository::default::http://localhost", null ) ); - } + assertEquals( repository, + mojo.getDeploymentRepository( project, null, + "altReleaseDeploymentRepository::default::http://localhost", null ) ); + } private void addFileToList( File file, List fileList ) { @@ -600,6 +656,9 @@ private int getSizeOfExpectedFiles( List fileList, List expected { 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" ); diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java b/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java index 7fbad2f3..5694b5cd 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java +++ b/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java @@ -19,29 +19,20 @@ * under the License. */ -import java.io.File; +import java.util.Collection; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.deployer.ArtifactDeployer; -import org.apache.maven.artifact.deployer.ArtifactDeploymentException; -import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; +import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; public class ArtifactDeployerStub implements ArtifactDeployer { - public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException - { - String extension = artifact.getArtifactHandler().getExtension(); - File source = new File( basedir, finalName + "." + extension ); - deploy( source, artifact, deploymentRepository, localRepository ); - } - - public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, - ArtifactRepository localRepository ) - throws ArtifactDeploymentException + @Override + public void deploy( ProjectBuildingRequest request, Collection mavenArtifacts ) + throws ArtifactDeployerException { // does nothing } diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub.java b/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub.java index 099ba2b4..51c4c27e 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub.java +++ b/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub.java @@ -25,9 +25,10 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; 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 - implements ArtifactRepository + extends StubArtifactRepository { private boolean blacklisted; @@ -36,6 +37,16 @@ public class ArtifactRepositoryStub private String url; private String basedir = System.getProperty( "basedir" ); + + public ArtifactRepositoryStub() + { + super( null ); + } + + public ArtifactRepositoryStub( String dir ) + { + super( dir ); + } public String pathOf( Artifact artifact ) { diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub2.java b/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub2.java index 2e17e458..3929a70e 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub2.java +++ b/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub2.java @@ -24,6 +24,16 @@ public class ArtifactRepositoryStub2 { private String protocol; + public ArtifactRepositoryStub2() + { + super(); + } + + public ArtifactRepositoryStub2( String dir ) + { + super( dir ); + } + public String getUrl() { return "file://" + System.getProperty( "basedir" ) + "/target/remote-repo/basic-deploy-scp"; diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/DeployArtifactStub.java b/src/test/java/org/apache/maven/plugin/deploy/stubs/DeployArtifactStub.java index e34c5879..93285046 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/DeployArtifactStub.java +++ b/src/test/java/org/apache/maven/plugin/deploy/stubs/DeployArtifactStub.java @@ -61,6 +61,12 @@ public String getBaseVersion() return getVersion(); } + @Override + public String getType() + { + return "jar"; + } + public void setFile( File file ) { this.file = file; diff --git a/src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.jar b/src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.jar deleted file mode 100644 index 6f5f2f81..00000000 --- a/src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.jar +++ /dev/null @@ -1 +0,0 @@ -This is not an actual jar \ No newline at end of file diff --git a/src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.pom b/src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.pom new file mode 100644 index 00000000..095ea0f2 --- /dev/null +++ b/src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.pom @@ -0,0 +1,28 @@ + + + + + 4.0.0 + org.apache.maven.test + maven-deploy-file-test + 1.0 + pom + + \ No newline at end of file From 8527ac1a3bbcd7b1bbe8c4ee58e30d51a0f48c5e Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Sun, 18 Oct 2015 11:07:33 +0000 Subject: [PATCH 016/153] Replace localRepository with RepositoryManager, push down to deploy-file since deploy doesn't use it git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1709260 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugin/deploy/AbstractDeployMojo.java | 22 +++++------------- .../maven/plugin/deploy/DeployFileMojo.java | 20 +++++++++------- .../maven/plugin/deploy/DeployMojo.java | 5 ++-- .../unit/basic-deploy-pom/plugin-config.xml | 1 - .../unit/basic-deploy-scp/plugin-config.xml | 1 - .../unit/basic-deploy-test/plugin-config.xml | Bin 3490 -> 3360 bytes .../plugin-config.xml | 3 +-- .../plugin-config.xml | 1 - .../deploy-file-classifier/plugin-config.xml | 1 - .../plugin-config.xml | 1 - .../deploy-file-pom-file/plugin-config.xml | Bin 3502 -> 3372 bytes .../unit/deploy-file-test/plugin-config.xml | 1 - 12 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java index d8d29f87..29ca1a58 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java @@ -60,11 +60,6 @@ public abstract class AbstractDeployMojo @Component( role = ArtifactRepositoryLayout.class ) private Map repositoryLayouts; - /** - */ - @Parameter( defaultValue = "${localRepository}", required = true, readonly = true ) - private ArtifactRepository localRepository; - /** * Flag whether Maven is currently in online/offline mode. */ @@ -101,16 +96,6 @@ public void setDeployer( ArtifactDeployer deployer ) this.deployer = deployer; } - public ArtifactRepository getLocalRepository() - { - return localRepository; - } - - public void setLocalRepository( ArtifactRepository localRepository ) - { - this.localRepository = localRepository; - } - void failIfOffline() throws MojoFailureException { @@ -153,7 +138,7 @@ int getRetryFailedDeploymentCount() * @throws ArtifactDeployerException if an error occurred deploying the artifact */ protected void deploy( Collection artifacts, ArtifactRepository deploymentRepository, - ArtifactRepository localRepository, int retryFailedDeploymentCount ) + int retryFailedDeploymentCount ) throws ArtifactDeployerException { @@ -200,4 +185,9 @@ protected ArtifactRepository createDeploymentArtifactRepository( String id, Stri return new MavenArtifactRepository( id, url, layout, new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); } + + protected final MavenSession getSession() + { + return session; + } } diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java index 1b6fd977..ff3552fa 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java @@ -35,7 +35,6 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.InputLocation; @@ -43,8 +42,8 @@ import org.apache.maven.model.Parent; import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.model.validation.ModelValidator; @@ -57,6 +56,7 @@ import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; +import org.apache.maven.shared.artifact.repository.RepositoryManager; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; @@ -211,7 +211,10 @@ public class DeployFileMojo */ @Parameter( property = "files" ) private String files; - + + @Component + private RepositoryManager repoManager; + void initProperties() throws MojoExecutionException { @@ -343,12 +346,12 @@ public void execute() { if ( pomFile != null ) { - ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); + ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); artifact.addMetadata( metadata ); } else if ( generatePom ) { - ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, generatePomFile() ); + ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, generatePomFile() ); artifact.addMetadata( metadata ); } } @@ -469,7 +472,7 @@ else if ( generatePom ) try { - deploy( deployableArtifacts, deploymentRepository, getLocalRepository(), getRetryFailedDeploymentCount() ); + deploy( deployableArtifacts, deploymentRepository, getRetryFailedDeploymentCount() ); } catch ( ArtifactDeployerException e ) { @@ -486,8 +489,8 @@ else if ( generatePom ) */ private File getLocalRepoFile( Artifact artifact ) { - String path = getLocalRepository().pathOf( artifact ); - return new File( getLocalRepository().getBasedir(), path ); + String path = repoManager.getPathForLocalArtifact( getSession().getProjectBuildingRequest(), artifact ); + return new File( repoManager.getLocalRepositoryBasedir( getSession().getProjectBuildingRequest() ), path ); } /** @@ -731,4 +734,5 @@ public String render( String indentation ) return message.toString(); } }; + } diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java index 4dd03099..c797488a 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java @@ -29,7 +29,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; @@ -203,7 +202,7 @@ private void deployProject( DeployRequest request ) boolean isPomArtifact = "pom".equals( packaging ); if ( !isPomArtifact ) { - ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); + ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); artifact.addMetadata( metadata ); } else @@ -275,7 +274,7 @@ else if ( !attachedArtifacts.isEmpty() ) deployableArtifacts.add( attached ); } - deploy( deployableArtifacts, repo, getLocalRepository(), retryFailedDeploymentCount ); + deploy( deployableArtifacts, repo, retryFailedDeploymentCount ); } catch ( ArtifactDeployerException e ) { diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml index 706ae344..cd39b18c 100644 --- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml @@ -23,7 +23,6 @@ under the License. maven-deploy-plugin - ${localRepository} ${basedir}/src/test/resources/unit/basic-deploy-pom/plugin-config.xml pom diff --git a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml index 0d785501..93f18565 100644 --- a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml @@ -23,7 +23,6 @@ under the License. maven-deploy-plugin - ${localRepository} ${basedir}/src/test/resources/unit/basic-deploy-scp/plugin-config.xml jar diff --git a/src/test/resources/unit/basic-deploy-test/plugin-config.xml b/src/test/resources/unit/basic-deploy-test/plugin-config.xml index 708190083f1dd6cf0b030567577cc6fe8b87cc3d..85cd2f03aa35b5fd079ccea78570cd3a1a8f1325 100644 GIT binary patch delta 12 TcmZ1^y+CTiH1^FB99^sc9?JwL delta 98 zcmZ1=wMcryH1@z8hJ1!(hD3%Oh9HJih5{h3m?4v)1V|S#R5I8xs4!FmpkH1;l50C1ZY?EnA( diff --git a/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml b/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml index 4e234f2d..b2e730cc 100644 --- a/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml @@ -23,8 +23,7 @@ under the License. maven-deploy-plugin - ${localRepository} - + ${basedir}/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml jar diff --git a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml b/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml index 5ec690ce..f9b092e2 100644 --- a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml @@ -30,7 +30,6 @@ under the License. deploy-test file://${basedir}/target/remote-repo/deploy-file-artifact-not-jar true - ${localRepository} default true diff --git a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml b/src/test/resources/unit/deploy-file-classifier/plugin-config.xml index a633e12a..7929357d 100644 --- a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-classifier/plugin-config.xml @@ -31,7 +31,6 @@ under the License. deploy-test file://${basedir}/target/remote-repo/deploy-file-classifier true - ${localRepository} bin default true diff --git a/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml b/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml index ed5e519d..d59b015e 100644 --- a/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml @@ -31,7 +31,6 @@ under the License. deploy-test file://${basedir}/target/remote-repo/deploy-file-legacy-repository-layout true - ${localRepository} legacy true diff --git a/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml b/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml index f8ed5438ab9d5e9d5bf865e569252b153309d1da..d1e9b0e52c7c848338b8223e2546c22064199a15 100644 GIT binary patch delta 12 TcmZ1{y+&$74EN@H+!q)DA^rsv delta 76 zcmZ1@wN83N3^#WULq0CL(t?z9$`T{1{H>CAP-fvmcfQWA6<0vBX*h1G29mz E0kfile://${basedir}/target/remote-repo/deploy-file-test POM was created from deploy:deploy-file true - ${localRepository} default true From 1eed50a987552f9a89ab33de0550535ffc92181a Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Sun, 18 Oct 2015 12:50:46 +0000 Subject: [PATCH 017/153] MDEPLOY-202: deploy-file goal insists on deploying source file for previous deploy-file execution git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1709276 13f79535-47bb-0310-9956-ffa450edef68 --- .../org.eclipse.equinox.common.source_1.0.jar | Bin 0 -> 361 bytes .../lib/org.eclipse.equinox.common_1.0.jar | Bin 0 -> 361 bytes .../lib/org.eclipse.osgi.source_1.0.jar | Bin 0 -> 361 bytes .../lib/org.eclipse.osgi_1.0.jar | Bin 0 -> 361 bytes .../pom.xml | 100 ++++++++++++++++++ .../classes/org.eclipse.equinox.common.pom | 20 ++++ .../target/classes/org.eclipse.osgi.pom | 20 ++++ .../verify.groovy | 22 ++++ .../plugin/deploy/AbstractDeployMojo.java | 2 +- .../maven/plugin/deploy/DeployFileMojo.java | 14 ++- .../deploy/stubs/ArtifactDeployerStub.java | 8 ++ 11 files changed, 183 insertions(+), 3 deletions(-) create mode 100644 src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.equinox.common.source_1.0.jar create mode 100644 src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.equinox.common_1.0.jar create mode 100644 src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.osgi.source_1.0.jar create mode 100644 src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.osgi_1.0.jar create mode 100644 src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml create mode 100644 src/it/MDEPLOY-202_deployfile-with-multiple-executions/target/classes/org.eclipse.equinox.common.pom create mode 100644 src/it/MDEPLOY-202_deployfile-with-multiple-executions/target/classes/org.eclipse.osgi.pom create mode 100644 src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.equinox.common.source_1.0.jar b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.equinox.common.source_1.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..2fa3a2422d76a214014c943ea7981069f62c8b81 GIT binary patch literal 361 zcmWIWW@h1H0D<$FLGEA%l;8x?zOEsTx}JV+`T;;?A`Bcrcn(dO2(mI?M?X(D*WeI6 zU$@V`XHNTg>*`(P_14uocjo-&AcHH$51tn3c%3_;w4vmq^oO<4?t2L6tk_bO#B02L&G}>SOIZDY=qsUuWvdO0Hv7ZdGjp zb2WFxY2H*gt>bX*V-X`mfHylw+zr=^LZE{>fH=ULkx7IZx8HzDfIxuZts{s=@+n9g l!mr3ig8T{tOB&UIOt>~Ap9grevVl}F0bwPOz6Ihi004LRR@(po literal 0 HcmV?d00001 diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.equinox.common_1.0.jar b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.equinox.common_1.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..2fa3a2422d76a214014c943ea7981069f62c8b81 GIT binary patch literal 361 zcmWIWW@h1H0D<$FLGEA%l;8x?zOEsTx}JV+`T;;?A`Bcrcn(dO2(mI?M?X(D*WeI6 zU$@V`XHNTg>*`(P_14uocjo-&AcHH$51tn3c%3_;w4vmq^oO<4?t2L6tk_bO#B02L&G}>SOIZDY=qsUuWvdO0Hv7ZdGjp zb2WFxY2H*gt>bX*V-X`mfHylw+zr=^LZE{>fH=ULkx7IZx8HzDfIxuZts{s=@+n9g l!mr3ig8T{tOB&UIOt>~Ap9grevVl}F0bwPOz6Ihi004LRR@(po literal 0 HcmV?d00001 diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.osgi.source_1.0.jar b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.osgi.source_1.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..2fa3a2422d76a214014c943ea7981069f62c8b81 GIT binary patch literal 361 zcmWIWW@h1H0D<$FLGEA%l;8x?zOEsTx}JV+`T;;?A`Bcrcn(dO2(mI?M?X(D*WeI6 zU$@V`XHNTg>*`(P_14uocjo-&AcHH$51tn3c%3_;w4vmq^oO<4?t2L6tk_bO#B02L&G}>SOIZDY=qsUuWvdO0Hv7ZdGjp zb2WFxY2H*gt>bX*V-X`mfHylw+zr=^LZE{>fH=ULkx7IZx8HzDfIxuZts{s=@+n9g l!mr3ig8T{tOB&UIOt>~Ap9grevVl}F0bwPOz6Ihi004LRR@(po literal 0 HcmV?d00001 diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.osgi_1.0.jar b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.osgi_1.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..2fa3a2422d76a214014c943ea7981069f62c8b81 GIT binary patch literal 361 zcmWIWW@h1H0D<$FLGEA%l;8x?zOEsTx}JV+`T;;?A`Bcrcn(dO2(mI?M?X(D*WeI6 zU$@V`XHNTg>*`(P_14uocjo-&AcHH$51tn3c%3_;w4vmq^oO<4?t2L6tk_bO#B02L&G}>SOIZDY=qsUuWvdO0Hv7ZdGjp zb2WFxY2H*gt>bX*V-X`mfHylw+zr=^LZE{>fH=ULkx7IZx8HzDfIxuZts{s=@+n9g l!mr3ig8T{tOB&UIOt>~Ap9grevVl}F0bwPOz6Ihi004LRR@(po literal 0 HcmV?d00001 diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml new file mode 100644 index 00000000..d52e4485 --- /dev/null +++ b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml @@ -0,0 +1,100 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mdeploy-170 + configperproject + 1.0 + pom + + + Tests file deployment with multiple execution blocks + + + https://issues.apache.org/jira/browse/MDEPLOY-202 + + + true + + lib + 1.0 + 1.0 + + + + + it + file:///${basedir}/target/repo + false + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + file:target/repo + + + + + + + + deploy-equinox-snapshots + + true + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + deploy-osgi + + deploy-file + + deploy + + ${downloaded}/org.eclipse.osgi_${org.eclipse.osgi}.jar + ${downloaded}/org.eclipse.osgi.source_${org.eclipse.osgi}.jar + ${project.build.outputDirectory}/org.eclipse.osgi.pom + + + + deploy-equinox-common + + deploy-file + + deploy + + ${downloaded}/org.eclipse.equinox.common_${org.eclipse.equinox.common}.jar + ${downloaded}/org.eclipse.equinox.common.source_${org.eclipse.equinox.common}.jar + ${project.build.outputDirectory}/org.eclipse.equinox.common.pom + + + + + + + + + diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/target/classes/org.eclipse.equinox.common.pom b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/target/classes/org.eclipse.equinox.common.pom new file mode 100644 index 00000000..f3fbaf91 --- /dev/null +++ b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/target/classes/org.eclipse.equinox.common.pom @@ -0,0 +1,20 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.deploy.it + org.eclipse.equinox.common + 1.0 + \ No newline at end of file diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/target/classes/org.eclipse.osgi.pom b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/target/classes/org.eclipse.osgi.pom new file mode 100644 index 00000000..a5054d4b --- /dev/null +++ b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/target/classes/org.eclipse.osgi.pom @@ -0,0 +1,20 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.deploy.it + org.eclipse.osgi + 1.0 + \ No newline at end of file diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy new file mode 100644 index 00000000..119b9387 --- /dev/null +++ b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy @@ -0,0 +1,22 @@ +/* + * 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. + */ + +def buildLog = new File ( basedir, "build.log") + +assert 1 == buildLog.text.count( 'Uploading: file:target/repo/org/apache/maven/plugins/deploy/it/org.eclipse.osgi/1.0/org.eclipse.osgi-1.0-sources.jar') \ No newline at end of file diff --git a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java index 29ca1a58..c1b93a4e 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java @@ -155,7 +155,7 @@ protected void deploy( Collection artifacts, ArtifactRepository deploy + retryFailedDeploymentCounter ); } - getDeployer().deploy( session.getProjectBuildingRequest(), artifacts ); + getDeployer().deploy( session.getProjectBuildingRequest(), deploymentRepository, artifacts ); exception = null; break; } diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java index ff3552fa..2afb7ba5 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java @@ -373,12 +373,22 @@ else if ( generatePom ) if ( sources != null ) { - projectHelper.attachArtifact( project, "jar", "sources", sources ); + Artifact sourcesArtifact = + artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, "jar", "sources" ); + + sourcesArtifact.setFile( sources ); + + deployableArtifacts.add( sourcesArtifact ); } if ( javadoc != null ) { - projectHelper.attachArtifact( project, "jar", "javadoc", javadoc ); + Artifact javadocArtifact = + artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, "jar", "javadoc" ); + + javadocArtifact.setFile( javadoc ); + + deployableArtifacts.add( javadocArtifact ); } if ( files != null ) diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java b/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java index 5694b5cd..32c43454 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java +++ b/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java @@ -22,6 +22,7 @@ import java.util.Collection; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; @@ -36,4 +37,11 @@ public void deploy( ProjectBuildingRequest request, Collection mavenAr { // does nothing } + + @Override + public void deploy( ProjectBuildingRequest arg0, ArtifactRepository arg1, Collection arg2 ) + throws ArtifactDeployerException + { + // does nothing + } } From e83820242a2124d694a6429676a8b0eb22149ba2 Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Mon, 19 Oct 2015 19:25:45 +0000 Subject: [PATCH 018/153] use released version of parent-28 git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1709467 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 426395bc..02d62dbf 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 28-SNAPSHOT + 28 ../maven-plugins/pom.xml From 24105c57dfed4b55c242a5bc644cbfcd7fdb3b03 Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Mon, 19 Oct 2015 20:27:27 +0000 Subject: [PATCH 019/153] [MDEPLOY-203] Rename package to org.apache.maven.plugins git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1709475 13f79535-47bb-0310-9956-ffa450edef68 --- .../deploy/AbstractDeployMojo.java | 2 +- .../deploy/DeployFileMojo.java | 2 +- .../deploy/DeployMojo.java | 2 +- .../deploy/DeployRequest.java | 2 +- .../deploy/DeployFileMojoTest.java | 2 +- .../deploy/DeployFileMojoUnitTest.java | 2 +- .../deploy/DeployMojoTest.java | 8 ++++---- .../deploy/stubs/ArtifactDeployerStub.java | 2 +- .../deploy/stubs/ArtifactRepositoryStub.java | 2 +- .../deploy/stubs/ArtifactRepositoryStub2.java | 2 +- .../deploy/stubs/AttachedArtifactStub.java | 2 +- .../deploy/stubs/DeployArtifactStub.java | 2 +- .../deploy/stubs/MavenProjectStub.java | 2 +- .../unit/basic-deploy-pom/plugin-config.xml | 6 +++--- .../unit/basic-deploy-scp/plugin-config.xml | 8 ++++---- .../unit/basic-deploy-test/plugin-config.xml | Bin 3360 -> 3366 bytes .../plugin-config.xml | 8 ++++---- 17 files changed, 27 insertions(+), 27 deletions(-) rename src/main/java/org/apache/maven/{plugin => plugins}/deploy/AbstractDeployMojo.java (99%) rename src/main/java/org/apache/maven/{plugin => plugins}/deploy/DeployFileMojo.java (99%) rename src/main/java/org/apache/maven/{plugin => plugins}/deploy/DeployMojo.java (99%) rename src/main/java/org/apache/maven/{plugin => plugins}/deploy/DeployRequest.java (95%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/DeployFileMojoTest.java (99%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/DeployFileMojoUnitTest.java (99%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/DeployMojoTest.java (99%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/stubs/ArtifactDeployerStub.java (97%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/stubs/ArtifactRepositoryStub.java (98%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/stubs/ArtifactRepositoryStub2.java (97%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/stubs/AttachedArtifactStub.java (96%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/stubs/DeployArtifactStub.java (98%) rename src/test/java/org/apache/maven/{plugin => plugins}/deploy/stubs/MavenProjectStub.java (96%) diff --git a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java similarity index 99% rename from src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java rename to src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java index c1b93a4e..e54c7781 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy; +package org.apache.maven.plugins.deploy; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java similarity index 99% rename from src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java rename to src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java index 2afb7ba5..30552c28 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy; +package org.apache.maven.plugins.deploy; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java similarity index 99% rename from src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java rename to src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java index c797488a..115a235a 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy; +package org.apache.maven.plugins.deploy; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java b/src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java similarity index 95% rename from src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java rename to src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java index b5505d92..cdb99f7e 100644 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy; +package org.apache.maven.plugins.deploy; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java similarity index 99% rename from src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java rename to src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java index e3e4c40e..9979513d 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy; +package org.apache.maven.plugins.deploy; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoUnitTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java similarity index 99% rename from src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoUnitTest.java rename to src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java index b0cfd857..4418853d 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoUnitTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy; +package org.apache.maven.plugins.deploy; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java similarity index 99% rename from src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java rename to src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java index 738e00b6..54b2c924 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy; +package org.apache.maven.plugins.deploy; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -35,9 +35,9 @@ import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.deploy.stubs.ArtifactDeployerStub; -import org.apache.maven.plugin.deploy.stubs.ArtifactRepositoryStub; -import org.apache.maven.plugin.deploy.stubs.DeployArtifactStub; +import org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub; +import org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub; +import org.apache.maven.plugins.deploy.stubs.DeployArtifactStub; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.project.MavenProject; diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java similarity index 97% rename from src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java rename to src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java index 32c43454..518e36be 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy.stubs; +package org.apache.maven.plugins.deploy.stubs; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java similarity index 98% rename from src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub.java rename to src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java index 51c4c27e..0b94ebed 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy.stubs; +package org.apache.maven.plugins.deploy.stubs; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub2.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java similarity index 97% rename from src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub2.java rename to src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java index 3929a70e..0e3338fc 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub2.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy.stubs; +package org.apache.maven.plugins.deploy.stubs; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/AttachedArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java similarity index 96% rename from src/test/java/org/apache/maven/plugin/deploy/stubs/AttachedArtifactStub.java rename to src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java index b500fff1..0419a85c 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/AttachedArtifactStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy.stubs; +package org.apache.maven.plugins.deploy.stubs; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/DeployArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java similarity index 98% rename from src/test/java/org/apache/maven/plugin/deploy/stubs/DeployArtifactStub.java rename to src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java index 93285046..24f31d58 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/DeployArtifactStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy.stubs; +package org.apache.maven.plugins.deploy.stubs; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java similarity index 96% rename from src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java rename to src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java index 3c8531f2..91709a36 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy.stubs; +package org.apache.maven.plugins.deploy.stubs; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml index cd39b18c..1f5ae632 100644 --- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml @@ -23,12 +23,12 @@ under the License. maven-deploy-plugin - + ${basedir}/src/test/resources/unit/basic-deploy-pom/plugin-config.xml pom - + - + ${basedir} diff --git a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml index 93f18565..ffb387ad 100644 --- a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml @@ -23,15 +23,15 @@ under the License. maven-deploy-plugin - + ${basedir}/src/test/resources/unit/basic-deploy-scp/plugin-config.xml jar - + - + false - + diff --git a/src/test/resources/unit/basic-deploy-test/plugin-config.xml b/src/test/resources/unit/basic-deploy-test/plugin-config.xml index 85cd2f03aa35b5fd079ccea78570cd3a1a8f1325..ae6eeaf21c833221d84a50b5eca9872782c72d74 100644 GIT binary patch delta 36 mcmZ1=wM=Tm7k0+t$ maven-deploy-plugin - + ${basedir}/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml jar - + - + - + ${basedir} From ddee82bb3523a467ea03123d397719fc79f5d7cb Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Tue, 17 Nov 2015 20:21:30 +0000 Subject: [PATCH 020/153] [MPOM-95] updated parent pom location git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1714875 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 02d62dbf..08d01f06 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ under the License. org.apache.maven.plugins maven-plugins 28 - ../maven-plugins/pom.xml + ../../pom/maven/maven-plugins/pom.xml maven-deploy-plugin From b2c2b5a7c1b3449f639969605376bde690d8519c Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Sun, 27 Dec 2015 20:13:37 +0000 Subject: [PATCH 021/153] Adjust package of RepositoryManager git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1721839 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/maven/plugins/deploy/DeployFileMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 30552c28..5a630a0b 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -56,7 +56,7 @@ import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; -import org.apache.maven.shared.artifact.repository.RepositoryManager; +import org.apache.maven.shared.repository.RepositoryManager; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; From 0d61f9d2cf309f0f74d188a0493d2eb2522bde8b Mon Sep 17 00:00:00 2001 From: Robert Scholte Date: Tue, 12 Jan 2016 21:20:47 +0000 Subject: [PATCH 022/153] [MDEPLOY-205] MavenProject with only attachments must have packaging "pom" git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1724326 13f79535-47bb-0310-9956-ffa450edef68 --- src/it/mdeploy-45-test/pom.xml | 38 ++++++++--- src/it/no-main-artifact-1/invoker.properties | 17 +++++ src/it/no-main-artifact-1/pom.xml | 1 + .../{verify.bsh => verify.groovy} | 63 +++++++------------ src/it/no-main-artifact-2/invoker.properties | 17 +++++ .../{verify.bsh => verify.groovy} | 63 +++++++------------ src/it/no-main-artifact-snapshot/pom.xml | 28 +++++++-- .../maven/plugins/deploy/DeployFileMojo.java | 4 ++ .../maven/plugins/deploy/DeployMojo.java | 21 ++----- 9 files changed, 141 insertions(+), 111 deletions(-) create mode 100644 src/it/no-main-artifact-1/invoker.properties rename src/it/no-main-artifact-1/{verify.bsh => verify.groovy} (59%) create mode 100644 src/it/no-main-artifact-2/invoker.properties rename src/it/no-main-artifact-2/{verify.bsh => verify.groovy} (59%) diff --git a/src/it/mdeploy-45-test/pom.xml b/src/it/mdeploy-45-test/pom.xml index 4cd030ed..c30df9e6 100644 --- a/src/it/mdeploy-45-test/pom.xml +++ b/src/it/mdeploy-45-test/pom.xml @@ -25,11 +25,12 @@ under the License. org.apache.maven.its.deploy.45 test 0.1 - war + + pom MDEPLOY-45 sample web project with classified artifact output - http://jira.codehaus.org/browse/MDEPLOY-45 + https://issues.apache.org/jira/browse/MDEPLOY-45 mdp45 @@ -51,21 +52,42 @@ under the License. - maven-deploy-plugin - @project.version@ - - - mine::default::file://${basedir}/target - + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + + resources + + + + org.apache.maven.plugins maven-war-plugin 2.0.2 + + + + war + + + ${mdp45.artifact.classifier} + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + mine::default::file://${basedir}/target + + diff --git a/src/it/no-main-artifact-1/invoker.properties b/src/it/no-main-artifact-1/invoker.properties new file mode 100644 index 00000000..e497ae44 --- /dev/null +++ b/src/it/no-main-artifact-1/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.buildResult=failure \ No newline at end of file diff --git a/src/it/no-main-artifact-1/pom.xml b/src/it/no-main-artifact-1/pom.xml index 2f30111c..a9a7c2bb 100644 --- a/src/it/no-main-artifact-1/pom.xml +++ b/src/it/no-main-artifact-1/pom.xml @@ -25,6 +25,7 @@ under the License. org.apache.maven.its.deploy.nma1 test 1.0 + jar diff --git a/src/it/no-main-artifact-1/verify.bsh b/src/it/no-main-artifact-1/verify.groovy similarity index 59% rename from src/it/no-main-artifact-1/verify.bsh rename to src/it/no-main-artifact-1/verify.groovy index c6d7a377..9442aa7d 100644 --- a/src/it/no-main-artifact-1/verify.bsh +++ b/src/it/no-main-artifact-1/verify.groovy @@ -1,40 +1,23 @@ -/* - * 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.*; - -String[] paths = -{ - "org/apache/maven/its/deploy/nma1/test/maven-metadata.xml", - "org/apache/maven/its/deploy/nma1/test/1.0/test-1.0.pom", - "org/apache/maven/its/deploy/nma1/test/1.0/test-1.0-it.jar", -}; - -for ( String path : paths ) -{ - File file = new File( new File( basedir, "target/repo" ), path ); - System.out.println( "Checking for existence of " + file ); - if ( !file.isFile() ) - { - throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() ); - } -} - -return true; +/* + * 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. + */ + +def buildLog = new File ( basedir, "build.log") + +assert buildLog.text.contains( "The packaging plugin for this project did not assign " + + "a main file to the project but it has attachments. Change packaging to 'pom'." ) \ No newline at end of file diff --git a/src/it/no-main-artifact-2/invoker.properties b/src/it/no-main-artifact-2/invoker.properties new file mode 100644 index 00000000..e497ae44 --- /dev/null +++ b/src/it/no-main-artifact-2/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.buildResult=failure \ No newline at end of file diff --git a/src/it/no-main-artifact-2/verify.bsh b/src/it/no-main-artifact-2/verify.groovy similarity index 59% rename from src/it/no-main-artifact-2/verify.bsh rename to src/it/no-main-artifact-2/verify.groovy index 4468ed8f..9442aa7d 100644 --- a/src/it/no-main-artifact-2/verify.bsh +++ b/src/it/no-main-artifact-2/verify.groovy @@ -1,40 +1,23 @@ -/* - * 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.*; - -String[] paths = -{ - "org/apache/maven/its/deploy/nma2/test/maven-metadata.xml", - "org/apache/maven/its/deploy/nma2/test/1.0/test-1.0.pom", - "org/apache/maven/its/deploy/nma2/test/1.0/test-1.0-it.jar", -}; - -for ( String path : paths ) -{ - File file = new File( new File( basedir, "target/repo" ), path ); - System.out.println( "Checking for existence of " + file ); - if ( !file.isFile() ) - { - throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() ); - } -} - -return true; +/* + * 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. + */ + +def buildLog = new File ( basedir, "build.log") + +assert buildLog.text.contains( "The packaging plugin for this project did not assign " + + "a main file to the project but it has attachments. Change packaging to 'pom'." ) \ No newline at end of file diff --git a/src/it/no-main-artifact-snapshot/pom.xml b/src/it/no-main-artifact-snapshot/pom.xml index ac2935ca..cb906106 100644 --- a/src/it/no-main-artifact-snapshot/pom.xml +++ b/src/it/no-main-artifact-snapshot/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.its.deploy.nmas test 1.0-SNAPSHOT - jar + pom Tests the deployment of a snapshot for a project that has no main artifact file but only attached artifacts @@ -49,6 +49,13 @@ under the License. org.apache.maven.plugins maven-compiler-plugin 2.0.2 + + + + compile + + + org.apache.maven.plugins @@ -59,6 +66,13 @@ under the License. org.apache.maven.plugins maven-jar-plugin 2.1 + + + + jar + + + it @@ -72,11 +86,13 @@ under the License. org.apache.maven.plugins maven-resources-plugin 2.2 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.3.1 + + + + resources + + + 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 5a630a0b..f17dd8ae 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -54,6 +54,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuildingHelper; import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; import org.apache.maven.shared.repository.RepositoryManager; @@ -215,6 +216,9 @@ public class DeployFileMojo @Component private RepositoryManager repoManager; + @Component + private ProjectBuildingHelper projectBuildingHelper; + void initProperties() throws MojoExecutionException { 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 115a235a..3c8ee440 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -235,26 +235,13 @@ private void deployProject( DeployRequest request ) } else if ( !attachedArtifacts.isEmpty() ) { - getLog().info( "No primary artifact to deploy, deploying attached artifacts instead." ); - - Artifact pomArtifact = - artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getBaseVersion() ); - pomArtifact.setFile( pomFile ); - if ( request.isUpdateReleaseInfo() ) - { - pomArtifact.setRelease( true ); - } - - deployableArtifacts.add( pomArtifact ); - - // propagate the timestamped version to the main artifact for the attached artifacts to pick it up - artifact.setResolvedVersion( pomArtifact.getVersion() ); + 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 { - String message = "The packaging for this project did not assign a file to the build artifact"; - throw new MojoExecutionException( message ); + throw new MojoExecutionException( "The packaging for this project did not assign " + + "a file to the build artifact" ); } } From cfee7eec96e38ef68faadba0ec366ee5ed7eaa0d Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Thu, 5 May 2016 03:22:53 +0000 Subject: [PATCH 023/153] o Updated to 'plexus-utils-3.0.23'. o Updated to stop suppressing exceptions incorrectly when closing resources. Most of the time the 'IOUtils.closeQuietly' methods of 'commons-io' and the 'IOUtil.close' method of 'plexus-utils' are used incorrectly. They are meant to be used in 'finally' blocks to not suppress an exception already thrown in the 'try' block. The documentation of the 'IOUtils.closeQuietly' methods explicitly contains usage examples. As soon as 'commons-io' or 'plexus-utils' is targetted at Java 1.7, those methods should get deprecated and people should be told to use the try-with-resources statement instead. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1742353 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- .../maven/plugins/deploy/DeployFileMojo.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 08d01f06..c7a27e77 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.0.20 + 3.0.23 org.apache.maven.plugin-testing 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 f17dd8ae..f8068e88 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -267,6 +267,11 @@ void initProperties() IOUtil.copy( pomInputStream, pomOutputStream ); + pomOutputStream.close(); + pomOutputStream = null; + pomInputStream.close(); + pomInputStream = null; + processModel( readModel( pomFile ) ); break; @@ -556,7 +561,10 @@ Model readModel( File pomFile ) try { reader = ReaderFactory.newXmlReader( pomFile ); - return new MavenXpp3Reader().read( reader ); + final Model model = new MavenXpp3Reader().read( reader ); + reader.close(); + reader = null; + return model; } catch ( FileNotFoundException e ) { @@ -594,8 +602,12 @@ private File generatePomFile() tempFile.deleteOnExit(); fw = WriterFactory.newXmlWriter( tempFile ); + new MavenXpp3Writer().write( fw, model ); + fw.close(); + fw = null; + return tempFile; } catch ( IOException e ) From d912c04ea6b1fd96c2ba8ac41a2637a43c01606e Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Sun, 8 May 2016 00:27:05 +0000 Subject: [PATCH 024/153] o Updated to 'plexus-utils' 3.0.24. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1742760 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c7a27e77..777cb0f2 100644 --- a/pom.xml +++ b/pom.xml @@ -100,7 +100,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.0.23 + 3.0.24 org.apache.maven.plugin-testing From 34b54a10303cff8925a85c9e795245231dbdc91e Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Sun, 15 May 2016 09:15:02 +0000 Subject: [PATCH 025/153] updated Jira url git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1743895 13f79535-47bb-0310-9956-ffa450edef68 --- src/site/site.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/site.xml b/src/site/site.xml index d4d31b4c..195d0356 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -29,7 +29,7 @@ under the License. - + From e45544218b4cabe45c47bb9f2582e83ddc268d0a Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 25 May 2016 21:10:11 +0000 Subject: [PATCH 026/153] Cleaned up code. o Removed unused code. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1745541 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugins/deploy/DeployFileMojoTest.java | 6 ------ .../maven/plugins/deploy/DeployMojoTest.java | 15 ++------------- 2 files changed, 2 insertions(+), 19 deletions(-) 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 9979513d..2564d77e 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -292,12 +292,6 @@ public void testDeployIfRepositoryLayoutIsLegacy() String repositoryLayout = (String) getVariableValueFromObject( mojo, "repositoryLayout" ); - String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); - - String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" ); - - String version = (String) getVariableValueFromObject( mojo, "version" ); - assertEquals( "legacy", repositoryLayout ); try 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 54b2c924..97f2d3f5 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -29,31 +29,24 @@ import java.util.List; import java.util.Properties; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub; import org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub; import org.apache.maven.plugins.deploy.stubs.DeployArtifactStub; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.internal.MavenRepositorySystemSession; -import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; import org.codehaus.plexus.util.FileUtils; -import org.junit.Assume; import org.junit.Ignore; -import org.junit.internal.builders.IgnoredBuilder; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.sonatype.aether.RepositorySystemSession; import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; -import org.sonatype.aether.repository.LocalRepositoryManager; /** * @author Allan Ramirez @@ -468,10 +461,6 @@ public void testDeployWithAttachedArtifacts() artifact.setFile( file ); - for( Artifact attachment :project.getAttachedArtifacts() ) - {} - - ArtifactRepositoryStub repo = getRepoStub( mojo ); repo.setAppendToUrl( "basic-deploy-with-attached-artifacts" ); From 56db802dd57d1e4420fc6ac319e7fe7460d85677 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 29 May 2016 12:02:28 +0000 Subject: [PATCH 027/153] [MDEPLOY-209] Upgrade maven-shared-components parent to version 30 git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1745987 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 777cb0f2..6d311a5e 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 28 + 30 ../../pom/maven/maven-plugins/pom.xml From 20f5b8a96df0d3103f56975c0f8a6ecafa97b975 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 29 May 2016 12:04:14 +0000 Subject: [PATCH 028/153] Make a three digit version. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1745988 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6d311a5e..5bcd2395 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-deploy-plugin - 3.0-SNAPSHOT + 3.0.0-SNAPSHOT maven-plugin Apache Maven Deploy Plugin From e1575565b9ee05fadc81937445e6ee5610378a63 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 29 May 2016 12:05:03 +0000 Subject: [PATCH 029/153] [MDEPLOY-209] Upgrade maven-shared-components parent to version 30 o Followup let the parent do it's work. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1745989 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5bcd2395..de229ca4 100644 --- a/pom.xml +++ b/pom.xml @@ -59,8 +59,6 @@ under the License. 3.0 - 1.6 - 1.6 From ecd4a82346930b643c999fb419c3028836f5ba4d Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 29 May 2016 12:13:39 +0000 Subject: [PATCH 030/153] Use three digit version line for artifact-transfer as well. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1745991 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index de229ca4..f9a85f36 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ under the License. org.apache.maven.shared maven-artifact-transfer - 3.0-SNAPSHOT + 3.0.0-SNAPSHOT From a7facac10e4587454df3e8a72b6fae7fe649a57a Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Sat, 18 Jun 2016 13:51:35 +0000 Subject: [PATCH 031/153] [MDEPLOY-210] Upgrade of commons-io to 2.5. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1749029 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index f9a85f36..7effe705 100644 --- a/pom.xml +++ b/pom.xml @@ -88,6 +88,12 @@ under the License. maven-artifact-transfer 3.0.0-SNAPSHOT + + + commons-io + commons-io + 2.5 + From 91f24da53bca3299d743266f2b46b936674e5349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Bou=C3=A9?= Date: Sat, 6 Aug 2016 18:38:21 +0000 Subject: [PATCH 032/153] [MDEPLOY-181] DeployAtEnd cannot be overwritten from command line using -DdeployAtEnd=false This issue is closed as "Not A Problem", removing the IT introduced in r1620139. It is expected for the parameters configured in the POM to have precedence over the ones from the default configuration. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1755406 13f79535-47bb-0310-9956-ffa450edef68 --- src/it/MDEPLOY-181/invoker.properties | 20 ----- src/it/MDEPLOY-181/module1/pom.xml | 25 ------- src/it/MDEPLOY-181/module2/pom.xml | 38 ---------- src/it/MDEPLOY-181/pom.xml | 101 -------------------------- src/it/MDEPLOY-181/test.properties | 18 ----- src/it/MDEPLOY-181/verify.groovy | 21 ------ 6 files changed, 223 deletions(-) delete mode 100644 src/it/MDEPLOY-181/invoker.properties delete mode 100644 src/it/MDEPLOY-181/module1/pom.xml delete mode 100644 src/it/MDEPLOY-181/module2/pom.xml delete mode 100644 src/it/MDEPLOY-181/pom.xml delete mode 100644 src/it/MDEPLOY-181/test.properties delete mode 100644 src/it/MDEPLOY-181/verify.groovy diff --git a/src/it/MDEPLOY-181/invoker.properties b/src/it/MDEPLOY-181/invoker.properties deleted file mode 100644 index ac00f436..00000000 --- a/src/it/MDEPLOY-181/invoker.properties +++ /dev/null @@ -1,20 +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. - -invoker.goals = clean deploy -# waiting for MDEPLOY-181 fix -invoker.maven.version = 3.2.4+ \ No newline at end of file diff --git a/src/it/MDEPLOY-181/module1/pom.xml b/src/it/MDEPLOY-181/module1/pom.xml deleted file mode 100644 index aecbca0b..00000000 --- a/src/it/MDEPLOY-181/module1/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.mdeploy-170 - configperproject - 1.0 - - module1 - - diff --git a/src/it/MDEPLOY-181/module2/pom.xml b/src/it/MDEPLOY-181/module2/pom.xml deleted file mode 100644 index d811568c..00000000 --- a/src/it/MDEPLOY-181/module2/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.mdeploy-170 - configperproject - 1.0 - - module2 - pom - - - - - org.apache.maven.plugins - maven-deploy-plugin - @project.version@ - - true - - - - - diff --git a/src/it/MDEPLOY-181/pom.xml b/src/it/MDEPLOY-181/pom.xml deleted file mode 100644 index 3e7d3cc7..00000000 --- a/src/it/MDEPLOY-181/pom.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - 4.0.0 - - org.apache.maven.its.mdeploy-170 - configperproject - 1.0 - pom - - - Tests deployment at end with with different plugin configurations. - - - - true - - - - - it - file:///${basedir}/target/repo - false - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - - org.apache.maven.plugins - maven-deploy-plugin - @project.version@ - - true - - - - org.apache.maven.plugins - maven-install-plugin - 2.2 - - - org.apache.maven.plugins - maven-jar-plugin - 2.1 - - - org.apache.maven.plugins - maven-resources-plugin - 2.2 - - - org.apache.maven.plugins - maven-source-plugin - 2.0.4 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.3.1 - - - - - - module1 - module2 - - diff --git a/src/it/MDEPLOY-181/test.properties b/src/it/MDEPLOY-181/test.properties deleted file mode 100644 index fb658e56..00000000 --- a/src/it/MDEPLOY-181/test.properties +++ /dev/null @@ -1,18 +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. - -deployAtEnd=false \ No newline at end of file diff --git a/src/it/MDEPLOY-181/verify.groovy b/src/it/MDEPLOY-181/verify.groovy deleted file mode 100644 index 0c55d6e1..00000000 --- a/src/it/MDEPLOY-181/verify.groovy +++ /dev/null @@ -1,21 +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. - */ - -def buildLog = new File ( basedir, "build.log") -assert !buildLog.text.contains( 'true') From f9575b1475914e70a873eda20041e707bc677917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Bou=C3=A9?= Date: Sun, 7 Aug 2016 14:14:46 +0000 Subject: [PATCH 033/153] [MDEPLOY-212] deploy-file incorrectly deploys attached artifacts [MDEPLOY-213] deploy-file replaces main artifact of a project The deploy-file Mojo now creates a new MavenProject and attaches to this project all artifacts to deploy. This also fixes the use of deprecated code from ArtifactFactory. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1755441 13f79535-47bb-0310-9956-ffa450edef68 --- .../invoker.properties | 18 +++ src/it/3rd-party-pom-with-extras/pom.xml | 44 ++++++ .../test-0.1-src.tar.gz | Bin 0 -> 357 bytes src/it/3rd-party-pom-with-extras/test-0.1.pom | 28 ++++ .../3rd-party-pom-with-extras/test-0.1.tar.gz | Bin 0 -> 357 bytes src/it/3rd-party-pom-with-extras/test-0.1.zip | Bin 0 -> 345 bytes .../3rd-party-pom-with-extras/test.properties | 27 ++++ src/it/3rd-party-pom-with-extras/verify.bsh | 57 ++++++++ src/it/MDEPLOY-212/invoker.properties | 18 +++ src/it/MDEPLOY-212/pom.xml | 79 ++++++++++ .../org/apache/maven/test/HelloWorld.java | 37 +++++ src/it/MDEPLOY-212/test-1.0.tar.gz | Bin 0 -> 357 bytes src/it/MDEPLOY-212/test-1.0.zip | Bin 0 -> 345 bytes src/it/MDEPLOY-212/verify.bsh | 56 ++++++++ src/it/MDEPLOY-213/invoker.properties | 18 +++ src/it/MDEPLOY-213/pom.xml | 88 ++++++++++++ .../org/apache/maven/test/HelloWorld.java | 37 +++++ src/it/MDEPLOY-213/test-1.0.tar.gz | Bin 0 -> 357 bytes src/it/MDEPLOY-213/test-1.0.zip | Bin 0 -> 345 bytes src/it/MDEPLOY-213/verify.bsh | 42 ++++++ .../maven/plugins/deploy/DeployFileMojo.java | 136 +++++++++++------- .../plugins/deploy/DeployFileMojoTest.java | 14 -- 22 files changed, 637 insertions(+), 62 deletions(-) create mode 100644 src/it/3rd-party-pom-with-extras/invoker.properties create mode 100644 src/it/3rd-party-pom-with-extras/pom.xml create mode 100644 src/it/3rd-party-pom-with-extras/test-0.1-src.tar.gz create mode 100644 src/it/3rd-party-pom-with-extras/test-0.1.pom create mode 100644 src/it/3rd-party-pom-with-extras/test-0.1.tar.gz create mode 100644 src/it/3rd-party-pom-with-extras/test-0.1.zip create mode 100644 src/it/3rd-party-pom-with-extras/test.properties create mode 100644 src/it/3rd-party-pom-with-extras/verify.bsh create mode 100644 src/it/MDEPLOY-212/invoker.properties create mode 100644 src/it/MDEPLOY-212/pom.xml create mode 100644 src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java create mode 100644 src/it/MDEPLOY-212/test-1.0.tar.gz create mode 100644 src/it/MDEPLOY-212/test-1.0.zip create mode 100644 src/it/MDEPLOY-212/verify.bsh create mode 100644 src/it/MDEPLOY-213/invoker.properties create mode 100644 src/it/MDEPLOY-213/pom.xml create mode 100644 src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java create mode 100644 src/it/MDEPLOY-213/test-1.0.tar.gz create mode 100644 src/it/MDEPLOY-213/test-1.0.zip create mode 100644 src/it/MDEPLOY-213/verify.bsh diff --git a/src/it/3rd-party-pom-with-extras/invoker.properties b/src/it/3rd-party-pom-with-extras/invoker.properties new file mode 100644 index 00000000..51d90e1b --- /dev/null +++ b/src/it/3rd-party-pom-with-extras/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 = org.apache.maven.plugins:maven-deploy-plugin:${project.version}:deploy-file diff --git a/src/it/3rd-party-pom-with-extras/pom.xml b/src/it/3rd-party-pom-with-extras/pom.xml new file mode 100644 index 00000000..593d478a --- /dev/null +++ b/src/it/3rd-party-pom-with-extras/pom.xml @@ -0,0 +1,44 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.tppwoc + test + 1.0 + jar + + + Tests the manual deployment of a simple POM along with extra files. + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + + + diff --git a/src/it/3rd-party-pom-with-extras/test-0.1-src.tar.gz b/src/it/3rd-party-pom-with-extras/test-0.1-src.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..2169f44a259a4bb8c65052af09615d7bf3eedaa0 GIT binary patch literal 357 zcmV-r0h<0FiwFQtO#n^+1MSm6OT#b}2kW>}kpdJ9L68;%$VQ zVZmiv+kyKe`WgI`rmmY|)ii)&h$rI}33QqoLK?v;+#jWffB!!PD3_OXipM6k?18w9Oh zx6|&2Ea+_ZALcw<$623$TiB)i3oe?3^35*eb32}Ya!@-Y`{o|Vh+g&SEiL4I~vgBPJ)42gRl{nMj?*T9IiZKSqCfMSOol z+l7x-^}n_1|Gxe$?v?7_ahn45{~H3Siw + + + + + 4.0.0 + org.apache.maven.its.deploy.tppwoc + test + 1.0 + pom + \ No newline at end of file diff --git a/src/it/3rd-party-pom-with-extras/test-0.1.tar.gz b/src/it/3rd-party-pom-with-extras/test-0.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ad736b0d7b2e3120ed3a365a1cffe9cfbbd4e85c GIT binary patch literal 357 zcmV-r0h<0FiwFQcO#n^+1MSm6OT#b}2kW>}kpdJ9L68;%$VQ zVZmiv+kyKe`WgI`rmmY|)ii)&h$rI}33QqoLK?v;+#jWffB!!PD3_OXipM6k?18w9Oh zx6|&2Ea+_ZALcw<$623$TiB)i3oe?3^35*eb32}Ya!@-Y`{o|Vh+g&SEiL4I~vgBPJ)42gRl{nMj?*T9IiZKSqCfMSOol z+l7x-^}n_1|Gxe$?v?7_ahn45{~H3Siw + + + + + 4.0.0 + + org.apache.maven.its.mdeploy-212 + test + 1.0 + jar + + + Tests that deploy-file only deploys the configured files when run in an existing project with attached artifacts + + + https://issues.apache.org/jira/browse/MDEPLOY-212 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.7 + + + attach-javadoc + + jar + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + test-deploy + + deploy-file + + package + + org.apache.maven.its.mdeploy-212 + test + 1.0 + test-1.0.tar.gz + tar.gz + file://${basedir}/target/repo + test-1.0.zip + zip + it + + + + + + + + diff --git a/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java b/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java new file mode 100644 index 00000000..ed8b2ca7 --- /dev/null +++ b/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java @@ -0,0 +1,37 @@ +package org.apache.maven.test; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Hello World class + */ +public class HelloWorld +{ + + /** + * Main method + * @param args Arguments + */ + public static void main( String[] args ) + { + System.out.println( "Hello world" ); + } + +} diff --git a/src/it/MDEPLOY-212/test-1.0.tar.gz b/src/it/MDEPLOY-212/test-1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ad736b0d7b2e3120ed3a365a1cffe9cfbbd4e85c GIT binary patch literal 357 zcmV-r0h<0FiwFQcO#n^+1MSm6OT#b}2kW>}kpdJ9L68;%$VQ zVZmiv+kyKe`WgI`rmmY|)ii)&h$rI}33QqoLK?v;+#jWffB!!PD3_OXipM6k?18w9Oh zx6|&2Ea+_ZALcw<$623$TiB)i3oe?3^35*eb32}Ya!@-Y`{o|Vh+g&SEiL4I~vgBPJ)42gRl{nMj?*T9IiZKSqCfMSOol z+l7x-^}n_1|Gxe$?v?7_ahn45{~H3Siw + + + + + 4.0.0 + + org.apache.maven.its.mdeploy-213 + test + 1.0 + jar + + + Tests that deploy-file does not change the main artifact of the project being built + + + https://issues.apache.org/jira/browse/MDEPLOY-213 + + + + it + file://${basedir}/target/repo + false + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.7 + + + attach-javadoc + + jar + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + test-deploy + + deploy-file + + package + + org.apache.maven.its.mdeploy-213 + test + 1.0 + test-1.0.tar.gz + tar.gz + file://${basedir}/target/repo + test-1.0.zip + zip + it + + + + + + + + diff --git a/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java b/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java new file mode 100644 index 00000000..ed8b2ca7 --- /dev/null +++ b/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java @@ -0,0 +1,37 @@ +package org.apache.maven.test; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Hello World class + */ +public class HelloWorld +{ + + /** + * Main method + * @param args Arguments + */ + public static void main( String[] args ) + { + System.out.println( "Hello world" ); + } + +} diff --git a/src/it/MDEPLOY-213/test-1.0.tar.gz b/src/it/MDEPLOY-213/test-1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ad736b0d7b2e3120ed3a365a1cffe9cfbbd4e85c GIT binary patch literal 357 zcmV-r0h<0FiwFQcO#n^+1MSm6OT#b}2kW>}kpdJ9L68;%$VQ zVZmiv+kyKe`WgI`rmmY|)ii)&h$rI}33QqoLK?v;+#jWffB!!PD3_OXipM6k?18w9Oh zx6|&2Ea+_ZALcw<$623$TiB)i3oe?3^35*eb32}Ya!@-Y`{o|Vh+g&SEiL4I~vgBPJ)42gRl{nMj?*T9IiZKSqCfMSOol z+l7x-^}n_1|Gxe$?v?7_ahn45{~H3Siw deployableArtifacts = new ArrayList(); + + if ( classifier == null ) + { + artifact.setFile( file ); + deployableArtifacts.add( artifact ); + } + else + { + projectHelper.attachArtifact( project, packaging, classifier, file ); + } + // Upload the POM if requested, generating one if need be if ( !"pom".equals( packaging ) ) { - if ( pomFile != null ) + File pom = pomFile; + if ( pom == null && generatePom ) { - ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); - artifact.addMetadata( metadata ); + pom = generatePomFile(); } - else if ( generatePom ) + if ( pom != null ) { - ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, generatePomFile() ); - artifact.addMetadata( metadata ); + if ( classifier == null ) + { + ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom ); + artifact.addMetadata( metadata ); + } + else + { + artifact.setFile( pom ); + deployableArtifacts.add( artifact ); + } } } @@ -369,35 +391,16 @@ else if ( generatePom ) { artifact.setRelease( true ); } - - project.setArtifact( artifact ); - - artifact.setFile( file ); - artifact.setRepository( deploymentRepository ); - - List deployableArtifacts = new ArrayList(); - - deployableArtifacts.add( artifact ); if ( sources != null ) { - Artifact sourcesArtifact = - artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, "jar", "sources" ); - - sourcesArtifact.setFile( sources ); - - deployableArtifacts.add( sourcesArtifact ); + projectHelper.attachArtifact( project, "jar", "sources", sources ); } if ( javadoc != null ) { - Artifact javadocArtifact = - artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, "jar", "javadoc" ); - - javadocArtifact.setFile( javadoc ); - - deployableArtifacts.add( javadocArtifact ); + projectHelper.attachArtifact( project, "jar", "javadoc", javadoc ); } if ( files != null ) @@ -498,17 +501,54 @@ else if ( generatePom ) throw new MojoExecutionException( e.getMessage(), e ); } } - + + /** + * Creates a Maven project in-memory from the user-supplied groupId, artifactId and version. + * When a classifier is supplied, the packaging must be POM because the project with only have attachments. + * This project serves as basis to attach the artifacts to deploy to. + * + * @return The created Maven project, never null. + * @throws MojoFailureException When building the project failed. + */ + private MavenProject createMavenProject() + throws MojoFailureException + { + ModelSource modelSource = new StringModelSource( + "" + + "4.0.0" + + "" + groupId + "" + + "" + artifactId + "" + + "" + version + "" + + "" + ( classifier == null ? packaging : "pom" ) + "" + + "" ); + DefaultProjectBuildingRequest buildingRequest = + new DefaultProjectBuildingRequest( getSession().getProjectBuildingRequest() ); + buildingRequest.setProcessPlugins( false ); + try + { + return projectBuilder.build( modelSource, buildingRequest ).getProject(); + } + catch ( ProjectBuildingException e ) + { + throw new MojoFailureException( e.getMessage(), e ); + } + } + /** - * Gets the path of the specified artifact within the local repository. Note that the returned path need not exist - * (yet). + * Gets the path of the artifact constructed from the supplied groupId, artifactId, version, classifier + * and packaging within the local repository. Note that the returned path need not exist (yet). * - * @param artifact The artifact whose local repo path should be determined, must not be null. * @return The absolute path to the artifact when installed, never null. */ - private File getLocalRepoFile( Artifact artifact ) + private File getLocalRepoFile() { - String path = repoManager.getPathForLocalArtifact( getSession().getProjectBuildingRequest(), artifact ); + DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate(); + coordinate.setGroupId( groupId ); + coordinate.setArtifactId( artifactId ); + coordinate.setVersion( version ); + coordinate.setClassifier( classifier ); + coordinate.setExtension( packaging ); + String path = repoManager.getPathForLocalArtifact( getSession().getProjectBuildingRequest(), coordinate ); return new File( repoManager.getLocalRepositoryBasedir( getSession().getProjectBuildingRequest() ), path ); } 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 2564d77e..fff8676a 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -26,12 +26,10 @@ import java.util.ArrayList; import java.util.List; -import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.internal.MavenRepositorySystemSession; import org.mockito.InjectMocks; @@ -53,8 +51,6 @@ public class DeployFileMojoTest private File remoteRepo; - MavenProjectStub projectStub = new MavenProjectStub(); - @Mock private MavenSession session; @@ -72,8 +68,6 @@ public void setUp() { remoteRepo.mkdirs(); } - - projectStub.setAttachedArtifacts( new ArrayList() ); } public void testDeployTestEnvironment() @@ -103,8 +97,6 @@ public void testBasicDeployFile() repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - setVariableValueToObject( mojo, "project", projectStub ); - String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" ); @@ -206,8 +198,6 @@ public void testDeployIfClassifierIsSet() repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - setVariableValueToObject( mojo, "project", projectStub ); - String classifier = ( String ) getVariableValueFromObject( mojo, "classifier" ); String groupId = ( String ) getVariableValueFromObject( mojo, "groupId" ); @@ -256,8 +246,6 @@ public void testDeployIfArtifactIsNotJar() repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - setVariableValueToObject( mojo, "project", projectStub ); - String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" ); @@ -288,8 +276,6 @@ public void testDeployIfRepositoryLayoutIsLegacy() assertNotNull( mojo ); - setVariableValueToObject( mojo, "project", projectStub ); - String repositoryLayout = (String) getVariableValueFromObject( mojo, "repositoryLayout" ); assertEquals( "legacy", repositoryLayout ); From 01c8658e8e5792eb42f69e0b15d838fad1568953 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 18 Sep 2016 17:24:00 +0000 Subject: [PATCH 034/153] o DeployMojo Using ProjectDeployer instead of ArtifactDeployer which makes code much more simpler and using ProjectDeployerRequest instead of DeployRequest. o DeployFileMojo using ArtifactDeployer. o Added slf4j-api and slf4j-noop in test scope to get running the tests. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1761345 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 13 ++ .../plugins/deploy/AbstractDeployMojo.java | 69 ------- .../maven/plugins/deploy/DeployFileMojo.java | 53 +++--- .../maven/plugins/deploy/DeployMojo.java | 175 +++++++----------- .../maven/plugins/deploy/DeployRequest.java | 149 --------------- .../maven/plugins/deploy/DeployMojoTest.java | 23 ++- .../deploy/stubs/ArtifactDeployerStub.java | 2 +- 7 files changed, 128 insertions(+), 356 deletions(-) delete mode 100644 src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java diff --git a/pom.xml b/pom.xml index 7effe705..31a8e935 100644 --- a/pom.xml +++ b/pom.xml @@ -136,6 +136,19 @@ under the License. 1.7 test + + org.slf4j + slf4j-api + 1.7.5 + provided + + + org.slf4j + slf4j-nop + 1.7.5 + test + + 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 e54c7781..7a78e8bc 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -19,10 +19,8 @@ * under the License. */ -import java.util.Collection; import java.util.Map; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; @@ -34,8 +32,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; -import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; /** * @version $Id$ @@ -43,11 +39,6 @@ public abstract class AbstractDeployMojo extends AbstractMojo { - /** - */ - @Component - private ArtifactDeployer deployer; - /** * Component used to create an artifact. */ @@ -86,16 +77,6 @@ public abstract class AbstractDeployMojo /* Setters and Getters */ - public ArtifactDeployer getDeployer() - { - return deployer; - } - - public void setDeployer( ArtifactDeployer deployer ) - { - this.deployer = deployer; - } - void failIfOffline() throws MojoFailureException { @@ -128,56 +109,6 @@ int getRetryFailedDeploymentCount() return retryFailedDeploymentCount; } - /** - * Deploy an artifact from a particular file. - * @param artifacts the artifact definitions - * @param deploymentRepository the repository to deploy to - * @param localRepository the local repository to install into - * @param retryFailedDeploymentCount TODO - * - * @throws ArtifactDeployerException if an error occurred deploying the artifact - */ - protected void deploy( Collection artifacts, ArtifactRepository deploymentRepository, - int retryFailedDeploymentCount ) - throws ArtifactDeployerException - { - - // for now retry means redeploy the complete artifacts collection - int retryFailedDeploymentCounter = Math.max( 1, Math.min( 10, retryFailedDeploymentCount ) ); - ArtifactDeployerException exception = null; - for ( int count = 0; count < retryFailedDeploymentCounter; count++ ) - { - try - { - if ( count > 0 ) - { - getLog().info( "Retrying deployment attempt " + ( count + 1 ) + " of " - + retryFailedDeploymentCounter ); - } - - getDeployer().deploy( session.getProjectBuildingRequest(), deploymentRepository, artifacts ); - exception = null; - break; - } - catch ( ArtifactDeployerException e ) - { - if ( count + 1 < retryFailedDeploymentCounter ) - { - getLog().warn( "Encountered issue during deployment: " + e.getLocalizedMessage() ); - getLog().debug( e ); - } - if ( exception == null ) - { - exception = e; - } - } - } - if ( exception != null ) - { - throw exception; - } - } - protected ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion2 ) 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 5334c11a..9afe7ea5 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -61,6 +61,7 @@ import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.apache.maven.shared.artifact.DefaultArtifactCoordinate; +import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; import org.apache.maven.shared.repository.RepositoryManager; import org.codehaus.plexus.util.FileUtils; @@ -79,13 +80,15 @@ public class DeployFileMojo extends AbstractDeployMojo { + @Component + private ArtifactDeployer artifactDeployer; /** * Used for attaching the artifacts to deploy to the project. */ @Component private MavenProjectHelper projectHelper; - + /** * Used for creating the project to which the artifacts to deploy will be attached. */ @@ -218,10 +221,10 @@ public class DeployFileMojo */ @Parameter( property = "files" ) private String files; - + @Component private RepositoryManager repoManager; - + void initProperties() throws MojoExecutionException { @@ -258,16 +261,16 @@ void initProperties() try { pomInputStream = jarFile.getInputStream( entry ); - + String base = file.getName(); if ( base.indexOf( '.' ) > 0 ) { base = base.substring( 0, base.lastIndexOf( '.' ) ); } pomFile = new File( file.getParentFile(), base + ".pom" ); - + pomOutputStream = new FileOutputStream( pomFile ); - + IOUtil.copy( pomInputStream, pomOutputStream ); pomOutputStream.close(); @@ -494,18 +497,19 @@ public void execute() try { - deploy( deployableArtifacts, deploymentRepository, getRetryFailedDeploymentCount() ); + artifactDeployer.deploy( getSession().getProjectBuildingRequest(), deploymentRepository, + deployableArtifacts ); } catch ( ArtifactDeployerException e ) { throw new MojoExecutionException( e.getMessage(), e ); } } - + /** - * Creates a Maven project in-memory from the user-supplied groupId, artifactId and version. - * When a classifier is supplied, the packaging must be POM because the project with only have attachments. - * This project serves as basis to attach the artifacts to deploy to. + * Creates a Maven project in-memory from the user-supplied groupId, artifactId and version. When a classifier is + * supplied, the packaging must be POM because the project with only have attachments. This project serves as basis + * to attach the artifacts to deploy to. * * @return The created Maven project, never null. * @throws MojoFailureException When building the project failed. @@ -513,14 +517,10 @@ public void execute() private MavenProject createMavenProject() throws MojoFailureException { - ModelSource modelSource = new StringModelSource( - "" - + "4.0.0" - + "" + groupId + "" - + "" + artifactId + "" - + "" + version + "" - + "" + ( classifier == null ? packaging : "pom" ) + "" - + "" ); + ModelSource modelSource = + new StringModelSource( "" + "4.0.0" + "" + groupId + + "" + "" + artifactId + "" + "" + version + "" + + "" + ( classifier == null ? packaging : "pom" ) + "" + "" ); DefaultProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest( getSession().getProjectBuildingRequest() ); buildingRequest.setProcessPlugins( false ); @@ -533,10 +533,10 @@ private MavenProject createMavenProject() throw new MojoFailureException( e.getMessage(), e ); } } - + /** - * Gets the path of the artifact constructed from the supplied groupId, artifactId, version, classifier - * and packaging within the local repository. Note that the returned path need not exist (yet). + * Gets the path of the artifact constructed from the supplied groupId, artifactId, version, classifier and + * packaging within the local repository. Note that the returned path need not exist (yet). * * @return The absolute path to the artifact when installed, never null. */ @@ -673,7 +673,7 @@ private void validateArtifactInformation() ModelBuildingRequest buildingRequest = new DefaultModelBuildingRequest(); DeployModelProblemCollector problemCollector = new DeployModelProblemCollector(); - + modelValidator.validateEffectiveModel( model, buildingRequest, problemCollector ); if ( problemCollector.getMessageCount() > 0 ) @@ -763,15 +763,16 @@ void setClassifier( String classifier ) { this.classifier = classifier; } - - private static class DeployModelProblemCollector implements ModelProblemCollector + + private static class DeployModelProblemCollector + implements ModelProblemCollector { /** */ private static final String NEWLINE = System.getProperty( "line.separator" ); /** */ private List messages = new ArrayList(); - + @Override public void add( Severity severity, String message, InputLocation location, Exception cause ) { 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 3c8ee440..e1e61389 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -19,7 +19,27 @@ * under the License. */ -import java.io.File; +import java.io.IOException; + +/* + * 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.util.ArrayList; import java.util.Collections; import java.util.List; @@ -27,18 +47,20 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.project.NoFileAssignedException; +import org.apache.maven.shared.project.deploy.ProjectDeployer; +import org.apache.maven.shared.project.deploy.ProjectDeployerRequest; /** * Deploys an artifact to remote repository. @@ -60,8 +82,8 @@ public class DeployMojo */ private static final AtomicInteger READYPROJECTSCOUNTER = new AtomicInteger(); - private static final List DEPLOYREQUESTS = - Collections.synchronizedList( new ArrayList() ); + private static final List DEPLOYREQUESTS = + Collections.synchronizedList( new ArrayList() ); /** */ @@ -124,6 +146,12 @@ public class DeployMojo @Parameter( property = "maven.deploy.skip", defaultValue = "false" ) private boolean skip; + /** + * Component used to deploy project. + */ + @Component + private ProjectDeployer projectDeployer; + public void execute() throws MojoExecutionException, MojoFailureException { @@ -137,17 +165,26 @@ public void execute() failIfOffline(); // CHECKSTYLE_OFF: LineLength - DeployRequest currentExecutionDeployRequest = - new DeployRequest().setProject( project ).setUpdateReleaseInfo( isUpdateReleaseInfo() ).setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ).setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ).setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ).setAltDeploymentRepository( altDeploymentRepository ); + // @formatter:off + ProjectDeployerRequest pdr = new ProjectDeployerRequest() + .setProject( project ) + .setUpdateReleaseInfo( isUpdateReleaseInfo() ) + .setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ) + .setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ) + .setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ) + .setAltDeploymentRepository( altDeploymentRepository ); + // @formatter:on // CHECKSTYLE_ON: LineLength + ArtifactRepository repo = getDeploymentRepository( pdr ); + if ( !deployAtEnd ) { - deployProject( currentExecutionDeployRequest ); + deployProject( getSession().getProjectBuildingRequest(), pdr, repo ); } else { - DEPLOYREQUESTS.add( currentExecutionDeployRequest ); + DEPLOYREQUESTS.add( pdr ); addedDeployRequest = true; } } @@ -159,121 +196,46 @@ public void execute() { while ( !DEPLOYREQUESTS.isEmpty() ) { - deployProject( DEPLOYREQUESTS.remove( 0 ) ); + ArtifactRepository repo = getDeploymentRepository( DEPLOYREQUESTS.get( 0 ) ); + + deployProject( getSession().getProjectBuildingRequest(), DEPLOYREQUESTS.remove( 0 ), repo ); } } } else if ( addedDeployRequest ) { getLog().info( "Deploying " + project.getGroupId() + ":" + project.getArtifactId() + ":" - + project.getVersion() + " at end" ); + + project.getVersion() + " at end" ); } } - private void deployProject( DeployRequest request ) - throws MojoExecutionException, MojoFailureException + private void deployProject( ProjectBuildingRequest pbr, ProjectDeployerRequest pir, ArtifactRepository repo ) + throws MojoFailureException, MojoExecutionException { - List deployableArtifacts = new ArrayList(); - - Artifact artifact = request.getProject().getArtifact(); - String packaging = request.getProject().getPackaging(); - File pomFile = request.getProject().getFile(); - - List attachedArtifacts = request.getProject().getAttachedArtifacts(); - - ArtifactRepository repo = - getDeploymentRepository( request.getProject(), request.getAltDeploymentRepository(), - request.getAltReleaseDeploymentRepository(), - request.getAltSnapshotDeploymentRepository() ); - - String protocol = repo.getProtocol(); - - if ( protocol.equalsIgnoreCase( "scp" ) ) - { - File sshFile = new File( System.getProperty( "user.home" ), ".ssh" ); - - if ( !sshFile.exists() ) - { - sshFile.mkdirs(); - } - } - - // Deploy the POM - boolean isPomArtifact = "pom".equals( packaging ); - if ( !isPomArtifact ) + try { - ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); - artifact.addMetadata( metadata ); + projectDeployer.deployProject( pbr, pir, repo ); } - else + catch ( IOException e ) { - artifact.setFile( pomFile ); + throw new MojoFailureException( "IOException", e ); } - - if ( request.isUpdateReleaseInfo() ) + catch ( NoFileAssignedException e ) { - artifact.setRelease( true ); + throw new MojoExecutionException( "NoFileAssignedException", e ); } - artifact.setRepository( repo ); - - int retryFailedDeploymentCount = request.getRetryFailedDeploymentCount(); - - try - { - if ( isPomArtifact ) - { - deployableArtifacts.add( artifact ); - } - else - { - File file = artifact.getFile(); - - if ( file != null && file.isFile() ) - { - deployableArtifacts.add( artifact ); - } - else if ( !attachedArtifacts.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" ); - } - } - - for ( Artifact attached : attachedArtifacts ) - { - // This is here when AttachedArtifact is used, like m-sources-plugin:2.0.4 - try - { - attached.setRepository( repo ); - } - catch ( UnsupportedOperationException e ) - { - getLog().warn( attached.getId() + " has been attached with deprecated code, " - + "try to upgrade the responsible plugin" ); - } - - deployableArtifacts.add( attached ); - } - - deploy( deployableArtifacts, repo, retryFailedDeploymentCount ); - } - catch ( ArtifactDeployerException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } } - ArtifactRepository getDeploymentRepository( MavenProject project, String altDeploymentRepository, - String altReleaseDeploymentRepository, - String altSnapshotDeploymentRepository ) + ArtifactRepository getDeploymentRepository( ProjectDeployerRequest pdr ) + throws MojoExecutionException, MojoFailureException { + MavenProject project = pdr.getProject(); + String altDeploymentRepository = pdr.getAltDeploymentRepository(); + String altReleaseDeploymentRepository = pdr.getAltReleaseDeploymentRepository(); + String altSnapshotDeploymentRepository = pdr.getAltSnapshotDeploymentRepository(); + ArtifactRepository repo = null; String altDeploymentRepo; @@ -320,9 +282,8 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym if ( repo == null ) { - String msg = - "Deployment failed: repository element was not specified in the POM inside" - + " distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter"; + String msg = "Deployment failed: repository element was not specified in the POM inside" + + " distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter"; throw new MojoExecutionException( msg ); } diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java b/src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java deleted file mode 100644 index cdb99f7e..00000000 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployRequest.java +++ /dev/null @@ -1,149 +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 org.apache.maven.project.MavenProject; - -/** - * - * @author Robert Scholte - * @since 2.8.1 - */ -class DeployRequest -{ - - // From AbstractDeployMojo - - private boolean updateReleaseInfo; - - private int retryFailedDeploymentCount; - - // From DeployMojo - - private MavenProject project; - - private String altDeploymentRepository; - - private String altSnapshotDeploymentRepository; - - private String altReleaseDeploymentRepository; - - /** - * @return the updateReleaseInfo - */ - public boolean isUpdateReleaseInfo() - { - return updateReleaseInfo; - } - - /** - * @param updateReleaseInfo the updateReleaseInfo to set - */ - public DeployRequest setUpdateReleaseInfo( boolean updateReleaseInfo ) - { - this.updateReleaseInfo = updateReleaseInfo; - return this; - } - - /** - * @return the retryFailedDeploymentCount - */ - public int getRetryFailedDeploymentCount() - { - return retryFailedDeploymentCount; - } - - /** - * @param retryFailedDeploymentCount the retryFailedDeploymentCount to set - */ - public DeployRequest setRetryFailedDeploymentCount( int retryFailedDeploymentCount ) - { - this.retryFailedDeploymentCount = retryFailedDeploymentCount; - return this; - } - - /** - * @return the project - */ - public MavenProject getProject() - { - return project; - } - - /** - * @param project the project to set - */ - public DeployRequest setProject( MavenProject project ) - { - this.project = project; - return this; - } - - /** - * @return the altDeploymentRepository - */ - public String getAltDeploymentRepository() - { - return altDeploymentRepository; - } - - /** - * @param altDeploymentRepository the altDeploymentRepository to set - */ - public DeployRequest setAltDeploymentRepository( String altDeploymentRepository ) - { - this.altDeploymentRepository = altDeploymentRepository; - return this; - } - - /** - * @return the altSnapshotDeploymentRepository - */ - public String getAltSnapshotDeploymentRepository() - { - return altSnapshotDeploymentRepository; - } - - /** - * @param altSnapshotDeploymentRepository the altSnapshotDeploymentRepository to set - */ - public DeployRequest setAltSnapshotDeploymentRepository( String altSnapshotDeploymentRepository ) - { - this.altSnapshotDeploymentRepository = altSnapshotDeploymentRepository; - return this; - } - - /** - * @return the altReleaseDeploymentRepository - */ - public String getAltReleaseDeploymentRepository() - { - return altReleaseDeploymentRepository; - } - - /** - * @param altReleaseDeploymentRepository the altReleaseDeploymentRepository to set - */ - public DeployRequest setAltReleaseDeploymentRepository( String altReleaseDeploymentRepository ) - { - this.altReleaseDeploymentRepository = altReleaseDeploymentRepository; - return this; - } -} 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 97f2d3f5..17e63c10 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -41,6 +41,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.apache.maven.shared.project.deploy.ProjectDeployerRequest; import org.codehaus.plexus.util.FileUtils; import org.junit.Ignore; import org.mockito.InjectMocks; @@ -405,6 +406,13 @@ public void testDeployIfArtifactFileIsNull() "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 ); @@ -598,9 +606,12 @@ public void testAltSnapshotDeploymentRepository() project.setVersion( "1.0-SNAPSHOT" ); + ProjectDeployerRequest pdr = + new ProjectDeployerRequest() + .setProject( project ) + .setAltDeploymentRepository( "altSnapshotDeploymentRepository::default::http://localhost" ); assertEquals( repository, - mojo.getDeploymentRepository( project, null, null, - "altSnapshotDeploymentRepository::default::http://localhost" ) ); + mojo.getDeploymentRepository( pdr )); } public void testAltReleaseDeploymentRepository() @@ -618,9 +629,13 @@ public void testAltReleaseDeploymentRepository() project.setVersion( "1.0" ); + ProjectDeployerRequest pdr = + new ProjectDeployerRequest() + .setProject( project ) + .setAltReleaseDeploymentRepository( "altReleaseDeploymentRepository::default::http://localhost" ); + assertEquals( repository, - mojo.getDeploymentRepository( project, null, - "altReleaseDeploymentRepository::default::http://localhost", null ) ); + mojo.getDeploymentRepository( pdr )); } private void addFileToList( File file, List fileList ) diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java index 518e36be..9bdf48ae 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java @@ -39,7 +39,7 @@ public void deploy( ProjectBuildingRequest request, Collection mavenAr } @Override - public void deploy( ProjectBuildingRequest arg0, ArtifactRepository arg1, Collection arg2 ) + public void deploy( ProjectBuildingRequest arg0, ArtifactRepository arg1, Collection arg2) throws ArtifactDeployerException { // does nothing From cb1a5a39b75db2d4f64db03179a9a81a720c4924 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 18 Sep 2016 17:53:04 +0000 Subject: [PATCH 035/153] Fixed duplicated license header. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1761349 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugins/deploy/DeployMojo.java | 19 ------------------- 1 file changed, 19 deletions(-) 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 e1e61389..2680cb31 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -21,25 +21,6 @@ import java.io.IOException; -/* - * 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.util.ArrayList; import java.util.Collections; import java.util.List; From ed6d6ecaed80a863fb97381b5ed62252189eb77e Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 21 Sep 2016 19:37:25 +0000 Subject: [PATCH 036/153] Followed renaming methods in DeployProject interface. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1761801 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2680cb31..02c08806 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -195,7 +195,7 @@ private void deployProject( ProjectBuildingRequest pbr, ProjectDeployerRequest p { try { - projectDeployer.deployProject( pbr, pir, repo ); + projectDeployer.deploy( pbr, pir, repo ); } catch ( IOException e ) { From 5a5598836664ac3b6e5428923a9705a94cd31ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Bou=C3=A9?= Date: Sun, 25 Sep 2016 15:26:55 +0000 Subject: [PATCH 037/153] Removed unused artifactFactory git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1762216 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/plugins/deploy/AbstractDeployMojo.java | 6 ------ 1 file changed, 6 deletions(-) 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 7a78e8bc..bc9c4c07 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -21,7 +21,6 @@ import java.util.Map; -import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; @@ -39,11 +38,6 @@ public abstract class AbstractDeployMojo extends AbstractMojo { - /** - * Component used to create an artifact. - */ - @Component - protected ArtifactFactory artifactFactory; /** * Map that contains the layouts. From 9c7f253423ce3c81bb0e504d269d8ba5443b53e5 Mon Sep 17 00:00:00 2001 From: Anders Hammar Date: Fri, 4 Nov 2016 22:04:13 +0000 Subject: [PATCH 038/153] [MDEPLOY-215] Remove link to non-existing Codehaus wiki git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1768110 13f79535-47bb-0310-9956-ffa450edef68 --- src/site/apt/index.apt.vm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index c053e1a7..fedbe54a 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -78,9 +78,7 @@ ${project.name} * Usage General instructions on how to use the Deploy Plugin can be found on the {{{./usage.html}usage page}}. Some more - specific use cases are described in the examples given below. Last but not least, users occasionally contribute - additional examples, tips or errata to the - {{{http://docs.codehaus.org/display/MAVENUSER/Deploy+Plugin}plugin's wiki page}}. + specific use cases are described in the examples given below. In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel free to contact the {{{./mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could From c47aeea877cc2804469db8c265c39040b79b753a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Bou=C3=A9?= Date: Fri, 11 Nov 2016 20:36:18 +0000 Subject: [PATCH 039/153] [MDEPLOY-211] uniqueVersion broken (if not supported, should be removed from doc, and warning printed) The parameter uniqueVersion in the deploy-file goal isn't supported since Maven 3, so it is removed from the code base and from the documentation of the plugin. A check is made to fail the build if it is still used, and the index page mentions the removal. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1769339 13f79535-47bb-0310-9956-ffa450edef68 --- .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - src/it/MDEPLOY-213/pom.xml | 1 - src/it/attach-release-jar/pom.xml | 1 - src/it/deploy-at-end-fail/pom.xml | 1 - src/it/deploy-at-end-pass/pom.xml | 1 - src/it/offline/pom.xml | 1 - src/it/release-jar/pom.xml | 1 - src/it/release-pom/pom.xml | 1 - .../plugins/deploy/AbstractDeployMojo.java | 3 +-- .../maven/plugins/deploy/DeployFileMojo.java | 17 ++++++++++++++--- .../maven/plugins/deploy/DeployMojo.java | 2 +- src/site/apt/file-deployment.apt | 2 -- src/site/apt/index.apt.vm | 10 ++++++++++ src/site/apt/usage.apt | 3 +-- .../maven/plugins/deploy/DeployMojoTest.java | 10 ++++------ .../plugin-config.xml | 1 - .../deploy-file-classifier/plugin-config.xml | 1 - .../plugin-config.xml | 1 - .../deploy-file-pom-file/plugin-config.xml | Bin 3372 -> 3278 bytes .../unit/deploy-file-test/plugin-config.xml | 1 - 22 files changed, 31 insertions(+), 30 deletions(-) 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 b1913bd2..576847dd 100644 --- a/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml +++ b/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml @@ -39,7 +39,6 @@ under the License. it file:///${basedir}/target/repo - false 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 3e7d3cc7..42f53daf 100644 --- a/src/it/MDEPLOY-170_deploy-at-end-configperproject/pom.xml +++ b/src/it/MDEPLOY-170_deploy-at-end-configperproject/pom.xml @@ -39,7 +39,6 @@ under the License. it file:///${basedir}/target/repo - false diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml index d52e4485..a9a99927 100644 --- a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml +++ b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml @@ -38,7 +38,6 @@ it file:///${basedir}/target/repo - false diff --git a/src/it/MDEPLOY-213/pom.xml b/src/it/MDEPLOY-213/pom.xml index 23a18488..7688d377 100644 --- a/src/it/MDEPLOY-213/pom.xml +++ b/src/it/MDEPLOY-213/pom.xml @@ -37,7 +37,6 @@ under the License. it file://${basedir}/target/repo - false diff --git a/src/it/attach-release-jar/pom.xml b/src/it/attach-release-jar/pom.xml index 035707c5..3d2039eb 100644 --- a/src/it/attach-release-jar/pom.xml +++ b/src/it/attach-release-jar/pom.xml @@ -40,7 +40,6 @@ under the License. it file:///${basedir}/target/repo - false diff --git a/src/it/deploy-at-end-fail/pom.xml b/src/it/deploy-at-end-fail/pom.xml index 92e45b05..be9ef50c 100644 --- a/src/it/deploy-at-end-fail/pom.xml +++ b/src/it/deploy-at-end-fail/pom.xml @@ -39,7 +39,6 @@ under the License. it file:///${basedir}/target/repo - false diff --git a/src/it/deploy-at-end-pass/pom.xml b/src/it/deploy-at-end-pass/pom.xml index 8021f6a1..ecf739a8 100644 --- a/src/it/deploy-at-end-pass/pom.xml +++ b/src/it/deploy-at-end-pass/pom.xml @@ -39,7 +39,6 @@ under the License. it file:///${basedir}/target/repo - false diff --git a/src/it/offline/pom.xml b/src/it/offline/pom.xml index c6043142..32e53ec2 100644 --- a/src/it/offline/pom.xml +++ b/src/it/offline/pom.xml @@ -39,7 +39,6 @@ under the License. it file:///${basedir}/target/repo - false diff --git a/src/it/release-jar/pom.xml b/src/it/release-jar/pom.xml index a4e0eadc..51fe2487 100644 --- a/src/it/release-jar/pom.xml +++ b/src/it/release-jar/pom.xml @@ -40,7 +40,6 @@ under the License. it file:///${basedir}/target/repo - false diff --git a/src/it/release-pom/pom.xml b/src/it/release-pom/pom.xml index ec19a46f..526fb37c 100644 --- a/src/it/release-pom/pom.xml +++ b/src/it/release-pom/pom.xml @@ -40,7 +40,6 @@ under the License. it file:///${basedir}/target/repo - false 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 bc9c4c07..504806e7 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -104,8 +104,7 @@ int getRetryFailedDeploymentCount() } protected ArtifactRepository createDeploymentArtifactRepository( String id, String url, - ArtifactRepositoryLayout layout, - boolean uniqueVersion2 ) + ArtifactRepositoryLayout layout ) { return new MavenArtifactRepository( id, url, layout, new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); 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 9afe7ea5..73b44255 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -191,9 +191,13 @@ public class DeployFileMojo /** * Whether to deploy snapshots with a unique version or not. + * + * @deprecated As of Maven 3, this isn't supported anymore and this parameter is only present to break the build + * if you use it! */ - @Parameter( property = "uniqueVersion", defaultValue = "true" ) - private boolean uniqueVersion; + @Parameter( property = "uniqueVersion" ) + @Deprecated + private Boolean uniqueVersion; /** * The component used to validate the user-supplied artifact coordinates. @@ -324,6 +328,13 @@ void initProperties() public void execute() throws MojoExecutionException, MojoFailureException { + if ( uniqueVersion != null ) + { + throw new MojoExecutionException( "You are using 'uniqueVersion' which has been removed" + + " from the maven-deploy-plugin. " + + "Please see the >>Major Version Upgrade to version 3.0.0<< on the plugin site." ); + } + failIfOffline(); if ( !file.exists() ) @@ -338,7 +349,7 @@ public void execute() ArtifactRepositoryLayout layout = getLayout( repositoryLayout ); ArtifactRepository deploymentRepository = - createDeploymentArtifactRepository( repositoryId, url, layout, uniqueVersion ); + createDeploymentArtifactRepository( repositoryId, url, layout ); String protocol = deploymentRepository.getProtocol(); 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 02c08806..b626d319 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -252,7 +252,7 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym ArtifactRepositoryLayout repoLayout = getLayout( layout ); - repo = createDeploymentArtifactRepository( id, url, repoLayout, true ); + repo = createDeploymentArtifactRepository( id, url, repoLayout ); } } diff --git a/src/site/apt/file-deployment.apt b/src/site/apt/file-deployment.apt index ee121408..a886cbf0 100644 --- a/src/site/apt/file-deployment.apt +++ b/src/site/apt/file-deployment.apt @@ -38,8 +38,6 @@ File Deployment * {{{./examples/deploying-sources-javadoc.html}Deploy an artifact with sources and javadoc jars}} - * {{{./examples/disabling-timestamps-suffix.html}Disable timestamps suffix in an artifact}} - * {{{./examples/deploying-in-legacy-layout.html}Deploy an artifact in legacy layout}} [] \ No newline at end of file diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index fedbe54a..c5e814e3 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -75,6 +75,16 @@ ${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 + + [] + + 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/apt/usage.apt b/src/site/apt/usage.apt index 156e027a..8eafe93d 100644 --- a/src/site/apt/usage.apt +++ b/src/site/apt/usage.apt @@ -119,8 +119,7 @@ mvn deploy:deploy-file -Durl=file://C:\m2-repo \ [-Dclassifier=test] \ [-DgeneratePom=true] \ [-DgeneratePom.description="My Project Description"] \ - [-DrepositoryLayout=legacy] \ - [-DuniqueVersion=false] + [-DrepositoryLayout=legacy] +---+ If the following required information is not specified in some way, the goal 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 17e63c10..e88bfb59 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -600,9 +600,8 @@ public void testAltSnapshotDeploymentRepository() setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) ); ArtifactRepository repository = mock( ArtifactRepository.class ); - when( - mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost", - repositoryLayout, true ) ).thenReturn( repository ); + when( mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost", + repositoryLayout ) ).thenReturn( repository ); project.setVersion( "1.0-SNAPSHOT" ); @@ -623,9 +622,8 @@ public void testAltReleaseDeploymentRepository() setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) ); ArtifactRepository repository = mock( ArtifactRepository.class ); - when( - mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost", - repositoryLayout, true ) ).thenReturn( repository ); + when( mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost", + repositoryLayout ) ).thenReturn( repository ); project.setVersion( "1.0" ); diff --git a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml b/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml index f9b092e2..4c7fc951 100644 --- a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml @@ -29,7 +29,6 @@ under the License. ${basedir}/src/test/resources/unit/deploy-file-artifact-not-jar/target/deploy-test-file.zip deploy-test file://${basedir}/target/remote-repo/deploy-file-artifact-not-jar - true default true
diff --git a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml b/src/test/resources/unit/deploy-file-classifier/plugin-config.xml index 7929357d..59e09452 100644 --- a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-classifier/plugin-config.xml @@ -30,7 +30,6 @@ under the License. ${basedir}/src/test/resources/unit/deploy-file-classifier/target/deploy-test-file-1.0-SNAPSHOT.jar deploy-test file://${basedir}/target/remote-repo/deploy-file-classifier - true bin default true diff --git a/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml b/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml index d59b015e..97531f1b 100644 --- a/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml @@ -30,7 +30,6 @@ under the License. ${basedir}/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar deploy-test file://${basedir}/target/remote-repo/deploy-file-legacy-repository-layout - true legacy true
diff --git a/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml b/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml index d1e9b0e52c7c848338b8223e2546c22064199a15..97f60b0a64958e1e0b07850c1b94e8f4924bc773 100644 GIT binary patch delta 12 TcmZ1@bxv}_Kd#L&+!q)DC58o2 delta 69 zcmX>nxkhTkKQ7Z!hCGH$hC+r?hE#?yATDAk2J-WPqIL`=KpsfkhCv@lBdMF*&!N4E H`y3+xeCQER 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 8dd3915d..78c4c1ed 100644 --- a/src/test/resources/unit/deploy-file-test/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-test/plugin-config.xml @@ -31,7 +31,6 @@ under the License. deploy-test file://${basedir}/target/remote-repo/deploy-file-test POM was created from deploy:deploy-file - true default true
From 1170494f0d3247b6c4a1bc602a0d2d6359cf6ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Bou=C3=A9?= Date: Sat, 19 Nov 2016 15:21:30 +0000 Subject: [PATCH 040/153] Migration to Maven 3: because of an API change in ModelProblemCollector between 3.0.x and 3.1.x, that interface cannot be used as-is for compatibility for both in order to determine if the coordinate information passed by the user is valid. The plugins are compiled with 3.0 core and are currently linked to a specific ModelProblemCollector, but starting with 3.1.0-alpha-1, Maven core calls a different method than the one the plugins were compiled with. This results in AbstractMethodError at run-time. (this was not detected by the ITs because, although they tested that the build failed with missing parameters, it didn't test the cause of the failure.) Since the plugins are now using a new MavenProject instance, and attaching things to it in order to deploy or install them, it is possible to rely on the validation performed during the building of that project to catch model errors. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1770497 13f79535-47bb-0310-9956-ffa450edef68 --- src/it/gav-validation/invoker.properties | 3 + ...est.properties => test-invalid.properties} | 0 src/it/gav-validation/test-missing.properties | 23 +++++ .../{verify.bsh => verify.groovy} | 19 ++-- .../maven/plugins/deploy/DeployFileMojo.java | 98 ++++--------------- 5 files changed, 55 insertions(+), 88 deletions(-) rename src/it/gav-validation/{test.properties => test-invalid.properties} (100%) create mode 100644 src/it/gav-validation/test-missing.properties rename src/it/gav-validation/{verify.bsh => verify.groovy} (75%) diff --git a/src/it/gav-validation/invoker.properties b/src/it/gav-validation/invoker.properties index af74ba28..6635374e 100644 --- a/src/it/gav-validation/invoker.properties +++ b/src/it/gav-validation/invoker.properties @@ -17,3 +17,6 @@ invoker.goals = org.apache.maven.plugins:maven-deploy-plugin:${project.version}:deploy-file invoker.buildResult = failure + +invoker.systemPropertiesFile.1 = test-invalid.properties +invoker.systemPropertiesFile.2 = test-missing.properties diff --git a/src/it/gav-validation/test.properties b/src/it/gav-validation/test-invalid.properties similarity index 100% rename from src/it/gav-validation/test.properties rename to src/it/gav-validation/test-invalid.properties diff --git a/src/it/gav-validation/test-missing.properties b/src/it/gav-validation/test-missing.properties new file mode 100644 index 00000000..f43471ec --- /dev/null +++ b/src/it/gav-validation/test-missing.properties @@ -0,0 +1,23 @@ +# 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 = test.jar +url = file:///${basedir}/target/repo +packaging = jar + +# missing coordinates should have deploy-file bail out +groupId = groupId diff --git a/src/it/gav-validation/verify.bsh b/src/it/gav-validation/verify.groovy similarity index 75% rename from src/it/gav-validation/verify.bsh rename to src/it/gav-validation/verify.groovy index d1c2f46c..64caa903 100644 --- a/src/it/gav-validation/verify.bsh +++ b/src/it/gav-validation/verify.groovy @@ -17,22 +17,19 @@ * under the License. */ -import java.io.*; -import java.util.*; - String[] paths = -{ +[ "org/apache/maven/its/deploy/gv", -}; +]; for ( String path : paths ) { - File file = new File( new File( basedir, "target/repo" ), path ); - System.out.println( "Checking for absence of " + file ); - if ( file.exists() ) - { - throw new Exception( "Existing: " + file.getAbsolutePath() ); - } + assert !new File( new File( basedir, "target/repo" ), path ).exists() } +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.exists() +assert buildLog.text.contains( "The artifact information is incomplete" ) +assert buildLog.text.contains( "The artifact information is not valid" ) + return true; 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 73b44255..1c493d35 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -37,13 +37,9 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.model.InputLocation; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; -import org.apache.maven.model.building.DefaultModelBuildingRequest; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelProblem.Severity; -import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelSource; import org.apache.maven.model.building.StringModelSource; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; @@ -64,6 +60,7 @@ import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; import org.apache.maven.shared.repository.RepositoryManager; +import org.apache.maven.shared.utils.Os; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; @@ -192,8 +189,8 @@ public class DeployFileMojo /** * Whether to deploy snapshots with a unique version or not. * - * @deprecated As of Maven 3, this isn't supported anymore and this parameter is only present to break the build - * if you use it! + * @deprecated As of Maven 3, this isn't supported anymore and this parameter is only present to break the build if + * you use it! */ @Parameter( property = "uniqueVersion" ) @Deprecated @@ -344,12 +341,9 @@ public void execute() initProperties(); - validateArtifactInformation(); - ArtifactRepositoryLayout layout = getLayout( repositoryLayout ); - ArtifactRepository deploymentRepository = - createDeploymentArtifactRepository( repositoryId, url, layout ); + ArtifactRepository deploymentRepository = createDeploymentArtifactRepository( repositoryId, url, layout ); String protocol = deploymentRepository.getProtocol(); @@ -358,14 +352,14 @@ public void execute() throw new MojoExecutionException( "No transfer protocol found." ); } + MavenProject project = createMavenProject(); + Artifact artifact = project.getArtifact(); + if ( file.equals( getLocalRepoFile() ) ) { throw new MojoFailureException( "Cannot deploy artifact from the local repository: " + file ); } - MavenProject project = createMavenProject(); - Artifact artifact = project.getArtifact(); - List deployableArtifacts = new ArrayList(); if ( classifier == null ) @@ -523,11 +517,17 @@ public void execute() * to attach the artifacts to deploy to. * * @return The created Maven project, never null. + * @throws MojoExecutionException When the model of the project could not be built. * @throws MojoFailureException When building the project failed. */ private MavenProject createMavenProject() - throws MojoFailureException + throws MojoExecutionException, MojoFailureException { + if ( groupId == null || artifactId == null || version == null || packaging == null ) + { + throw new MojoExecutionException( "The artifact information is incomplete: 'groupId', 'artifactId', " + + "'version' and 'packaging' are required." ); + } ModelSource modelSource = new StringModelSource( "" + "4.0.0" + "" + groupId + "" + "" + artifactId + "" + "" + version + "" @@ -541,7 +541,12 @@ private MavenProject createMavenProject() } catch ( ProjectBuildingException e ) { - throw new MojoFailureException( e.getMessage(), e ); + if ( e.getCause() instanceof ModelBuildingException ) + { + throw new MojoExecutionException( "The artifact information is not valid:" + Os.LINE_SEP + + e.getCause().getMessage() ); + } + throw new MojoFailureException( "Unable to create the project.", e ); } } @@ -671,29 +676,6 @@ private File generatePomFile() } } - /** - * Validates the user-supplied artifact information. - * - * @throws MojoExecutionException If any artifact coordinate is invalid. - */ - private void validateArtifactInformation() - throws MojoExecutionException - { - Model model = generateModel(); - - ModelBuildingRequest buildingRequest = new DefaultModelBuildingRequest(); - - DeployModelProblemCollector problemCollector = new DeployModelProblemCollector(); - - modelValidator.validateEffectiveModel( model, buildingRequest, problemCollector ); - - if ( problemCollector.getMessageCount() > 0 ) - { - throw new MojoExecutionException( "The artifact information is incomplete or not valid:\n" - + problemCollector.render( " " ) ); - } - } - /** * Generates a minimal model from the user-supplied artifact information. * @@ -775,42 +757,4 @@ void setClassifier( String classifier ) this.classifier = classifier; } - private static class DeployModelProblemCollector - implements ModelProblemCollector - { - /** */ - private static final String NEWLINE = System.getProperty( "line.separator" ); - - /** */ - private List messages = new ArrayList(); - - @Override - public void add( Severity severity, String message, InputLocation location, Exception cause ) - { - messages.add( message ); - } - - public int getMessageCount() - { - return messages.size(); - } - - public String render( String indentation ) - { - if ( messages.size() == 0 ) - { - return indentation + "There were no validation errors."; - } - - StringBuilder message = new StringBuilder(); - - for ( int i = 0; i < messages.size(); i++ ) - { - message.append( indentation + "[" + i + "] " + messages.get( i ).toString() + NEWLINE ); - } - - return message.toString(); - } - }; - } From 2be1537350c1a4978ed45e1bb9505a4d39da8677 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Sat, 10 Dec 2016 23:24:24 +0000 Subject: [PATCH 041/153] Correct jira.codehaus.org to issues.apache.org/jira Submitted-by: John Patrick This closes #98 git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1773543 13f79535-47bb-0310-9956-ffa450edef68 --- src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml | 2 +- src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy | 2 +- .../path/to/pom.xml | 2 +- src/it/deploy-attached-sources/pom.xml | 2 +- src/it/deploy-default-packaging/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml index aa089934..8ff44f4d 100644 --- a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml +++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/pom.xml @@ -31,7 +31,7 @@ under the License. Test to verify that the pom inside the jar in used when deploying the file - https://jira.codehaus.org/browse/MDEPLOY-178 + https://issues.apache.org/jira/browse/MDEPLOY-178 diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy index 2c6701ad..2b197b2d 100644 --- a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy +++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy @@ -26,4 +26,4 @@ assert buildLog.exists() assert buildLog.text.contains( "[DEBUG] Using META-INF/maven/org.apache.maven.plugins.deploy.its/mdeploy178/pom.xml as pomFile" ) def pomProject = new XmlSlurper().parse( deployedPom ) -assert "https://jira.codehaus.org/browse/MDEPLOY-178".equals( pomProject.url.text() ) \ No newline at end of file +assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( pomProject.url.text() ) \ No newline at end of file diff --git a/src/it/MDEPLOY-184_deployfile-with-javadoc-and-sources/path/to/pom.xml b/src/it/MDEPLOY-184_deployfile-with-javadoc-and-sources/path/to/pom.xml index 0f56b2d4..3b0f7d9f 100644 --- a/src/it/MDEPLOY-184_deployfile-with-javadoc-and-sources/path/to/pom.xml +++ b/src/it/MDEPLOY-184_deployfile-with-javadoc-and-sources/path/to/pom.xml @@ -26,6 +26,6 @@ under the License. artifact-name 1.0 - http://jira.codehaus.org/browse/MDEPLOY-184 + https://issues.apache.org/jira/browse/MDEPLOY-184 diff --git a/src/it/deploy-attached-sources/pom.xml b/src/it/deploy-attached-sources/pom.xml index d0aac263..8dbaec1b 100644 --- a/src/it/deploy-attached-sources/pom.xml +++ b/src/it/deploy-attached-sources/pom.xml @@ -29,7 +29,7 @@ under the License. deploy-attached-sources sample jar project with attached sources - http://jira.codehaus.org/browse/MDEPLOY-48 + https://issues.apache.org/jira/browse/MDEPLOY-48 diff --git a/src/it/deploy-default-packaging/pom.xml b/src/it/deploy-default-packaging/pom.xml index 6394e352..9764c8b8 100644 --- a/src/it/deploy-default-packaging/pom.xml +++ b/src/it/deploy-default-packaging/pom.xml @@ -29,7 +29,7 @@ under the License. deploy-attached-sources sample jar project with attached sources - http://jira.codehaus.org/browse/MDEPLOY-106 + https://issues.apache.org/jira/browse/MDEPLOY-106 From e619ea32fc26b4650a55ececec567221f855e63d Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Sun, 18 Dec 2016 00:49:25 +0000 Subject: [PATCH 042/153] o Updated to latest parent SNAPSHOT. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1774838 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 31a8e935..3ce74f6e 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 30 + 31-SNAPSHOT ../../pom/maven/maven-plugins/pom.xml From 05614775669a78e8d8d7e0455a871c57b237654d Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Sun, 18 Dec 2016 03:37:05 +0000 Subject: [PATCH 043/153] o Reverted last commit to reset to release version parent's. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1774844 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3ce74f6e..31a8e935 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 31-SNAPSHOT + 30 ../../pom/maven/maven-plugins/pom.xml From cdf7d0afaa038323d33fa2a029d06de72cf51320 Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Sat, 24 Dec 2016 13:58:28 +0000 Subject: [PATCH 044/153] [MNG-5457] Show repository id when downloading or uploading from/to a remote repository o Updated to account for recent log messages in 3.4+. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1775953 13f79535-47bb-0310-9956-ffa450edef68 --- .../verify.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy index 119b9387..a01675be 100644 --- a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy +++ b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy @@ -19,4 +19,4 @@ def buildLog = new File ( basedir, "build.log") -assert 1 == buildLog.text.count( 'Uploading: file:target/repo/org/apache/maven/plugins/deploy/it/org.eclipse.osgi/1.0/org.eclipse.osgi-1.0-sources.jar') \ No newline at end of file +assert buildLog.text.matches( /Uploading .* file:target\/repo\/org\/apache\/maven\/plugins\/deploy\/it\/org\.eclipse\.osgi\/1\.0\/org\.eclipse\.osgi-1\.0-sources\.jar/) \ No newline at end of file From c820df8434b341a432757dddcc768199375482d3 Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Sat, 24 Dec 2016 15:28:58 +0000 Subject: [PATCH 045/153] [MNG-5457] Show repository id when downloading or uploading from/to a remote repository o Updated to account for recent log messages in 3.4+. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1775976 13f79535-47bb-0310-9956-ffa450edef68 --- .../verify.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy index a01675be..4232c455 100644 --- a/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy +++ b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/verify.groovy @@ -19,4 +19,4 @@ def buildLog = new File ( basedir, "build.log") -assert buildLog.text.matches( /Uploading .* file:target\/repo\/org\/apache\/maven\/plugins\/deploy\/it\/org\.eclipse\.osgi\/1\.0\/org\.eclipse\.osgi-1\.0-sources\.jar/) \ No newline at end of file +assert buildLog.text =~ /Uploading.*file:target\/repo\/org\/apache\/maven\/plugins\/deploy\/it\/org\.eclipse\.osgi\/1\.0\/org\.eclipse\.osgi-1\.0-sources\.jar/ From b0286fefaf5da3b8e449a19113e5f67de80bbbf8 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 16 Apr 2017 11:20:59 +0000 Subject: [PATCH 046/153] [MDEPLOY-207] Remove @Deprecated marked code o Removed the repositoryLayout parameter of deploy-file goal and the configuration part layout in altDeploymentRepository cause we are in Maven 3 and not Maven 2 and before anymore. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1791602 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugins/deploy/AbstractDeployMojo.java | 30 ++--------- .../maven/plugins/deploy/DeployFileMojo.java | 12 +---- .../maven/plugins/deploy/DeployMojo.java | 14 ++---- .../plugins/deploy/DeployFileMojoTest.java | 50 +++++++++---------- .../maven/plugins/deploy/DeployMojoTest.java | 18 ++----- 5 files changed, 38 insertions(+), 86 deletions(-) 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 504806e7..77e811f8 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -19,17 +19,13 @@ * under the License. */ -import java.util.Map; - import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; /** @@ -39,12 +35,6 @@ public abstract class AbstractDeployMojo extends AbstractMojo { - /** - * Map that contains the layouts. - */ - @Component( role = ArtifactRepositoryLayout.class ) - private Map repositoryLayouts; - /** * Flag whether Maven is currently in online/offline mode. */ @@ -80,19 +70,6 @@ void failIfOffline() } } - ArtifactRepositoryLayout getLayout( String id ) - throws MojoExecutionException - { - ArtifactRepositoryLayout layout = repositoryLayouts.get( id ); - - if ( layout == null ) - { - throw new MojoExecutionException( "Invalid repository layout: " + id ); - } - - return layout; - } - boolean isUpdateReleaseInfo() { return updateReleaseInfo; @@ -103,10 +80,9 @@ int getRetryFailedDeploymentCount() return retryFailedDeploymentCount; } - protected ArtifactRepository createDeploymentArtifactRepository( String id, String url, - ArtifactRepositoryLayout layout ) + protected ArtifactRepository createDeploymentArtifactRepository( String id, String url ) { - return new MavenArtifactRepository( id, url, layout, new ArtifactRepositoryPolicy(), + return new MavenArtifactRepository( id, url, new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() ); } 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 1c493d35..140e589b 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -36,7 +36,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.building.ModelBuildingException; @@ -154,13 +153,6 @@ public class DeployFileMojo @Parameter( property = "repositoryId", defaultValue = "remote-repository", required = true ) private String repositoryId; - /** - * The type of remote repository layout to deploy to. Try legacy for a Maven 1.x-style repository layout. - */ - @Deprecated - @Parameter( property = "repositoryLayout", defaultValue = "default" ) - private String repositoryLayout; - /** * URL where the artifact will be deployed.
* ie ( file:///C:/m2-repo or scp://host.com/path/to/repo ) @@ -341,9 +333,7 @@ public void execute() initProperties(); - ArtifactRepositoryLayout layout = getLayout( repositoryLayout ); - - ArtifactRepository deploymentRepository = createDeploymentArtifactRepository( repositoryId, url, layout ); + ArtifactRepository deploymentRepository = createDeploymentArtifactRepository( repositoryId, url ); String protocol = deploymentRepository.getProtocol(); 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 b626d319..11dca7c4 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; @@ -55,7 +54,7 @@ public class DeployMojo extends AbstractDeployMojo { - private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.+)::(.+)" ); + private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.+)" ); /** * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready @@ -91,12 +90,10 @@ public class DeployMojo *
*
id
*
The id can be used to pick up the correct credentials from the settings.xml
- *
layout
- *
Either default for the Maven2 layout or legacy for the Maven1 layout. Maven3 also - * uses the default layout.
*
url
*
The location of the repository
*
+ * Note: Since 3.0.0 the layout part has been removed. */ @Parameter( property = "altDeploymentRepository" ) private String altDeploymentRepository; @@ -247,12 +244,9 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym else { String id = matcher.group( 1 ).trim(); - String layout = matcher.group( 2 ).trim(); - String url = matcher.group( 3 ).trim(); + String url = matcher.group( 2 ).trim(); - ArtifactRepositoryLayout repoLayout = getLayout( layout ); - - repo = createDeploymentArtifactRepository( id, url, repoLayout ); + repo = createDeploymentArtifactRepository( id, url ); } } 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 fff8676a..2ebd83c4 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -267,31 +267,31 @@ public void testDeployIfArtifactIsNotJar() assertTrue( file.exists() ); } - public void testDeployIfRepositoryLayoutIsLegacy() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-legacy-repository-layout/plugin-config.xml" ); - - AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom ); - - assertNotNull( mojo ); - - String repositoryLayout = (String) getVariableValueFromObject( mojo, "repositoryLayout" ); - - assertEquals( "legacy", repositoryLayout ); - - try - { - mojo.execute(); - fail( "legacy is not supported anymore" ); - } - catch ( MojoExecutionException e ) - { - assertEquals( "Invalid repository layout: legacy", e.getMessage() ); - } - - } - +// public void testDeployIfRepositoryLayoutIsLegacy() +// throws Exception +// { +// File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-legacy-repository-layout/plugin-config.xml" ); +// +// AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom ); +// +// assertNotNull( mojo ); +// +// String repositoryLayout = (String) getVariableValueFromObject( mojo, "repositoryLayout" ); +// +// assertEquals( "legacy", repositoryLayout ); +// +// try +// { +// mojo.execute(); +// fail( "legacy is not supported anymore" ); +// } +// catch ( MojoExecutionException e ) +// { +// assertEquals( "Invalid repository layout: legacy", e.getMessage() ); +// } +// +// } +// private void addFileToList( File file, List fileList ) { if ( !file.isDirectory() ) 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 e88bfb59..4db5b2de 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -30,7 +30,6 @@ import java.util.Properties; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; @@ -596,19 +595,16 @@ public void testAltSnapshotDeploymentRepository() { DeployMojo mojo = spy( new DeployMojo() ); - ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class ); - setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) ); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost", - repositoryLayout ) ).thenReturn( repository ); + when( mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost" + ) ).thenReturn( repository ); project.setVersion( "1.0-SNAPSHOT" ); ProjectDeployerRequest pdr = new ProjectDeployerRequest() .setProject( project ) - .setAltDeploymentRepository( "altSnapshotDeploymentRepository::default::http://localhost" ); + .setAltDeploymentRepository( "altSnapshotDeploymentRepository::http://localhost" ); assertEquals( repository, mojo.getDeploymentRepository( pdr )); } @@ -618,19 +614,15 @@ public void testAltReleaseDeploymentRepository() { DeployMojo mojo = spy( new DeployMojo() ); - ArtifactRepositoryLayout repositoryLayout = mock( ArtifactRepositoryLayout.class ); - setVariableValueToObject( mojo, "repositoryLayouts", Collections.singletonMap( "default", repositoryLayout ) ); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost", - repositoryLayout ) ).thenReturn( repository ); + when( mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost" ) ).thenReturn( repository ); project.setVersion( "1.0" ); ProjectDeployerRequest pdr = new ProjectDeployerRequest() .setProject( project ) - .setAltReleaseDeploymentRepository( "altReleaseDeploymentRepository::default::http://localhost" ); + .setAltReleaseDeploymentRepository( "altReleaseDeploymentRepository::http://localhost" ); assertEquals( repository, mojo.getDeploymentRepository( pdr )); From 4ab9964c3cbd3d7d8cf801611124ea4a5a084498 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 16 Apr 2017 13:17:52 +0000 Subject: [PATCH 047/153] [MDEPLOY-207] Remove @Deprecated marked code o followup fixed the UT which are referencing plugin-config.xml files. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1791607 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugins/deploy/DeployFileMojoTest.java | 26 ------------ .../plugin-config.xml | 1 - .../deploy-file-classifier/plugin-config.xml | 1 - .../plugin-config.xml | 39 ------------------ .../target/deploy-test-file-1.0-SNAPSHOT.jar | 1 - .../deploy-file-pom-file/plugin-config.xml | Bin 3278 -> 3166 bytes .../unit/deploy-file-test/plugin-config.xml | 1 - 7 files changed, 69 deletions(-) delete mode 100644 src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml delete mode 100644 src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar 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 2ebd83c4..6c7064bb 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -28,7 +28,6 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.internal.MavenRepositorySystemSession; @@ -267,31 +266,6 @@ public void testDeployIfArtifactIsNotJar() assertTrue( file.exists() ); } -// public void testDeployIfRepositoryLayoutIsLegacy() -// throws Exception -// { -// File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-legacy-repository-layout/plugin-config.xml" ); -// -// AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom ); -// -// assertNotNull( mojo ); -// -// String repositoryLayout = (String) getVariableValueFromObject( mojo, "repositoryLayout" ); -// -// assertEquals( "legacy", repositoryLayout ); -// -// try -// { -// mojo.execute(); -// fail( "legacy is not supported anymore" ); -// } -// catch ( MojoExecutionException e ) -// { -// assertEquals( "Invalid repository layout: legacy", e.getMessage() ); -// } -// -// } -// private void addFileToList( File file, List fileList ) { if ( !file.isDirectory() ) diff --git a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml b/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml index 4c7fc951..7db42a33 100644 --- a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml @@ -29,7 +29,6 @@ under the License. ${basedir}/src/test/resources/unit/deploy-file-artifact-not-jar/target/deploy-test-file.zip deploy-test file://${basedir}/target/remote-repo/deploy-file-artifact-not-jar - default true
diff --git a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml b/src/test/resources/unit/deploy-file-classifier/plugin-config.xml index 59e09452..b77961b4 100644 --- a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-classifier/plugin-config.xml @@ -31,7 +31,6 @@ under the License. deploy-test file://${basedir}/target/remote-repo/deploy-file-classifier bin - default true diff --git a/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml b/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml deleted file mode 100644 index 97531f1b..00000000 --- a/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - maven-deploy-plugin - - org.apache.maven.test - maven-deploy-file-test - 1.0 - jar - ${basedir}/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar - deploy-test - file://${basedir}/target/remote-repo/deploy-file-legacy-repository-layout - legacy - true - - - - - diff --git a/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar b/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar deleted file mode 100644 index 6f5f2f81..00000000 --- a/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar +++ /dev/null @@ -1 +0,0 @@ -This is not an actual jar \ No newline at end of file diff --git a/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml b/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml index 97f60b0a64958e1e0b07850c1b94e8f4924bc773..3a4e2ce0e4fa409b2e183257514a22791aadf144 100644 GIT binary patch delta 11 ScmX>nc~4@)3GT@jJktOl#stm) delta 79 zcmca7aZYl>3GT@sIHl};7!nyO8S)uQ8A=%J7*ZHg8Pb3vr3^Vhz72yuLlID<04QI~ TkO>sY2l6W!kn~L6$h{T-RK*l5 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 78c4c1ed..67b98a17 100644 --- a/src/test/resources/unit/deploy-file-test/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-test/plugin-config.xml @@ -31,7 +31,6 @@ under the License. deploy-test file://${basedir}/target/remote-repo/deploy-file-test POM was created from deploy:deploy-file - default true From c62ba1e44f258f18b204850a75cf5a8063b27afd Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 16 Apr 2017 16:44:59 +0000 Subject: [PATCH 048/153] [MDEPLOY-207] Remove @Deprecated marked code o followup fixed the exception message. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1791612 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 11dca7c4..f2bd5b52 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -239,7 +239,7 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym if ( !matcher.matches() ) { throw new MojoFailureException( altDeploymentRepo, "Invalid syntax for repository.", - "Invalid syntax for alternative repository. Use \"id::layout::url\"." ); + "Invalid syntax for alternative repository. Use \"id::url\"." ); } else { From 914779f0543fdc7c3f2c5976a44a9276e3404e2f Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 23 Apr 2017 20:24:02 +0000 Subject: [PATCH 049/153] [MDEPLOY-207] Remove @Deprecated marked code o Fixed integration tests which used layout definition for altDeploymentRepository. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1792390 13f79535-47bb-0310-9956-ffa450edef68 --- src/it/alt-deploy-repo-with-dist-mgmt-snapshot/test.properties | 2 +- src/it/alt-deploy-repo-with-dist-mgmt/test.properties | 2 +- src/it/alt-deploy-repo-without-dist-mgmt/test.properties | 2 +- src/it/mdeploy-45-test/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/it/alt-deploy-repo-with-dist-mgmt-snapshot/test.properties b/src/it/alt-deploy-repo-with-dist-mgmt-snapshot/test.properties index e9992d60..a0875d1d 100644 --- a/src/it/alt-deploy-repo-with-dist-mgmt-snapshot/test.properties +++ b/src/it/alt-deploy-repo-with-dist-mgmt-snapshot/test.properties @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -altDeploymentRepository = alt-id::default::file:target/repo +altDeploymentRepository = alt-id::file:target/repo diff --git a/src/it/alt-deploy-repo-with-dist-mgmt/test.properties b/src/it/alt-deploy-repo-with-dist-mgmt/test.properties index e9992d60..a0875d1d 100644 --- a/src/it/alt-deploy-repo-with-dist-mgmt/test.properties +++ b/src/it/alt-deploy-repo-with-dist-mgmt/test.properties @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -altDeploymentRepository = alt-id::default::file:target/repo +altDeploymentRepository = alt-id::file:target/repo diff --git a/src/it/alt-deploy-repo-without-dist-mgmt/test.properties b/src/it/alt-deploy-repo-without-dist-mgmt/test.properties index e9992d60..a0875d1d 100644 --- a/src/it/alt-deploy-repo-without-dist-mgmt/test.properties +++ b/src/it/alt-deploy-repo-without-dist-mgmt/test.properties @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -altDeploymentRepository = alt-id::default::file:target/repo +altDeploymentRepository = alt-id::file:target/repo diff --git a/src/it/mdeploy-45-test/pom.xml b/src/it/mdeploy-45-test/pom.xml index c30df9e6..2447705a 100644 --- a/src/it/mdeploy-45-test/pom.xml +++ b/src/it/mdeploy-45-test/pom.xml @@ -85,7 +85,7 @@ under the License. @project.version@ - mine::default::file://${basedir}/target + mine::file://${basedir}/target From 1c2d34c01d5b2dd9e3eca753c792fa8e5460cb7b Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Tue, 16 May 2017 19:07:36 +0000 Subject: [PATCH 050/153] [MDEPLOY-219] Upgrade maven-artifact-transfer to version 0.9.1 git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1795356 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- .../java/org/apache/maven/plugins/deploy/DeployMojo.java | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 31a8e935..fa6aba4a 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ under the License. org.apache.maven.shared maven-artifact-transfer - 3.0.0-SNAPSHOT + 0.9.1 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 f2bd5b52..812b22d9 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -19,8 +19,6 @@ * under the License. */ -import java.io.IOException; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -194,10 +192,6 @@ private void deployProject( ProjectBuildingRequest pbr, ProjectDeployerRequest p { projectDeployer.deploy( pbr, pir, repo ); } - catch ( IOException e ) - { - throw new MojoFailureException( "IOException", e ); - } catch ( NoFileAssignedException e ) { throw new MojoExecutionException( "NoFileAssignedException", e ); From 57c8adca00b675afc8673405812a23b917d9dc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 9 Dec 2017 19:31:11 +0100 Subject: [PATCH 051/153] moved to git --- .gitignore | 15 +++++++++++++++ Jenkinsfile | 20 ++++++++++++++++++++ pom.xml | 11 ++++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 Jenkinsfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f79c9285 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +target/ +.project +.classpath +.settings/ +.svn/ +bin/ +# Intellij +*.ipr +*.iml +.idea +out/ +.DS_Store +/bootstrap +/dependencies.xml +.java-version diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..09ac70f1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,20 @@ +/** + * 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. + */ + +asfMavenTlpStdBuild() diff --git a/pom.xml b/pom.xml index fa6aba4a..7628e8b1 100644 --- a/pom.xml +++ b/pom.xml @@ -42,14 +42,19 @@ under the License. - scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-deploy-plugin/ - scm:svn:https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-deploy-plugin/ - http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/ + scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git + scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git + https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} + HEAD JIRA https://issues.apache.org/jira/browse/MDEPLOY + + Jenkins + https://builds.apache.org/job/maven-box/job/maven-deploy-plugin/ + apache.website From e2843fc249c74a022f00c8010e6d104f6deef976 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sat, 13 Jan 2018 21:04:05 +0100 Subject: [PATCH 052/153] [MDEPLOY-228] Upgrade plexus-utils 3.1.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7628e8b1..87b44239 100644 --- a/pom.xml +++ b/pom.xml @@ -109,7 +109,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.0.24 + 3.1.0 org.apache.maven.plugin-testing From 8ca9666c9ddd6b9db4fdd9c94f1ae52f25f173c6 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sat, 10 Feb 2018 16:46:12 +0100 Subject: [PATCH 053/153] [MDEPLOY-230] - Update parent to 31. --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 87b44239..83649978 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 30 + 31 ../../pom/maven/maven-plugins/pom.xml @@ -200,7 +200,6 @@ under the License. org.apache.maven.plugins maven-changes-plugin - 2.3 Type,Key,Summary,Assignee,Status,Resolution,Fix Version From e880d2f25aaa3e0575232188cecc06b194482652 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 7 Mar 2018 21:44:44 +0100 Subject: [PATCH 054/153] [MDEPLOY-232] - Using maven-fluido-skin 1.7 --- src/site/site.xml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/site/site.xml b/src/site/site.xml index 195d0356..50bd8869 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -22,6 +22,30 @@ under the License. + + http://maven.apache.org/images/apache-maven-project.png + http://www.apache.org/ + + + + http://maven.apache.org/images/maven-logo-black-on-white.png + http://maven.apache.org/ + + + org.apache.maven.skins + maven-fluido-skin + 1.7 + + + + + true + + + maven.apache.org/plugins/maven-deploy-plugin/ + + + From 9aa2ba77af3a160c133f3751d10d6ec896225a7c Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 7 Mar 2018 22:20:57 +0100 Subject: [PATCH 055/153] [MDEPLOY-233] - Remove unused code --- .../org/apache/maven/plugins/deploy/DeployFileMojo.java | 7 ------- 1 file changed, 7 deletions(-) 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 140e589b..6dd5da71 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -43,7 +43,6 @@ import org.apache.maven.model.building.StringModelSource; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; -import org.apache.maven.model.validation.ModelValidator; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; @@ -188,12 +187,6 @@ public class DeployFileMojo @Deprecated private Boolean uniqueVersion; - /** - * The component used to validate the user-supplied artifact coordinates. - */ - @Component - private ModelValidator modelValidator; - /** * 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. From a2e826ffa5966e895490056b8e6f4b28d420bf85 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 11 Apr 2018 20:12:47 +0200 Subject: [PATCH 056/153] =?UTF-8?q?[MDEPLOY-235]=C2=A0-=20Upgrade=20mave-s?= =?UTF-8?q?urefire/failsafe-plugin=202.21.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 83649978..2ef373aa 100644 --- a/pom.xml +++ b/pom.xml @@ -64,6 +64,7 @@ under the License. 3.0 + 2.21.0 From d7e07cb878fd9a656cd5db73a0711d2a7fff9245 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Tue, 10 Apr 2018 18:06:02 +0200 Subject: [PATCH 057/153] [MNGSITE-332] - Changed download templates of plugins not to reference .md5 anymore --- src/site/xdoc/download.xml.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index 09d4f421..cf13dc93 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -108,7 +108,7 @@ under the License. ${project.name} ${project.version} (Source zip) maven/plugins/${project.artifactId}-${project.version}-source-release.zip - maven/plugins/${project.artifactId}-${project.version}-source-release.zip.md5 + maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha1 maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc From d78b1157d28fc555dfba146ca9bae227c906aea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Tue, 19 Jun 2018 00:02:19 +0200 Subject: [PATCH 058/153] [INFRA-16467] move components documentation out of CMS space --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2ef373aa..1e4849d8 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ under the License. apache.website - scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path} + scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path} From e3506923ac136edb1e629f6e44d1ddc6198e2b85 Mon Sep 17 00:00:00 2001 From: rfscholte Date: Mon, 2 Jul 2018 22:19:32 +0200 Subject: [PATCH 059/153] Switch to asfMavenTlpPlgnBuild --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 09ac70f1..e9f05f7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,4 +17,4 @@ * under the License. */ -asfMavenTlpStdBuild() +asfMavenTlpPlgnBuild() From 9d61acb18cbd20de665d7cea0939cbcfd2c62687 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 22 Jul 2018 19:51:07 +0200 Subject: [PATCH 060/153] [MDEPLOY-237] - Upgrade maven-plugins parent to version 32 --- pom.xml | 4 ++-- src/it/MDEPLOY-212/pom.xml | 2 +- src/it/MDEPLOY-213/pom.xml | 2 +- src/it/deploy-attached-sources/pom.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 1e4849d8..f80e782b 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 31 + 32 ../../pom/maven/maven-plugins/pom.xml @@ -64,7 +64,6 @@ under the License. 3.0 - 2.21.0 @@ -175,6 +174,7 @@ under the License. maven-invoker-plugin true + true ${project.build.directory}/it true diff --git a/src/it/MDEPLOY-212/pom.xml b/src/it/MDEPLOY-212/pom.xml index a46c8e71..c6376ff4 100644 --- a/src/it/MDEPLOY-212/pom.xml +++ b/src/it/MDEPLOY-212/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-javadoc-plugin - 2.7 + 3.0.1 attach-javadoc diff --git a/src/it/MDEPLOY-213/pom.xml b/src/it/MDEPLOY-213/pom.xml index 7688d377..36e6d23a 100644 --- a/src/it/MDEPLOY-213/pom.xml +++ b/src/it/MDEPLOY-213/pom.xml @@ -46,7 +46,7 @@ under the License. org.apache.maven.plugins maven-javadoc-plugin - 2.7 + 3.0.1 attach-javadoc diff --git a/src/it/deploy-attached-sources/pom.xml b/src/it/deploy-attached-sources/pom.xml index 8dbaec1b..43a2e22e 100644 --- a/src/it/deploy-attached-sources/pom.xml +++ b/src/it/deploy-attached-sources/pom.xml @@ -62,7 +62,7 @@ under the License. org.apache.maven.plugins maven-javadoc-plugin - 2.7 + 3.0.1 attach-javadoc From edf6740b71de55d46ca2053e83d33299dd479f4a Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 22 Jul 2018 20:22:54 +0200 Subject: [PATCH 061/153] [MDEPLOY-238] - Upgrade JUnit 4.11 to 4.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f80e782b..a0e07880 100644 --- a/pom.xml +++ b/pom.xml @@ -132,7 +132,7 @@ under the License. junit junit - 4.11 + 4.12 test From 9d34533aceb3a9433c9076fed739c691ef31e7f7 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Tue, 24 Jul 2018 19:58:01 +0200 Subject: [PATCH 062/153] [MDEPLOY-239] - Add GitHub documentation --- .github/pull_request_template.md | 29 ++++++++++ CONTRIBUTING.md | 91 ++++++++++++++++++++++++++++++ README.md | 97 ++++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 CONTRIBUTING.md create mode 100644 README.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..b9b9dde8 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,29 @@ +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 + 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 + 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. + - [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will + be performed on your pull request automatically. + - [ ] You have run the integration tests successfully (`mvn -Prun-its clean verify`). + +If your pull request is about ~20 lines of code you don't need to sign an +[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure +please ask on the developers list. + +To make clear that you license your contribution under +the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) +you have to acknowledge this by using the following check-box. + + - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) + + - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c75ccce1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,91 @@ + +Contributing to Apache Maven Help Plugin +====================== + +You have found a bug or you have an idea for a cool new feature? Contributing +code is a great way to give something back to the open source community. Before +you dig right into the code, there are a few guidelines that we need +contributors to follow so that we can have a chance of keeping on top of +things. + +Some of the ideas are documented in the [Maven Wiki][maven-wiki] +which might be interesting to read and for further discussion. + +Getting Started +--------------- + ++ Make sure you have a [JIRA account](https://issues.apache.org/jira/). ++ Make sure you have a [GitHub account](https://github.com/signup/free). ++ If you're planning to implement a new feature, it makes sense to discuss your changes + on the [dev list](https://maven.apache.org/mail-lists.html) first. + This way you can make sure you're not wasting your time on something that isn't + considered to be in Apache Maven's scope. ++ Submit a ticket for your issue, assuming one does not already exist. + + Clearly describe the issue, including steps to reproduce when it is a bug. + + Make sure you fill in the earliest version that you know has the issue. ++ Fork the repository on GitHub. + +Making and Submitting Changes +-------------- + +We accept Pull Requests via GitHub. The [developer mailing list][dev-ml-list] is the +main channel of communication for contributors. +There are some guidelines which will make applying PRs easier for us: ++ Create a topic branch from where you want to base your work (this is usually the master branch). + Push your changes to a topic branch in your fork of the repository. ++ Make commits of logical units. ++ Respect the original code style: by using the same [codestyle][code-style], + patches should only highlight the actual difference, not being disturbed by any formatting issues: + + Only use spaces for indentation. + + Create minimal diffs - disable on save actions like reformat source code or organize imports. + If you feel the source code should be reformatted, create a separate PR for this change. + + Check for unnecessary whitespace with `git diff --check` before committing. ++ Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue. +``` +[MDEPLOY-XXX] - Subject of the JIRA Ticket + Optional supplemental description. +``` ++ Make sure you have added the necessary tests (JUnit/IT) for your changes. ++ Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken. ++ Submit a pull request to the repository in the Apache organization. ++ Update your JIRA ticket and include a link to the pull request in the ticket. + +If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla]. + +Making Trivial Changes +---------------------- + +For changes of a trivial nature to comments and documentation, it is not always +necessary to create a new ticket in JIRA. In this case, it is appropriate to +start the first line of a commit with '(doc)' instead of a ticket number. + +Additional Resources +-------------------- + ++ [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch) ++ [Apache Maven Help JIRA project page](https://issues.apache.org/jira/projects/MDEPLOY/) ++ [Contributor License Agreement][cla] ++ [General GitHub documentation](https://help.github.com/) ++ [GitHub pull request documentation](https://help.github.com/send-pull-requests/) ++ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject) ++ #Maven IRC channel on freenode.org + +[dev-ml-list]: https://maven.apache.org/mailing-lists.html +[code-style]: https://maven.apache.org/developers/conventions/code.html +[cla]: https://www.apache.org/licenses/#clas +[maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index diff --git a/README.md b/README.md new file mode 100644 index 00000000..438ae424 --- /dev/null +++ b/README.md @@ -0,0 +1,97 @@ + +Contributing to Apache Deploy Plugin +====================== + +[![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] +[![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-deploy-plugin.svg?label=Maven%20Central)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.apache.maven.plugins%22%20AND%20a%3A%22maven-deploy-plugin%22) +[![Jenkins Status](https://img.shields.io/jenkins/s/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?style=flat-square)][build] +[![Jenkins tests](https://img.shields.io/jenkins/t/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?style=flat-square)][test-results] + + +You have found a bug or you have an idea for a cool new feature? Contributing +code is a great way to give something back to the open source community. Before +you dig right into the code, there are a few guidelines that we need +contributors to follow so that we can have a chance of keeping on top of +things. + +Getting Started +--------------- + ++ Make sure you have a [JIRA account](https://issues.apache.org/jira/). ++ Make sure you have a [GitHub account](https://github.com/signup/free). ++ If you're planning to implement a new feature, it makes sense to discuss your changes + on the [dev list](https://maven.apache.org/mail-lists.html) first. + This way you can make sure you're not wasting your time on something that isn't + considered to be in Apache Maven's scope. ++ Submit a ticket for your issue, assuming one does not already exist. + + Clearly describe the issue, including steps to reproduce when it is a bug. + + Make sure you fill in the earliest version that you know has the issue. ++ Fork the repository on GitHub. + +Making and Submitting Changes +-------------- + +We accept Pull Requests via GitHub. The [developer mailing list][dev-ml-list] is the +main channel of communication for contributors. +There are some guidelines which will make applying PRs easier for us: ++ Create a topic branch from where you want to base your work (this is usually the master branch). + Push your changes to a topic branch in your fork of the repository. ++ Make commits of logical units. ++ Respect the original code style: by using the same [codestyle][code-style], + patches should only highlight the actual difference, not being disturbed by any formatting issues: + + Only use spaces for indentation. + + Create minimal diffs - disable on save actions like reformat source code or organize imports. + If you feel the source code should be reformatted, create a separate PR for this change. + + Check for unnecessary whitespace with `git diff --check` before committing. ++ Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue. +``` +[MDEPLOY-XXX] - Subject of the JIRA Ticket + Optional supplemental description. +``` ++ Make sure you have added the necessary tests (JUnit/IT) for your changes. ++ Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken. ++ Submit a pull request to the repository in the Apache organization. ++ Update your JIRA ticket and include a link to the pull request in the ticket. + +If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla]. + +Making Trivial Changes +---------------------- + +For changes of a trivial nature to comments and documentation, it is not always +necessary to create a new ticket in JIRA. In this case, it is appropriate to +start the first line of a commit with '(doc)' instead of a ticket number. + +Additional Resources +-------------------- + ++ [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch) ++ [Apache Maven Help JIRA project page](https://issues.apache.org/jira/projects/MDEPLOY/) ++ [Contributor License Agreement][cla] ++ [General GitHub documentation](https://help.github.com/) ++ [GitHub pull request documentation](https://help.github.com/send-pull-requests/) ++ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject) ++ #Maven IRC channel on freenode.org + +[license]: https://www.apache.org/licenses/LICENSE-2.0 +[dev-ml-list]: https://maven.apache.org/mailing-lists.html +[code-style]: https://maven.apache.org/developers/conventions/code.html +[cla]: https://www.apache.org/licenses/#clas +[maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index +[test-results]: https://builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master/lastCompletedBuild/testReport/ +[build]: https://builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master/ From 694f98d41785a1df8cef505af2793cdb92b79dc2 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Thu, 9 Aug 2018 19:36:24 +0200 Subject: [PATCH 063/153] No negative logic. --- .../apache/maven/plugins/deploy/DeployFileMojo.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 6dd5da71..b79010f2 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -214,11 +214,7 @@ public class DeployFileMojo void initProperties() throws MojoExecutionException { - if ( pomFile != null ) - { - processModel( readModel( pomFile ) ); - } - else + if ( pomFile == null ) { boolean foundPom = false; @@ -300,6 +296,10 @@ void initProperties() } } } + else + { + processModel( readModel( pomFile ) ); + } if ( packaging == null && file != null ) { From 41a40f6892a3ebd818d2881643cc10ecca8342be Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 19 Aug 2018 16:51:38 +0200 Subject: [PATCH 064/153] [MDEPLOY-240] - Remove updateReleaseInfo parameter - Removed Tests which rely on updateReleaseInfo - Removed the configuration from plugin-config.xml for updateReleaseInfo --- .../plugins/deploy/AbstractDeployMojo.java | 11 ----- .../maven/plugins/deploy/DeployFileMojo.java | 4 -- .../maven/plugins/deploy/DeployMojo.java | 1 - .../maven/plugins/deploy/DeployMojoTest.java | 38 ------------------ .../unit/basic-deploy-pom/plugin-config.xml | 1 - .../unit/basic-deploy-scp/plugin-config.xml | 1 - .../unit/basic-deploy-test/plugin-config.xml | Bin 3366 -> 3254 bytes .../plugin-config.xml | 1 - 8 files changed, 57 deletions(-) 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 77e811f8..c0efde10 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -41,12 +41,6 @@ public abstract class AbstractDeployMojo @Parameter( defaultValue = "${settings.offline}", readonly = true ) private boolean offline; - /** - * Parameter used to update the metadata to make the artifact as release. - */ - @Parameter( property = "updateReleaseInfo", defaultValue = "false" ) - protected boolean updateReleaseInfo; - /** * Parameter used to control how many times a failed deployment will be retried before giving up and failing. If a * value outside the range 1-10 is specified it will be pulled to the nearest value within the range 1-10. @@ -70,11 +64,6 @@ void failIfOffline() } } - boolean isUpdateReleaseInfo() - { - return updateReleaseInfo; - } - int getRetryFailedDeploymentCount() { return retryFailedDeploymentCount; 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 b79010f2..23014bb9 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -378,10 +378,6 @@ public void execute() } } - if ( updateReleaseInfo ) - { - artifact.setRelease( true ); - } artifact.setRepository( deploymentRepository ); if ( sources != null ) 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 812b22d9..72d672f8 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -144,7 +144,6 @@ public void execute() // @formatter:off ProjectDeployerRequest pdr = new ProjectDeployerRequest() .setProject( project ) - .setUpdateReleaseInfo( isUpdateReleaseInfo() ) .setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ) .setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ) .setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ) 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 4db5b2de..746be91d 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -360,44 +360,6 @@ public void testBasicDeployWithPackagingAsPom() assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); } - public void testUpdateReleaseParamSetToTrue() - 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 ); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); - when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); - - boolean updateReleaseInfo = (Boolean) getVariableValueFromObject(mojo, "updateReleaseInfo"); - - assertTrue( updateReleaseInfo ); - - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); - - artifact = (DeployArtifactStub) project.getArtifact(); - - artifact.setFile( testPom ); - - ArtifactRepositoryStub repo = getRepoStub( mojo ); - - repo.setAppendToUrl( "basic-deploy-updateReleaseParam" ); - - mojo.execute(); - - assertTrue( artifact.isRelease() ); - } - public void testDeployIfArtifactFileIsNull() throws Exception { diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml index 1f5ae632..8cf373c8 100644 --- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml @@ -32,7 +32,6 @@ under the License. ${basedir} - true diff --git a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml index ffb387ad..4b3a9bfe 100644 --- a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml @@ -30,7 +30,6 @@ under the License. - false diff --git a/src/test/resources/unit/basic-deploy-test/plugin-config.xml b/src/test/resources/unit/basic-deploy-test/plugin-config.xml index ae6eeaf21c833221d84a50b5eca9872782c72d74..a98749b1574d542007b8f1409d64cf80e8fed0d9 100644 GIT binary patch delta 11 ScmZ1`wM}w^0?*_LJktOf)dVpB delta 103 zcmdlcxlC$<0?*_L>}wdM THVpa<1a(a2${basedir} - true From 83b2d51cb3427a54ea465ff836c68da18accd426 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Thu, 9 Aug 2018 17:24:14 +0200 Subject: [PATCH 065/153] [MDEPLOY-231] - Move checksum generation from install to deploy plugin --- pom.xml | 7 +- src/it/attach-jar-checksum-release/pom.xml | 103 ++++++++++++++++++ src/it/attach-jar-checksum-release/setup.bsh | 29 +++++ .../attach-jar-checksum-release/verify.groovy | 64 +++++++++++ src/it/attach-jar-checksum-snapshot/pom.xml | 102 +++++++++++++++++ src/it/attach-jar-checksum-snapshot/setup.bsh | 29 +++++ .../verify.groovy | 95 ++++++++++++++++ .../maven/plugins/deploy/DeployFileMojo.java | 8 +- .../maven/plugins/deploy/DeployMojo.java | 11 +- .../maven/plugins/deploy/DeployMojoTest.java | 2 +- .../apache/maven/plugins/deploy/Utils.java | 64 +++++++++++ .../deploy/stubs/ArtifactDeployerStub.java | 4 +- 12 files changed, 507 insertions(+), 11 deletions(-) create mode 100644 src/it/attach-jar-checksum-release/pom.xml create mode 100644 src/it/attach-jar-checksum-release/setup.bsh create mode 100644 src/it/attach-jar-checksum-release/verify.groovy create mode 100644 src/it/attach-jar-checksum-snapshot/pom.xml create mode 100644 src/it/attach-jar-checksum-snapshot/setup.bsh create mode 100644 src/it/attach-jar-checksum-snapshot/verify.groovy create mode 100644 src/test/java/org/apache/maven/plugins/deploy/Utils.java diff --git a/pom.xml b/pom.xml index a0e07880..36cafaf2 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ under the License. org.apache.maven.shared maven-artifact-transfer - 0.9.1 + 0.10.0 @@ -185,9 +185,14 @@ under the License. verify ${project.build.directory}/local-repo src/it/settings.xml + true deploy + + + ${https.protocols} + diff --git a/src/it/attach-jar-checksum-release/pom.xml b/src/it/attach-jar-checksum-release/pom.xml new file mode 100644 index 00000000..bda659d4 --- /dev/null +++ b/src/it/attach-jar-checksum-release/pom.xml @@ -0,0 +1,103 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.ajc + test + 1.0 + jar + + + 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 + + + + true + + + + it + file:///${basedir}/target/remoterepo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + + false + + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-source-plugin + 2.0.4 + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.3.1 + + + + + diff --git a/src/it/attach-jar-checksum-release/setup.bsh b/src/it/attach-jar-checksum-release/setup.bsh new file mode 100644 index 00000000..4d739715 --- /dev/null +++ b/src/it/attach-jar-checksum-release/setup.bsh @@ -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. + */ + +import java.io.*; +import java.util.*; + +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; diff --git a/src/it/attach-jar-checksum-release/verify.groovy b/src/it/attach-jar-checksum-release/verify.groovy new file mode 100644 index 00000000..ac362f81 --- /dev/null +++ b/src/it/attach-jar-checksum-release/verify.groovy @@ -0,0 +1,64 @@ +/* + * 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/pom.xml b/src/it/attach-jar-checksum-snapshot/pom.xml new file mode 100644 index 00000000..89ddce78 --- /dev/null +++ b/src/it/attach-jar-checksum-snapshot/pom.xml @@ -0,0 +1,102 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.ajc + test + 1.0-SNAPSHOT + jar + + + Tests the deployment of a simple SNAPSHOT JAR with an attached artifact and checksums + + + + true + + + + it + file:///${basedir}/target/remoterepo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + + false + + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-source-plugin + 2.0.4 + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.3.1 + + + + + diff --git a/src/it/attach-jar-checksum-snapshot/setup.bsh b/src/it/attach-jar-checksum-snapshot/setup.bsh new file mode 100644 index 00000000..7d54f90e --- /dev/null +++ b/src/it/attach-jar-checksum-snapshot/setup.bsh @@ -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. + */ + +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; diff --git a/src/it/attach-jar-checksum-snapshot/verify.groovy b/src/it/attach-jar-checksum-snapshot/verify.groovy new file mode 100644 index 00000000..0a4a14f9 --- /dev/null +++ b/src/it/attach-jar-checksum-snapshot/verify.groovy @@ -0,0 +1,95 @@ +/* + * 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/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java index 23014bb9..43044218 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -54,10 +54,10 @@ import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import org.apache.maven.shared.artifact.DefaultArtifactCoordinate; -import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; -import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; -import org.apache.maven.shared.repository.RepositoryManager; +import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate; +import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployer; +import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException; +import org.apache.maven.shared.transfer.repository.RepositoryManager; import org.apache.maven.shared.utils.Os; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; 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 72d672f8..94b94055 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -36,9 +36,10 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.project.NoFileAssignedException; -import org.apache.maven.shared.project.deploy.ProjectDeployer; -import org.apache.maven.shared.project.deploy.ProjectDeployerRequest; +import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException; +import org.apache.maven.shared.transfer.project.NoFileAssignedException; +import org.apache.maven.shared.transfer.project.deploy.ProjectDeployer; +import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest; /** * Deploys an artifact to remote repository. @@ -195,6 +196,10 @@ private void deployProject( ProjectBuildingRequest pbr, ProjectDeployerRequest p { throw new MojoExecutionException( "NoFileAssignedException", e ); } + catch ( ArtifactDeployerException e ) + { + throw new MojoExecutionException( "ArtifactDeployerException", e ); + } } 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 746be91d..6c6f9387 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -40,7 +40,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.internal.MavenRepositorySystemSession; -import org.apache.maven.shared.project.deploy.ProjectDeployerRequest; +import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest; import org.codehaus.plexus.util.FileUtils; import org.junit.Ignore; import org.mockito.InjectMocks; diff --git a/src/test/java/org/apache/maven/plugins/deploy/Utils.java b/src/test/java/org/apache/maven/plugins/deploy/Utils.java new file mode 100644 index 00000000..09949a65 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/Utils.java @@ -0,0 +1,64 @@ +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.sonatype.aether.util.ChecksumUtils; + +/** + * A utility class to assist testing. + * + * @author Benjamin Bentmann + * @version $Id$ + */ +public class Utils +{ + + public static final List 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 null. + * @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 checksums = ChecksumUtils.calc( file, CHECKSUM_ALGORITHMS ); + for ( Map.Entry 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/ArtifactDeployerStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java index 9bdf48ae..d0b47d43 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java @@ -24,8 +24,8 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.artifact.deploy.ArtifactDeployer; -import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException; +import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployer; +import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException; public class ArtifactDeployerStub implements ArtifactDeployer From db21c8fee0c040210aa0aa0275560a962ad3b840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Wed, 29 Aug 2018 14:42:27 +0200 Subject: [PATCH 066/153] [MNGSITE-341] use https for sigs, hashes and KEYS --- src/site/xdoc/download.xml.vm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index cf13dc93..7047d2c6 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -34,7 +34,7 @@ under the License.

In order to guard against corrupted downloads/installations, it is highly recommended to verify the signature - of the release bundles against the public KEYS used by the Apache Maven + of the release bundles against the public KEYS used by the Apache Maven developers.

${project.name} is distributed under the Apache License, version 2.0.

@@ -108,8 +108,8 @@ under the License. ${project.name} ${project.version} (Source zip) maven/plugins/${project.artifactId}-${project.version}-source-release.zip - maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha1 - maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc + maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha1 + maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc From 6bc4d8d8d401c8f9ead8245d16ba18c7c0f5d97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Wed, 29 Aug 2018 14:53:27 +0200 Subject: [PATCH 067/153] [MPOM-205] use sha512 checksums instead of sha1 --- src/site/xdoc/download.xml.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index 7047d2c6..3f710359 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -108,7 +108,7 @@ under the License. ${project.name} ${project.version} (Source zip) maven/plugins/${project.artifactId}-${project.version}-source-release.zip - maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha1 + maven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512 maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc From d8baa8dc13a75d814c275e9cfe622ea93017b7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 16 Sep 2018 20:00:34 +0200 Subject: [PATCH 068/153] upgraded parent POM from 32 to 33 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 36cafaf2..ab457324 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 32 + 33 ../../pom/maven/maven-plugins/pom.xml From 54329afd813cfca8c298eda1710468578998224d Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 23 Sep 2018 14:34:09 +0200 Subject: [PATCH 069/153] [MDEPLOY-242] - Lift JDK minimum to JDK 7 --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index ab457324..0afaf1b2 100644 --- a/pom.xml +++ b/pom.xml @@ -64,6 +64,7 @@ under the License. 3.0 + 7 From 5aa24d1848f4d4d6ab4838b00fa2b7b5e5c0f3ef Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 23 Sep 2018 19:30:11 +0200 Subject: [PATCH 070/153] [maven-release-plugin] prepare release maven-deploy-plugin-3.0.0-M1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 0afaf1b2..d582c14e 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-deploy-plugin - 3.0.0-SNAPSHOT + 3.0.0-M1 maven-plugin Apache Maven Deploy Plugin @@ -45,7 +45,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} - HEAD + maven-deploy-plugin-3.0.0-M1 JIRA From 72c179744b86120716e166ba59e2754b02fc1c4d Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 23 Sep 2018 19:30:32 +0200 Subject: [PATCH 071/153] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d582c14e..b006e455 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-deploy-plugin - 3.0.0-M1 + 3.0.0-M2-SNAPSHOT maven-plugin Apache Maven Deploy Plugin @@ -45,7 +45,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} - maven-deploy-plugin-3.0.0-M1 + HEAD JIRA From 3f279e4801ebc9a77585c309444b5b12620d9046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Fri, 18 Jan 2019 19:01:20 +0100 Subject: [PATCH 072/153] [MDEPLOY-249] fixed javadoc: format has no layout part now --- .../java/org/apache/maven/plugins/deploy/DeployMojo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 94b94055..986591a8 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -85,14 +85,15 @@ public class DeployMojo /** * Specifies an alternative repository to which the project artifacts should be deployed ( other than those * specified in <distributionManagement> ).
- * Format: id::layout::url + * Format: id::url *
*
id
*
The id can be used to pick up the correct credentials from the settings.xml
*
url
*
The location of the repository
*
- * Note: Since 3.0.0 the layout part has been removed. + * Note: In version 2, the format was id::layout::url, but since 3.0.0 the layout part has been removed because Maven 3 + * only supports default (ie. Maven 2) layout and not legacy (Maven 1) layout. */ @Parameter( property = "altDeploymentRepository" ) private String altDeploymentRepository; From a00bd1931f8712a56fb34a917edb7857764b5038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 19 Jan 2019 09:05:16 +0100 Subject: [PATCH 073/153] [MDEPLOY-249] fixed javadoc: format has no layout part now --- .../java/org/apache/maven/plugins/deploy/DeployMojo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 986591a8..75918ac7 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -92,8 +92,9 @@ public class DeployMojo *
url
*
The location of the repository
* - * Note: In version 2, the format was id::layout::url, but since 3.0.0 the layout part has been removed because Maven 3 - * only supports default (ie. Maven 2) layout and not legacy (Maven 1) layout. + * Note: In version 2, the format was id::layout::url, but since 3.0.0 the layout part has been + * removed because Maven 3 only supports default (ie. Maven 2) layout and not legacy + * (Maven 1) layout. */ @Parameter( property = "altDeploymentRepository" ) private String altDeploymentRepository; From c34d0b5ede097734f9433f29a94466b3b8f7cd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 20 Jan 2019 17:26:38 +0100 Subject: [PATCH 074/153] [MDEPOY-250] document network issues workaround found by PLC4X --- .../apt/examples/deploy-network-issues.apt | 123 ++++++++++++++++++ src/site/apt/index.apt.vm | 2 + src/site/apt/project-deployment.apt | 2 + 3 files changed, 127 insertions(+) create mode 100644 src/site/apt/examples/deploy-network-issues.apt diff --git a/src/site/apt/examples/deploy-network-issues.apt b/src/site/apt/examples/deploy-network-issues.apt new file mode 100644 index 00000000..059f4eb8 --- /dev/null +++ b/src/site/apt/examples/deploy-network-issues.apt @@ -0,0 +1,123 @@ + ------ + Deploying With Network Issues + ------ + Hervé Boutemy + ------ + 2019-01-20 + ------ + +~~ 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. + +~~ NOTE: For help with the syntax of this file, see: +~~ http://maven.apache.org/doxia/references/apt-format.html + +Deploying With Network Issues + + Sometimes, network quality from building machine to the remote repository is not perfect. + Of course, improving the network would be the best solution, but it is not always possible. + + There are a few strategies to work around the network issue. + +* Configuring Multiple Tries + + Deploy plugin provides {{{../deploy-mojo.html#retryFailedDeploymentCount}<<>> parameter}} + to retry deployment multiple times before giving up and returning a failure for the <<>> goal: + ++----+ + + [...] + + + + org.apache.maven.plugins + maven-deploy-plugin + + 3 + + + + + [...] + ++----+ + +* Deploying to a Local Staging Directory + + When the network is really not consistent, a deeper strategy is to deploy in 2 steps: + + 1. <<>> to a local <<>> directory during the build, + + 2. then copy from the local area to the target remote repository, retrying as much as necessary. + + [] + +** Deploying to a Local Directory + + Deploying to a local directory can be done from command line, without changing POM, using + {{{../deploy-mojo.html#altDeploymentRepository}<<>> parameter}}: + ++----+ +mvn deploy -DaltDeploymentRepository=local::file:./target/staging-deploy ++----+ + + Notice: with maven-deploy-plugin 2.x, the parameter format was <<>> + + Of course, if you want can configure the repository in your <<>> if you want to go from a temporary strategy + to the general strategy. + +** Copying from Local Directory to Target Remote Repository + + <<>>'s {{{http://www.mojohaus.org/wagon-maven-plugin/merge-maven-repos-mojo.html}<<>> goal}} + provides a mechanism to copy from one remote repository to the other, while merging repository metadata. + + <<>>'s {{{http://www.mojohaus.org/wagon-maven-plugin/upload-mojo.html}<<>> goal}} + will do the same without taking care of repository metadata: use it if you have an empty repository as target, + like a staging repository provided by a repository manager. + + It can be invoked fully from command line (renaming <<<-Dwagon.>>> with <<>> when + {{{https://github.com/mojohaus/wagon-maven-plugin/pull/26}2.0.1 will be released}}): + ++----+ +mvn org.codehaus.mojo:wagon-maven-plugin:2.0.0:merge-maven-repos \ + -Dwagon.source=file:./target/staging-deploy \ + -Dwagon.target=https://... \ + -Dwagon.=id ++----+ + + or more simply with <<>> with configuration in <<>>: + ++----+ + + [...] + + + + org.codehaus.mojo + wagon-maven-plugin + 2.0.0 + + file:./target/staging-deploy + https://... + id + + + + + [...] + ++----+ diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index c5e814e3..c91364d6 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -114,6 +114,8 @@ ${project.name} * {{{./examples/deploy-ssh-external.html}Deployment with external SSH}} + * {{{./examples/deploy-network-issues.html}Workarounds when there are network issues}} + [] diff --git a/src/site/apt/project-deployment.apt b/src/site/apt/project-deployment.apt index 39d33904..e74a029a 100644 --- a/src/site/apt/project-deployment.apt +++ b/src/site/apt/project-deployment.apt @@ -34,4 +34,6 @@ Project Deployment * {{{./examples/deploy-ssh-external.html}Deployment with external SSH}} + * {{{./examples/deploy-network-issues.html}Workarounds when there are network issues}} + [] \ No newline at end of file From 7057a0266c23d4413435f4c697638cfddfbba31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 20 Jan 2019 17:31:10 +0100 Subject: [PATCH 075/153] fixed date format for Doxia parsing --- src/site/apt/examples/deploy-ftp.apt | 2 +- src/site/apt/examples/deploy-ssh-external.apt | 2 +- src/site/apt/examples/deploying-in-legacy-layout.apt.vm | 2 +- src/site/apt/examples/deploying-sources-javadoc.apt.vm | 2 +- src/site/apt/examples/deploying-with-classifiers.apt.vm | 2 +- src/site/apt/examples/deploying-with-customed-pom.apt.vm | 2 +- src/site/apt/examples/disabling-generic-pom.apt.vm | 2 +- src/site/apt/file-deployment.apt | 2 +- src/site/apt/project-deployment.apt | 2 +- src/site/apt/usage.apt | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/site/apt/examples/deploy-ftp.apt b/src/site/apt/examples/deploy-ftp.apt index e7654b3b..efb41192 100644 --- a/src/site/apt/examples/deploy-ftp.apt +++ b/src/site/apt/examples/deploy-ftp.apt @@ -3,7 +3,7 @@ ------ Jason van Zyl ------ - 12 October 2005 + 2005-10-12 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/examples/deploy-ssh-external.apt b/src/site/apt/examples/deploy-ssh-external.apt index e424a748..4536d799 100644 --- a/src/site/apt/examples/deploy-ssh-external.apt +++ b/src/site/apt/examples/deploy-ssh-external.apt @@ -3,7 +3,7 @@ ------ Jason van Zyl ------ - 12 October 2005 + 2005-10-12 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/examples/deploying-in-legacy-layout.apt.vm b/src/site/apt/examples/deploying-in-legacy-layout.apt.vm index c87ae353..bc9a88ba 100644 --- a/src/site/apt/examples/deploying-in-legacy-layout.apt.vm +++ b/src/site/apt/examples/deploying-in-legacy-layout.apt.vm @@ -3,7 +3,7 @@ ------ Allan Ramirez ------ - June 2006 + 2006-06-21 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/examples/deploying-sources-javadoc.apt.vm b/src/site/apt/examples/deploying-sources-javadoc.apt.vm index 69630b2f..4a7a406e 100644 --- a/src/site/apt/examples/deploying-sources-javadoc.apt.vm +++ b/src/site/apt/examples/deploying-sources-javadoc.apt.vm @@ -2,7 +2,7 @@ Deploy sources and javadocs for an artifact ------ ------ - February 2011 + 20011-02-23 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/examples/deploying-with-classifiers.apt.vm b/src/site/apt/examples/deploying-with-classifiers.apt.vm index c0b58701..ca4b5fa3 100644 --- a/src/site/apt/examples/deploying-with-classifiers.apt.vm +++ b/src/site/apt/examples/deploying-with-classifiers.apt.vm @@ -3,7 +3,7 @@ ------ Robert Scholte ------ - September 2013 + 2013-09-01 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/examples/deploying-with-customed-pom.apt.vm b/src/site/apt/examples/deploying-with-customed-pom.apt.vm index b86caf87..1773a94e 100644 --- a/src/site/apt/examples/deploying-with-customed-pom.apt.vm +++ b/src/site/apt/examples/deploying-with-customed-pom.apt.vm @@ -3,7 +3,7 @@ ------ Allan Ramirez ------ - June 2006 + 2006-06-21 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/examples/disabling-generic-pom.apt.vm b/src/site/apt/examples/disabling-generic-pom.apt.vm index 17a0342c..2d23e9fc 100644 --- a/src/site/apt/examples/disabling-generic-pom.apt.vm +++ b/src/site/apt/examples/disabling-generic-pom.apt.vm @@ -3,7 +3,7 @@ ------ Allan Ramirez ------ - June 2006 + 2006-06-21 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/file-deployment.apt b/src/site/apt/file-deployment.apt index a886cbf0..47758973 100644 --- a/src/site/apt/file-deployment.apt +++ b/src/site/apt/file-deployment.apt @@ -3,7 +3,7 @@ ------ Allan Ramirez ------ - July 2006 + 2006-07-14 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/project-deployment.apt b/src/site/apt/project-deployment.apt index e74a029a..c462e702 100644 --- a/src/site/apt/project-deployment.apt +++ b/src/site/apt/project-deployment.apt @@ -3,7 +3,7 @@ ------ Allan Ramirez ------ - July 2006 + 2006-07-14 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt index 8eafe93d..2a222ff7 100644 --- a/src/site/apt/usage.apt +++ b/src/site/apt/usage.apt @@ -4,7 +4,7 @@ Jerome Lacoste John Casey ------ - January 29 2006 + 2006-01-29 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one From 539fcc7820b55eb8e85ff1c702a4c936a6eb7ab7 Mon Sep 17 00:00:00 2001 From: Alex Shesterov Date: Thu, 4 Oct 2018 23:31:17 +0200 Subject: [PATCH 076/153] [MDEPLOY-245] - Remove the remnants of the obsolete `updateReleaseInfo` parameter. --- src/it/3rd-party-jar-with-extras/test.properties | 1 - src/it/3rd-party-jar-without-pom/test.properties | 1 - src/it/3rd-party-pom-with-extras/test.properties | 1 - src/it/attach-release-jar/pom.xml | 1 - src/it/external-release-jar/test.properties | 1 - src/it/release-jar/pom.xml | 1 - src/it/release-pom/pom.xml | 1 - 7 files changed, 7 deletions(-) diff --git a/src/it/3rd-party-jar-with-extras/test.properties b/src/it/3rd-party-jar-with-extras/test.properties index c2b57c06..6fd20939 100644 --- a/src/it/3rd-party-jar-with-extras/test.properties +++ b/src/it/3rd-party-jar-with-extras/test.properties @@ -17,7 +17,6 @@ file = test-0.1.jar url = file:target/repo -updateReleaseInfo = true groupId = org.apache.maven.its.deploy.tpjwop artifactId = test version = 1.0 diff --git a/src/it/3rd-party-jar-without-pom/test.properties b/src/it/3rd-party-jar-without-pom/test.properties index 02fcbcf6..269719d4 100644 --- a/src/it/3rd-party-jar-without-pom/test.properties +++ b/src/it/3rd-party-jar-without-pom/test.properties @@ -17,7 +17,6 @@ file = test-0.1.jar url = file:target/repo -updateReleaseInfo = true groupId = org.apache.maven.its.deploy.tpjwop artifactId = test version = 1.0 diff --git a/src/it/3rd-party-pom-with-extras/test.properties b/src/it/3rd-party-pom-with-extras/test.properties index 3d13f162..5c4d1159 100644 --- a/src/it/3rd-party-pom-with-extras/test.properties +++ b/src/it/3rd-party-pom-with-extras/test.properties @@ -17,7 +17,6 @@ file = test-0.1.pom url = file:target/repo -updateReleaseInfo = true groupId = org.apache.maven.its.deploy.tppwoc artifactId = test version = 1.0 diff --git a/src/it/attach-release-jar/pom.xml b/src/it/attach-release-jar/pom.xml index 3d2039eb..4557d222 100644 --- a/src/it/attach-release-jar/pom.xml +++ b/src/it/attach-release-jar/pom.xml @@ -33,7 +33,6 @@ under the License. true - true diff --git a/src/it/external-release-jar/test.properties b/src/it/external-release-jar/test.properties index 1be2c630..c8deb502 100644 --- a/src/it/external-release-jar/test.properties +++ b/src/it/external-release-jar/test.properties @@ -18,4 +18,3 @@ file = test-0.1.jar pomFile = test-0.1.pom url = file:target/repo -updateReleaseInfo = true diff --git a/src/it/release-jar/pom.xml b/src/it/release-jar/pom.xml index 51fe2487..af72e7d7 100644 --- a/src/it/release-jar/pom.xml +++ b/src/it/release-jar/pom.xml @@ -33,7 +33,6 @@ under the License. true - true diff --git a/src/it/release-pom/pom.xml b/src/it/release-pom/pom.xml index 526fb37c..d7bff31b 100644 --- a/src/it/release-pom/pom.xml +++ b/src/it/release-pom/pom.xml @@ -33,7 +33,6 @@ under the License. true - true From 4b1a9920808a6d34c844c7f932118c9200c32543 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 10 Mar 2019 23:42:45 +0100 Subject: [PATCH 077/153] [MDEPLOY-247] - Version 3.0.0-M1 breaks deploy using alt*DeploymentRepository with old syntax on Windows - Enhanced docs --- .../org/apache/maven/plugins/deploy/DeployMojo.java | 10 ++++++++-- src/site/apt/index.apt.vm | 11 ++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) 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 75918ac7..5953d6e2 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -101,7 +101,10 @@ public class DeployMojo /** * The alternative repository to use when the project has a snapshot version. - * + * + * Note: In version 2, the format was id::layout::url, but since 3.0.0 the layout part has been + * removed because Maven 3 only supports default (ie. Maven 2) layout and not legacy + * (Maven 1) layout. * @since 2.8 * @see DeployMojo#altDeploymentRepository */ @@ -110,7 +113,10 @@ public class DeployMojo /** * The alternative repository to use when the project has a final version. - * + * + * Note: In version 2, the format was id::layout::url, but since 3.0.0 the layout part has been + * removed because Maven 3 only supports default (ie. Maven 2) layout and not legacy + * (Maven 1) layout. * @since 2.8 * @see DeployMojo#altDeploymentRepository */ diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index c91364d6..a23f6a0e 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -80,7 +80,16 @@ ${project.name} 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: <<>> + The new format is: <<>> + [] As of Maven 3, snapshot artifacts will always be deployed using a timestamped version. From 790b5633e68cd0203818d8c87e67414d00b9f663 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Thu, 27 Dec 2018 13:45:15 +0100 Subject: [PATCH 078/153] [MDEPLOY-248] - Update maven-artifact-transfer from 0.10.0 to 0.11.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b006e455..cd84a638 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ under the License. org.apache.maven.shared maven-artifact-transfer - 0.10.0 + 0.11.0 From 0900d06cd019925bc70730ac960e72fcf1223b83 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 10 Mar 2019 23:30:58 +0100 Subject: [PATCH 079/153] [MDEPLOY-243] - Remove JIRA report from generated site --- pom.xml | 25 ------------------------- src/site/site.xml | 1 - 2 files changed, 26 deletions(-) diff --git a/pom.xml b/pom.xml index cd84a638..3a62f501 100644 --- a/pom.xml +++ b/pom.xml @@ -200,30 +200,5 @@ under the License. - - reporting - - - - org.apache.maven.plugins - maven-changes-plugin - - - Type,Key,Summary,Assignee,Status,Resolution,Fix Version - true - Closed - Type,Key - - - - - jira-report - - - - - - - diff --git a/src/site/site.xml b/src/site/site.xml index 50bd8869..d5762ede 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -52,7 +52,6 @@ under the License. - From 54c0de7a88d5bf8d03ca4440963123ce1d02caa6 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 17 Mar 2019 13:03:11 +0100 Subject: [PATCH 080/153] [MDEPLOY-253] - Upgrade plexus-utils to 3.2.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3a62f501..3d48158f 100644 --- a/pom.xml +++ b/pom.xml @@ -110,7 +110,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.1.0 + 3.2.0 org.apache.maven.plugin-testing From 8f5aae8acde646670de7890e6ed1ab4be72751ce Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 17 Mar 2019 13:43:17 +0100 Subject: [PATCH 081/153] Removed Subversion lagacy --- .../org/apache/maven/plugins/deploy/AbstractDeployMojo.java | 2 +- src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java | 1 - .../org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java | 1 - src/test/java/org/apache/maven/plugins/deploy/Utils.java | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) 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 c0efde10..f933e36c 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -29,7 +29,7 @@ import org.apache.maven.plugins.annotations.Parameter; /** - * @version $Id$ + * Abstract class for Deploy mojo's. */ public abstract class AbstractDeployMojo extends AbstractMojo 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 5953d6e2..0f830e63 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -46,7 +46,6 @@ * * @author Emmanuel Venisse * @author John Casey (refactoring only) - * @version $Id$ */ @Mojo( name = "deploy", defaultPhase = LifecyclePhase.DEPLOY, threadSafe = true ) public class DeployMojo 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 4418853d..6131f79d 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java @@ -30,7 +30,6 @@ /** * @author Jerome Lacoste - * @version $Id$ */ public class DeployFileMojoUnitTest extends TestCase diff --git a/src/test/java/org/apache/maven/plugins/deploy/Utils.java b/src/test/java/org/apache/maven/plugins/deploy/Utils.java index 09949a65..4df74424 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/Utils.java +++ b/src/test/java/org/apache/maven/plugins/deploy/Utils.java @@ -32,7 +32,6 @@ * A utility class to assist testing. * * @author Benjamin Bentmann - * @version $Id$ */ public class Utils { From 0331156b6e59ddc3d383073f194d6e4339e6c36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 5 May 2019 16:30:48 +0200 Subject: [PATCH 082/153] [MDEPLOY-207] removed forgotten layout --- src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0f830e63..2b8652db 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -263,7 +263,7 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym if ( repo == null ) { String msg = "Deployment failed: repository element was not specified in the POM inside" - + " distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter"; + + " distributionManagement element or in -DaltDeploymentRepository=id::url parameter"; throw new MojoExecutionException( msg ); } From 157b624f271cd2dfb6414bc1aa6e2e12695adabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 5 May 2019 16:42:28 +0200 Subject: [PATCH 083/153] improved documentation --- .../maven/plugins/deploy/DeployMojo.java | 22 +++++++++---------- .../apt/examples/deploy-network-issues.apt | 18 ++++++++++----- 2 files changed, 23 insertions(+), 17 deletions(-) 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 2b8652db..0953ff64 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -82,8 +82,8 @@ public class DeployMojo private boolean deployAtEnd; /** - * Specifies an alternative repository to which the project artifacts should be deployed ( other than those - * specified in <distributionManagement> ).
+ * Specifies an alternative repository to which the project artifacts should be deployed (other than those specified + * in <distributionManagement>).
* Format: id::url *
*
id
@@ -91,9 +91,9 @@ public class DeployMojo *
url
*
The location of the repository
*
- * Note: In version 2, the format was id::layout::url, but since 3.0.0 the layout part has been - * removed because Maven 3 only supports default (ie. Maven 2) layout and not legacy - * (Maven 1) layout. + * Note: In version 2.x, the format was id::layout::url where layout + * could be default (ie. Maven 2) or legacy (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" ) private String altDeploymentRepository; @@ -101,9 +101,9 @@ public class DeployMojo /** * The alternative repository to use when the project has a snapshot version. * - * Note: In version 2, the format was id::layout::url, but since 3.0.0 the layout part has been - * removed because Maven 3 only supports default (ie. Maven 2) layout and not legacy - * (Maven 1) layout. + * Note: In version 2.x, the format was id::layout::url where layout + * could be default (ie. Maven 2) or legacy (ie. Maven 1), but since 3.0.0 the layout part + * has been removed because Maven 3 only supports Maven 2 repository layout. * @since 2.8 * @see DeployMojo#altDeploymentRepository */ @@ -113,9 +113,9 @@ public class DeployMojo /** * The alternative repository to use when the project has a final version. * - * Note: In version 2, the format was id::layout::url, but since 3.0.0 the layout part has been - * removed because Maven 3 only supports default (ie. Maven 2) layout and not legacy - * (Maven 1) layout. + * Note: In version 2.x, the format was id::layout::url where layout + * could be default (ie. Maven 2) or legacy (ie. Maven 1), but since 3.0.0 the layout part + * has been removed because Maven 3 only supports Maven 2 repository layout. * @since 2.8 * @see DeployMojo#altDeploymentRepository */ diff --git a/src/site/apt/examples/deploy-network-issues.apt b/src/site/apt/examples/deploy-network-issues.apt index 059f4eb8..10cbdee4 100644 --- a/src/site/apt/examples/deploy-network-issues.apt +++ b/src/site/apt/examples/deploy-network-issues.apt @@ -60,7 +60,7 @@ Deploying With Network Issues When the network is really not consistent, a deeper strategy is to deploy in 2 steps: - 1. <<>> to a local <<>> directory during the build, + 1. <<>> to a local directory during the build, for example <<>>, 2. then copy from the local area to the target remote repository, retrying as much as necessary. @@ -75,9 +75,13 @@ Deploying With Network Issues mvn deploy -DaltDeploymentRepository=local::file:./target/staging-deploy +----+ - Notice: with maven-deploy-plugin 2.x, the parameter format was <<>> + or for older 2.x version of maven-deploy-plugin - Of course, if you want can configure the repository in your <<>> if you want to go from a temporary strategy ++----+ +mvn deploy -DaltDeploymentRepository=local::default::file:./target/staging-deploy ++----+ + + Of course, you can configure the repository in your <<>> if you want to go from a temporary strategy to the general strategy. ** Copying from Local Directory to Target Remote Repository @@ -90,13 +94,15 @@ mvn deploy -DaltDeploymentRepository=local::file:./target/staging-deploy like a staging repository provided by a repository manager. It can be invoked fully from command line (renaming <<<-Dwagon.>>> with <<>> when - {{{https://github.com/mojohaus/wagon-maven-plugin/pull/26}2.0.1 will be released}}): + {{{https://github.com/mojohaus/wagon-maven-plugin/pull/26}Wagon Maven Plugin 2.0.1 will be released}}): +----+ mvn org.codehaus.mojo:wagon-maven-plugin:2.0.0:merge-maven-repos \ -Dwagon.source=file:./target/staging-deploy \ -Dwagon.target=https://... \ -Dwagon.=id +# or once wagon-maven-plugin 2.0.1 is released: + -Dwagon.targetId=id +----+ or more simply with <<>> with configuration in <<>>: @@ -112,8 +118,8 @@ mvn org.codehaus.mojo:wagon-maven-plugin:2.0.0:merge-maven-repos \ 2.0.0 file:./target/staging-deploy - https://... - id + ${project.distributionManagement.repository.url} + ${project.distributionManagement.repository.id} From fc905d5399ad2d02c51b6b0846387da6eb2106b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Sat, 25 May 2019 09:47:51 +0200 Subject: [PATCH 084/153] (doc) - fix some typos --- src/site/apt/examples/deploying-with-classifiers.apt.vm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/site/apt/examples/deploying-with-classifiers.apt.vm b/src/site/apt/examples/deploying-with-classifiers.apt.vm index ca4b5fa3..c9cc4cf2 100644 --- a/src/site/apt/examples/deploying-with-classifiers.apt.vm +++ b/src/site/apt/examples/deploying-with-classifiers.apt.vm @@ -28,13 +28,13 @@ Deploy an artifact with classifier - Beside the main artifact there can be additional files which are attached to the Maven project. Such attached filed can be recognized and accessed by their classifier. + Beside the main artifact there can be additional files which are attached to the Maven project. Such attached files can be recognized and accessed by their classifier. - For example: from the following artifact names, the classifier is be located between the version and extension name of the artifact. + For example: from the following artifact names, the classifier is located between the version and extension name of the artifact. * <<>> the main jar which contains classes compiled without {{{http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#debug}debugging}} information (such as linenumbers) - * <<>> the classified jar which contains classes compiled with {{{http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#debug}debugging}} information, so will be smaller + * <<>> the classified jar which contains classes compiled with {{{http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#debug}debugging}} information, so will be larger * <<>> a pdf which contains an export of the site documentation. From 088e0ebca07d836accf0725f9a21d281ac20cfc3 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sat, 25 May 2019 13:06:44 +0200 Subject: [PATCH 085/153] consistenly changed to https instead of http. --- src/site/apt/examples/deploy-network-issues.apt | 4 ++-- src/site/apt/examples/deploy-ssh-external.apt | 2 +- .../apt/examples/deploying-with-classifiers.apt.vm | 4 ++-- src/site/apt/index.apt.vm | 2 +- src/site/apt/usage.apt | 2 +- src/site/site.xml | 10 +++++----- src/site/xdoc/download.xml.vm | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/site/apt/examples/deploy-network-issues.apt b/src/site/apt/examples/deploy-network-issues.apt index 10cbdee4..90718919 100644 --- a/src/site/apt/examples/deploy-network-issues.apt +++ b/src/site/apt/examples/deploy-network-issues.apt @@ -86,10 +86,10 @@ mvn deploy -DaltDeploymentRepository=local::default::file:./target/staging-deplo ** Copying from Local Directory to Target Remote Repository - <<>>'s {{{http://www.mojohaus.org/wagon-maven-plugin/merge-maven-repos-mojo.html}<<>> goal}} + <<>>'s {{{https://www.mojohaus.org/wagon-maven-plugin/merge-maven-repos-mojo.html}<<>> goal}} provides a mechanism to copy from one remote repository to the other, while merging repository metadata. - <<>>'s {{{http://www.mojohaus.org/wagon-maven-plugin/upload-mojo.html}<<>> goal}} + <<>>'s {{{https://www.mojohaus.org/wagon-maven-plugin/upload-mojo.html}<<>> goal}} will do the same without taking care of repository metadata: use it if you have an empty repository as target, like a staging repository provided by a repository manager. diff --git a/src/site/apt/examples/deploy-ssh-external.apt b/src/site/apt/examples/deploy-ssh-external.apt index 4536d799..99849c92 100644 --- a/src/site/apt/examples/deploy-ssh-external.apt +++ b/src/site/apt/examples/deploy-ssh-external.apt @@ -122,4 +122,4 @@ mvn deploy <> If you are using Putty it will expect the private key to be in the <<>> format and not the standard format so make sure you use <<>> to convert your openssh format key to <<>> format or generate another one. Windows users can find the Putty tools on the - {{{http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html}PuTTY Download Page}}. + {{{https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html}PuTTY Download Page}}. diff --git a/src/site/apt/examples/deploying-with-classifiers.apt.vm b/src/site/apt/examples/deploying-with-classifiers.apt.vm index c9cc4cf2..ce3cb225 100644 --- a/src/site/apt/examples/deploying-with-classifiers.apt.vm +++ b/src/site/apt/examples/deploying-with-classifiers.apt.vm @@ -32,9 +32,9 @@ Deploy an artifact with classifier For example: from the following artifact names, the classifier is located between the version and extension name of the artifact. - * <<>> the main jar which contains classes compiled without {{{http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#debug}debugging}} information (such as linenumbers) + * <<>> the main jar which contains classes compiled without {{{https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#debug}debugging}} information (such as linenumbers) - * <<>> the classified jar which contains classes compiled with {{{http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#debug}debugging}} information, so will be larger + * <<>> the classified jar which contains classes compiled with {{{https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#debug}debugging}} information, so will be larger * <<>> a pdf which contains an export of the site documentation. diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index a23f6a0e..87eb032c 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -110,7 +110,7 @@ ${project.name} entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{./source-repository.html}source repository}} and will find supplementary information in the - {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. + {{{https://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt index 2a222ff7..45333a5a 100644 --- a/src/site/apt/usage.apt +++ b/src/site/apt/usage.apt @@ -84,7 +84,7 @@ Usage +---+ Please see the article about - {{{http://maven.apache.org/guides/mini/guide-encryption.html}Password Encryption}} + {{{https://maven.apache.org/guides/mini/guide-encryption.html}Password Encryption}} for instructions on how to avoid clear text passwords in the <<>>. Once you've configured your repository deployment information correctly diff --git a/src/site/site.xml b/src/site/site.xml index d5762ede..1674c5dc 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -23,13 +23,13 @@ under the License. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> - http://maven.apache.org/images/apache-maven-project.png - http://www.apache.org/ + https://maven.apache.org/images/apache-maven-project.png + https://www.apache.org/ - http://maven.apache.org/images/maven-logo-black-on-white.png - http://maven.apache.org/ + https://maven.apache.org/images/maven-logo-black-on-white.png + https://maven.apache.org/ org.apache.maven.skins @@ -53,7 +53,7 @@ under the License. - +
diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index 3f710359..f1cd28ed 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -33,11 +33,11 @@ under the License. hours to reach all mirrors.

In order to guard against corrupted downloads/installations, it is highly recommended to - verify the signature + verify the signature of the release bundles against the public KEYS used by the Apache Maven developers.

-

${project.name} is distributed under the Apache License, version 2.0.

+

${project.name} is distributed under the Apache License, version 2.0.

We strongly encourage our users to configure a Maven repository mirror closer to their location, please read How to Use Mirrors for Repositories.

@@ -85,7 +85,7 @@ under the License.

You may also consult the - complete list of + complete list of mirrors.

@@ -117,7 +117,7 @@ under the License. -

Older non-recommended releases can be found on our archive site.

+

Older non-recommended releases can be found on our archive site.

From 1516090b561f0b4adadd06dad96e7456ee0ca456 Mon Sep 17 00:00:00 2001 From: maffe Date: Wed, 28 Aug 2019 16:41:40 +0200 Subject: [PATCH 086/153] Rename deploying-with-customed-pom.apt.vm to deploying-with-customized-pom.apt.vm --- ...customed-pom.apt.vm => deploying-with-customized-pom.apt.vm} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/site/apt/examples/{deploying-with-customed-pom.apt.vm => deploying-with-customized-pom.apt.vm} (99%) diff --git a/src/site/apt/examples/deploying-with-customed-pom.apt.vm b/src/site/apt/examples/deploying-with-customized-pom.apt.vm similarity index 99% rename from src/site/apt/examples/deploying-with-customed-pom.apt.vm rename to src/site/apt/examples/deploying-with-customized-pom.apt.vm index 1773a94e..9e6654a8 100644 --- a/src/site/apt/examples/deploying-with-customed-pom.apt.vm +++ b/src/site/apt/examples/deploying-with-customized-pom.apt.vm @@ -43,4 +43,4 @@ mvn ${project.groupId}:${project.artifactId}:${project.version}:deploy-file -Dur <>: By using the fully qualified path of a goal, you're ensured to be using the preferred version of the maven-deploy-plugin. When using <<>> its version depends on its specification in the pom or the version of Apache Maven. - \ No newline at end of file + From f4df7e694230882710792053022858b7a94d8165 Mon Sep 17 00:00:00 2001 From: maffe Date: Wed, 28 Aug 2019 16:44:11 +0200 Subject: [PATCH 087/153] =?UTF-8?q?o=20typo:=20customed=20=E2=86=92=20cust?= =?UTF-8?q?omized?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/site/apt/file-deployment.apt | 4 ++-- src/site/apt/index.apt.vm | 2 +- src/site/site.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/site/apt/file-deployment.apt b/src/site/apt/file-deployment.apt index 47758973..ca21471b 100644 --- a/src/site/apt/file-deployment.apt +++ b/src/site/apt/file-deployment.apt @@ -32,7 +32,7 @@ File Deployment * {{{./examples/disabling-generic-pom.html}Disable the generation of pom}} - * {{{./examples/deploying-with-customed-pom.html}Deploy an artifact with a customized pom}} + * {{{./examples/deploying-with-customized-pom.html}Deploy an artifact with a customized pom}} * {{{./examples/deploying-with-classifiers.html}Deploy an artifact with classifier}} @@ -40,4 +40,4 @@ File Deployment * {{{./examples/deploying-in-legacy-layout.html}Deploy an artifact in legacy layout}} - [] \ No newline at end of file + [] diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 87eb032c..b64c4c0e 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -131,7 +131,7 @@ ${project.name} * {{{./examples/disabling-generic-pom.html}Disable the generation of pom}} - * {{{./examples/deploying-with-customed-pom.html}Deploy an artifact with a customed pom}} + * {{{./examples/deploying-with-customized-pom.html}Deploy an artifact with a customized pom}} * {{{./examples/deploying-with-classifiers.html}Deploy an artifact with classifier}} diff --git a/src/site/site.xml b/src/site/site.xml index 1674c5dc..f4ccb71a 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -64,7 +64,7 @@ under the License. - + From c7ad6850656e9489b28be28d501f681128cccda3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 27 Oct 2019 18:22:23 +0100 Subject: [PATCH 088/153] added a menu entry for the new "deploy with network issues" doc --- src/site/site.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/site/site.xml b/src/site/site.xml index f4ccb71a..6541e2e3 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -59,7 +59,8 @@ under the License. - + + From 08834920d4f80cb34886dbb2c7e11fa8b13dc6f9 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 8 Dec 2019 12:27:35 +0100 Subject: [PATCH 089/153] [MDEPLOY-263] - Add .asf.yaml --- .asf.yaml | 10 ++++++++++ pom.xml | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .asf.yaml diff --git a/.asf.yaml b/.asf.yaml new file mode 100644 index 00000000..5feedc51 --- /dev/null +++ b/.asf.yaml @@ -0,0 +1,10 @@ +# see https://s.apache.org/asfyaml +github: + description: "Apache Maven Deploy Plugin" + homepage: https://maven.apache.org/plugins/maven-deploy-plugin + labels: + - java + - build-management + - apache-maven + - maven-plugins + - maven-deploy-plugin diff --git a/pom.xml b/pom.xml index 3d48158f..dcb7af92 100644 --- a/pom.xml +++ b/pom.xml @@ -163,7 +163,21 @@ under the License. Hermann Josef Hill - + + + + + + org.apache.rat + apache-rat-plugin + + + .asf.yaml + + + + + run-its From b58ff3c9e5cf80948d0f9180a30132c8871192ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Tue, 7 Apr 2020 23:12:46 +0200 Subject: [PATCH 090/153] [MDEPLOY-269] make build Reproducible --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dcb7af92..0809c55e 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 33 + 34 ../../pom/maven/maven-plugins/pom.xml @@ -65,6 +65,7 @@ under the License. 3.0 7 + 2020-04-07T21:04:00Z From 91bfa2eff06552ac66827be67c6efa1ef1499be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 11 Apr 2020 16:39:55 +0200 Subject: [PATCH 091/153] fixed link to mailing lists --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 438ae424..d88ab75b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> -Contributing to Apache Deploy Plugin +Contributing to [Apache Maven Deploy Plugin](https://maven.apache.org/plugins/maven-deploy-plugin/) ====================== [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] @@ -35,7 +35,7 @@ Getting Started + Make sure you have a [JIRA account](https://issues.apache.org/jira/). + Make sure you have a [GitHub account](https://github.com/signup/free). + If you're planning to implement a new feature, it makes sense to discuss your changes - on the [dev list](https://maven.apache.org/mail-lists.html) first. + on the [dev list][ml-list]] first. This way you can make sure you're not wasting your time on something that isn't considered to be in Apache Maven's scope. + Submit a ticket for your issue, assuming one does not already exist. @@ -46,7 +46,7 @@ Getting Started Making and Submitting Changes -------------- -We accept Pull Requests via GitHub. The [developer mailing list][dev-ml-list] is the +We accept Pull Requests via GitHub. The [developer mailing list][ml-list] is the main channel of communication for contributors. There are some guidelines which will make applying PRs easier for us: + Create a topic branch from where you want to base your work (this is usually the master branch). @@ -89,7 +89,7 @@ Additional Resources + #Maven IRC channel on freenode.org [license]: https://www.apache.org/licenses/LICENSE-2.0 -[dev-ml-list]: https://maven.apache.org/mailing-lists.html +[ml-list]: https://maven.apache.org/mailing-lists.html [code-style]: https://maven.apache.org/developers/conventions/code.html [cla]: https://www.apache.org/licenses/#clas [maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index From 67aa82bc6f12fe5f37ad32bb6695d21910d403f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 11 Apr 2020 21:30:18 +0200 Subject: [PATCH 092/153] added ASF Jira badge --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d88ab75b..d5712059 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Contributing to [Apache Maven Deploy Plugin](https://maven.apache.org/plugins/maven-deploy-plugin/) ====================== +[![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MDEPLOY.json)][jira] [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-deploy-plugin.svg?label=Maven%20Central)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.apache.maven.plugins%22%20AND%20a%3A%22maven-deploy-plugin%22) [![Jenkins Status](https://img.shields.io/jenkins/s/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?style=flat-square)][build] @@ -81,13 +82,14 @@ Additional Resources -------------------- + [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch) -+ [Apache Maven Help JIRA project page](https://issues.apache.org/jira/projects/MDEPLOY/) ++ [Apache Maven Deploy JIRA project page][jira] + [Contributor License Agreement][cla] + [General GitHub documentation](https://help.github.com/) + [GitHub pull request documentation](https://help.github.com/send-pull-requests/) + [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject) + #Maven IRC channel on freenode.org +[jira]: https://issues.apache.org/jira/projects/MDEPLOY/ [license]: https://www.apache.org/licenses/LICENSE-2.0 [ml-list]: https://maven.apache.org/mailing-lists.html [code-style]: https://maven.apache.org/developers/conventions/code.html From 5378b4936866a927260b893dfd81abb2f4ceb1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 12 Apr 2020 15:14:01 +0200 Subject: [PATCH 093/153] fixed broken links (MPIR 3) --- src/site/apt/index.apt.vm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index b64c4c0e..da65261e 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -100,16 +100,16 @@ ${project.name} specific use cases are described in the examples given below. In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel - free to contact the {{{./mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could + free to contact the {{{./mailing-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching - the {{{./mail-lists.html}mail archive}}. + the {{{./mailing-lists.html}mail archive}}. If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our - {{{./issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your + {{{./issue-management.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our - {{{./source-repository.html}source repository}} and will find supplementary information in the + {{{./scm.html}source repository}} and will find supplementary information in the {{{https://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples From 02ec0cbfccc47b7a94463dd8cb42e5863c807963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 13 Apr 2020 22:20:49 +0200 Subject: [PATCH 094/153] README improvement --- CONTRIBUTING.md | 91 ------------------------------------------------- README.md | 6 ++-- 2 files changed, 3 insertions(+), 94 deletions(-) delete mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index c75ccce1..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,91 +0,0 @@ - -Contributing to Apache Maven Help Plugin -====================== - -You have found a bug or you have an idea for a cool new feature? Contributing -code is a great way to give something back to the open source community. Before -you dig right into the code, there are a few guidelines that we need -contributors to follow so that we can have a chance of keeping on top of -things. - -Some of the ideas are documented in the [Maven Wiki][maven-wiki] -which might be interesting to read and for further discussion. - -Getting Started ---------------- - -+ Make sure you have a [JIRA account](https://issues.apache.org/jira/). -+ Make sure you have a [GitHub account](https://github.com/signup/free). -+ If you're planning to implement a new feature, it makes sense to discuss your changes - on the [dev list](https://maven.apache.org/mail-lists.html) first. - This way you can make sure you're not wasting your time on something that isn't - considered to be in Apache Maven's scope. -+ Submit a ticket for your issue, assuming one does not already exist. - + Clearly describe the issue, including steps to reproduce when it is a bug. - + Make sure you fill in the earliest version that you know has the issue. -+ Fork the repository on GitHub. - -Making and Submitting Changes --------------- - -We accept Pull Requests via GitHub. The [developer mailing list][dev-ml-list] is the -main channel of communication for contributors. -There are some guidelines which will make applying PRs easier for us: -+ Create a topic branch from where you want to base your work (this is usually the master branch). - Push your changes to a topic branch in your fork of the repository. -+ Make commits of logical units. -+ Respect the original code style: by using the same [codestyle][code-style], - patches should only highlight the actual difference, not being disturbed by any formatting issues: - + Only use spaces for indentation. - + Create minimal diffs - disable on save actions like reformat source code or organize imports. - If you feel the source code should be reformatted, create a separate PR for this change. - + Check for unnecessary whitespace with `git diff --check` before committing. -+ Make sure your commit messages are in the proper format. Your commit message should contain the key of the JIRA issue. -``` -[MDEPLOY-XXX] - Subject of the JIRA Ticket - Optional supplemental description. -``` -+ Make sure you have added the necessary tests (JUnit/IT) for your changes. -+ Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken. -+ Submit a pull request to the repository in the Apache organization. -+ Update your JIRA ticket and include a link to the pull request in the ticket. - -If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla]. - -Making Trivial Changes ----------------------- - -For changes of a trivial nature to comments and documentation, it is not always -necessary to create a new ticket in JIRA. In this case, it is appropriate to -start the first line of a commit with '(doc)' instead of a ticket number. - -Additional Resources --------------------- - -+ [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch) -+ [Apache Maven Help JIRA project page](https://issues.apache.org/jira/projects/MDEPLOY/) -+ [Contributor License Agreement][cla] -+ [General GitHub documentation](https://help.github.com/) -+ [GitHub pull request documentation](https://help.github.com/send-pull-requests/) -+ [Apache Maven Twitter Account](https://twitter.com/ASFMavenProject) -+ #Maven IRC channel on freenode.org - -[dev-ml-list]: https://maven.apache.org/mailing-lists.html -[code-style]: https://maven.apache.org/developers/conventions/code.html -[cla]: https://www.apache.org/licenses/#clas -[maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index diff --git a/README.md b/README.md index d5712059..25586ec7 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ Contributing to [Apache Maven Deploy Plugin](https://maven.apache.org/plugins/ma [![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MDEPLOY.json)][jira] [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] -[![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-deploy-plugin.svg?label=Maven%20Central)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.apache.maven.plugins%22%20AND%20a%3A%22maven-deploy-plugin%22) -[![Jenkins Status](https://img.shields.io/jenkins/s/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?style=flat-square)][build] -[![Jenkins tests](https://img.shields.io/jenkins/t/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?style=flat-square)][test-results] +[![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-deploy-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-deploy-plugin) +[![Jenkins Status](https://img.shields.io/jenkins/s/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][build] +[![Jenkins tests](https://img.shields.io/jenkins/t/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][test-results] You have found a bug or you have an idea for a cool new feature? Contributing From 4291f5ee3bffe51292a94884f28fc9549aff8438 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Fri, 15 May 2020 14:57:44 +1000 Subject: [PATCH 095/153] [MDEPLOY-267] change type of skip parameter to String with possible values releases,snapshots,true default will be false Signed-off-by: olivier lamy --- src/it/skip-release-jar/pom.xml | 83 +++++++++++++++++++ src/it/skip-release-jar/setup.bsh | 33 ++++++++ src/it/skip-release-jar/verify.bsh | 40 +++++++++ src/it/skip-snapshot-jar/pom.xml | 83 +++++++++++++++++++ src/it/skip-snapshot-jar/setup.bsh | 33 ++++++++ src/it/skip-snapshot-jar/verify.bsh | 46 ++++++++++ .../maven/plugins/deploy/DeployMojo.java | 15 +++- .../maven/plugins/deploy/DeployMojoTest.java | 2 +- 8 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 src/it/skip-release-jar/pom.xml create mode 100644 src/it/skip-release-jar/setup.bsh create mode 100644 src/it/skip-release-jar/verify.bsh create mode 100644 src/it/skip-snapshot-jar/pom.xml create mode 100644 src/it/skip-snapshot-jar/setup.bsh create mode 100644 src/it/skip-snapshot-jar/verify.bsh diff --git a/src/it/skip-release-jar/pom.xml b/src/it/skip-release-jar/pom.xml new file mode 100644 index 00000000..3e57a45e --- /dev/null +++ b/src/it/skip-release-jar/pom.xml @@ -0,0 +1,83 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.srj + test + 1.0 + jar + + + Tests the deployment of a simple release JAR has been skipped. + + + + true + + + + + it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + releases + + + + org.apache.maven.plugins + maven-install-plugin + 2.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.3.1 + + + + + diff --git a/src/it/skip-release-jar/setup.bsh b/src/it/skip-release-jar/setup.bsh new file mode 100644 index 00000000..bb1b4e86 --- /dev/null +++ b/src/it/skip-release-jar/setup.bsh @@ -0,0 +1,33 @@ +/* + * 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.codehaus.plexus.util.*; + +File file = new File( localRepositoryPath, "org/apache/maven/its/deploy/srj" ); +System.out.println( "Deleting " + file ); +FileUtils.deleteDirectory( file ); + +file = new File( basedir, "target/repo" ); +System.out.println( "Deleting " + file ); +FileUtils.deleteDirectory( file ); + +return true; diff --git a/src/it/skip-release-jar/verify.bsh b/src/it/skip-release-jar/verify.bsh new file mode 100644 index 00000000..6fe57019 --- /dev/null +++ b/src/it/skip-release-jar/verify.bsh @@ -0,0 +1,40 @@ +/* + * 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.*; + +String[] paths = +{ + "org/apache/maven/its/deploy/srj/test/maven-metadata.xml", + "org/apache/maven/its/deploy/srj/test/1.0/test-1.0.pom", + "org/apache/maven/its/deploy/srj/test/1.0/test-1.0.jar", +}; + +for ( String path : paths ) +{ + File file = new File( new File( basedir, "target/repo" ), path ); + System.out.println( "Checking for existence of " + file ); + if ( file.isFile() ) + { + throw new FileNotFoundException( "File has been deployed: " + file.getAbsolutePath() ); + } +} + +return true; diff --git a/src/it/skip-snapshot-jar/pom.xml b/src/it/skip-snapshot-jar/pom.xml new file mode 100644 index 00000000..a58a66fa --- /dev/null +++ b/src/it/skip-snapshot-jar/pom.xml @@ -0,0 +1,83 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.ssj + test + 1.0.0-SNAPSHOT + jar + + + Tests the deployment of a simple snapshot JAR has been skipped. + + + + true + + + + + it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + snapshots + + + + org.apache.maven.plugins + maven-install-plugin + 2.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.3.1 + + + + + diff --git a/src/it/skip-snapshot-jar/setup.bsh b/src/it/skip-snapshot-jar/setup.bsh new file mode 100644 index 00000000..f35751bf --- /dev/null +++ b/src/it/skip-snapshot-jar/setup.bsh @@ -0,0 +1,33 @@ +/* + * 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.codehaus.plexus.util.*; + +File file = new File( localRepositoryPath, "org/apache/maven/its/deploy/ssj" ); +System.out.println( "Deleting " + file ); +FileUtils.deleteDirectory( file ); + +file = new File( basedir, "target/repo" ); +System.out.println( "Deleting " + file ); +FileUtils.deleteDirectory( file ); + +return true; diff --git a/src/it/skip-snapshot-jar/verify.bsh b/src/it/skip-snapshot-jar/verify.bsh new file mode 100644 index 00000000..1c35d56b --- /dev/null +++ b/src/it/skip-snapshot-jar/verify.bsh @@ -0,0 +1,46 @@ +/* + * 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.*; + +String[] paths = +{ + "org/apache/maven/its/deploy/ssj/test/maven-metadata.xml", + "org/apache/maven/its/deploy/ssj/test/1.0.0-SNAPSHOT/test-1.0.0-SNAPSHOT.pom", + "org/apache/maven/its/deploy/ssj/test/1.0.0-SNAPSHOT/test-1.0.0-SNAPSHOT.jar", +}; + +for ( String path : paths ) +{ + File file = new File( new File( basedir, "target/repo" ), path ); + System.out.println( "Checking for existence of " + file ); + if ( file.isFile() ) + { + throw new IllegalStateException( "File has been deployed: " + file.getAbsolutePath() ); + } +} + +File directory = new File( new File( basedir, "target/repo" ), "org/apache/maven/its/deploy/ssj/test/1.0.0-SNAPSHOT/" ); +if ( directory.exists() ) +{ + throw new IllegalStateException( "directory exists: " + directory.getAbsolutePath() ); +} + +return true; 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 0953ff64..5bc471d7 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -124,11 +124,17 @@ public class DeployMojo /** * Set this to 'true' to bypass artifact deploy - * + * Since since 3.0.0-M2 it's not anymore a real boolean as it can have more than 2 values: + *
    + *
  • true: will skip as usual
  • + *
  • releases: will skip if current version of the project is a release
  • + *
  • snapshots: will skip if current version of the project is a snapshot
  • + *
  • any other values will be considered as false
  • + *
* @since 2.4 */ @Parameter( property = "maven.deploy.skip", defaultValue = "false" ) - private boolean skip; + private String skip = Boolean.FALSE.toString(); /** * Component used to deploy project. @@ -140,7 +146,10 @@ public void execute() throws MojoExecutionException, MojoFailureException { boolean addedDeployRequest = false; - if ( skip ) + if ( Boolean.parseBoolean( skip ) + || ( "releases".equals( skip ) && !ArtifactUtils.isSnapshot( project.getVersion() ) ) + || ( "snapshots".equals( skip ) && ArtifactUtils.isSnapshot( project.getVersion() ) ) + ) { getLog().info( "Skipping artifact deployment" ); } 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 6c6f9387..ee762ef4 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -271,7 +271,7 @@ public void testSkippingDeploy() assertEquals( "file", repo.getProtocol() ); assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() ); - setVariableValueToObject( mojo, "skip", Boolean.TRUE ); + setVariableValueToObject( mojo, "skip", Boolean.TRUE.toString() ); mojo.execute(); From ed06af05d224581a2cb952221d22862eb65026f1 Mon Sep 17 00:00:00 2001 From: Andrew McCallum <1956944+crewmanmud@users.noreply.github.com> Date: Wed, 18 Apr 2018 09:31:59 +0100 Subject: [PATCH 096/153] Remove dead link from examples --- src/site/apt/index.apt.vm | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index da65261e..81515002 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -135,8 +135,6 @@ ${project.name} * {{{./examples/deploying-with-classifiers.html}Deploy an artifact with classifier}} - * {{{./examples/disabling-timestamps-suffix.html}Disable timestamps suffix in an artifact}} - * {{{./examples/deploying-in-legacy-layout.html}Deploy an artifact in legacy layout}} [] From bc8aad86560b4f81c9fa40ea49e9f60a3107aa0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Fri, 28 Aug 2020 09:18:28 +0200 Subject: [PATCH 097/153] update ASF CI url --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 25586ec7..b5c65ebd 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ Contributing to [Apache Maven Deploy Plugin](https://maven.apache.org/plugins/ma [![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MDEPLOY.json)][jira] [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-deploy-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-deploy-plugin) -[![Jenkins Status](https://img.shields.io/jenkins/s/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][build] -[![Jenkins tests](https://img.shields.io/jenkins/t/https/builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][test-results] +[![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][build] +[![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][test-results] You have found a bug or you have an idea for a cool new feature? Contributing @@ -95,5 +95,5 @@ Additional Resources [code-style]: https://maven.apache.org/developers/conventions/code.html [cla]: https://www.apache.org/licenses/#clas [maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index -[test-results]: https://builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master/lastCompletedBuild/testReport/ -[build]: https://builds.apache.org/job/maven-box/job/maven-deploy-plugin/job/master/ +[test-results]: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master/lastCompletedBuild/testReport/ +[build]: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master/ From 10faef1ce1c58b3c103172220d8e7a7c51ca9af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 29 Aug 2020 09:50:52 +0200 Subject: [PATCH 098/153] update ASF CI url --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0809c55e..5e328349 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ under the License. Jenkins - https://builds.apache.org/job/maven-box/job/maven-deploy-plugin/ + https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/ From 538f484352f88d6f281830e8679a8b1085093992 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Tue, 13 Oct 2020 20:35:08 +0200 Subject: [PATCH 099/153] Bump junit from 4.12 to 4.13.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5e328349..94af8952 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,7 @@ under the License. junit junit - 4.12 + 4.13.1 test From 46a5f40d354204fb7ac9d8500579e400000848a7 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Sat, 12 Dec 2020 13:49:53 +0100 Subject: [PATCH 100/153] Add GH CI To validate PRs w/ running UTs and ITs --- .github/workflows/maven.yml | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 00000000..3fdac5f0 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,49 @@ +# 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: Java CI + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + fail-fast: false + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up cache for ~/.m2/repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: maven-${{ matrix.os }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + maven-${{ matrix.os }}- + + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Build with Maven + run: mvn -e -B -V clean verify -P run-its From 92d7e747c2228ed411ae6e9d1639401a6b8fe6cc Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 10 Dec 2020 14:14:16 +0100 Subject: [PATCH 101/153] [MDEPLOY-279] Missing validation of altDeploymentRepository mojo parameter This closes #12 --- .../maven/plugins/deploy/DeployMojo.java | 46 +++++- .../maven/plugins/deploy/DeployMojoTest.java | 137 +++++++++++++++++- 2 files changed, 174 insertions(+), 9 deletions(-) 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 5bc471d7..ab0c72b2 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -51,8 +51,9 @@ 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( "(.+?)::(.+)" ); /** * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready @@ -248,19 +249,48 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym { getLog().info( "Using alternate deployment repository " + altDeploymentRepo ); - Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( altDeploymentRepo ); + Matcher matcher = ALT_LEGACY_REPO_SYNTAX_PATTERN.matcher( altDeploymentRepo ); - if ( !matcher.matches() ) + if ( matcher.matches() ) { - throw new MojoFailureException( altDeploymentRepo, "Invalid syntax for repository.", - "Invalid syntax for alternative repository. Use \"id::url\"." ); + String id = matcher.group( 1 ).trim(); + String layout = matcher.group( 2 ).trim(); + String url = matcher.group( 3 ).trim(); + + if ( "default".equals( layout ) ) + { + throw new MojoFailureException( altDeploymentRepo, + "Invalid legacy syntax for repository.", + "Invalid legacy syntax for alternative repository. Use \"" + id + "::" + url + "\" instead." + ); + } + else + { + throw new MojoFailureException( 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." + ); + } } else { - String id = matcher.group( 1 ).trim(); - String url = matcher.group( 2 ).trim(); + matcher = ALT_REPO_SYNTAX_PATTERN.matcher( altDeploymentRepo ); + + if ( !matcher.matches() ) + { + throw new MojoFailureException( 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(); - repo = createDeploymentArtifactRepository( id, url ); + repo = createDeploymentArtifactRepository( id, url ); + } } } 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 ee762ef4..9a02b1c4 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -32,6 +32,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub; @@ -551,7 +552,141 @@ public void _testBasicDeployWithScpAsProtocol() FileUtils.deleteDirectory( sshFile ); } - + + public void testLegacyAltDeploymentRepositoryWithDefaultLayout() + throws Exception + { + DeployMojo mojo = spy( new DeployMojo() ); + + ArtifactRepository repository = mock( ArtifactRepository.class ); + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" + ) ).thenReturn( repository ); + + project.setVersion( "1.0-SNAPSHOT" ); + + ProjectDeployerRequest pdr = + new ProjectDeployerRequest() + .setProject( project ) + .setAltDeploymentRepository( "altDeploymentRepository::default::http://localhost" ); + try + { + mojo.getDeploymentRepository( pdr ); + fail( "Should throw: Invalid legacy syntax for repository." ); + } + catch( MojoFailureException e ) + { + assertEquals( e.getMessage(), "Invalid legacy syntax for repository."); + assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead."); + } + } + + public void testLegacyAltDeploymentRepositoryWithLegacyLayout() + throws Exception + { + DeployMojo mojo = spy( new DeployMojo() ); + + ArtifactRepository repository = mock( ArtifactRepository.class ); + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" + ) ).thenReturn( repository ); + + project.setVersion( "1.0-SNAPSHOT" ); + + ProjectDeployerRequest pdr = + new ProjectDeployerRequest() + .setProject( project ) + .setAltDeploymentRepository( "altDeploymentRepository::legacy::http://localhost" ); + try + { + mojo.getDeploymentRepository( pdr ); + 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."); + } + } + + public void testInsaneAltDeploymentRepository() + throws Exception + { + DeployMojo mojo = spy( new DeployMojo() ); + + ArtifactRepository repository = mock( ArtifactRepository.class ); + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" + ) ).thenReturn( repository ); + + project.setVersion( "1.0-SNAPSHOT" ); + + ProjectDeployerRequest pdr = + new ProjectDeployerRequest() + .setProject( project ) + .setAltDeploymentRepository( "altDeploymentRepository::hey::wow::foo::http://localhost" ); + try + { + mojo.getDeploymentRepository( pdr ); + 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."); + } + } + + public void testDefaultScmSvnAltDeploymentRepository() + throws Exception + { + DeployMojo mojo = spy( new DeployMojo() ); + + ArtifactRepository repository = mock( ArtifactRepository.class ); + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" + ) ).thenReturn( repository ); + + project.setVersion( "1.0-SNAPSHOT" ); + + ProjectDeployerRequest pdr = + new ProjectDeployerRequest() + .setProject( project ) + .setAltDeploymentRepository( "altDeploymentRepository::default::scm:svn:http://localhost" ); + try + { + mojo.getDeploymentRepository( pdr ); + fail( "Should throw: Invalid legacy syntax for repository." ); + } + catch( MojoFailureException e ) + { + assertEquals( e.getMessage(), "Invalid legacy syntax for repository."); + assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead."); + } + } + public void testLegacyScmSvnAltDeploymentRepository() + throws Exception + { + DeployMojo mojo = spy( new DeployMojo() ); + + ArtifactRepository repository = mock( ArtifactRepository.class ); + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" + ) ).thenReturn( repository ); + + project.setVersion( "1.0-SNAPSHOT" ); + + ProjectDeployerRequest pdr = + new ProjectDeployerRequest() + .setProject( project ) + .setAltDeploymentRepository( "altDeploymentRepository::legacy::scm:svn:http://localhost" ); + try + { + mojo.getDeploymentRepository( pdr ); + 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."); + } + } + public void testAltSnapshotDeploymentRepository() throws Exception { From 02a055bde67f23cf908f97a04813c044d16c5490 Mon Sep 17 00:00:00 2001 From: Phil Clay Date: Tue, 22 Dec 2020 08:37:41 -0800 Subject: [PATCH 102/153] [MDEPLOY-265] Allow old alt*DeploymentRepository property format if default layout is used The legacy format (<=2.x) of alt*DeploymentRepository is id::layout::url. The new format (>= 3.x) of alt*DeploymentRepository is id::url which is equivalent to id::default:url from the legacy format. This change introduces backwards compatibility with 2.x by supporting alt*DeploymentRepository values in the id::layout::url format if and only if the layout is equal to "default". The "default" layout is the most commonly used layout, so this should maintain backwards compatibility with the large majority of projects using the alt*DeploymentRepository properties. * Usage of the legacy format with the "default" layout will result in a warning message being logged. * Usage of the legacy format with layouts other than "default" will result in an exception being thrown. This closes #15 --- .../maven/plugins/deploy/DeployMojo.java | 7 ++--- .../maven/plugins/deploy/DeployMojoTest.java | 29 +++++-------------- 2 files changed, 11 insertions(+), 25 deletions(-) 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 ab0c72b2..ae26134b 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -259,10 +259,9 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym if ( "default".equals( layout ) ) { - throw new MojoFailureException( altDeploymentRepo, - "Invalid legacy syntax for repository.", - "Invalid legacy syntax for alternative repository. Use \"" + id + "::" + url + "\" instead." - ); + getLog().warn( "Using legacy syntax for alternative repository. " + + "Use \"" + id + "::" + url + "\" instead." ); + repo = createDeploymentArtifactRepository( id, url ); } else { 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 9a02b1c4..63fe2dee 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -568,16 +568,10 @@ public void testLegacyAltDeploymentRepositoryWithDefaultLayout() new ProjectDeployerRequest() .setProject( project ) .setAltDeploymentRepository( "altDeploymentRepository::default::http://localhost" ); - try - { - mojo.getDeploymentRepository( pdr ); - fail( "Should throw: Invalid legacy syntax for repository." ); - } - catch( MojoFailureException e ) - { - assertEquals( e.getMessage(), "Invalid legacy syntax for repository."); - assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead."); - } + + assertEquals( repository, + mojo.getDeploymentRepository( pdr ) ); + } public void testLegacyAltDeploymentRepositoryWithLegacyLayout() @@ -640,7 +634,7 @@ public void testDefaultScmSvnAltDeploymentRepository() DeployMojo mojo = spy( new DeployMojo() ); ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" + when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "scm:svn:http://localhost" ) ).thenReturn( repository ); project.setVersion( "1.0-SNAPSHOT" ); @@ -649,16 +643,9 @@ public void testDefaultScmSvnAltDeploymentRepository() new ProjectDeployerRequest() .setProject( project ) .setAltDeploymentRepository( "altDeploymentRepository::default::scm:svn:http://localhost" ); - try - { - mojo.getDeploymentRepository( pdr ); - fail( "Should throw: Invalid legacy syntax for repository." ); - } - catch( MojoFailureException e ) - { - assertEquals( e.getMessage(), "Invalid legacy syntax for repository."); - assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead."); - } + + assertEquals( repository, + mojo.getDeploymentRepository( pdr ) ); } public void testLegacyScmSvnAltDeploymentRepository() throws Exception From c140a848a91ec7504a974c6f7daa97f5f0e1a088 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 24 Dec 2020 20:39:28 +0100 Subject: [PATCH 103/153] [MDEPLOY-264] Upgrade Maven Artifact Transfer to 0.13.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 94af8952..2488cf6a 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ under the License. org.apache.maven.shared maven-artifact-transfer - 0.11.0 + 0.13.1 From 3f30d5f503df2823bd564b75cd5e41d96f18b96b Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Tue, 9 Feb 2021 11:36:30 +0100 Subject: [PATCH 104/153] Bump mockito-core from 1.9.5 to 2.28.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2488cf6a..3c590c66 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ under the License. org.mockito mockito-core - 1.9.5 + 2.28.2 test From 74555b71263d59aec6d87b532beee558fa5f2774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 25 Jul 2021 11:29:50 +0200 Subject: [PATCH 105/153] update CI url --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b5c65ebd..0cf6df08 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ Contributing to [Apache Maven Deploy Plugin](https://maven.apache.org/plugins/ma [![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MDEPLOY.json)][jira] [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-deploy-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-deploy-plugin) -[![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][build] -[![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][test-results] +[![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][build] +[![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][test-results] You have found a bug or you have an idea for a cool new feature? Contributing @@ -95,5 +95,5 @@ Additional Resources [code-style]: https://maven.apache.org/developers/conventions/code.html [cla]: https://www.apache.org/licenses/#clas [maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index -[test-results]: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master/lastCompletedBuild/testReport/ -[build]: https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master/ +[test-results]: https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master/lastCompletedBuild/testReport/ +[build]: https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master/ From f1b3241951171cd273a157363a832c2c08161718 Mon Sep 17 00:00:00 2001 From: Christopher Sauer Date: Fri, 30 Jul 2021 14:02:39 -0700 Subject: [PATCH 106/153] Minor improvement to English grammar in usage doc Happened upon a typo/grammar issue while reading the docs. Goal is to quickly leave things even better than I found them :) --- src/site/apt/usage.apt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt index 45333a5a..baaf7a94 100644 --- a/src/site/apt/usage.apt +++ b/src/site/apt/usage.apt @@ -98,7 +98,7 @@ mvn deploy * The <<>> Mojo - The <<>> mojo is used primarily for deploying artifacts to + The <<>> mojo is used primarily for deploying artifacts, which were not built by Maven. The project's development team may or may not provide a POM for the artifact, and in some cases you may want to deploy the artifact to an internal remote repository. The deploy-file mojo provides From d4a468deee36fbdf02a56ed5b5278006c7dc3113 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 27 Dec 2021 15:11:10 +0100 Subject: [PATCH 107/153] [maven-release-plugin] prepare release maven-deploy-plugin-3.0.0-M2 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 3c590c66..94d8784f 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-deploy-plugin - 3.0.0-M2-SNAPSHOT + 3.0.0-M2 maven-plugin Apache Maven Deploy Plugin @@ -45,7 +45,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} - HEAD + maven-deploy-plugin-3.0.0-M2 JIRA @@ -65,7 +65,7 @@ under the License. 3.0 7 - 2020-04-07T21:04:00Z + 2021-12-27T14:10:57Z From 992930360d5878261d61c28b4c79c8bfe1159edf Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 27 Dec 2021 15:11:19 +0100 Subject: [PATCH 108/153] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 94d8784f..bb3114c5 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-deploy-plugin - 3.0.0-M2 + 3.0.0-M3-SNAPSHOT maven-plugin Apache Maven Deploy Plugin @@ -45,7 +45,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} - maven-deploy-plugin-3.0.0-M2 + HEAD JIRA @@ -65,7 +65,7 @@ under the License. 3.0 7 - 2021-12-27T14:10:57Z + 2021-12-27T14:11:19Z From 36a2030c8851e21cd1e0bec01c3cea4dc6055a48 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 9 Jan 2022 12:12:33 +0100 Subject: [PATCH 109/153] Use Shared GitHub Actions --- .../workflows/{maven.yml => maven-verify.yml} | 34 ++++--------------- 1 file changed, 6 insertions(+), 28 deletions(-) rename .github/workflows/{maven.yml => maven-verify.yml} (53%) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven-verify.yml similarity index 53% rename from .github/workflows/maven.yml rename to .github/workflows/maven-verify.yml index 3fdac5f0..bbd77865 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven-verify.yml @@ -15,35 +15,13 @@ # specific language governing permissions and limitations # under the License. -name: Java CI +name: Verify -on: [push, pull_request] +on: + push: + pull_request: jobs: build: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - fail-fast: false - - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up cache for ~/.m2/repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: maven-${{ matrix.os }}-${{ hashFiles('**/pom.xml') }} - restore-keys: | - maven-${{ matrix.os }}- - - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - - name: Build with Maven - run: mvn -e -B -V clean verify -P run-its + name: Verify + uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v2 From 6eb066eff3314418c4c4eb73c4e8eda636a4042c Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 6 May 2022 09:54:39 +0200 Subject: [PATCH 110/153] [MDEPLOY-291] Update POM parent and Maven (#22) Update plugin build: * update parent to 36 * update maven to 3.2.5 * leave the plugin to Java7 * warn user if older that Maven 3.9.0 is used to deploy a maven-plugin --- pom.xml | 89 +++++++++++++------ .../plugins/deploy/AbstractDeployMojo.java | 39 +++++++- .../maven/plugins/deploy/DeployFileMojo.java | 1 + .../maven/plugins/deploy/DeployMojo.java | 1 + .../plugins/deploy/DeployFileMojoTest.java | 20 +++-- .../maven/plugins/deploy/DeployMojoTest.java | 17 ++-- .../apache/maven/plugins/deploy/Utils.java | 2 +- .../deploy/stubs/ArtifactRepositoryStub.java | 12 +++ 8 files changed, 136 insertions(+), 45 deletions(-) diff --git a/pom.xml b/pom.xml index bb3114c5..1284f130 100644 --- a/pom.xml +++ b/pom.xml @@ -25,8 +25,8 @@ under the License. org.apache.maven.plugins maven-plugins - 34 - ../../pom/maven/maven-plugins/pom.xml + 36 + maven-deploy-plugin @@ -63,7 +63,9 @@ under the License. - 3.0 + 3.2.5 + 1.7.5 + 1.0.0.v20140518 7 2021-12-27T14:11:19Z @@ -73,50 +75,71 @@ under the License. org.apache.maven maven-plugin-api ${mavenVersion} + provided org.apache.maven maven-core ${mavenVersion} + provided org.apache.maven maven-model ${mavenVersion} + provided org.apache.maven maven-artifact ${mavenVersion} + provided + + + + org.slf4j + slf4j-api + ${slf4jVersion} + provided - org.apache.maven.shared maven-artifact-transfer 0.13.1 - commons-io commons-io - 2.5 + 2.6 - + + org.codehaus.plexus + plexus-utils + 3.3.1 + + + org.eclipse.aether + aether-api + ${resolverVersion} + + + org.eclipse.aether + aether-util + ${resolverVersion} + + org.apache.maven.plugin-tools maven-plugin-annotations provided - - org.codehaus.plexus - plexus-utils - 3.2.0 - + + org.apache.maven.plugin-testing maven-plugin-testing-harness - 2.1 + 3.3.0 test @@ -126,33 +149,45 @@ under the License. test - org.mockito - mockito-core - 2.28.2 + org.apache.maven + maven-aether-provider + ${mavenVersion} test - junit - junit - 4.13.1 + org.eclipse.aether + aether-connector-basic + ${resolverVersion} test - org.sonatype.aether - aether-connector-file - 1.7 + org.eclipse.aether + aether-transport-file + ${resolverVersion} test - org.slf4j - slf4j-api - 1.7.5 - provided + org.eclipse.aether + aether-transport-http + ${resolverVersion} + test + + + org.mockito + mockito-core + 2.28.2 + test + + + junit + junit + 4.13.2 + test org.slf4j slf4j-nop - 1.7.5 + ${slf4jVersion} test 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 f933e36c..3939a8ea 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -26,7 +26,12 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.rtinfo.RuntimeInformation; +import org.eclipse.aether.util.version.GenericVersionScheme; +import org.eclipse.aether.version.InvalidVersionSpecificationException; +import org.eclipse.aether.version.Version; /** * Abstract class for Deploy mojo's. @@ -52,7 +57,14 @@ public abstract class AbstractDeployMojo @Parameter( defaultValue = "${session}", readonly = true, required = true ) private MavenSession session; - + + @Component + private RuntimeInformation runtimeInformation; + + private static final String AFFECTED_MAVEN_PACKAGING = "maven-plugin"; + + private static final String FIXED_MAVEN_VERSION = "3.9.0"; + /* Setters and Getters */ void failIfOffline() @@ -79,4 +91,29 @@ protected final MavenSession getSession() { return session; } + + 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( "" ); + } + } + catch ( InvalidVersionSpecificationException e ) + { + // skip it: Generic does not throw, only API contains this 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 43044218..12267e7e 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -481,6 +481,7 @@ public void execute() try { + warnIfAffectedPackagingAndMaven( packaging ); artifactDeployer.deploy( getSession().getProjectBuildingRequest(), deploymentRepository, deployableArtifacts ); } 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 ae26134b..4aaa971a 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -207,6 +207,7 @@ private void deployProject( ProjectBuildingRequest pbr, ProjectDeployerRequest p { try { + warnIfAffectedPackagingAndMaven( pir.getProject().getPackaging() ); projectDeployer.deploy( pbr, pir, repo ); } catch ( NoFileAssignedException e ) 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 6c7064bb..371838bd 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -30,11 +30,12 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.repository.LocalRepository; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; /** * @author Allan Ramirez @@ -91,9 +92,10 @@ public void testBasicDeployFile() assertNotNull( mojo ); ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( buildingRequest.getRepositoryMerging() ).thenReturn( ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT ); when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); @@ -192,9 +194,10 @@ public void testDeployIfClassifierIsSet() assertNotNull( mojo ); ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( buildingRequest.getRepositoryMerging() ).thenReturn( ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT ); when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); String classifier = ( String ) getVariableValueFromObject( mojo, "classifier" ); @@ -240,9 +243,10 @@ public void testDeployIfArtifactIsNotJar() assertNotNull( mojo ); ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); + when( buildingRequest.getRepositoryMerging() ).thenReturn( ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT ); when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); 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 63fe2dee..6404f5ad 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -40,14 +40,15 @@ import org.apache.maven.plugins.deploy.stubs.DeployArtifactStub; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest; import org.codehaus.plexus.util.FileUtils; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.repository.LocalRepository; import org.junit.Ignore; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; /** * @author Allan Ramirez @@ -132,8 +133,8 @@ public void testBasicDeploy() ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); File file = new File( getBasedir(), @@ -303,8 +304,8 @@ public void testBasicDeployWithPackagingAsPom() ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); File pomFile = new File( getBasedir(), @@ -415,8 +416,8 @@ public void testDeployWithAttachedArtifacts() ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class ); when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest ); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( LOCAL_REPO ) ); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession ); MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); diff --git a/src/test/java/org/apache/maven/plugins/deploy/Utils.java b/src/test/java/org/apache/maven/plugins/deploy/Utils.java index 4df74424..f4acbc9d 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/Utils.java +++ b/src/test/java/org/apache/maven/plugins/deploy/Utils.java @@ -26,7 +26,7 @@ import java.util.Map; import org.apache.maven.plugin.MojoExecutionException; -import org.sonatype.aether.util.ChecksumUtils; +import org.eclipse.aether.util.ChecksumUtils; /** * A utility class to assist testing. 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 0b94ebed..92db6c19 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 @@ -131,4 +131,16 @@ public boolean isBlacklisted() { return blacklisted; } + + // @Override + public boolean isBlocked() + { + return false; + } + + // @Override + public void setBlocked( boolean b ) + { + + } } From d4bdd053f2e5e8bd9a3c8301f04d6b227ceb6410 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Fri, 6 May 2022 11:26:36 +0200 Subject: [PATCH 111/153] (doc) drop obsolete Google tracking code --- src/site/site.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/site/site.xml b/src/site/site.xml index 6541e2e3..eb26a824 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -40,7 +40,6 @@ under the License. true - maven.apache.org/plugins/maven-deploy-plugin/ From dd39f5d12cb604ae674c9669425255116b1b72d4 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Fri, 6 May 2022 11:28:45 +0200 Subject: [PATCH 112/153] (doc) Update Fluido Skin to 1.10.0 --- src/site/site.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/site.xml b/src/site/site.xml index eb26a824..6df80c46 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -34,7 +34,7 @@ under the License. org.apache.maven.skins maven-fluido-skin - 1.7 + 1.10.0 From 89c28fb8d095b7c76115124d868579a5d4529d0b Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Sun, 3 Jul 2022 20:18:39 +0200 Subject: [PATCH 113/153] [MDEPLOY-193] Deploy At End feature (no extension) (#20) This PR makes deployAtEnd work as expected even if maven-deploy-plugin is not used as extension. How it works: it uses mojo Context to store "state markers" (and params): * presence of marker means project was "processed" * value of state marker tells what should be done * if needed, other params are stored as well UTs adjusted to provide plugin context (was null before). --- src/it/deploy-at-end-fail/verify.groovy | 2 +- src/it/deploy-at-end-pass/verify.groovy | 2 +- .../maven/plugins/deploy/DeployMojo.java | 147 +++++++++++++----- .../maven/plugins/deploy/DeployMojoTest.java | 22 ++- 4 files changed, 127 insertions(+), 46 deletions(-) diff --git a/src/it/deploy-at-end-fail/verify.groovy b/src/it/deploy-at-end-fail/verify.groovy index 03398e8b..27d678a6 100644 --- a/src/it/deploy-at-end-fail/verify.groovy +++ b/src/it/deploy-at-end-fail/verify.groovy @@ -22,5 +22,5 @@ assert !( new File( basedir, "module1/target/repo/org/apache/maven/its/deploy/da File buildLog = new File( basedir, 'build.log' ) assert buildLog.exists() -assert buildLog.text.contains( "[INFO] Deploying org.apache.maven.its.deploy.dae.fail:dae:1.0 at end" ) +assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.fail:dae:1.0 at end" ) diff --git a/src/it/deploy-at-end-pass/verify.groovy b/src/it/deploy-at-end-pass/verify.groovy index d776935a..634808a5 100644 --- a/src/it/deploy-at-end-pass/verify.groovy +++ b/src/it/deploy-at-end-pass/verify.groovy @@ -22,5 +22,5 @@ assert new File( basedir, "module1/target/repo/org/apache/maven/its/deploy/dae/p File buildLog = new File( basedir, 'build.log' ) assert buildLog.exists() -assert buildLog.text.contains( "[INFO] Deploying 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:dae:1.0 at end" ) 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 4aaa971a..bec6b384 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -19,10 +19,8 @@ * under the License. */ -import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -30,6 +28,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -55,23 +54,15 @@ public class DeployMojo private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+?)::(.+)" ); - /** - * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready - * to be deployed - */ - private static final AtomicInteger READYPROJECTSCOUNTER = new AtomicInteger(); - - private static final List DEPLOYREQUESTS = - Collections.synchronizedList( new ArrayList() ); - - /** - */ @Parameter( defaultValue = "${project}", readonly = true, required = true ) private MavenProject project; @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) private List reactorProjects; + @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. @@ -143,63 +134,139 @@ public class DeployMojo @Component private ProjectDeployer projectDeployer; + 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"; + + private static final String DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY = + DeployMojo.class.getName() + ".altSnapshotDeploymentRepository"; + + private static final String DEPLOY_ALT_DEPLOYMENT_REPOSITORY = + DeployMojo.class.getName() + ".altDeploymentRepository"; + + 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 String getPluginContextValue( Map pluginContext, String key ) + { + return (String) pluginContext.get( key ); + } + + private State getState( Map pluginContext ) + { + return State.valueOf( getPluginContextValue( pluginContext, DEPLOY_PROCESSED_MARKER ) ); + } + + private boolean hasState( MavenProject project ) + { + Map pluginContext = getSession().getPluginContext( pluginDescriptor, project ); + return pluginContext.containsKey( DEPLOY_PROCESSED_MARKER ); + } + public void execute() throws MojoExecutionException, MojoFailureException { - boolean addedDeployRequest = false; 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 { failIfOffline(); - // CHECKSTYLE_OFF: LineLength - // @formatter:off - ProjectDeployerRequest pdr = new ProjectDeployerRequest() - .setProject( project ) - .setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ) - .setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ) - .setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ) - .setAltDeploymentRepository( altDeploymentRepository ); - // @formatter:on - // CHECKSTYLE_ON: LineLength - - ArtifactRepository repo = getDeploymentRepository( pdr ); - if ( !deployAtEnd ) { + // CHECKSTYLE_OFF: LineLength + // @formatter:off + ProjectDeployerRequest pdr = new ProjectDeployerRequest() + .setProject( project ) + .setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ) + .setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ) + .setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ) + .setAltDeploymentRepository( altDeploymentRepository ); + // @formatter:on + // CHECKSTYLE_ON: LineLength + + ArtifactRepository repo = getDeploymentRepository( pdr ); + deployProject( getSession().getProjectBuildingRequest(), pdr, repo ); + putState( State.DEPLOYED ); } else { - DEPLOYREQUESTS.add( pdr ); - addedDeployRequest = true; + putState( State.TO_BE_DEPLOYED ); + putPluginContextValue( DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository ); + putPluginContextValue( DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY, altSnapshotDeploymentRepository ); + putPluginContextValue( DEPLOY_ALT_DEPLOYMENT_REPOSITORY, altDeploymentRepository ); + getLog().info( "Deferring deploy for " + getProjectReferenceId( project ) + " at end" ); } } - boolean projectsReady = READYPROJECTSCOUNTER.incrementAndGet() == reactorProjects.size(); - if ( projectsReady ) + if ( allProjectsMarked() ) { - synchronized ( DEPLOYREQUESTS ) + for ( MavenProject reactorProject : reactorProjects ) { - while ( !DEPLOYREQUESTS.isEmpty() ) + Map pluginContext = getSession().getPluginContext( pluginDescriptor, reactorProject ); + State state = getState( pluginContext ); + if ( state == State.TO_BE_DEPLOYED ) { - ArtifactRepository repo = getDeploymentRepository( DEPLOYREQUESTS.get( 0 ) ); - - deployProject( getSession().getProjectBuildingRequest(), DEPLOYREQUESTS.remove( 0 ), repo ); + 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 ); + + ProjectDeployerRequest pdr = new ProjectDeployerRequest() + .setProject( reactorProject ) + .setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ) + .setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ) + .setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ) + .setAltDeploymentRepository( altDeploymentRepository ); + + ArtifactRepository repo = getDeploymentRepository( pdr ); + + deployProject( getSession().getProjectBuildingRequest(), pdr, repo ); } } } - else if ( addedDeployRequest ) + } + + private String getProjectReferenceId( MavenProject mavenProject ) + { + return mavenProject.getGroupId() + ":" + mavenProject.getArtifactId() + ":" + mavenProject.getVersion(); + } + + private boolean allProjectsMarked() + { + for ( MavenProject reactorProject : reactorProjects ) { - getLog().info( "Deploying " + project.getGroupId() + ":" + project.getArtifactId() + ":" - + project.getVersion() + " at end" ); + if ( !hasState( reactorProject ) ) + { + return false; + } } + return true; } private void deployProject( ProjectBuildingRequest pbr, ProjectDeployerRequest pir, ArtifactRepository repo ) 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 6404f5ad..c8350c47 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -19,6 +19,7 @@ * under the License. */ +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -28,11 +29,13 @@ import java.util.Collections; import java.util.List; import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; import org.apache.maven.artifact.repository.ArtifactRepository; 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; import org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub; @@ -68,7 +71,6 @@ public class DeployMojoTest MavenProjectStub project = new MavenProjectStub(); - @Mock private MavenSession session; @InjectMocks @@ -78,7 +80,11 @@ public void setUp() throws Exception { super.setUp(); - + + session = mock( MavenSession.class ); + when( session.getPluginContext(any(PluginDescriptor.class), any(MavenProject.class))) + .thenReturn( new ConcurrentHashMap() ); + remoteRepo = new File( REMOTE_REPO ); remoteRepo.mkdirs(); @@ -144,7 +150,8 @@ public void testBasicDeploy() assertTrue( file.exists() ); MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - + + setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); artifact = ( DeployArtifactStub ) project.getArtifact(); @@ -251,8 +258,11 @@ public void testSkippingDeploy() assertTrue( file.exists() ); 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 ); artifact = (DeployArtifactStub) project.getArtifact(); @@ -316,6 +326,7 @@ public void testBasicDeployWithPackagingAsPom() MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); + setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); artifact = (DeployArtifactStub) project.getArtifact(); @@ -381,6 +392,7 @@ public void testDeployIfArtifactFileIsNull() MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); + setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); artifact = (DeployArtifactStub) project.getArtifact(); @@ -422,6 +434,7 @@ public void testDeployWithAttachedArtifacts() MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); + setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); artifact = (DeployArtifactStub) project.getArtifact(); @@ -523,6 +536,7 @@ public void _testBasicDeployWithScpAsProtocol() MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); + setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); artifact = (DeployArtifactStub) project.getArtifact(); From 16541da43c51237cf7183c4500a576108ad946b8 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 12 Jul 2022 15:11:25 +0200 Subject: [PATCH 114/153] [MDEPLOY-296] Streamline plugin (#26) Original plugin made hoops and loops, instead to perform what it needed to perform. Partly to blame this was unfinished state of MAT API (it was able to install project only). Deploying project is needed in DeployMojo, but DeployFileMojo was forced to make hoops and loops due this, as it was passed one file (and maybe pomFile), and it was forced to create "fake" project, decorate and fake setup it with all whistle and bells, only to get it via MAT to resolver that would "decompose" it back into set of artifacts needing a deploy. So it went this file-artifact-project-artifact route, that made all the logic fragile and overly complicated. This PR completely reworks m-deploy-p making it (almost trivially) simple: it does what it needs to do, without any fuss, and does it in streamlined way: No fuss, no magic, no fake project building etc. --- pom.xml | 14 +- .../plugins/deploy/AbstractDeployMojo.java | 111 +++++-- .../maven/plugins/deploy/DeployFileMojo.java | 302 +++++++++--------- .../maven/plugins/deploy/DeployMojo.java | 158 +++++---- .../plugins/deploy/DeployFileMojoTest.java | 5 +- .../deploy/DeployFileMojoUnitTest.java | 33 +- .../maven/plugins/deploy/DeployMojoTest.java | 145 ++++----- .../deploy/stubs/ArtifactDeployerStub.java | 47 --- 8 files changed, 407 insertions(+), 408 deletions(-) delete mode 100644 src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java diff --git a/pom.xml b/pom.xml index 1284f130..385b4d9f 100644 --- a/pom.xml +++ b/pom.xml @@ -63,10 +63,10 @@ under the License. + 7 3.2.5 1.7.5 1.0.0.v20140518 - 7 2021-12-27T14:11:19Z @@ -102,16 +102,6 @@ under the License. ${slf4jVersion} provided - - org.apache.maven.shared - maven-artifact-transfer - 0.13.1 - - - commons-io - commons-io - 2.6 - org.codehaus.plexus plexus-utils @@ -121,11 +111,13 @@ under the License. org.eclipse.aether aether-api ${resolverVersion} + provided org.eclipse.aether aether-util ${resolverVersion} + compile 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 3939a8ea..4a66ecd8 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -19,16 +19,18 @@ * under the License. */ -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.MavenArtifactRepository; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; 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; import org.eclipse.aether.util.version.GenericVersionScheme; import org.eclipse.aether.version.InvalidVersionSpecificationException; import org.eclipse.aether.version.Version; @@ -37,9 +39,8 @@ * Abstract class for Deploy mojo's. */ public abstract class AbstractDeployMojo - extends AbstractMojo + extends AbstractMojo { - /** * Flag whether Maven is currently in online/offline mode. */ @@ -49,17 +50,20 @@ public abstract class AbstractDeployMojo /** * Parameter used to control how many times a failed deployment will be retried before giving up and failing. If a * value outside the range 1-10 is specified it will be pulled to the nearest value within the range 1-10. - * + * * @since 2.7 */ @Parameter( property = "retryFailedDeploymentCount", defaultValue = "1" ) private int retryFailedDeploymentCount; + @Component + private RuntimeInformation runtimeInformation; + @Parameter( defaultValue = "${session}", readonly = true, required = true ) - private MavenSession session; + protected MavenSession session; @Component - private RuntimeInformation runtimeInformation; + protected RepositorySystem repositorySystem; private static final String AFFECTED_MAVEN_PACKAGING = "maven-plugin"; @@ -68,7 +72,7 @@ public abstract class AbstractDeployMojo /* Setters and Getters */ void failIfOffline() - throws MojoFailureException + throws MojoFailureException { if ( offline ) { @@ -76,22 +80,9 @@ void failIfOffline() } } - int getRetryFailedDeploymentCount() - { - return retryFailedDeploymentCount; - } - - protected ArtifactRepository createDeploymentArtifactRepository( String id, String url ) - { - return new MavenArtifactRepository( id, url, new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), - new ArtifactRepositoryPolicy() ); - } - - protected final MavenSession getSession() - { - return session; - } - + /** + * 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 ) ) @@ -116,4 +107,72 @@ protected void warnIfAffectedPackagingAndMaven( final String packaging ) } } } + + /** + * 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 ) ); + } + + if ( result.getProxy() == null ) + { + builder.setProxy( session.getRepositorySession().getProxySelector().getProxy( result ) ); + } + + result = builder.build(); + } + + 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 ) ); + DeploymentException exception = null; + for ( int count = 0; count < retryFailedDeploymentCounter; count++ ) + { + try + { + if ( count > 0 ) + { + getLog().info( "Retrying deployment attempt " + ( count + 1 ) + " of " + + retryFailedDeploymentCounter ); + } + + repositorySystem.deploy( session, deployRequest ); + exception = null; + break; + } + catch ( DeploymentException e ) + { + if ( count + 1 < retryFailedDeploymentCounter ) + { + getLog().warn( "Encountered issue during deployment: " + e.getLocalizedMessage() ); + getLog().debug( e ); + } + if ( exception == null ) + { + exception = e; + } + } + } + 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 12267e7e..5d950438 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -27,44 +27,34 @@ import java.io.OutputStream; import java.io.Reader; import java.io.Writer; -import java.util.ArrayList; import java.util.Enumeration; -import java.util.List; +import java.util.Objects; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.regex.Pattern; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; -import org.apache.maven.model.building.ModelBuildingException; -import org.apache.maven.model.building.ModelSource; -import org.apache.maven.model.building.StringModelSource; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.DefaultProjectBuildingRequest; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectHelper; -import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.ProjectBuildingException; -import org.apache.maven.project.artifact.ProjectArtifactMetadata; -import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate; -import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployer; -import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException; -import org.apache.maven.shared.transfer.repository.RepositoryManager; -import org.apache.maven.shared.utils.Os; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.ArtifactType; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.deployment.DeployRequest; +import org.eclipse.aether.deployment.DeploymentException; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.util.artifact.SubArtifact; /** * Installs the artifact in the remote repository. @@ -75,21 +65,6 @@ public class DeployFileMojo extends AbstractDeployMojo { - @Component - private ArtifactDeployer artifactDeployer; - - /** - * Used for attaching the artifacts to deploy to the project. - */ - @Component - private MavenProjectHelper projectHelper; - - /** - * Used for creating the project to which the artifacts to deploy will be attached. - */ - @Component - private ProjectBuilder projectBuilder; - /** * GroupId of the artifact to be deployed. Retrieved from POM file if specified. */ @@ -177,16 +152,6 @@ public class DeployFileMojo @Parameter( property = "classifier" ) private String classifier; - /** - * Whether to deploy snapshots with a unique version or not. - * - * @deprecated As of Maven 3, this isn't supported anymore and this parameter is only present to break the build if - * you use it! - */ - @Parameter( property = "uniqueVersion" ) - @Deprecated - private Boolean uniqueVersion; - /** * 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. @@ -208,9 +173,6 @@ public class DeployFileMojo @Parameter( property = "files" ) private String files; - @Component - private RepositoryManager repoManager; - void initProperties() throws MojoExecutionException { @@ -303,22 +265,13 @@ void initProperties() if ( packaging == null && file != null ) { - packaging = FileUtils.getExtension( file.getName() ); + packaging = getExtension( file ); } } public void execute() throws MojoExecutionException, MojoFailureException { - if ( uniqueVersion != null ) - { - throw new MojoExecutionException( "You are using 'uniqueVersion' which has been removed" - + " from the maven-deploy-plugin. " - + "Please see the >>Major Version Upgrade to version 3.0.0<< on the plugin site." ); - } - - failIfOffline(); - if ( !file.exists() ) { throw new MojoExecutionException( file.getPath() + " not found." ); @@ -326,68 +279,86 @@ public void execute() initProperties(); - ArtifactRepository deploymentRepository = createDeploymentArtifactRepository( repositoryId, url ); - - String protocol = deploymentRepository.getProtocol(); + RemoteRepository remoteRepository = getRemoteRepository( repositoryId, url ); - if ( StringUtils.isEmpty( protocol ) ) + if ( StringUtils.isEmpty( remoteRepository.getProtocol() ) ) { throw new MojoExecutionException( "No transfer protocol found." ); } - MavenProject project = createMavenProject(); - Artifact artifact = project.getArtifact(); + 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 ( file.equals( getLocalRepoFile() ) ) + if ( !isValidId( groupId ) + || !isValidId( artifactId ) + || !isValidVersion( version ) ) { - throw new MojoFailureException( "Cannot deploy artifact from the local repository: " + file ); + throw new MojoExecutionException( "The artifact information is not valid: uses invalid characters." ); } - List deployableArtifacts = new ArrayList(); + failIfOffline(); + warnIfAffectedPackagingAndMaven( packaging ); - if ( classifier == null ) + DeployRequest deployRequest = new DeployRequest(); + deployRequest.setRepository( remoteRepository ); + + boolean isFilePom = classifier == null && "pom".equals( packaging ); + if ( !isFilePom ) { - artifact.setFile( file ); - deployableArtifacts.add( artifact ); + ArtifactType artifactType = session.getRepositorySession().getArtifactTypeRegistry().get( packaging ); + if ( artifactType != null + && StringUtils.isEmpty( classifier ) + && !StringUtils.isEmpty( artifactType.getClassifier() ) ) + { + classifier = artifactType.getClassifier(); + } } - else + 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 ) ) { - projectHelper.attachArtifact( project, packaging, classifier, file ); + throw new MojoFailureException( "Cannot deploy artifact from the local repository: " + file ); } - // Upload the POM if requested, generating one if need be + File temporaryPom = null; if ( !"pom".equals( packaging ) ) { - File pom = pomFile; - if ( pom == null && generatePom ) + if ( pomFile != null ) { - pom = generatePomFile(); + deployRequest.addArtifact( new SubArtifact( mainArtifact, "", "pom", pomFile ) ); } - if ( pom != null ) + else if ( generatePom ) { - if ( classifier == null ) - { - ProjectArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom ); - artifact.addMetadata( metadata ); - } - else - { - artifact.setFile( pom ); - deployableArtifacts.add( artifact ); - } + temporaryPom = generatePomFile(); + getLog().debug( "Deploying generated POM" ); + deployRequest.addArtifact( new SubArtifact( mainArtifact, "", "pom", temporaryPom ) ); + } + else + { + getLog().debug( "Skipping deploying POM" ); } } - artifact.setRepository( deploymentRepository ); - if ( sources != null ) { - projectHelper.attachArtifact( project, "jar", "sources", sources ); + deployRequest.addArtifact( new SubArtifact( mainArtifact, "sources", "jar", sources ) ); } if ( javadoc != null ) { - projectHelper.attachArtifact( project, "jar", "javadoc", javadoc ); + deployRequest.addArtifact( new SubArtifact( mainArtifact, "javadoc", "jar", javadoc ) ); } if ( files != null ) @@ -406,12 +377,12 @@ public void execute() if ( typesLength != filesLength ) { throw new MojoExecutionException( "You must specify the same number of entries in 'files' and " - + "'types' (respectively " + filesLength + " and " + typesLength + " entries )" ); + + "'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 )" ); + + "'classifiers' (respectively " + filesLength + " and " + classifiersLength + " entries )" ); } int fi = 0; int ti = 0; @@ -437,19 +408,21 @@ public void execute() if ( !file.isFile() ) { // try relative to the project basedir just in case - file = new File( project.getBasedir(), files.substring( fi, nfi ) ); + file = new File( files.substring( fi, nfi ) ); } if ( file.isFile() ) { - if ( StringUtils.isWhitespace( classifiers.substring( ci, nci ) ) ) + String extension = getExtension( file ); + ArtifactType artifactType = session.getRepositorySession().getArtifactTypeRegistry() + .get( types.substring( ti, nti ).trim() ); + if ( artifactType != null && !Objects.equals( extension, artifactType.getExtension() ) ) { - projectHelper.attachArtifact( project, types.substring( ti, nti ).trim(), file ); - } - else - { - projectHelper.attachArtifact( project, types.substring( ti, nti ).trim(), - classifiers.substring( ci, nci ).trim(), file ); + extension = artifactType.getExtension(); } + + deployRequest.addArtifact( + new SubArtifact( mainArtifact, classifiers.substring( ci, nci ).trim(), extension, file ) + ); } else { @@ -472,80 +445,32 @@ public void execute() } } - List attachedArtifacts = project.getAttachedArtifacts(); - - for ( Artifact attached : attachedArtifacts ) - { - deployableArtifacts.add( attached ); - } - try { - warnIfAffectedPackagingAndMaven( packaging ); - artifactDeployer.deploy( getSession().getProjectBuildingRequest(), deploymentRepository, - deployableArtifacts ); + repositorySystem.deploy( session.getRepositorySession(), deployRequest ); } - catch ( ArtifactDeployerException e ) + catch ( DeploymentException e ) { throw new MojoExecutionException( e.getMessage(), e ); } - } - - /** - * Creates a Maven project in-memory from the user-supplied groupId, artifactId and version. When a classifier is - * supplied, the packaging must be POM because the project with only have attachments. This project serves as basis - * to attach the artifacts to deploy to. - * - * @return The created Maven project, never null. - * @throws MojoExecutionException When the model of the project could not be built. - * @throws MojoFailureException When building the project failed. - */ - private MavenProject createMavenProject() - throws MojoExecutionException, MojoFailureException - { - if ( groupId == null || artifactId == null || version == null || packaging == null ) - { - throw new MojoExecutionException( "The artifact information is incomplete: 'groupId', 'artifactId', " - + "'version' and 'packaging' are required." ); - } - ModelSource modelSource = - new StringModelSource( "" + "4.0.0" + "" + groupId - + "" + "" + artifactId + "" + "" + version + "" - + "" + ( classifier == null ? packaging : "pom" ) + "" + "" ); - DefaultProjectBuildingRequest buildingRequest = - new DefaultProjectBuildingRequest( getSession().getProjectBuildingRequest() ); - buildingRequest.setProcessPlugins( false ); - try - { - return projectBuilder.build( modelSource, buildingRequest ).getProject(); - } - catch ( ProjectBuildingException e ) + finally { - if ( e.getCause() instanceof ModelBuildingException ) + if ( temporaryPom != null ) { - throw new MojoExecutionException( "The artifact information is not valid:" + Os.LINE_SEP - + e.getCause().getMessage() ); + // noinspection ResultOfMethodCallIgnored + temporaryPom.delete(); } - throw new MojoFailureException( "Unable to create the project.", e ); } } /** - * Gets the path of the artifact constructed from the supplied groupId, artifactId, version, classifier and - * packaging within the local repository. Note that the returned path need not exist (yet). - * - * @return The absolute path to the artifact when installed, never null. + * Gets the path of the specified artifact within the local repository. Note that the returned path need not exist + * (yet). */ - private File getLocalRepoFile() + private File getLocalRepositoryFile( RepositorySystemSession session, Artifact artifact ) { - DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate(); - coordinate.setGroupId( groupId ); - coordinate.setArtifactId( artifactId ); - coordinate.setVersion( version ); - coordinate.setClassifier( classifier ); - coordinate.setExtension( packaging ); - String path = repoManager.getPathForLocalArtifact( getSession().getProjectBuildingRequest(), coordinate ); - return new File( repoManager.getLocalRepositoryBasedir( getSession().getProjectBuildingRequest() ), path ); + String path = session.getLocalRepositoryManager().getPathForLocalArtifact( artifact ); + return new File( session.getLocalRepository().getBasedir(), path ); } /** @@ -737,4 +662,63 @@ void setClassifier( String classifier ) this.classifier = classifier; } + // these below should be shared (duplicated in m-install-p, m-deploy-p) + + /** + * Specialization of {@link FileUtils#getExtension(String)} that honors various {@code tar.xxx} combinations. + */ + private String getExtension( final File file ) + { + String filename = file.getName(); + 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 ) + { + 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 == '.' ) ) + { + return false; + } + } + return true; + } + + private static final String ILLEGAL_VERSION_CHARS = "\\/:\"<>|?*[](){},"; + + /** + * Returns {@code true} if passed in string is "valid Maven (simple. non range, expression, etc) version". + */ + 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 ) + { + return false; + } + } + return true; + } } 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 bec6b384..d169ab8a 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -19,26 +19,26 @@ * under the License. */ +import java.io.File; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException; -import org.apache.maven.shared.transfer.project.NoFileAssignedException; -import org.apache.maven.shared.transfer.project.deploy.ProjectDeployer; -import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest; +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. @@ -128,12 +128,6 @@ public class DeployMojo @Parameter( property = "maven.deploy.skip", defaultValue = "false" ) private String skip = Boolean.FALSE.toString(); - /** - * Component used to deploy project. - */ - @Component - private ProjectDeployer projectDeployer; - private enum State { SKIPPED, DEPLOYED, TO_BE_DEPLOYED @@ -175,7 +169,7 @@ private State getState( Map pluginContext ) private boolean hasState( MavenProject project ) { - Map pluginContext = getSession().getPluginContext( pluginDescriptor, project ); + Map pluginContext = session.getPluginContext( pluginDescriptor, project ); return pluginContext.containsKey( DEPLOY_PROCESSED_MARKER ); } @@ -193,32 +187,23 @@ public void execute() else { failIfOffline(); + warnIfAffectedPackagingAndMaven( project.getPackaging() ); if ( !deployAtEnd ) { - // CHECKSTYLE_OFF: LineLength - // @formatter:off - ProjectDeployerRequest pdr = new ProjectDeployerRequest() - .setProject( project ) - .setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ) - .setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ) - .setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ) - .setAltDeploymentRepository( altDeploymentRepository ); - // @formatter:on - // CHECKSTYLE_ON: LineLength - - ArtifactRepository repo = getDeploymentRepository( pdr ); - - deployProject( getSession().getProjectBuildingRequest(), pdr, repo ); + deploy( session.getRepositorySession(), + processProject( project, + altSnapshotDeploymentRepository, altReleaseDeploymentRepository, altDeploymentRepository ) ); putState( State.DEPLOYED ); } else { - putState( State.TO_BE_DEPLOYED ); putPluginContextValue( DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository ); putPluginContextValue( DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY, altSnapshotDeploymentRepository ); putPluginContextValue( DEPLOY_ALT_DEPLOYMENT_REPOSITORY, altDeploymentRepository ); - getLog().info( "Deferring deploy for " + getProjectReferenceId( project ) + " at end" ); + putState( State.TO_BE_DEPLOYED ); + getLog().info( "Deferring deploy for " + project.getGroupId() + + ":" + project.getArtifactId() + ":" + project.getVersion() + " at end" ); } } @@ -226,7 +211,7 @@ public void execute() { for ( MavenProject reactorProject : reactorProjects ) { - Map pluginContext = getSession().getPluginContext( pluginDescriptor, reactorProject ); + Map pluginContext = session.getPluginContext( pluginDescriptor, reactorProject ); State state = getState( pluginContext ); if ( state == State.TO_BE_DEPLOYED ) { @@ -237,26 +222,15 @@ public void execute() String altDeploymentRepository = getPluginContextValue( pluginContext, DEPLOY_ALT_DEPLOYMENT_REPOSITORY ); - ProjectDeployerRequest pdr = new ProjectDeployerRequest() - .setProject( reactorProject ) - .setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ) - .setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ) - .setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ) - .setAltDeploymentRepository( altDeploymentRepository ); - - ArtifactRepository repo = getDeploymentRepository( pdr ); - - deployProject( getSession().getProjectBuildingRequest(), pdr, repo ); + deploy( session.getRepositorySession(), + processProject( reactorProject, + altSnapshotDeploymentRepository, altReleaseDeploymentRepository, altDeploymentRepository ) + ); } } } } - private String getProjectReferenceId( MavenProject mavenProject ) - { - return mavenProject.getGroupId() + ":" + mavenProject.getArtifactId() + ":" + mavenProject.getVersion(); - } - private boolean allProjectsMarked() { for ( MavenProject reactorProject : reactorProjects ) @@ -269,35 +243,89 @@ private boolean allProjectsMarked() return true; } - private void deployProject( ProjectBuildingRequest pbr, ProjectDeployerRequest pir, ArtifactRepository repo ) - throws MojoFailureException, MojoExecutionException + private DeployRequest processProject( final MavenProject project, + final String altSnapshotDeploymentRepository, + final String altReleaseDeploymentRepository, + final String altDeploymentRepository ) + throws MojoExecutionException, MojoFailureException { - try + 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 ) { - warnIfAffectedPackagingAndMaven( pir.getProject().getPackaging() ); - projectDeployer.deploy( pbr, pir, repo ); + request.addArtifact( RepositoryUtils.toArtifact( new ProjectArtifact( project ) ) ); + pomArtifactAttached = true; } - catch ( NoFileAssignedException e ) + + if ( !isPomArtifact ) { - throw new MojoExecutionException( "NoFileAssignedException", e ); + 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" ); + } } - catch ( ArtifactDeployerException e ) + + if ( !pomArtifactAttached ) + { + throw new MojoExecutionException( "The POM could not be attached" ); + } + + for ( org.apache.maven.artifact.Artifact attached : project.getAttachedArtifacts() ) { - throw new MojoExecutionException( "ArtifactDeployerException", e ); + getLog().debug( "Attaching for install: " + attached.getId() ); + request.addArtifact( RepositoryUtils.toArtifact( attached ) ); } + return request; } - ArtifactRepository getDeploymentRepository( ProjectDeployerRequest pdr ) + /** + * Visible for testing. + */ + RemoteRepository getDeploymentRepository( final MavenProject project, + final String altSnapshotDeploymentRepository, + final String altReleaseDeploymentRepository, + final String altDeploymentRepository ) throws MojoExecutionException, MojoFailureException { - MavenProject project = pdr.getProject(); - String altDeploymentRepository = pdr.getAltDeploymentRepository(); - String altReleaseDeploymentRepository = pdr.getAltReleaseDeploymentRepository(); - String altSnapshotDeploymentRepository = pdr.getAltSnapshotDeploymentRepository(); - - ArtifactRepository repo = null; + RemoteRepository repo = null; String altDeploymentRepo; if ( ArtifactUtils.isSnapshot( project.getVersion() ) && altSnapshotDeploymentRepository != null ) @@ -329,7 +357,7 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym { getLog().warn( "Using legacy syntax for alternative repository. " + "Use \"" + id + "::" + url + "\" instead." ); - repo = createDeploymentArtifactRepository( id, url ); + repo = getRemoteRepository( id, url ); } else { @@ -356,14 +384,14 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym String id = matcher.group( 1 ).trim(); String url = matcher.group( 2 ).trim(); - repo = createDeploymentArtifactRepository( id, url ); + repo = getRemoteRepository( id, url ); } } } if ( repo == null ) { - repo = project.getDistributionManagementArtifactRepository(); + repo = RepositoryUtils.toRepo( project.getDistributionManagementArtifactRepository() ); } if ( repo == null ) 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 371838bd..d8538705 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -97,7 +97,8 @@ public void testBasicDeployFile() DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); 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" ); @@ -199,6 +200,7 @@ public void testDeployIfClassifierIsSet() DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); 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" ); @@ -248,6 +250,7 @@ public void testDeployIfArtifactIsNotJar() DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); 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" ); 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 6131f79d..a7bbd8b7 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java @@ -19,36 +19,27 @@ * under the License. */ -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; +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 Jerome Lacoste */ public class DeployFileMojoUnitTest - extends TestCase { - public static void main( String[] args ) - { - junit.textui.TestRunner.run( suite() ); - } - - public static Test suite() - { - TestSuite suite = new TestSuite( DeployFileMojoUnitTest.class ); - - return suite; - } - MockDeployFileMojo mojo; Parent parent; + @Before public void setUp() { Model pomModel = new Model(); @@ -62,12 +53,13 @@ public void setUp() mojo = new MockDeployFileMojo( pomModel ); } + @After public void tearDown() { mojo = null; } - class MockDeployFileMojo extends DeployFileMojo { + static class MockDeployFileMojo extends DeployFileMojo { private Model model; public MockDeployFileMojo(Model model) { @@ -83,6 +75,7 @@ protected Model readModel(File pomFile) throws MojoExecutionException { } } + @Test public void testProcessPomFromPomFileWithParent1() throws MojoExecutionException { mojo.setPomFile( new File( "foo.bar" ) ); @@ -98,6 +91,7 @@ public void testProcessPomFromPomFileWithParent1() throws MojoExecutionException checkMojoProperties("parentGroup", null, "parentVersion", null); } + @Test public void testProcessPomFromPomFileWithParent2() throws MojoExecutionException { mojo.setPomFile( new File( "foo.bar" ) ); @@ -113,6 +107,7 @@ public void testProcessPomFromPomFileWithParent2() throws MojoExecutionException } + @Test public void testProcessPomFromPomFileWithParent3() throws MojoExecutionException { mojo.setPomFile( new File( "foo.bar" ) ); @@ -127,6 +122,7 @@ public void testProcessPomFromPomFileWithParent3() throws MojoExecutionException checkMojoProperties( "parentGroup", "artifact", "version", null ); } + @Test public void testProcessPomFromPomFileWithParent4() throws MojoExecutionException { mojo.setPomFile( new File( "foo.bar" ) ); @@ -137,6 +133,7 @@ public void testProcessPomFromPomFileWithParent4() throws MojoExecutionException checkMojoProperties("parentGroup", "artifact", "version", "packaging"); } + @Test public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException { mojo.setPomFile( new File( "foo.bar" ) ); @@ -147,6 +144,7 @@ public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException checkMojoProperties("group", "artifact", "version", "packaging"); } + @Test public void testProcessPomFromPomFileWithParent6() throws MojoExecutionException { mojo.setPomFile( new File( "foo.bar" ) ); @@ -158,6 +156,7 @@ public void testProcessPomFromPomFileWithParent6() throws MojoExecutionException } + @Test public void testProcessPomFromPomFileWithOverrides() throws MojoExecutionException { mojo.setPomFile( new File( "foo.bar" ) ); 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 c8350c47..f34abd06 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -20,6 +20,7 @@ */ 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; @@ -31,25 +32,23 @@ import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; -import org.apache.maven.artifact.repository.ArtifactRepository; 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; -import org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub; import org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub; import org.apache.maven.plugins.deploy.stubs.DeployArtifactStub; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest; import org.codehaus.plexus.util.FileUtils; import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; import org.junit.Ignore; import org.mockito.InjectMocks; -import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; @@ -84,6 +83,9 @@ public void setUp() session = mock( MavenSession.class ); when( session.getPluginContext(any(PluginDescriptor.class), any(MavenProject.class))) .thenReturn( new ConcurrentHashMap() ); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) ); + when( session.getRepositorySession() ).thenReturn( repositorySession ); remoteRepo = new File( REMOTE_REPO ); @@ -100,8 +102,6 @@ public void setUp() { FileUtils.deleteDirectory( remoteRepo ); } - - } public void tearDown() @@ -136,13 +136,14 @@ public void testBasicDeploy() 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 file = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/target/" + "deploy-test-file-1.0-SNAPSHOT.jar" ); @@ -150,6 +151,9 @@ public void testBasicDeploy() 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" ); setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); @@ -317,6 +321,7 @@ public void testBasicDeployWithPackagingAsPom() 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/" + @@ -325,6 +330,9 @@ public void testBasicDeployWithPackagingAsPom() 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 ) ); @@ -391,6 +399,9 @@ public void testDeployIfArtifactFileIsNull() 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 ) ); @@ -431,8 +442,12 @@ public void testDeployWithAttachedArtifacts() DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); 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" ); setVariableValueToObject( mojo, "pluginContext", new ConcurrentHashMap<>() ); setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); @@ -524,9 +539,9 @@ public void _testBasicDeployWithScpAsProtocol() assertNotNull( mojo ); - ArtifactDeployerStub deployer = new ArtifactDeployerStub(); + RepositorySystem repositorySystem = mock( RepositorySystem.class ); - setVariableValueToObject( mojo, "deployer", deployer ); + setVariableValueToObject( mojo, "repositorySystem", repositorySystem ); File file = new File( getBasedir(), "target/test-classes/unit/basic-deploy-scp/target/" + @@ -571,42 +586,32 @@ public void _testBasicDeployWithScpAsProtocol() public void testLegacyAltDeploymentRepositoryWithDefaultLayout() throws Exception { - DeployMojo mojo = spy( new DeployMojo() ); + DeployMojo mojo = new DeployMojo(); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" - ) ).thenReturn( repository ); + setVariableValueToObject( mojo, "project", project ); + setVariableValueToObject( mojo, "session", session ); + setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::default::http://localhost" ); project.setVersion( "1.0-SNAPSHOT" ); - ProjectDeployerRequest pdr = - new ProjectDeployerRequest() - .setProject( project ) - .setAltDeploymentRepository( "altDeploymentRepository::default::http://localhost" ); - - assertEquals( repository, - mojo.getDeploymentRepository( pdr ) ); + assertEquals( new RemoteRepository.Builder( "altDeploymentRepository", "default", "http://localhost" ).build(), + mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::default::http://localhost") ); } public void testLegacyAltDeploymentRepositoryWithLegacyLayout() throws Exception { - DeployMojo mojo = spy( new DeployMojo() ); + DeployMojo mojo = new DeployMojo(); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" - ) ).thenReturn( repository ); + setVariableValueToObject( mojo, "project", project ); + setVariableValueToObject( mojo, "session", session ); + setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::http://localhost" ); project.setVersion( "1.0-SNAPSHOT" ); - - ProjectDeployerRequest pdr = - new ProjectDeployerRequest() - .setProject( project ) - .setAltDeploymentRepository( "altDeploymentRepository::legacy::http://localhost" ); try { - mojo.getDeploymentRepository( pdr ); + mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::legacy::http://localhost" ); fail( "Should throw: Invalid legacy syntax and layout for repository." ); } catch( MojoFailureException e ) @@ -619,21 +624,16 @@ public void testLegacyAltDeploymentRepositoryWithLegacyLayout() public void testInsaneAltDeploymentRepository() throws Exception { - DeployMojo mojo = spy( new DeployMojo() ); + DeployMojo mojo = new DeployMojo(); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" - ) ).thenReturn( repository ); + setVariableValueToObject( mojo, "project", project ); + setVariableValueToObject( mojo, "session", session ); + setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::hey::wow::foo::http://localhost" ); project.setVersion( "1.0-SNAPSHOT" ); - - ProjectDeployerRequest pdr = - new ProjectDeployerRequest() - .setProject( project ) - .setAltDeploymentRepository( "altDeploymentRepository::hey::wow::foo::http://localhost" ); try { - mojo.getDeploymentRepository( pdr ); + mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::hey::wow::foo::http://localhost" ); fail( "Should throw: Invalid legacy syntax and layout for repository." ); } catch( MojoFailureException e ) @@ -646,40 +646,29 @@ public void testInsaneAltDeploymentRepository() public void testDefaultScmSvnAltDeploymentRepository() throws Exception { - DeployMojo mojo = spy( new DeployMojo() ); + DeployMojo mojo = new DeployMojo(); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "scm:svn:http://localhost" - ) ).thenReturn( repository ); + setVariableValueToObject( mojo, "project", project ); + setVariableValueToObject( mojo, "session", session ); + setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::default::scm:svn:http://localhost" ); project.setVersion( "1.0-SNAPSHOT" ); - ProjectDeployerRequest pdr = - new ProjectDeployerRequest() - .setProject( project ) - .setAltDeploymentRepository( "altDeploymentRepository::default::scm:svn:http://localhost" ); - - assertEquals( repository, - mojo.getDeploymentRepository( pdr ) ); + 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 = spy( new DeployMojo() ); + DeployMojo mojo = new DeployMojo(); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" - ) ).thenReturn( repository ); + setVariableValueToObject( mojo, "project", project ); + setVariableValueToObject( mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::scm:svn:http://localhost" ); project.setVersion( "1.0-SNAPSHOT" ); - - ProjectDeployerRequest pdr = - new ProjectDeployerRequest() - .setProject( project ) - .setAltDeploymentRepository( "altDeploymentRepository::legacy::scm:svn:http://localhost" ); try { - mojo.getDeploymentRepository( pdr ); + mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::legacy::scm:svn:http://localhost" ); fail( "Should throw: Invalid legacy syntax and layout for repository." ); } catch( MojoFailureException e ) @@ -692,39 +681,31 @@ public void testLegacyScmSvnAltDeploymentRepository() public void testAltSnapshotDeploymentRepository() throws Exception { - DeployMojo mojo = spy( new DeployMojo() ); + DeployMojo mojo = new DeployMojo(); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost" - ) ).thenReturn( repository ); + setVariableValueToObject( mojo, "project", project ); + setVariableValueToObject( mojo, "session", session ); + setVariableValueToObject( mojo, "altSnapshotDeploymentRepository", "altSnapshotDeploymentRepository::http://localhost" ); project.setVersion( "1.0-SNAPSHOT" ); - ProjectDeployerRequest pdr = - new ProjectDeployerRequest() - .setProject( project ) - .setAltDeploymentRepository( "altSnapshotDeploymentRepository::http://localhost" ); - assertEquals( repository, - mojo.getDeploymentRepository( pdr )); + assertEquals( new RemoteRepository.Builder( "altSnapshotDeploymentRepository", "default", "http://localhost" ).build(), + mojo.getDeploymentRepository( project, "altSnapshotDeploymentRepository::http://localhost", null, null )); } public void testAltReleaseDeploymentRepository() throws Exception { - DeployMojo mojo = spy( new DeployMojo() ); + DeployMojo mojo = new DeployMojo(); - ArtifactRepository repository = mock( ArtifactRepository.class ); - when( mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost" ) ).thenReturn( repository ); + setVariableValueToObject( mojo, "project", project ); + setVariableValueToObject( mojo, "session", session ); + setVariableValueToObject( mojo, "altReleaseDeploymentRepository", "altReleaseDeploymentRepository::http://localhost" ); project.setVersion( "1.0" ); - ProjectDeployerRequest pdr = - new ProjectDeployerRequest() - .setProject( project ) - .setAltReleaseDeploymentRepository( "altReleaseDeploymentRepository::http://localhost" ); - - assertEquals( repository, - mojo.getDeploymentRepository( pdr )); + assertEquals( new RemoteRepository.Builder("altReleaseDeploymentRepository", "default", "http://localhost").build(), + mojo.getDeploymentRepository( project, null, "altReleaseDeploymentRepository::http://localhost", null )); } private void addFileToList( File file, List fileList ) diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java deleted file mode 100644 index d0b47d43..00000000 --- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactDeployerStub.java +++ /dev/null @@ -1,47 +0,0 @@ -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 - * 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.util.Collection; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployer; -import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException; - -public class ArtifactDeployerStub - implements ArtifactDeployer -{ - - @Override - public void deploy( ProjectBuildingRequest request, Collection mavenArtifacts ) - throws ArtifactDeployerException - { - // does nothing - } - - @Override - public void deploy( ProjectBuildingRequest arg0, ArtifactRepository arg1, Collection arg2) - throws ArtifactDeployerException - { - // does nothing - } -} From b9052355f7e425bc11f12fda44cb280f2d52c738 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Sat, 16 Jul 2022 18:14:09 +0200 Subject: [PATCH 115/153] [maven-release-plugin] prepare release maven-deploy-plugin-3.0.0 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 385b4d9f..f5347685 100644 --- a/pom.xml +++ b/pom.xml @@ -26,11 +26,11 @@ under the License. org.apache.maven.plugins maven-plugins 36 - + maven-deploy-plugin - 3.0.0-M3-SNAPSHOT + 3.0.0 maven-plugin Apache Maven Deploy Plugin @@ -45,7 +45,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} - HEAD + maven-deploy-plugin-3.0.0 JIRA @@ -67,7 +67,7 @@ under the License. 3.2.5 1.7.5 1.0.0.v20140518 - 2021-12-27T14:11:19Z + 2022-07-16T16:14:02Z From bee2a14323b7d4308c00bddb2cb81cbb2d0dddd4 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Sat, 16 Jul 2022 18:14:30 +0200 Subject: [PATCH 116/153] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index f5347685..d35854da 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-deploy-plugin - 3.0.0 + 3.0.1-SNAPSHOT maven-plugin Apache Maven Deploy Plugin @@ -45,7 +45,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} - maven-deploy-plugin-3.0.0 + HEAD JIRA @@ -67,7 +67,7 @@ under the License. 3.2.5 1.7.5 1.0.0.v20140518 - 2022-07-16T16:14:02Z + 2022-07-16T16:14:30Z From f8fad3d14c1f9bd16a40a849bd99f0819e7c8f34 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 7 Aug 2022 11:38:32 +0200 Subject: [PATCH 117/153] Added release drafter. --- .github/release-drafter.yml | 18 ++++++++++++++++++ .github/workflows/release-drafter.yml | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..387b9ca2 --- /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/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..58e5ee49 --- /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@v2 From 4a72d8e9778c1878058435bdb919d40d65c879dd Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Sun, 7 Aug 2022 11:49:24 +0200 Subject: [PATCH 118/153] [MDEPLOY-299] - Upgrade maven-plugin parent to 37 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d35854da..c6b619e7 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 36 + 37 From ff5b76e6c79f922668c541cb615e274499a0d65d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Wed, 2 Nov 2022 23:41:27 +0100 Subject: [PATCH 119/153] add Reproducible Builds badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0cf6df08..52b7b0fd 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Contributing to [Apache Maven Deploy Plugin](https://maven.apache.org/plugins/ma [![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MDEPLOY.json)][jira] [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/apache/maven.svg?label=License)][license] [![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-deploy-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-deploy-plugin) +[![Reproducible Builds](https://img.shields.io/badge/Reproducible_Builds-ok-green?labelColor=blue)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/plugins/maven-deploy-plugin/README.md) [![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][build] [![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/job/master.svg?)][test-results] From 8bce035ce35dea500a5b632a3de7f263a5b446c7 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 7 Nov 2022 23:37:18 +0100 Subject: [PATCH 120/153] Use shared GH actions v3 --- .github/workflows/maven-verify.yml | 2 +- .github/workflows/release-drafter.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index bbd77865..4d67fdcf 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 index 58e5ee49..b44872cf 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -22,4 +22,4 @@ on: - master jobs: update_release_draft: - uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v2 + uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v3 From 600bda797b81c8bdbaa80cbb6e8bc633d0c1cbcb Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Fri, 6 May 2022 11:24:04 +0200 Subject: [PATCH 121/153] [MDEPLOY-292] Require Java 8 --- pom.xml | 6 +- .../maven/plugins/deploy/DeployFileMojo.java | 59 ++++--------------- .../plugins/deploy/DeployFileMojoTest.java | 11 ++-- .../deploy/DeployFileMojoUnitTest.java | 9 +-- .../maven/plugins/deploy/DeployMojoTest.java | 33 ++++++----- .../apache/maven/plugins/deploy/Utils.java | 1 + .../deploy/stubs/ArtifactRepositoryStub.java | 2 +- .../deploy/stubs/DeployArtifactStub.java | 4 +- 8 files changed, 44 insertions(+), 81 deletions(-) diff --git a/pom.xml b/pom.xml index c6b619e7..d0a221d9 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ under the License. - 7 + 8 3.2.5 1.7.5 1.0.0.v20140518 @@ -232,10 +232,6 @@ under the License. deploy - - - ${https.protocols} - 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 5d950438..11bb2859 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -21,12 +21,12 @@ 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; @@ -179,14 +179,9 @@ void initProperties() if ( pomFile == null ) { boolean foundPom = false; - - JarFile jarFile = null; - try + try ( JarFile jarFile = new JarFile( file ) ) { Pattern pomEntry = Pattern.compile( "META-INF/maven/.*/pom\\.xml" ); - - jarFile = new JarFile( file ); - Enumeration jarEntries = jarFile.entries(); while ( jarEntries.hasMoreElements() ) @@ -196,41 +191,23 @@ void initProperties() if ( pomEntry.matcher( entry.getName() ).matches() ) { getLog().debug( "Using " + entry.getName() + " as pomFile" ); - foundPom = true; - - InputStream pomInputStream = null; - OutputStream pomOutputStream = null; - - try + String base = file.getName(); + if ( base.indexOf( '.' ) > 0 ) { - pomInputStream = jarFile.getInputStream( entry ); + base = base.substring( 0, base.lastIndexOf( '.' ) ); + } + pomFile = new File( file.getParentFile(), base + ".pom" ); - String base = file.getName(); - if ( base.indexOf( '.' ) > 0 ) + try ( InputStream pomInputStream = jarFile.getInputStream( entry ) ) + { + try ( OutputStream pomOutputStream = Files.newOutputStream( pomFile.toPath() ) ) { - base = base.substring( 0, base.lastIndexOf( '.' ) ); + 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 ) ); - break; } - finally - { - IOUtil.close( pomInputStream ); - IOUtil.close( pomOutputStream ); - } } } @@ -243,20 +220,6 @@ void initProperties() { // ignore, artifact not packaged by Maven } - finally - { - if ( jarFile != null ) - { - try - { - jarFile.close(); - } - catch ( IOException e ) - { - // we did our best - } - } - } } else { 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 d8538705..0700dfbf 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -25,6 +25,7 @@ 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; @@ -43,7 +44,7 @@ public class DeployFileMojoTest extends AbstractMojoTestCase { - private String LOCAL_REPO = getBasedir() + "/target/local-repo"; + private final String LOCAL_REPO = getBasedir() + "/target/local-repo"; private List expectedFiles; @@ -151,14 +152,14 @@ public void testBasicDeployFile() assertEquals( "POM was created from deploy:deploy-file", model.getDescription() ); //check the remote-repo - expectedFiles = new ArrayList(); - fileList = new ArrayList(); + expectedFiles = new ArrayList<>(); + fileList = new ArrayList<>(); 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); } @@ -285,7 +286,7 @@ private void addFileToList( File file, List fileList ) File[] files = file.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull( files ) ) { addFileToList(file1, fileList); } } 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 a7bbd8b7..0edf72f1 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java @@ -70,13 +70,14 @@ public void setModel(Model model) { this.model = model; } - protected Model readModel(File pomFile) throws MojoExecutionException { + protected Model readModel(File pomFile) + { return model; } } @Test - public void testProcessPomFromPomFileWithParent1() throws MojoExecutionException + public void testProcessPomFromPomFileWithParent1() { mojo.setPomFile( new File( "foo.bar" ) ); @@ -92,7 +93,7 @@ public void testProcessPomFromPomFileWithParent1() throws MojoExecutionException } @Test - public void testProcessPomFromPomFileWithParent2() throws MojoExecutionException + public void testProcessPomFromPomFileWithParent2() { mojo.setPomFile( new File( "foo.bar" ) ); setMojoModel( mojo.model, null, "artifact", null, null, parent ); @@ -108,7 +109,7 @@ public void testProcessPomFromPomFileWithParent2() throws MojoExecutionException } @Test - public void testProcessPomFromPomFileWithParent3() throws MojoExecutionException + public void testProcessPomFromPomFileWithParent3() { mojo.setPomFile( new File( "foo.bar" ) ); setMojoModel( mojo.model, null, "artifact", "version", null, 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 f34abd06..54bc16fa 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -29,6 +29,7 @@ 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; @@ -62,13 +63,13 @@ public class DeployMojoTest private File localRepo; - private String LOCAL_REPO = getBasedir() + "/target/local-repo"; + private final String LOCAL_REPO = getBasedir() + "/target/local-repo"; - private String REMOTE_REPO = getBasedir() + "/target/remote-repo"; + private final String REMOTE_REPO = getBasedir() + "/target/remote-repo"; DeployArtifactStub artifact; - MavenProjectStub project = new MavenProjectStub(); + final MavenProjectStub project = new MavenProjectStub(); private MavenSession session; @@ -180,8 +181,8 @@ public void testBasicDeploy() mojo.execute(); //check the artifact in local repository - List expectedFiles = new ArrayList(); - List fileList = new ArrayList(); + List expectedFiles = new ArrayList<>(); + List fileList = new ArrayList<>(); expectedFiles.add( "org" ); expectedFiles.add( "apache" ); @@ -202,7 +203,7 @@ public void testBasicDeploy() File[] files = localRepo.listFiles(); - for (File file2 : files) { + for (File file2 : Objects.requireNonNull( files ) ) { addFileToList(file2, fileList); } @@ -211,8 +212,8 @@ public void testBasicDeploy() assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); //check the artifact in remote repository - expectedFiles = new ArrayList(); - fileList = new ArrayList(); + expectedFiles = new ArrayList<>(); + fileList = new ArrayList<>(); expectedFiles.add( "org" ); expectedFiles.add( "apache" ); @@ -238,7 +239,7 @@ public void testBasicDeploy() files = remoteRepo.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull( files ) ) { addFileToList(file1, fileList); } @@ -349,8 +350,8 @@ public void testBasicDeployWithPackagingAsPom() mojo.execute(); - List expectedFiles = new ArrayList(); - List fileList = new ArrayList(); + List expectedFiles = new ArrayList<>(); + List fileList = new ArrayList<>(); expectedFiles.add( "org" ); expectedFiles.add( "apache" ); @@ -372,7 +373,7 @@ public void testBasicDeployWithPackagingAsPom() File[] files = remoteRepo.listFiles(); - for (File file : files) { + for (File file : Objects.requireNonNull( files ) ) { addFileToList(file, fileList); } @@ -467,8 +468,8 @@ public void testDeployWithAttachedArtifacts() mojo.execute(); //check the artifacts in remote repository - List expectedFiles = new ArrayList(); - List fileList = new ArrayList(); + List expectedFiles = new ArrayList<>(); + List fileList = new ArrayList<>(); expectedFiles.add( "org" ); expectedFiles.add( "apache" ); @@ -506,7 +507,7 @@ public void testDeployWithAttachedArtifacts() File[] files = remoteRepo.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull( files ) ) { addFileToList(file1, fileList); } @@ -720,7 +721,7 @@ private void addFileToList( File file, List fileList ) File[] files = file.listFiles(); - for (File file1 : files) { + for (File file1 : Objects.requireNonNull( files ) ) { addFileToList(file1, fileList); } } diff --git a/src/test/java/org/apache/maven/plugins/deploy/Utils.java b/src/test/java/org/apache/maven/plugins/deploy/Utils.java index f4acbc9d..be963420 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/Utils.java +++ b/src/test/java/org/apache/maven/plugins/deploy/Utils.java @@ -30,6 +30,7 @@ /** * A utility class to assist testing. + * used in IntegrationTests like attach-jar-checksum-snapshot, attach-jar-checksum-snapshot * * @author Benjamin Bentmann */ 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 92db6c19..238c5f79 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 @@ -36,7 +36,7 @@ public class ArtifactRepositoryStub private String url; - private String basedir = System.getProperty( "basedir" ); + private final String basedir = System.getProperty( "basedir" ); public ArtifactRepositoryStub() { 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 24f31d58..8993ed99 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 @@ -101,7 +101,7 @@ public void addMetadata( ArtifactMetadata metadata ) { if ( metadataMap == null ) { - metadataMap = new HashMap(); + metadataMap = new HashMap<>(); } ArtifactMetadata m = metadataMap.get( metadata.getKey() ); @@ -117,7 +117,7 @@ public void addMetadata( ArtifactMetadata metadata ) public Collection getMetadataList() { - return metadataMap == null ? Collections.emptyList() : metadataMap.values(); + return metadataMap == null ? Collections.emptyList() : metadataMap.values(); } public boolean isRelease() From dbf3a07cf68ec228ae0f227e3638ce58a81a039a Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Mon, 28 Nov 2022 21:04:55 +0000 Subject: [PATCH 122/153] Assume at least Maven 3 (#29) @michael-o --- src/site/apt/index.apt.vm | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 81515002..262e90a1 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: <<>> - The new format is: <<>> - - [] - - 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 From 365122c614fc27f4185c6d63b82ada2d43f9d46e Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 20 Jan 2023 20:46:01 +0100 Subject: [PATCH 123/153] Disable merge button and add jira autolink --- .asf.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.asf.yaml b/.asf.yaml index 5feedc51..699735c5 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 From 273179603fa8e4be751bace9c33b62abdac41037 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 20 Jan 2023 20:46:58 +0100 Subject: [PATCH 124/153] Fix jira key in PR template --- .github/pull_request_template.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b9b9dde8..7f4ebfaa 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. From 11474f15ac679090dbe38e20a3b3c41f0d34e85c Mon Sep 17 00:00:00 2001 From: Jens Awisus Date: Fri, 2 Dec 2022 20:41:29 +0100 Subject: [PATCH 125/153] [MDEPLOY-272] - Skip deploy-file as done in DeployMojo --- .../invoker.properties | 17 +++++++ src/it/deployfile-release-skip-fail/pom.xml | 48 +++++++++++++++++++ .../test.properties | 18 +++++++ .../verify.groovy | 26 ++++++++++ .../invoker.properties | 17 +++++++ src/it/deployfile-release-skip/pom.xml | 48 +++++++++++++++++++ .../deployfile-release-skip/test.properties | 18 +++++++ src/it/deployfile-release-skip/verify.groovy | 24 ++++++++++ .../deployfile-skip-fail/invoker.properties | 17 +++++++ src/it/deployfile-skip-fail/pom.xml | 47 ++++++++++++++++++ src/it/deployfile-skip-fail/test.properties | 18 +++++++ src/it/deployfile-skip-fail/verify.groovy | 26 ++++++++++ src/it/deployfile-skip/invoker.properties | 17 +++++++ src/it/deployfile-skip/pom.xml | 47 ++++++++++++++++++ src/it/deployfile-skip/test.properties | 18 +++++++ src/it/deployfile-skip/verify.groovy | 24 ++++++++++ .../invoker.properties | 17 +++++++ src/it/deployfile-snapshot-skip-fail/pom.xml | 48 +++++++++++++++++++ .../test.properties | 18 +++++++ .../verify.groovy | 28 +++++++++++ .../invoker.properties | 17 +++++++ src/it/deployfile-snapshot-skip/pom.xml | 48 +++++++++++++++++++ .../deployfile-snapshot-skip/test.properties | 18 +++++++ src/it/deployfile-snapshot-skip/verify.groovy | 24 ++++++++++ .../maven/plugins/deploy/DeployFileMojo.java | 24 ++++++++++ .../plugins/deploy/DeployFileMojoTest.java | 4 ++ .../unit/deploy-file-test/plugin-config.xml | 1 + 27 files changed, 677 insertions(+) create mode 100644 src/it/deployfile-release-skip-fail/invoker.properties create mode 100644 src/it/deployfile-release-skip-fail/pom.xml create mode 100644 src/it/deployfile-release-skip-fail/test.properties create mode 100644 src/it/deployfile-release-skip-fail/verify.groovy create mode 100644 src/it/deployfile-release-skip/invoker.properties create mode 100644 src/it/deployfile-release-skip/pom.xml create mode 100644 src/it/deployfile-release-skip/test.properties create mode 100644 src/it/deployfile-release-skip/verify.groovy create mode 100644 src/it/deployfile-skip-fail/invoker.properties create mode 100644 src/it/deployfile-skip-fail/pom.xml create mode 100644 src/it/deployfile-skip-fail/test.properties create mode 100644 src/it/deployfile-skip-fail/verify.groovy create mode 100644 src/it/deployfile-skip/invoker.properties create mode 100644 src/it/deployfile-skip/pom.xml create mode 100644 src/it/deployfile-skip/test.properties create mode 100644 src/it/deployfile-skip/verify.groovy create mode 100644 src/it/deployfile-snapshot-skip-fail/invoker.properties create mode 100644 src/it/deployfile-snapshot-skip-fail/pom.xml create mode 100644 src/it/deployfile-snapshot-skip-fail/test.properties create mode 100644 src/it/deployfile-snapshot-skip-fail/verify.groovy create mode 100644 src/it/deployfile-snapshot-skip/invoker.properties create mode 100644 src/it/deployfile-snapshot-skip/pom.xml create mode 100644 src/it/deployfile-snapshot-skip/test.properties create mode 100644 src/it/deployfile-snapshot-skip/verify.groovy 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 00000000..44aca986 --- /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 00000000..ab4e9cb7 --- /dev/null +++ b/src/it/deployfile-release-skip-fail/pom.xml @@ -0,0 +1,48 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.deploy.its + deployfile-release-skip-fail + 1.0 + + + Test to verify that skip stops artifact deployment + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + 1.0 + snapshots + + + + + + 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 00000000..4b138a5c --- /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 00000000..17fe4366 --- /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 00000000..44aca986 --- /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 00000000..3a02d9af --- /dev/null +++ b/src/it/deployfile-release-skip/pom.xml @@ -0,0 +1,48 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.deploy.its + deployfile-release-skip + 1.0 + + + Test to verify that skip stops artifact deployment + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + 1.0 + releases + + + + + + diff --git a/src/it/deployfile-release-skip/test.properties b/src/it/deployfile-release-skip/test.properties new file mode 100644 index 00000000..28953464 --- /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 00000000..c476e408 --- /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 00000000..44aca986 --- /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 00000000..ae7aa257 --- /dev/null +++ b/src/it/deployfile-skip-fail/pom.xml @@ -0,0 +1,47 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.deploy.its + deployfile-skip-fail + 1.0 + + + Test to verify that skip stops artifact deployment + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + false + + + + + + diff --git a/src/it/deployfile-skip-fail/test.properties b/src/it/deployfile-skip-fail/test.properties new file mode 100644 index 00000000..f93ace8d --- /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 00000000..35e8db1f --- /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 00000000..44aca986 --- /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 00000000..530a84ec --- /dev/null +++ b/src/it/deployfile-skip/pom.xml @@ -0,0 +1,47 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.deploy.its + deployfile-skip + 1.0 + + + Test to verify that skip stops artifact deployment + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + true + + + + + + diff --git a/src/it/deployfile-skip/test.properties b/src/it/deployfile-skip/test.properties new file mode 100644 index 00000000..b1cd0111 --- /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/deployfile-skip/verify.groovy b/src/it/deployfile-skip/verify.groovy new file mode 100644 index 00000000..618ff5e4 --- /dev/null +++ b/src/it/deployfile-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-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-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 00000000..44aca986 --- /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 00000000..aba1a40d --- /dev/null +++ b/src/it/deployfile-snapshot-skip-fail/pom.xml @@ -0,0 +1,48 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.deploy.its + deployfile-snapshot-skip-fail + 1.0 + + + Test to verify that skip stops artifact deployment + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + 1.0-SNAPSHOT + releases + + + + + + 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 00000000..24b71939 --- /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 00000000..21ef0c72 --- /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 00000000..44aca986 --- /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 00000000..cbedfd8c --- /dev/null +++ b/src/it/deployfile-snapshot-skip/pom.xml @@ -0,0 +1,48 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.deploy.its + deployfile-snapshot-skip + 1.0 + + + Test to verify that skip stops artifact deployment + + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + 1.0-SNAPSHOT + snapshots + + + + + + diff --git a/src/it/deployfile-snapshot-skip/test.properties b/src/it/deployfile-snapshot-skip/test.properties new file mode 100644 index 00000000..b33c8181 --- /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 00000000..ab46c590 --- /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/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java index 11bb2859..7f27f39f 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -33,6 +33,7 @@ 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; @@ -173,6 +174,20 @@ public class DeployFileMojo @Parameter( property = "files" ) private String files; + /** + * Set this to 'true' to bypass artifact deploy + * It's not a real boolean as it can have more than 2 values: + *
    + *
  • true: will skip as usual
  • + *
  • releases: will skip if current version of the project is a release
  • + *
  • snapshots: will skip if current version of the project is a snapshot
  • + *
  • any other values will be considered as false
  • + *
+ * @since 3.1.0 + */ + @Parameter( property = "maven.deploy.file.skip", defaultValue = "false" ) + private String skip = Boolean.FALSE.toString(); + void initProperties() throws MojoExecutionException { @@ -235,6 +250,15 @@ void initProperties() 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." ); 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 0700dfbf..deb9fa3e 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -114,6 +114,8 @@ public void testBasicDeployFile() String url = (String) getVariableValueFromObject( mojo, "url" ); + String skip = (String) getVariableValueFromObject( mojo, "skip" ); + assertEquals( "org.apache.maven.test", groupId ); assertEquals( "maven-deploy-file-test", artifactId ); @@ -122,6 +124,8 @@ public void testBasicDeployFile() assertEquals( "jar", packaging ); + assertEquals( "snapshots", skip ); + assertTrue( file.exists() ); assertEquals( "deploy-test", repositoryId ); 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 67b98a17..9f522553 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. file://${basedir}/target/remote-repo/deploy-file-test POM was created from deploy:deploy-file true + snapshots From a9ba23474ed3576fc69e8909d13f1b73e7656260 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 21 Jan 2023 16:10:58 +0100 Subject: [PATCH 126/153] [MDEPLOY-302] Upgrade maven-plugin parent to 39 --- pom.xml | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index d0a221d9..b2618273 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ under the License. org.apache.maven.plugins maven-plugins - 37 + 39 @@ -65,8 +65,10 @@ under the License. 8 3.2.5 - 1.7.5 - 1.0.0.v20140518 + + 1.7.5 + + 1.0.0.v20140518 2022-07-16T16:14:30Z @@ -105,7 +107,6 @@ under the License. org.codehaus.plexus plexus-utils - 3.3.1 org.eclipse.aether @@ -117,7 +118,8 @@ under the License. org.eclipse.aether aether-util ${resolverVersion} - compile + + compile @@ -134,7 +136,8 @@ under the License. 3.3.0 test - + + org.apache.maven maven-compat ${mavenVersion} @@ -192,20 +195,6 @@ under the License. - - - - - org.apache.rat - apache-rat-plugin - - - .asf.yaml - - - - - run-its From 27026fb9d50f2ccf008387d562e9dc7800bfb975 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 21 Jan 2023 16:52:39 +0100 Subject: [PATCH 127/153] [MDEPLOY-302] Upgrade maven-plugin parent to 39 - reformat --- pom.xml | 22 +- .../plugins/deploy/AbstractDeployMojo.java | 120 +- .../maven/plugins/deploy/DeployFileMojo.java | 529 ++++----- .../maven/plugins/deploy/DeployMojo.java | 352 +++--- .../plugins/deploy/DeployFileMojoTest.java | 325 +++--- .../deploy/DeployFileMojoUnitTest.java | 128 +-- .../maven/plugins/deploy/DeployMojoTest.java | 1011 ++++++++--------- .../apache/maven/plugins/deploy/Utils.java | 27 +- .../deploy/stubs/ArtifactRepositoryStub.java | 145 +-- .../deploy/stubs/ArtifactRepositoryStub2.java | 46 +- .../deploy/stubs/AttachedArtifactStub.java | 26 +- .../deploy/stubs/DeployArtifactStub.java | 97 +- .../deploy/stubs/MavenProjectStub.java | 13 +- 13 files changed, 1255 insertions(+), 1586 deletions(-) diff --git a/pom.xml b/pom.xml index b2618273..5c30c552 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - - + - 4.0.0 @@ -37,6 +35,13 @@ under the License. Uploads the project artifacts to the internal remote repository. 2004 + + + + Hermann Josef Hill + + + ${mavenVersion} @@ -44,8 +49,8 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git - https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} HEAD + https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} JIRA @@ -185,15 +190,8 @@ under the License. ${slf4jVersion} test - -
- - - - Hermann Josef Hill - - +
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 4a66ecd8..33ecad0b 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 @@ * "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 @@ * 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; @@ -38,13 +37,11 @@ /** * 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 +50,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 +68,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 +99,21 @@ protected void warnIfAffectedPackagingAndMaven( final String packaging ) /** * 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(); @@ -139,40 +125,30 @@ protected RemoteRepository getRemoteRepository( final String repositoryId, final /** * 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 ) ); + protected void deploy(RepositorySystemSession session, 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, 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 7f27f39f..c6c875b1 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 @@ * "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 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy; import java.io.File; import java.io.FileNotFoundException; @@ -59,29 +58,27 @@ /** * Installs the artifact in the remote repository. - * + * * @author Allan Ramirez */ -@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; /** @@ -90,88 +87,88 @@ 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.
* 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; /** @@ -185,265 +182,202 @@ public class DeployFileMojo * * @since 3.1.0 */ - @Parameter( property = "maven.deploy.file.skip", defaultValue = "false" ) + @Parameter(property = "maven.deploy.file.skip", defaultValue = "false") private String skip = Boolean.FALSE.toString(); - void initProperties() - throws MojoExecutionException - { - if ( pomFile == null ) - { + 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" ); + try (JarFile jarFile = new JarFile(file)) { + Pattern pomEntry = Pattern.compile("META-INF/maven/.*/pom\\.xml"); Enumeration 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( '.' ) ); + if (base.indexOf('.') > 0) { + base = base.substring(0, base.lastIndexOf('.')); } - pomFile = new File( file.getParentFile(), base + ".pom" ); + pomFile = new File(file.getParentFile(), base + ".pom"); - try ( InputStream pomInputStream = jarFile.getInputStream( entry ) ) - { - try ( OutputStream pomOutputStream = Files.newOutputStream( pomFile.toPath() ) ) - { - IOUtil.copy( pomInputStream, pomOutputStream ); + try (InputStream pomInputStream = jarFile.getInputStream(entry)) { + try (OutputStream pomOutputStream = Files.newOutputStream(pomFile.toPath())) { + IOUtil.copy(pomInputStream, pomOutputStream); } - processModel( readModel( pomFile ) ); + processModel(readModel(pomFile)); break; } } } - 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 } - } - 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 ( Boolean.parseBoolean( skip ) - || ( "releases".equals( skip ) && !ArtifactUtils.isSnapshot( version ) ) - || ( "snapshots".equals( skip ) && ArtifactUtils.isSnapshot( version ) ) - ) - { - getLog().info( "Skipping artifact deployment" ); + 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." ); + 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(); } @@ -454,198 +388,159 @@ else if ( generatePom ) * 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 null. */ - 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 null. * @return The model from the POM file, never null. * @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 null. * @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 null. */ - 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; } @@ -654,34 +549,30 @@ void setClassifier( String classifier ) /** * 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; } } @@ -693,16 +584,12 @@ private boolean isValidId( String id ) /** * 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 d169ab8a..09214174 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 @@ * "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 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy; import java.io.File; import java.util.List; @@ -42,35 +41,33 @@ /** * Deploys an artifact to remote repository. - * + * * @author Emmanuel Venisse * @author John Casey (refactoring only) */ -@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 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. * (experimental) - * + * * @since 2.8 */ - @Parameter( defaultValue = "false", property = "deployAtEnd" ) + @Parameter(defaultValue = "false", property = "deployAtEnd") private boolean deployAtEnd; /** @@ -87,7 +84,7 @@ public class DeployMojo * could be default (ie. Maven 2) or legacy (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 +96,7 @@ public class DeployMojo * @since 2.8 * @see DeployMojo#altDeploymentRepository */ - @Parameter( property = "altSnapshotDeploymentRepository" ) + @Parameter(property = "altSnapshotDeploymentRepository") private String altSnapshotDeploymentRepository; /** @@ -111,7 +108,7 @@ public class DeployMojo * @since 2.8 * @see DeployMojo#altDeploymentRepository */ - @Parameter( property = "altReleaseDeploymentRepository" ) + @Parameter(property = "altReleaseDeploymentRepository") private String altReleaseDeploymentRepository; /** @@ -125,191 +122,163 @@ public class DeployMojo * * @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 pluginContext, String key ) - { - return (String) pluginContext.get( key ); + private String getPluginContextValue(Map pluginContext, String key) { + return (String) pluginContext.get(key); } - private State getState( Map pluginContext ) - { - return State.valueOf( getPluginContextValue( pluginContext, DEPLOY_PROCESSED_MARKER ) ); + private State getState(Map pluginContext) { + return State.valueOf(getPluginContextValue(pluginContext, DEPLOY_PROCESSED_MARKER)); } - private boolean hasState( MavenProject project ) - { - Map pluginContext = session.getPluginContext( pluginDescriptor, project ); - return pluginContext.containsKey( DEPLOY_PROCESSED_MARKER ); + private boolean hasState(MavenProject project) { + Map 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 { + 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 { 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) { + 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"); } } - if ( allProjectsMarked() ) - { - for ( MavenProject reactorProject : reactorProjects ) - { - Map pluginContext = session.getPluginContext( pluginDescriptor, reactorProject ); - State state = getState( pluginContext ); - if ( state == State.TO_BE_DEPLOYED ) - { + if (allProjectsMarked()) { + for (MavenProject reactorProject : reactorProjects) { + Map pluginContext = session.getPluginContext(pluginDescriptor, reactorProject); + State state = getState(pluginContext); + if (state == State.TO_BE_DEPLOYED) { String altReleaseDeploymentRepository = - getPluginContextValue( pluginContext, DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY ); + getPluginContextValue(pluginContext, DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY); String altSnapshotDeploymentRepository = - getPluginContextValue( pluginContext, DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY ); + getPluginContextValue(pluginContext, DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY); String altDeploymentRepository = - getPluginContextValue( pluginContext, DEPLOY_ALT_DEPLOYMENT_REPOSITORY ); - - deploy( session.getRepositorySession(), - processProject( reactorProject, - altSnapshotDeploymentRepository, altReleaseDeploymentRepository, altDeploymentRepository ) - ); + getPluginContextValue(pluginContext, DEPLOY_ALT_DEPLOYMENT_REPOSITORY); + + deploy( + session.getRepositorySession(), + processProject( + reactorProject, + altSnapshotDeploymentRepository, + altReleaseDeploymentRepository, + altDeploymentRepository)); } } } } - private boolean allProjectsMarked() - { - for ( MavenProject reactorProject : reactorProjects ) - { - if ( !hasState( reactorProject ) ) - { + private boolean allProjectsMarked() { + for (MavenProject reactorProject : reactorProjects) { + 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 - { + 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 ) ); + 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 isPomArtifact = "pom".equals(packaging); boolean pomArtifactAttached = false; - if ( pomFile != null ) - { - request.addArtifact( RepositoryUtils.toArtifact( new ProjectArtifact( project ) ) ); + if (pomFile != null) { + request.addArtifact(RepositoryUtils.toArtifact(new ProjectArtifact(project))); pomArtifactAttached = true; } - if ( !isPomArtifact ) - { + 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() ) ); + 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" ); + } 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"); } } - if ( !pomArtifactAttached ) - { - throw new MojoExecutionException( "The POM could not be attached" ); + if (!pomArtifactAttached) { + throw new MojoExecutionException("The 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 ) ); + for (org.apache.maven.artifact.Artifact attached : project.getAttachedArtifacts()) { + getLog().debug("Attaching for install: " + attached.getId()); + request.addArtifact(RepositoryUtils.toArtifact(attached)); } return request; @@ -318,91 +287,72 @@ else if ( !project.getAttachedArtifacts().isEmpty() ) /** * 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, MojoFailureException { 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 MojoFailureException( + 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 MojoFailureException( + 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/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java index deb9fa3e..f36e6892 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 @@ * "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,9 +16,7 @@ * 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; @@ -32,20 +28,21 @@ 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 Allan Ramirez */ -public class DeployFileMojoTest - extends AbstractMojoTestCase -{ +public class DeployFileMojoTest extends AbstractMojoTestCase { private final String LOCAL_REPO = getBasedir() + "/target/local-repo"; - + private List expectedFiles; private List fileList; @@ -54,263 +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); + + 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 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"); - String packaging = (String) getVariableValueFromObject( mojo, "packaging" ); + String packaging = (String) getVariableValueFromObject(mojo, "packaging"); - File file = (File) getVariableValueFromObject( mojo, "file" ); + File file = (File) getVariableValueFromObject(mojo, "file"); - String repositoryId = (String) getVariableValueFromObject( mojo, "repositoryId" ); + String repositoryId = (String) getVariableValueFromObject(mojo, "repositoryId"); - String url = (String) getVariableValueFromObject( mojo, "url" ); + String url = (String) getVariableValueFromObject(mojo, "url"); - String skip = (String) getVariableValueFromObject( mojo, "skip" ); + String skip = (String) getVariableValueFromObject(mojo, "skip"); - 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 ); + 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 + // 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 : Objects.requireNonNull( 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 fileList ) - { - if ( !file.isDirectory() ) - { - fileList.add( file.getName() ); - } - else - { - fileList.add( file.getName() ); + private void addFileToList(File file, List fileList) { + if (!file.isDirectory()) { + fileList.add(file.getName()); + } else { + fileList.add(file.getName()); File[] files = file.listFiles(); - for (File file1 : Objects.requireNonNull( files ) ) { + for (File file1 : Objects.requireNonNull(files)) { addFileToList(file1, fileList); } } } - private int getSizeOfExpectedFiles( List fileList, List 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 fileList, List 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 0edf72f1..c368b365 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 @@ * "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 @@ * 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.Before; import org.junit.Test; -import java.io.File; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** * @author Jerome Lacoste */ -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,64 +66,58 @@ public void setModel(Model model) { this.model = model; } - protected Model readModel(File pomFile) - { + protected Model readModel(File pomFile) { return model; } } @Test - public void testProcessPomFromPomFileWithParent1() - { - 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() - { - 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() - { - 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(); @@ -135,10 +125,9 @@ public void testProcessPomFromPomFileWithParent4() throws MojoExecutionException } @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(); @@ -146,46 +135,47 @@ public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException } @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 54bc16fa..b99d7176 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 @@ * "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,12 +16,7 @@ * 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; @@ -46,707 +39,671 @@ 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 Allan Ramirez */ -public class DeployMojoTest - extends AbstractMojoTestCase -{ +public class DeployMojoTest extends AbstractMojoTestCase { private File remoteRepo; - + private File localRepo; - + private final String LOCAL_REPO = getBasedir() + "/target/local-repo"; - + private final String REMOTE_REPO = getBasedir() + "/target/remote-repo"; - + DeployArtifactStub artifact; - + 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() ); + session = mock(MavenSession.class); + when(session.getPluginContext(any(PluginDescriptor.class), any(MavenProject.class))) + .thenReturn(new ConcurrentHashMap()); 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 + // check the artifact in local repository List expectedFiles = new ArrayList<>(); List 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("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 : Objects.requireNonNull( 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 + 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" ); + + 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 : Objects.requireNonNull( 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 expectedFiles = new ArrayList<>(); List 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" ); + + 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 : Objects.requireNonNull( 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 + // check the artifacts in remote repository List expectedFiles = new ArrayList<>(); List 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" ); + + 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 : Objects.requireNonNull( 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 (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."); } } - 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 (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."); } } - 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 (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."); } } - 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 fileList ) - { - if( !file.isDirectory() ) - { - fileList.add( file.getName() ); - } - else - { - fileList.add( file.getName() ); + + private void addFileToList(File file, List fileList) { + if (!file.isDirectory()) { + fileList.add(file.getName()); + } else { + fileList.add(file.getName()); File[] files = file.listFiles(); - for (File file1 : Objects.requireNonNull( files ) ) { + for (File file1 : Objects.requireNonNull(files)) { addFileToList(file1, fileList); } } - } - - private int getSizeOfExpectedFiles( List fileList, List 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 fileList, List 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 index be963420..8fc876a4 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/Utils.java +++ b/src/test/java/org/apache/maven/plugins/deploy/Utils.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 @@ -18,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy; import java.io.File; import java.io.IOException; @@ -34,10 +33,9 @@ * * @author Benjamin Bentmann */ -public class Utils -{ +public class Utils { - public static final List CHECKSUM_ALGORITHMS = Arrays.asList( "MD5", "SHA-1" ); + public static final List CHECKSUM_ALGORITHMS = Arrays.asList("MD5", "SHA-1"); /** * Verifies the checksum files in the local repo for the given file. @@ -46,19 +44,14 @@ public class Utils * @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 checksums = ChecksumUtils.calc( file, CHECKSUM_ALGORITHMS ); - for ( Map.Entry 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 ); + public static void verifyChecksum(File file) throws MojoExecutionException, IOException { + Map checksums = ChecksumUtils.calc(file, CHECKSUM_ALGORITHMS); + for (Map.Entry 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 238c5f79..9dd95400 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 @@ * "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 @@ * 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.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 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() - { + + 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 0e3338fc..96d43bb9 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 @@ * "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 @@ * 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 0419a85c..9226bdcf 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 @@ * "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 @@ * 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 8993ed99..7218fdf7 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 @@ * "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 @@ * 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.metadata.ArtifactMetadata; import org.apache.maven.plugin.testing.stubs.ArtifactStub; -public class DeployArtifactStub - extends ArtifactStub -{ +public class DeployArtifactStub extends ArtifactStub { private Map 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 ) - { + + public void addMetadata(ArtifactMetadata metadata) { + if (metadataMap == null) { metadataMap = new HashMap<>(); } - ArtifactMetadata m = metadataMap.get( metadata.getKey() ); - if ( m != null ) - { - m.merge( metadata ); - } - 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 getMetadataList() - { + + public Collection 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 91709a36..ff97f913 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 @@ * "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,15 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.maven.plugins.deploy.stubs; import org.apache.maven.artifact.repository.ArtifactRepository; -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; } - } From 524bb2b5adede943bdd5874ff926ac586a39760a Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 21 Jan 2023 18:39:12 +0100 Subject: [PATCH 128/153] [MDEPLOY-302] Ignore reformat commit in git blame --- .git-blame-ignore-revs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..517a2a39 --- /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 From 5c4272df9122b4efab3eee56188188b69d5d04f6 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 22 Jan 2023 11:50:16 +0100 Subject: [PATCH 129/153] [MDEPLOY-303] Refresh download page --- src/site/xdoc/download.xml.vm | 117 ++++++++++------------------------ 1 file changed, 33 insertions(+), 84 deletions(-) diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index f1cd28ed..8f28f053 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -23,102 +23,51 @@ under the License. Download ${project.name} Source +
-

${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.

- -

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.

- -

In order to guard against corrupted downloads/installations, it is highly recommended to - verify the signature - of the release bundles against the public KEYS used by the Apache Maven - developers.

+

${project.name} ${project.version} is distributed in source format.

-

${project.name} is distributed under the Apache License, version 2.0.

+

Use a source archive if you intend to build ${project.name} yourself.

-

We strongly encourage our users to configure a Maven repository mirror closer to their location, please read How to Use Mirrors for Repositories.

- - - - -

- [if-any logo] - - logo - - [end] - The currently selected mirror is - [preferred]. - If you encounter a problem with this mirror, - please select another mirror. - If all mirrors are failing, there are - backup - mirrors - (at the end of the mirrors list) that should be available. -

+

Otherwise, simply use the ready-made binary artifacts from central repository.

-
- Other mirrors: - - -
+

${project.name} is distributed under the Apache License, version 2.0.

-

- You may also consult the - complete list of - mirrors. + + +

This is the current stable version of ${project.name}.

+ + + + + + + + + + + + + + + + + + +
LinkChecksumSignature
${project.name} ${project.version} (Source zip)${project.artifactId}-${project.version}-source-release.zip${project.artifactId}-${project.version}-source-release.zip.sha512${project.artifactId}-${project.version}-source-release.zip.asc
+ +

It is essential that you verify the integrity of the downloaded file + using the checksum (.sha512 file) + or using the signature (.asc file) against the public KEYS used by the Apache Maven developers.

- - - -

This is the current stable version of ${project.name}.

- - - - - - - - - - - - - - - - - - -
LinkChecksumSignature
${project.name} ${project.version} (Source zip)maven/plugins/${project.artifactId}-${project.version}-source-release.zipmaven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc
-
- -

Older non-recommended releases can be found on our archive site.

- +

It is strongly recommended to use the latest release version of ${project.name} to take advantage of the newest features and bug fixes.

+

Older non-recommended releases can be found on our archive site.

From 54faa43aef31872a1b6277369ae126a49e97a908 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 22 Jan 2023 18:50:34 +0100 Subject: [PATCH 130/153] [MDEPLOY-304] Clean up ITs - refresh plugins versions in tests - remove createChecksum - parameter from tests - was removed in MINSTALL-143 - remove unneeded plugins in test - remove tests with checksum validation --- pom.xml | 15 ++- .../invoker.properties | 35 +++--- .../pom.xml | 12 +- .../pom.xml | 12 +- src/it/MDEPLOY-212/pom.xml | 2 +- src/it/MDEPLOY-213/pom.xml | 2 +- .../pom.xml | 10 +- src/it/alt-deploy-repo-with-dist-mgmt/pom.xml | 10 +- .../alt-deploy-repo-without-dist-mgmt/pom.xml | 10 +- src/it/attach-jar-checksum-release/pom.xml | 103 ------------------ src/it/attach-jar-checksum-release/setup.bsh | 29 ----- .../attach-jar-checksum-release/verify.groovy | 64 ----------- src/it/attach-jar-checksum-snapshot/pom.xml | 102 ----------------- src/it/attach-jar-checksum-snapshot/setup.bsh | 29 ----- .../verify.groovy | 95 ---------------- src/it/attach-release-jar/pom.xml | 15 ++- src/it/deploy-at-end-fail/module1/pom.xml | 2 +- src/it/deploy-at-end-fail/pom.xml | 12 +- src/it/deploy-at-end-pass/module1/pom.xml | 23 ---- src/it/deploy-at-end-pass/pom.xml | 12 +- src/it/deploy-attached-sources/pom.xml | 4 +- src/it/deploy-default-packaging/pom.xml | 4 +- src/it/mdeploy-45-test/pom.xml | 4 +- src/it/no-main-artifact-1/pom.xml | 16 +-- src/it/no-main-artifact-2/pom.xml | 16 +-- src/it/no-main-artifact-snapshot/pom.xml | 8 +- src/it/non-default-pom/non-default-pom.xml | 7 +- src/it/offline/pom.xml | 10 +- src/it/release-jar/pom.xml | 10 +- src/it/release-pom/pom.xml | 13 +-- src/it/skip-release-jar/pom.xml | 10 +- src/it/skip-snapshot-jar/pom.xml | 10 +- src/it/skip/pom.xml | 13 +-- src/it/snapshot-jar/pom.xml | 10 +- src/it/snapshot-pom/pom.xml | 13 +-- .../apache/maven/plugins/deploy/Utils.java | 57 ---------- 36 files changed, 146 insertions(+), 653 deletions(-) delete mode 100644 src/it/attach-jar-checksum-release/pom.xml delete mode 100644 src/it/attach-jar-checksum-release/setup.bsh delete mode 100644 src/it/attach-jar-checksum-release/verify.groovy delete mode 100644 src/it/attach-jar-checksum-snapshot/pom.xml delete mode 100644 src/it/attach-jar-checksum-snapshot/setup.bsh delete mode 100644 src/it/attach-jar-checksum-snapshot/verify.groovy delete mode 100644 src/test/java/org/apache/maven/plugins/deploy/Utils.java diff --git a/pom.xml b/pom.xml index 5c30c552..aeb11b57 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,20 @@ under the License. 1.7.5 1.0.0.v20140518 + + + 3.1.0 + 3.10.1 + 3.1.0 + 3.1.0 + 3.3.0 + 3.4.1 + ${maven.plugin.tools.version} + 3.3.0 + 3.2.1 + ${surefire.version} + 3.3.2 + 2022-07-16T16:14:30Z @@ -215,7 +229,6 @@ under the License. verify ${project.build.directory}/local-repo src/it/settings.xml - true deploy 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 18efa761..50360fc0 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 576847dd..af8d8c2b 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. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -60,22 +60,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-source-plugin - 2.0.4 + @mavenSourcePluginVersion@ attach-sources @@ -88,7 +88,7 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ 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 42f53daf..8884e138 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. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -60,22 +60,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-source-plugin - 2.0.4 + @mavenSourcePluginVersion@ attach-sources @@ -88,7 +88,7 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/MDEPLOY-212/pom.xml b/src/it/MDEPLOY-212/pom.xml index c6376ff4..8bca65b1 100644 --- a/src/it/MDEPLOY-212/pom.xml +++ b/src/it/MDEPLOY-212/pom.xml @@ -38,7 +38,7 @@ under the License. org.apache.maven.plugins maven-javadoc-plugin - 3.0.1 + @mavenJavadocPluginVersion@ attach-javadoc diff --git a/src/it/MDEPLOY-213/pom.xml b/src/it/MDEPLOY-213/pom.xml index 36e6d23a..ff4574d6 100644 --- a/src/it/MDEPLOY-213/pom.xml +++ b/src/it/MDEPLOY-213/pom.xml @@ -46,7 +46,7 @@ under the License. org.apache.maven.plugins maven-javadoc-plugin - 3.0.1 + @mavenJavadocPluginVersion@ attach-javadoc 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 ac1f97eb..cd943815 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. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -58,22 +58,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ 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 aa1dd736..e29e00f4 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. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -58,22 +58,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ 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 a6826e95..185d92d7 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. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -51,22 +51,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/attach-jar-checksum-release/pom.xml b/src/it/attach-jar-checksum-release/pom.xml deleted file mode 100644 index bda659d4..00000000 --- a/src/it/attach-jar-checksum-release/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - 4.0.0 - - org.apache.maven.its.deploy.ajc - test - 1.0 - jar - - - 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 - - - - true - - - - it - file:///${basedir}/target/remoterepo - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - - org.apache.maven.plugins - maven-deploy-plugin - @project.version@ - - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - false - - - - org.apache.maven.plugins - maven-jar-plugin - 2.1 - - - org.apache.maven.plugins - maven-resources-plugin - 2.2 - - - org.apache.maven.plugins - maven-source-plugin - 2.0.4 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.3.1 - - - - - diff --git a/src/it/attach-jar-checksum-release/setup.bsh b/src/it/attach-jar-checksum-release/setup.bsh deleted file mode 100644 index 4d739715..00000000 --- a/src/it/attach-jar-checksum-release/setup.bsh +++ /dev/null @@ -1,29 +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.codehaus.plexus.util.*; - -File file = new File( basedir, "org/apache/maven/its/deploy/ajc" ); -System.out.println( "Deleting " + file ); -FileUtils.deleteDirectory( file ); - -return true; 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 ac362f81..00000000 --- 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/pom.xml b/src/it/attach-jar-checksum-snapshot/pom.xml deleted file mode 100644 index 89ddce78..00000000 --- a/src/it/attach-jar-checksum-snapshot/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - 4.0.0 - - org.apache.maven.its.deploy.ajc - test - 1.0-SNAPSHOT - jar - - - Tests the deployment of a simple SNAPSHOT JAR with an attached artifact and checksums - - - - true - - - - it - file:///${basedir}/target/remoterepo - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - - org.apache.maven.plugins - maven-deploy-plugin - @project.version@ - - - org.apache.maven.plugins - maven-jar-plugin - 2.1 - - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - false - - - - org.apache.maven.plugins - maven-resources-plugin - 2.2 - - - org.apache.maven.plugins - maven-source-plugin - 2.0.4 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.3.1 - - - - - diff --git a/src/it/attach-jar-checksum-snapshot/setup.bsh b/src/it/attach-jar-checksum-snapshot/setup.bsh deleted file mode 100644 index 7d54f90e..00000000 --- a/src/it/attach-jar-checksum-snapshot/setup.bsh +++ /dev/null @@ -1,29 +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.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; 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 0a4a14f9..00000000 --- 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 4557d222..916f2462 100644 --- a/src/it/attach-release-jar/pom.xml +++ b/src/it/attach-release-jar/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -57,22 +57,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-source-plugin - 2.0.4 + @mavenSourcePluginVersion@ attach-sources @@ -81,11 +81,14 @@ under the License. + + true + org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/deploy-at-end-fail/module1/pom.xml b/src/it/deploy-at-end-fail/module1/pom.xml index 7b48b486..ba919db5 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 @@ org.apache.maven.plugins maven-enforcer-plugin - 1.2 + @mavenEnforcerPluginVersion@ enforce diff --git a/src/it/deploy-at-end-fail/pom.xml b/src/it/deploy-at-end-fail/pom.xml index be9ef50c..ed5f9ba0 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. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -60,22 +60,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-source-plugin - 2.0.4 + @mavenSourcePluginVersion@ attach-sources @@ -88,7 +88,7 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/deploy-at-end-pass/module1/pom.xml b/src/it/deploy-at-end-pass/module1/pom.xml index 1a91fc56..602a8f5c 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 @@ module1 - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.2 - - - enforce - - enforce - - - - - - - - - - - - diff --git a/src/it/deploy-at-end-pass/pom.xml b/src/it/deploy-at-end-pass/pom.xml index ecf739a8..04250d5a 100644 --- a/src/it/deploy-at-end-pass/pom.xml +++ b/src/it/deploy-at-end-pass/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -60,22 +60,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-source-plugin - 2.0.4 + @mavenSourcePluginVersion@ attach-sources @@ -88,7 +88,7 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/deploy-attached-sources/pom.xml b/src/it/deploy-attached-sources/pom.xml index 43a2e22e..01a48240 100644 --- a/src/it/deploy-attached-sources/pom.xml +++ b/src/it/deploy-attached-sources/pom.xml @@ -49,7 +49,7 @@ under the License. org.apache.maven.plugins maven-source-plugin - 2.1.2 + @mavenSourcePluginVersion@ attach-sources @@ -62,7 +62,7 @@ under the License. org.apache.maven.plugins maven-javadoc-plugin - 3.0.1 + @mavenJavadocPluginVersion@ attach-javadoc diff --git a/src/it/deploy-default-packaging/pom.xml b/src/it/deploy-default-packaging/pom.xml index 9764c8b8..9440f68f 100644 --- a/src/it/deploy-default-packaging/pom.xml +++ b/src/it/deploy-default-packaging/pom.xml @@ -49,7 +49,7 @@ under the License. org.apache.maven.plugins maven-source-plugin - 2.1.2 + @mavenSourcePluginVersion@ attach-sources @@ -62,7 +62,7 @@ under the License. org.apache.maven.plugins maven-javadoc-plugin - 2.7 + @mavenJavadocPluginVersion@ attach-javadoc diff --git a/src/it/mdeploy-45-test/pom.xml b/src/it/mdeploy-45-test/pom.xml index 2447705a..cdefaade 100644 --- a/src/it/mdeploy-45-test/pom.xml +++ b/src/it/mdeploy-45-test/pom.xml @@ -54,7 +54,7 @@ under the License. org.apache.maven.plugins maven-resources-plugin - 2.5 + @mavenResourcesPluginVersion@ @@ -66,7 +66,7 @@ under the License. org.apache.maven.plugins maven-war-plugin - 2.0.2 + @mavenWarPluginVersion@ diff --git a/src/it/no-main-artifact-1/pom.xml b/src/it/no-main-artifact-1/pom.xml index a9a7c2bb..18944b67 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. org.apache.maven.plugins maven-antrun-plugin - 1.1 + @mavenAntrunPluginVersion@ - + - + @@ -71,7 +71,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -81,7 +81,7 @@ under the License. org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ it @@ -89,17 +89,17 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.3 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/no-main-artifact-2/pom.xml b/src/it/no-main-artifact-2/pom.xml index e063973c..f9644f9b 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. org.apache.maven.plugins maven-antrun-plugin - 1.1 + @mavenAntrunPluginVersion@ - + - + @@ -70,7 +70,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -80,7 +80,7 @@ under the License. org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ it @@ -88,17 +88,17 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/no-main-artifact-snapshot/pom.xml b/src/it/no-main-artifact-snapshot/pom.xml index cb906106..89c4fc99 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. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ @@ -65,7 +65,7 @@ under the License. org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ @@ -80,12 +80,12 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.3 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ diff --git a/src/it/non-default-pom/non-default-pom.xml b/src/it/non-default-pom/non-default-pom.xml index 231a7c13..e97b2b9b 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. org.apache.maven.plugins maven-install-plugin - 2.2 - - - org.apache.maven.plugins - maven-site-plugin - 2.0-beta-5 + @mavenInstallPluginVersion@ diff --git a/src/it/offline/pom.xml b/src/it/offline/pom.xml index 32e53ec2..cdad63cf 100644 --- a/src/it/offline/pom.xml +++ b/src/it/offline/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -57,22 +57,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/release-jar/pom.xml b/src/it/release-jar/pom.xml index af72e7d7..1d275c9c 100644 --- a/src/it/release-jar/pom.xml +++ b/src/it/release-jar/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -57,22 +57,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/release-pom/pom.xml b/src/it/release-pom/pom.xml index d7bff31b..fe9c110e 100644 --- a/src/it/release-pom/pom.xml +++ b/src/it/release-pom/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -57,22 +57,17 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 - - - org.apache.maven.plugins - maven-site-plugin - 2.0-beta-5 + @mavenSurefirePluginVersion@ diff --git a/src/it/skip-release-jar/pom.xml b/src/it/skip-release-jar/pom.xml index 3e57a45e..2774462e 100644 --- a/src/it/skip-release-jar/pom.xml +++ b/src/it/skip-release-jar/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -60,22 +60,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/skip-snapshot-jar/pom.xml b/src/it/skip-snapshot-jar/pom.xml index a58a66fa..a0099041 100644 --- a/src/it/skip-snapshot-jar/pom.xml +++ b/src/it/skip-snapshot-jar/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -60,22 +60,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/skip/pom.xml b/src/it/skip/pom.xml index 0b50d387..652b3080 100644 --- a/src/it/skip/pom.xml +++ b/src/it/skip/pom.xml @@ -42,7 +42,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -55,22 +55,17 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 - - - org.apache.maven.plugins - maven-site-plugin - 2.0-beta-5 + @mavenSurefirePluginVersion@ diff --git a/src/it/snapshot-jar/pom.xml b/src/it/snapshot-jar/pom.xml index bd215e05..899b5832 100644 --- a/src/it/snapshot-jar/pom.xml +++ b/src/it/snapshot-jar/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -57,22 +57,22 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ diff --git a/src/it/snapshot-pom/pom.xml b/src/it/snapshot-pom/pom.xml index 735559d7..5ff795c7 100644 --- a/src/it/snapshot-pom/pom.xml +++ b/src/it/snapshot-pom/pom.xml @@ -47,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -57,22 +57,17 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.2 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 + @mavenResourcesPluginVersion@ org.apache.maven.plugins maven-surefire-plugin - 2.3.1 - - - org.apache.maven.plugins - maven-site-plugin - 2.0-beta-5 + @mavenSurefirePluginVersion@ 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 8fc876a4..00000000 --- a/src/test/java/org/apache/maven/plugins/deploy/Utils.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugins.deploy; - -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. - * used in IntegrationTests like attach-jar-checksum-snapshot, attach-jar-checksum-snapshot - * - * @author Benjamin Bentmann - */ -public class Utils { - - public static final List 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 null. - * @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 checksums = ChecksumUtils.calc(file, CHECKSUM_ALGORITHMS); - for (Map.Entry 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); - } - } - } -} From 6c2ce4894791f7071285522ad5b243d28469818e Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 23 Jan 2023 19:04:36 +0100 Subject: [PATCH 131/153] Bump project version to 3.1.0-SNAPSHOT --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index aeb11b57..c6ec6c28 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-deploy-plugin - 3.0.1-SNAPSHOT + 3.1.0-SNAPSHOT maven-plugin Apache Maven Deploy Plugin @@ -88,7 +88,7 @@ under the License. ${surefire.version} 3.3.2 - 2022-07-16T16:14:30Z + 2023-01-23T18:00:59Z From 33d89b19e88702d581992d7e7acaec85c6d3757d Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 23 Jan 2023 22:44:42 +0100 Subject: [PATCH 132/153] [MDEPLOY-305] Improvement in DeployAtEnd - Fix when module does not use m-deploy-p - Don't use metadata from main artifact to fetch pom.xml - Deploy all artifacts in one request --- pom.xml | 6 + src/it/deploy-at-end-pass/module2/pom.xml | 39 +++++ src/it/deploy-at-end-pass/module3/pom.xml | 25 +++ src/it/deploy-at-end-pass/module4/pom.xml | 38 +++++ src/it/deploy-at-end-pass/pom.xml | 5 +- src/it/deploy-at-end-pass/verify.groovy | 9 +- .../invoker.properties | 18 +++ src/it/setup-mock-phase-maven-plugin/pom.xml | 57 +++++++ .../resources/META-INF/plexus/components.xml | 40 +++++ .../plugins/deploy/AbstractDeployMojo.java | 14 +- .../maven/plugins/deploy/DeployMojo.java | 145 ++++++++++-------- .../deploy/stubs/MavenProjectStub.java | 12 ++ 12 files changed, 332 insertions(+), 76 deletions(-) create mode 100644 src/it/deploy-at-end-pass/module2/pom.xml create mode 100644 src/it/deploy-at-end-pass/module3/pom.xml create mode 100644 src/it/deploy-at-end-pass/module4/pom.xml create mode 100644 src/it/setup-mock-phase-maven-plugin/invoker.properties create mode 100644 src/it/setup-mock-phase-maven-plugin/pom.xml create mode 100644 src/it/setup-mock-phase-maven-plugin/src/main/resources/META-INF/plexus/components.xml diff --git a/pom.xml b/pom.xml index c6ec6c28..de5f87b5 100644 --- a/pom.xml +++ b/pom.xml @@ -229,6 +229,12 @@ under the License. verify ${project.build.directory}/local-repo src/it/settings.xml + + ${project.build.directory}/remote-repo + + + ${project.build.directory}/remote-repo + deploy 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 00000000..827396fe --- /dev/null +++ b/src/it/deploy-at-end-pass/module2/pom.xml @@ -0,0 +1,39 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.deploy.dae.pass + dae + 1.0 + + module2 + + + + + org.apache.maven.plugins + maven-deploy-plugin + + + default-deploy + none + + + + + + 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 00000000..48c9caa0 --- /dev/null +++ b/src/it/deploy-at-end-pass/module3/pom.xml @@ -0,0 +1,25 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.deploy.dae.pass + dae + 1.0 + + module3 + + 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 00000000..05f07629 --- /dev/null +++ b/src/it/deploy-at-end-pass/module4/pom.xml @@ -0,0 +1,38 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.deploy.dae.pass + dae + 1.0 + + module4 + + + without-deploy + + + + + org.apache.maven.its.deploy.mock + mock-phase-maven-plugin + 1.0 + true + + + + diff --git a/src/it/deploy-at-end-pass/pom.xml b/src/it/deploy-at-end-pass/pom.xml index 04250d5a..90ed655c 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. it - file:///${basedir}/target/repo + file:///@remoteRepo@/deploy-at-end-pass @@ -95,5 +95,8 @@ under the License. module1 + module2 + module3 + module4 diff --git a/src/it/deploy-at-end-pass/verify.groovy b/src/it/deploy-at-end-pass/verify.groovy index 634808a5..6aedbb57 100644 --- a/src/it/deploy-at-end-pass/verify.groovy +++ b/src/it/deploy-at-end-pass/verify.groovy @@ -17,10 +17,15 @@ * 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" ) +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/setup-mock-phase-maven-plugin/invoker.properties b/src/it/setup-mock-phase-maven-plugin/invoker.properties new file mode 100644 index 00000000..d5d6ca5d --- /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 00000000..4ebb8af5 --- /dev/null +++ b/src/it/setup-mock-phase-maven-plugin/pom.xml @@ -0,0 +1,57 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.mock + mock-phase-maven-plugin + 1.0 + maven-plugin + + + @mavenVersion@ + + + plugin with Maven phase without m-deploy-p + + + + + + org.apache.maven.plugins + maven-install-plugin + @mavenInstallPluginVersion@ + + + org.apache.maven.plugins + maven-plugin-plugin + @mavenPluginToolsVersion@ + + true + + + + + + + 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 00000000..93e017ca --- /dev/null +++ b/src/it/setup-mock-phase-maven-plugin/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,40 @@ + + + + + + + + org.apache.maven.lifecycle.mapping.LifecycleMapping + without-deploy + org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping + + + + default + + org.apache.maven.plugins:maven-resources-plugin:resources + + + + + + + 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 33ecad0b..2c5c1d9c 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -26,7 +26,6 @@ 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; @@ -122,10 +121,13 @@ protected RemoteRepository getRemoteRepository(final String repositoryId, final return result; } - /** - * Handles high level retries (this was buried into MAT). - */ - protected void deploy(RepositorySystemSession session, DeployRequest deployRequest) throws MojoExecutionException { + // 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++) { @@ -134,7 +136,7 @@ protected void deploy(RepositorySystemSession session, DeployRequest deployReque getLog().info("Retrying deployment attempt " + (count + 1) + " of " + retryFailedDeploymentCounter); } - repositorySystem.deploy(session, deployRequest); + repositorySystem.deploy(session.getRepositorySession(), deployRequest); exception = null; break; } catch (DeploymentException e) { 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 09214174..806b3f33 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -19,6 +19,8 @@ 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; @@ -26,6 +28,8 @@ 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; @@ -34,10 +38,8 @@ 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. @@ -63,7 +65,6 @@ public class DeployMojo extends AbstractDeployMojo { /** * 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. - * (experimental) * * @since 2.8 */ @@ -176,17 +177,21 @@ public void execute() throws MojoExecutionException, MojoFailureException { warnIfAffectedPackagingAndMaven(project.getPackaging()); if (!deployAtEnd) { - deploy( - session.getRepositorySession(), - processProject( - project, - altSnapshotDeploymentRepository, - altReleaseDeploymentRepository, - altDeploymentRepository)); + + RemoteRepository deploymentRepository = getDeploymentRepository( + project, + altSnapshotDeploymentRepository, + altReleaseDeploymentRepository, + altDeploymentRepository); + + DeployRequest request = new DeployRequest(); + request.setRepository(deploymentRepository); + processProject(project, request); + deploy(request); putState(State.DEPLOYED); } else { - putPluginContextValue(DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository); putPluginContextValue(DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY, altSnapshotDeploymentRepository); + putPluginContextValue(DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository); putPluginContextValue(DEPLOY_ALT_DEPLOYMENT_REPOSITORY, altDeploymentRepository); putState(State.TO_BE_DEPLOYED); getLog().info("Deferring deploy for " + project.getGroupId() + ":" + project.getArtifactId() + ":" @@ -194,32 +199,41 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } - if (allProjectsMarked()) { - for (MavenProject reactorProject : reactorProjects) { + List allProjectsUsingPlugin = getAllProjectsUsingPlugin(); + + if (allProjectsMarked(allProjectsUsingPlugin)) { + Map requests = new LinkedHashMap<>(); + + // collect all arifacts from all modules to deploy + // requests are grouped by used remote repository + for (MavenProject reactorProject : allProjectsUsingPlugin) { Map 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)); + + 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) { + private boolean allProjectsMarked(List allProjectsUsingPlugin) { + for (MavenProject reactorProject : allProjectsUsingPlugin) { if (!hasState(reactorProject)) { return false; } @@ -227,61 +241,58 @@ private boolean allProjectsMarked() { 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)); + private List getAllProjectsUsingPlugin() { + ArrayList result = new ArrayList<>(); + for (MavenProject reactorProject : reactorProjects) { + if (hasExecution(reactorProject.getPlugin("org.apache.maven.plugins:maven-deploy-plugin"))) { + result.add(reactorProject); + } + } + return result; + } + + 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; + } - org.apache.maven.artifact.Artifact mavenMainArtifact = project.getArtifact(); - String packaging = project.getPackaging(); - File pomFile = project.getFile(); - boolean isPomArtifact = "pom".equals(packaging); - boolean pomArtifactAttached = false; + private void processProject(final MavenProject project, DeployRequest request) throws MojoExecutionException { - if (pomFile != null) { + if (isFile(project.getFile())) { request.addArtifact(RepositoryUtils.toArtifact(new ProjectArtifact(project))); - pomArtifactAttached = true; + } else { + throw new MojoExecutionException("The project POM could not be attached"); } - 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; - } - } - } + 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"); + "The packaging for this project did not assign a file to the build artifact"); } } - if (!pomArtifactAttached) { - throw new MojoExecutionException("The POM could not be attached"); - } - for (org.apache.maven.artifact.Artifact attached : project.getAttachedArtifacts()) { - getLog().debug("Attaching for install: " + attached.getId()); + getLog().debug("Attaching for deploy: " + attached.getId()); request.addArtifact(RepositoryUtils.toArtifact(attached)); } + } - return request; + private boolean isFile(File file) { + return file != null && file.isFile(); } /** 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 ff97f913..646e09ad 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 @@ -18,7 +18,11 @@ */ 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 { @@ -27,4 +31,12 @@ public class MavenProjectStub extends org.apache.maven.plugin.testing.stubs.Mave public ArtifactRepository getDistributionManagementArtifactRepository() { return deploymentRepository; } + + @Override + public Build getBuild() { + Plugin plugin = new Plugin(); + Build build = new Build(); + build.setPlugins(Collections.singletonList(plugin)); + return build; + } } From af8c615c0926f57c8dfd34d87e9160347021bc64 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 28 Jan 2023 17:15:36 +0100 Subject: [PATCH 133/153] [MDEPLOY-224] DeployAtEnd - ITs use only in modules --- .../module1/pom.xml | 37 ++++++++ .../module2/pom.xml | 38 ++++++++ .../pom.xml | 87 +++++++++++++++++++ .../verify.groovy | 28 ++++++ 4 files changed, 190 insertions(+) create mode 100644 src/it/MDEPLOY-224_deploy-at-end-only-modules/module1/pom.xml create mode 100644 src/it/MDEPLOY-224_deploy-at-end-only-modules/module2/pom.xml create mode 100644 src/it/MDEPLOY-224_deploy-at-end-only-modules/pom.xml create mode 100644 src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy 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 00000000..9f255085 --- /dev/null +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/module1/pom.xml @@ -0,0 +1,37 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.mdeploy-224 + parent + 1.0 + + module1 + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + true + + + + + + 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 00000000..081edc5a --- /dev/null +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/module2/pom.xml @@ -0,0 +1,38 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.mdeploy-224 + parent + 1.0 + + module2 + pom + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + true + + + + + diff --git a/src/it/MDEPLOY-224_deploy-at-end-only-modules/pom.xml b/src/it/MDEPLOY-224_deploy-at-end-only-modules/pom.xml new file mode 100644 index 00000000..f40c64ac --- /dev/null +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/pom.xml @@ -0,0 +1,87 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mdeploy-224 + parent + 1.0 + pom + + + Tests deployment at end only in modules. + + + + true + + + + + it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + @mavenCompilerPluginVersion@ + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + false + + + + org.apache.maven.plugins + maven-install-plugin + @mavenInstallPluginVersion@ + + + org.apache.maven.plugins + maven-jar-plugin + @mavenJarPluginVersion@ + + + org.apache.maven.plugins + maven-resources-plugin + @mavenResourcesPluginVersion@ + + + org.apache.maven.plugins + maven-surefire-plugin + @mavenSurefirePluginVersion@ + + + + + + module1 + module2 + + 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 00000000..ee4e5e75 --- /dev/null +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/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. + */ + +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') +assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module2:1.0 at end') From 1fb083bf2525276c1a355b8826ebea55c41cd333 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 28 Jan 2023 16:29:35 +0100 Subject: [PATCH 134/153] [MDEPLOY-225] DeployAtEnd - ITs for skipped root project --- .../module1/pom.xml | 37 ++++++++ .../module2/pom.xml | 38 ++++++++ .../pom.xml | 88 +++++++++++++++++++ .../verify.groovy | 22 +++++ 4 files changed, 185 insertions(+) create mode 100644 src/it/MDEPLOY-225_deploy-at-end-skip-root/module1/pom.xml create mode 100644 src/it/MDEPLOY-225_deploy-at-end-skip-root/module2/pom.xml create mode 100644 src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml create mode 100644 src/it/MDEPLOY-225_deploy-at-end-skip-root/verify.groovy 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 00000000..325a6342 --- /dev/null +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/module1/pom.xml @@ -0,0 +1,37 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.mdeploy-225 + parent + 1.0 + + module1 + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + false + + + + + + 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 00000000..5bb4f62a --- /dev/null +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/module2/pom.xml @@ -0,0 +1,38 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.mdeploy-225 + parent + 1.0 + + module2 + pom + + + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + false + + + + + diff --git a/src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml b/src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml new file mode 100644 index 00000000..8ac0f820 --- /dev/null +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml @@ -0,0 +1,88 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mdeploy-225 + parent + 1.0 + pom + + + Tests deployment at end with skipped root project. + + + + true + + + + + it + file:///${basedir}/target/repo + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + @mavenCompilerPluginVersion@ + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + true + true + + + + org.apache.maven.plugins + maven-install-plugin + @mavenInstallPluginVersion@ + + + org.apache.maven.plugins + maven-jar-plugin + @mavenJarPluginVersion@ + + + org.apache.maven.plugins + maven-resources-plugin + @mavenResourcesPluginVersion@ + + + org.apache.maven.plugins + maven-surefire-plugin + @mavenSurefirePluginVersion@ + + + + + + module1 + module2 + + diff --git a/src/it/MDEPLOY-225_deploy-at-end-skip-root/verify.groovy b/src/it/MDEPLOY-225_deploy-at-end-skip-root/verify.groovy new file mode 100644 index 00000000..edcc0b97 --- /dev/null +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/verify.groovy @@ -0,0 +1,22 @@ +/* + * 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" ).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() From 59bee05f8a935f4c8ac9fcf0da47bab60c425e92 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 26 Jan 2023 23:17:31 +0100 Subject: [PATCH 135/153] [MDEPLOY-206] Support parallel deployment for deployAtEnd Each whole module will be deployed by resolver in one thread. We have parallel deployment on module level. --- .../deploy-at-end-parallel/invoker.properties | 18 +++ src/it/deploy-at-end-parallel/module1/pom.xml | 25 ++++ src/it/deploy-at-end-parallel/module2/pom.xml | 25 ++++ src/it/deploy-at-end-parallel/module3/pom.xml | 25 ++++ src/it/deploy-at-end-parallel/module4/pom.xml | 25 ++++ src/it/deploy-at-end-parallel/pom.xml | 103 ++++++++++++++ src/it/deploy-at-end-parallel/setup.groovy | 26 ++++ src/it/deploy-at-end-parallel/verify.groovy | 37 +++++ .../maven/plugins/deploy/DeployMojo.java | 129 ++++++++++++++---- .../maven/plugins/deploy/DeployMojoTest.java | 7 +- 10 files changed, 388 insertions(+), 32 deletions(-) create mode 100644 src/it/deploy-at-end-parallel/invoker.properties create mode 100644 src/it/deploy-at-end-parallel/module1/pom.xml create mode 100644 src/it/deploy-at-end-parallel/module2/pom.xml create mode 100644 src/it/deploy-at-end-parallel/module3/pom.xml create mode 100644 src/it/deploy-at-end-parallel/module4/pom.xml create mode 100644 src/it/deploy-at-end-parallel/pom.xml create mode 100644 src/it/deploy-at-end-parallel/setup.groovy create mode 100644 src/it/deploy-at-end-parallel/verify.groovy diff --git a/src/it/deploy-at-end-parallel/invoker.properties b/src/it/deploy-at-end-parallel/invoker.properties new file mode 100644 index 00000000..4a11915f --- /dev/null +++ b/src/it/deploy-at-end-parallel/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.mavenOpts = -Dorg.slf4j.simpleLogger.showThreadName=true \ No newline at end of file diff --git a/src/it/deploy-at-end-parallel/module1/pom.xml b/src/it/deploy-at-end-parallel/module1/pom.xml new file mode 100644 index 00000000..4466ec7d --- /dev/null +++ b/src/it/deploy-at-end-parallel/module1/pom.xml @@ -0,0 +1,25 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.deploy.dae.parallel + dae + 1.0 + + module1 + + diff --git a/src/it/deploy-at-end-parallel/module2/pom.xml b/src/it/deploy-at-end-parallel/module2/pom.xml new file mode 100644 index 00000000..d38b6718 --- /dev/null +++ b/src/it/deploy-at-end-parallel/module2/pom.xml @@ -0,0 +1,25 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.deploy.dae.parallel + dae + 1.0 + + module2 + + diff --git a/src/it/deploy-at-end-parallel/module3/pom.xml b/src/it/deploy-at-end-parallel/module3/pom.xml new file mode 100644 index 00000000..be6d3437 --- /dev/null +++ b/src/it/deploy-at-end-parallel/module3/pom.xml @@ -0,0 +1,25 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.deploy.dae.parallel + dae + 1.0 + + module3 + + diff --git a/src/it/deploy-at-end-parallel/module4/pom.xml b/src/it/deploy-at-end-parallel/module4/pom.xml new file mode 100644 index 00000000..a3d83823 --- /dev/null +++ b/src/it/deploy-at-end-parallel/module4/pom.xml @@ -0,0 +1,25 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.deploy.dae.parallel + dae + 1.0 + + module4 + + diff --git a/src/it/deploy-at-end-parallel/pom.xml b/src/it/deploy-at-end-parallel/pom.xml new file mode 100644 index 00000000..3e783511 --- /dev/null +++ b/src/it/deploy-at-end-parallel/pom.xml @@ -0,0 +1,103 @@ + + + + + + 4.0.0 + + org.apache.maven.its.deploy.dae.parallel + dae + 1.0 + pom + + + Tests deployment at end with parallel. + + + + true + + + + + it + file:///@remoteRepo@/deploy-at-end-parallel + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + @mavenCompilerPluginVersion@ + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + true + 4 + + + + org.apache.maven.plugins + maven-install-plugin + @mavenInstallPluginVersion@ + + + org.apache.maven.plugins + maven-jar-plugin + @mavenJarPluginVersion@ + + + org.apache.maven.plugins + maven-resources-plugin + @mavenResourcesPluginVersion@ + + + org.apache.maven.plugins + maven-source-plugin + @mavenSourcePluginVersion@ + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + @mavenSurefirePluginVersion@ + + + + + + module1 + module2 + module3 + module4 + + diff --git a/src/it/deploy-at-end-parallel/setup.groovy b/src/it/deploy-at-end-parallel/setup.groovy new file mode 100644 index 00000000..3fd36199 --- /dev/null +++ b/src/it/deploy-at-end-parallel/setup.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. + */ + + +def mockrepo = new File( remoteRepo, "deploy-at-end-parallel") +mockrepo.deleteDir() + +assert !mockrepo.exists() + +mockrepo.mkdirs() \ No newline at end of file diff --git a/src/it/deploy-at-end-parallel/verify.groovy b/src/it/deploy-at-end-parallel/verify.groovy new file mode 100644 index 00000000..845a6951 --- /dev/null +++ b/src/it/deploy-at-end-parallel/verify.groovy @@ -0,0 +1,37 @@ +/* + * 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( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/dae/1.0/dae-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module1/1.0/module1-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module1/1.0/module1-1.0.jar" ).exists() +assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module2/1.0/module2-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module2/1.0/module2-1.0.jar" ).exists() +assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module3/1.0/module3-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module3/1.0/module3-1.0.jar" ).exists() +assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module4/1.0/module4-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module4/1.0/module4-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.parallel:dae:1.0 at end" ) +assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module1:1.0 at end" ) +assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module2:1.0 at end" ) +assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module3:1.0 at end" ) +assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module4:1.0 at end" ) + 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 806b3f33..98d5ee99 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -23,6 +23,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -71,6 +75,14 @@ public class DeployMojo extends AbstractDeployMojo { @Parameter(defaultValue = "false", property = "deployAtEnd") private boolean deployAtEnd; + /** + * The number of parallel threads which will be used for deployment with the {@code deployAtEnd} feature. + * + * @since 3.1.0 + */ + @Parameter(property = "maven.deploy.parallelThreads", defaultValue = "1") + private int parallelThreads; + /** * Specifies an alternative repository to which the project artifacts should be deployed (other than those specified * in <distributionManagement>).
@@ -202,32 +214,93 @@ public void execute() throws MojoExecutionException, MojoFailureException { List allProjectsUsingPlugin = getAllProjectsUsingPlugin(); if (allProjectsMarked(allProjectsUsingPlugin)) { - Map requests = new LinkedHashMap<>(); - - // collect all arifacts from all modules to deploy - // requests are grouped by used remote repository - for (MavenProject reactorProject : allProjectsUsingPlugin) { - Map 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); - } + if (parallelThreads <= 1) { + deployAllAtOnce(allProjectsUsingPlugin); + } else { + deployInParallel(allProjectsUsingPlugin); } - // finally execute all deployments request, lets resolver to optimize deployment - for (DeployRequest request : requests.values()) { - deploy(request); + } + } + + private void deployAllAtOnce(List allProjectsUsingPlugin) throws MojoExecutionException { + Map requests = new LinkedHashMap<>(); + + // collect all arifacts from all modules to deploy + // requests are grouped by used remote repository + for (MavenProject reactorProject : allProjectsUsingPlugin) { + Map 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 void deployInParallel(List allProjectsUsingPlugin) throws MojoExecutionException { + + List> requestTasks = new ArrayList<>(); + AtomicBoolean hasError = new AtomicBoolean(false); + + for (MavenProject reactorProject : allProjectsUsingPlugin) { + Map 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 = new DeployRequest(); + request.setRepository(deploymentRepository); + + processProject(reactorProject, request); + + requestTasks.add(() -> { + try { + if (!hasError.get()) { + deploy(request); + } + } catch (MojoExecutionException e) { + hasError.set(true); + getLog().error(e.getMessage(), e); + } + return null; + }); + } + } + + if (!requestTasks.isEmpty()) { + ExecutorService executorService = Executors.newFixedThreadPool(parallelThreads); + + try { + executorService.invokeAll(requestTasks); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new MojoExecutionException(e.getMessage(), e); + } + + executorService.shutdown(); + + if (hasError.get()) { + throw new MojoExecutionException("Deployment errors"); } } } @@ -303,7 +376,7 @@ RemoteRepository getDeploymentRepository( final String altSnapshotDeploymentRepository, final String altReleaseDeploymentRepository, final String altDeploymentRepository) - throws MojoExecutionException, MojoFailureException { + throws MojoExecutionException { RemoteRepository repo = null; String altDeploymentRepo; @@ -330,7 +403,7 @@ RemoteRepository getDeploymentRepository( + "\" instead."); repo = getRemoteRepository(id, url); } else { - throw new MojoFailureException( + throw new MojoExecutionException( altDeploymentRepo, "Invalid legacy syntax and layout for repository.", "Invalid legacy syntax and layout for alternative repository. Use \"" + id + "::" + url @@ -340,7 +413,7 @@ RemoteRepository getDeploymentRepository( matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altDeploymentRepo); if (!matcher.matches()) { - throw new MojoFailureException( + throw new MojoExecutionException( altDeploymentRepo, "Invalid syntax for repository.", "Invalid syntax for alternative repository. Use \"id::url\"."); 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 b99d7176..c43bdf5c 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -28,7 +28,6 @@ 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; @@ -581,7 +580,7 @@ public void testLegacyAltDeploymentRepositoryWithLegacyLayout() throws Exception try { mojo.getDeploymentRepository(project, null, null, "altDeploymentRepository::legacy::http://localhost"); fail("Should throw: Invalid legacy syntax and layout for repository."); - } catch (MojoFailureException e) { + } catch (MojoExecutionException e) { assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); assertEquals( e.getLongMessage(), @@ -602,7 +601,7 @@ public void testInsaneAltDeploymentRepository() throws Exception { mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::hey::wow::foo::http://localhost"); fail("Should throw: Invalid legacy syntax and layout for repository."); - } catch (MojoFailureException e) { + } catch (MojoExecutionException e) { assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); assertEquals( e.getLongMessage(), @@ -638,7 +637,7 @@ public void testLegacyScmSvnAltDeploymentRepository() throws Exception { mojo.getDeploymentRepository( project, null, null, "altDeploymentRepository::legacy::scm:svn:http://localhost"); fail("Should throw: Invalid legacy syntax and layout for repository."); - } catch (MojoFailureException e) { + } catch (MojoExecutionException e) { assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); assertEquals( e.getLongMessage(), From 2ff9a2eac94d2ca25e48af975ac47375d6fdb323 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 2 Feb 2023 09:12:29 +0100 Subject: [PATCH 136/153] [MDEPLOY-206] Deploy improvements (#38) Changes: * remove deployInParallel, deploy plugin when deployAtEnd always creates one deploy request and passes it to resolver * remove misleading log "deferring deploy" when the module is actually last and is not deferred by deploys all * Remove obsolete IT --- https://issues.apache.org/jira/browse/MDEPLOY-206 --- .../verify.groovy | 3 +- .../deploy-at-end-parallel/invoker.properties | 18 --- src/it/deploy-at-end-parallel/module1/pom.xml | 25 ----- src/it/deploy-at-end-parallel/module2/pom.xml | 25 ----- src/it/deploy-at-end-parallel/module3/pom.xml | 25 ----- src/it/deploy-at-end-parallel/module4/pom.xml | 25 ----- src/it/deploy-at-end-parallel/pom.xml | 103 ------------------ src/it/deploy-at-end-parallel/setup.groovy | 26 ----- src/it/deploy-at-end-parallel/verify.groovy | 37 ------- src/it/deploy-at-end-pass/verify.groovy | 3 +- .../maven/plugins/deploy/DeployMojo.java | 85 ++------------- 11 files changed, 14 insertions(+), 361 deletions(-) delete mode 100644 src/it/deploy-at-end-parallel/invoker.properties delete mode 100644 src/it/deploy-at-end-parallel/module1/pom.xml delete mode 100644 src/it/deploy-at-end-parallel/module2/pom.xml delete mode 100644 src/it/deploy-at-end-parallel/module3/pom.xml delete mode 100644 src/it/deploy-at-end-parallel/module4/pom.xml delete mode 100644 src/it/deploy-at-end-parallel/pom.xml delete mode 100644 src/it/deploy-at-end-parallel/setup.groovy delete mode 100644 src/it/deploy-at-end-parallel/verify.groovy 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 index ee4e5e75..063f2aee 100644 --- a/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy @@ -25,4 +25,5 @@ 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') -assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module2: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/deploy-at-end-parallel/invoker.properties b/src/it/deploy-at-end-parallel/invoker.properties deleted file mode 100644 index 4a11915f..00000000 --- a/src/it/deploy-at-end-parallel/invoker.properties +++ /dev/null @@ -1,18 +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. - -invoker.mavenOpts = -Dorg.slf4j.simpleLogger.showThreadName=true \ No newline at end of file diff --git a/src/it/deploy-at-end-parallel/module1/pom.xml b/src/it/deploy-at-end-parallel/module1/pom.xml deleted file mode 100644 index 4466ec7d..00000000 --- a/src/it/deploy-at-end-parallel/module1/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - - module1 - - diff --git a/src/it/deploy-at-end-parallel/module2/pom.xml b/src/it/deploy-at-end-parallel/module2/pom.xml deleted file mode 100644 index d38b6718..00000000 --- a/src/it/deploy-at-end-parallel/module2/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - - module2 - - diff --git a/src/it/deploy-at-end-parallel/module3/pom.xml b/src/it/deploy-at-end-parallel/module3/pom.xml deleted file mode 100644 index be6d3437..00000000 --- a/src/it/deploy-at-end-parallel/module3/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - - module3 - - diff --git a/src/it/deploy-at-end-parallel/module4/pom.xml b/src/it/deploy-at-end-parallel/module4/pom.xml deleted file mode 100644 index a3d83823..00000000 --- a/src/it/deploy-at-end-parallel/module4/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - - module4 - - diff --git a/src/it/deploy-at-end-parallel/pom.xml b/src/it/deploy-at-end-parallel/pom.xml deleted file mode 100644 index 3e783511..00000000 --- a/src/it/deploy-at-end-parallel/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - 4.0.0 - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - pom - - - Tests deployment at end with parallel. - - - - true - - - - - it - file:///@remoteRepo@/deploy-at-end-parallel - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - @mavenCompilerPluginVersion@ - - - org.apache.maven.plugins - maven-deploy-plugin - @project.version@ - - true - 4 - - - - org.apache.maven.plugins - maven-install-plugin - @mavenInstallPluginVersion@ - - - org.apache.maven.plugins - maven-jar-plugin - @mavenJarPluginVersion@ - - - org.apache.maven.plugins - maven-resources-plugin - @mavenResourcesPluginVersion@ - - - org.apache.maven.plugins - maven-source-plugin - @mavenSourcePluginVersion@ - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-surefire-plugin - @mavenSurefirePluginVersion@ - - - - - - module1 - module2 - module3 - module4 - - diff --git a/src/it/deploy-at-end-parallel/setup.groovy b/src/it/deploy-at-end-parallel/setup.groovy deleted file mode 100644 index 3fd36199..00000000 --- a/src/it/deploy-at-end-parallel/setup.groovy +++ /dev/null @@ -1,26 +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. - */ - - -def mockrepo = new File( remoteRepo, "deploy-at-end-parallel") -mockrepo.deleteDir() - -assert !mockrepo.exists() - -mockrepo.mkdirs() \ No newline at end of file diff --git a/src/it/deploy-at-end-parallel/verify.groovy b/src/it/deploy-at-end-parallel/verify.groovy deleted file mode 100644 index 845a6951..00000000 --- a/src/it/deploy-at-end-parallel/verify.groovy +++ /dev/null @@ -1,37 +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. - */ - -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/dae/1.0/dae-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module1/1.0/module1-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module1/1.0/module1-1.0.jar" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module2/1.0/module2-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module2/1.0/module2-1.0.jar" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module3/1.0/module3-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module3/1.0/module3-1.0.jar" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module4/1.0/module4-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module4/1.0/module4-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.parallel:dae:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module1:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module2:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module3:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module4:1.0 at end" ) - diff --git a/src/it/deploy-at-end-pass/verify.groovy b/src/it/deploy-at-end-pass/verify.groovy index 6aedbb57..8db44909 100644 --- a/src/it/deploy-at-end-pass/verify.groovy +++ b/src/it/deploy-at-end-pass/verify.groovy @@ -27,5 +27,6 @@ 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" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module3: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/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java index 98d5ee99..4e317acf 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -23,10 +23,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -75,14 +71,6 @@ public class DeployMojo extends AbstractDeployMojo { @Parameter(defaultValue = "false", property = "deployAtEnd") private boolean deployAtEnd; - /** - * The number of parallel threads which will be used for deployment with the {@code deployAtEnd} feature. - * - * @since 3.1.0 - */ - @Parameter(property = "maven.deploy.parallelThreads", defaultValue = "1") - private int parallelThreads; - /** * Specifies an alternative repository to which the project artifacts should be deployed (other than those specified * in <distributionManagement>).
@@ -179,11 +167,12 @@ private boolean hasState(MavenProject project) { } 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"); - putState(State.SKIPPED); + state = State.SKIPPED; } else { failIfOffline(); warnIfAffectedPackagingAndMaven(project.getPackaging()); @@ -200,25 +189,24 @@ public void execute() throws MojoExecutionException, MojoFailureException { request.setRepository(deploymentRepository); processProject(project, request); deploy(request); - putState(State.DEPLOYED); + state = State.DEPLOYED; } else { putPluginContextValue(DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY, altSnapshotDeploymentRepository); putPluginContextValue(DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository); putPluginContextValue(DEPLOY_ALT_DEPLOYMENT_REPOSITORY, altDeploymentRepository); - putState(State.TO_BE_DEPLOYED); - getLog().info("Deferring deploy for " + project.getGroupId() + ":" + project.getArtifactId() + ":" - + project.getVersion() + " at end"); + state = State.TO_BE_DEPLOYED; } } + putState(state); + List allProjectsUsingPlugin = getAllProjectsUsingPlugin(); if (allProjectsMarked(allProjectsUsingPlugin)) { - if (parallelThreads <= 1) { - deployAllAtOnce(allProjectsUsingPlugin); - } else { - deployInParallel(allProjectsUsingPlugin); - } + deployAllAtOnce(allProjectsUsingPlugin); + } else if (state == State.TO_BE_DEPLOYED) { + getLog().info("Deferring deploy for " + project.getGroupId() + ":" + project.getArtifactId() + ":" + + project.getVersion() + " at end"); } } @@ -252,59 +240,6 @@ private void deployAllAtOnce(List allProjectsUsingPlugin) throws M } } - private void deployInParallel(List allProjectsUsingPlugin) throws MojoExecutionException { - - List> requestTasks = new ArrayList<>(); - AtomicBoolean hasError = new AtomicBoolean(false); - - for (MavenProject reactorProject : allProjectsUsingPlugin) { - Map 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 = new DeployRequest(); - request.setRepository(deploymentRepository); - - processProject(reactorProject, request); - - requestTasks.add(() -> { - try { - if (!hasError.get()) { - deploy(request); - } - } catch (MojoExecutionException e) { - hasError.set(true); - getLog().error(e.getMessage(), e); - } - return null; - }); - } - } - - if (!requestTasks.isEmpty()) { - ExecutorService executorService = Executors.newFixedThreadPool(parallelThreads); - - try { - executorService.invokeAll(requestTasks); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new MojoExecutionException(e.getMessage(), e); - } - - executorService.shutdown(); - - if (hasError.get()) { - throw new MojoExecutionException("Deployment errors"); - } - } - } - private boolean allProjectsMarked(List allProjectsUsingPlugin) { for (MavenProject reactorProject : allProjectsUsingPlugin) { if (!hasState(reactorProject)) { From 1ef96fc4be5ee1837a0bb32b1f7f391f3a9c22d4 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Mon, 6 Feb 2023 13:43:27 +0100 Subject: [PATCH 137/153] [maven-release-plugin] prepare release maven-deploy-plugin-3.1.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index de5f87b5..be639a3f 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-deploy-plugin - 3.1.0-SNAPSHOT + 3.1.0 maven-plugin Apache Maven Deploy Plugin @@ -49,7 +49,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git - HEAD + maven-deploy-plugin-3.1.0 https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} @@ -88,7 +88,7 @@ under the License. ${surefire.version} 3.3.2 - 2023-01-23T18:00:59Z + 2023-02-06T12:43:17Z From 2de56bd2abec1963ed7a8d180c23d792d037950c Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Mon, 6 Feb 2023 13:43:51 +0100 Subject: [PATCH 138/153] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index be639a3f..680a704b 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-deploy-plugin - 3.1.0 + 3.1.1-SNAPSHOT maven-plugin Apache Maven Deploy Plugin @@ -49,7 +49,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git - maven-deploy-plugin-3.1.0 + HEAD https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} @@ -88,7 +88,7 @@ under the License. ${surefire.version} 3.3.2 - 2023-02-06T12:43:17Z + 2023-02-06T12:43:51Z From 04f5e8856adbe9019476d9a0aba6c8de95bdf107 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 21 Mar 2023 15:24:08 +0100 Subject: [PATCH 139/153] [MDEPLOY-308] Add parameter to lax project validation (#39) * [MDEPLOY-308] Add parameter to lax project validation --- https://issues.apache.org/jira/browse/MDEPLOY-308 * Reformat --- .../maven/plugins/deploy/DeployMojo.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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 4e317acf..c9b0d4a4 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -126,6 +126,18 @@ public class DeployMojo extends AbstractDeployMojo { @Parameter(property = "maven.deploy.skip", defaultValue = "false") private String skip = Boolean.FALSE.toString(); + /** + * Set this to true to allow incomplete project processing. By default, such projects are forbidden + * and Mojo will fail to process them. Incomplete project is a Maven Project that has any other packaging than + * "pom" and has no main artifact packaged. In the majority of cases, what user really wants here is a project + * with "pom" packaging and some classified artifact attached (typical example is some assembly being packaged + * and attached with classifier). + * + * @since 3.1.1 + */ + @Parameter(defaultValue = "false", property = "allowIncompleteProjects") + private boolean allowIncompleteProjects; + private enum State { SKIPPED, DEPLOYED, @@ -285,8 +297,17 @@ private void processProject(final MavenProject project, DeployRequest request) t 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'."); + if (allowIncompleteProjects) { + getLog().warn(""); + getLog().warn("The packaging plugin for this project did not assign"); + getLog().warn("a main file to the project but it has attachments. Change packaging to 'pom'."); + getLog().warn(""); + getLog().warn("Incomplete projects like this will fail in future Maven versions!"); + getLog().warn(""); + } else { + 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"); From 43aaa63898ed46935e987c269142101a1ddb3d72 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 21 Mar 2023 15:37:41 +0100 Subject: [PATCH 140/153] [maven-release-plugin] prepare release maven-deploy-plugin-3.1.1 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 680a704b..96df086c 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-deploy-plugin - 3.1.1-SNAPSHOT + 3.1.1 maven-plugin Apache Maven Deploy Plugin @@ -49,7 +49,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git - HEAD + maven-deploy-plugin-3.1.1 https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} @@ -88,7 +88,7 @@ under the License. ${surefire.version} 3.3.2 - 2023-02-06T12:43:51Z + 2023-03-21T14:37:32Z From d458eb11532896a2189547c265cbadaf1e7b6b24 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Tue, 21 Mar 2023 15:38:01 +0100 Subject: [PATCH 141/153] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 96df086c..fc75b7c3 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-deploy-plugin - 3.1.1 + 3.1.2-SNAPSHOT maven-plugin Apache Maven Deploy Plugin @@ -49,7 +49,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git - maven-deploy-plugin-3.1.1 + HEAD https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} @@ -88,7 +88,7 @@ under the License. ${surefire.version} 3.3.2 - 2023-03-21T14:37:32Z + 2023-03-21T14:38:01Z From c5481eb8a1f1867bd67a2528789fc3010ab87160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 24 Apr 2023 12:53:44 +0200 Subject: [PATCH 142/153] configure notifications --- .asf.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.asf.yaml b/.asf.yaml index 699735c5..d4bb4049 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -13,4 +13,9 @@ github: merge: false rebase: true autolink_jira: - - MDEPLOY \ No newline at end of file + - MDEPLOY +notifications: + commits: commits@maven.apache.org + issues: issues@maven.apache.org + pullrequests: issues@maven.apache.org + jira_options: link label comment From 707ab61615606053eb816e7c96d1fc276a80a47f Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Fri, 9 Jun 2023 13:33:58 +0200 Subject: [PATCH 143/153] [MNG-6829] Replace StringUtils#isEmpty(String) & #isNotEmpty(String) (#40) Last batch of is(Not)Empty for https://issues.apache.org/jira/browse/MNG-6829 These are the smallest change sets, hence why I opened more at the same time. After this we can target the next most often used method from the StringUtils classes. Use this link to re-run the recipe: https://public.moderne.io/recipes/org.openrewrite.java.migrate.apache.commons.lang.IsNotEmptyToJdk?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../java/org/apache/maven/plugins/deploy/DeployFileMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c6c875b1..7de11c83 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -269,7 +269,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { ArtifactType artifactType = session.getRepositorySession().getArtifactTypeRegistry().get(packaging); if (artifactType != null - && StringUtils.isEmpty(classifier) + && (classifier == null || classifier.isEmpty()) && !StringUtils.isEmpty(artifactType.getClassifier())) { classifier = artifactType.getClassifier(); } From 9039fc610f67dfd101a3e4bb8b7510994b2656d0 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Sun, 25 Jun 2023 21:36:29 +0000 Subject: [PATCH 144/153] Type: fill --> file --- src/site/apt/index.apt.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm index 262e90a1..1ad2e42a 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -85,7 +85,7 @@ ${project.name} already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{./mailing-lists.html}mail archive}}. - If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our + If you feel like the plugin is missing a feature or has a defect, you can file a feature request or bug report in our {{{./issue-management.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. From 29f3c81dfc5e3e603bf68870075161dc674680dc Mon Sep 17 00:00:00 2001 From: pavl_g <60224159+Scrappers-glitch@users.noreply.github.com> Date: Sat, 26 Aug 2023 12:23:25 +0300 Subject: [PATCH 145/153] DeployFileMojo#readModel(File): fixed MojoExecutionException javadoc * DeployFileMojo#readModel(File): fixed MojoExecutionException javadoc. --- .../java/org/apache/maven/plugins/deploy/DeployFileMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7de11c83..aeaf5f77 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -426,7 +426,7 @@ private void processModel(Model model) { * * @param pomFile The path of the POM file to parse, must not be null. * @return The model from the POM file, never null. - * @throws MojoExecutionException If the file doesn't exist of cannot be read. + * @throws MojoExecutionException If the file doesn't exist or cannot be read. */ Model readModel(File pomFile) throws MojoExecutionException { Reader reader = null; From 390e610c65ef0ec2ec0e4851d7e1eaf53e7787f3 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 12 Jan 2024 21:03:02 +0100 Subject: [PATCH 146/153] [MDEPLOY-313] Update to parent 41, cleanup (#47) In general perform a cleanup of plugin, apply updates where needed. The plugin now builds against 3.9.x latest, and minimum is left as is (3.2.5). A notable change along that above is removal of "baked in" packaging, now plugin relies completely and only on what project and artifact tells, there is no "if this is POM" check anymore. The new "BOM UT" shows this in action. Has to be noted though, that the UT tests ONLY the plugin, to use BOM packaging you need Maven that knows what it is (Maven 3 w/ extension or Maven 4 that has it OOTB). --- https://issues.apache.org/jira/browse/MDEPLOY-313 --- pom.xml | 72 +++++--- .../verify.groovy | 4 +- .../maven/plugins/deploy/DeployFileMojo.java | 27 +-- .../maven/plugins/deploy/DeployMojo.java | 32 +++- .../plugins/deploy/DeployFileMojoTest.java | 16 +- .../maven/plugins/deploy/DeployMojoTest.java | 166 ++++++++++-------- .../deploy/stubs/DeployBomArtifactStub.java | 37 ++++ .../deploy/stubs/DeployPomArtifactStub.java | 37 ++++ .../unit/basic-deploy-bom/plugin-config.xml | 39 ++++ .../target/deploy-test-file-1.0-SNAPSHOT.pom | 28 +++ .../unit/basic-deploy-pom/plugin-config.xml | 2 +- 11 files changed, 321 insertions(+), 139 deletions(-) create mode 100644 src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java create mode 100644 src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java create mode 100644 src/test/resources/unit/basic-deploy-bom/plugin-config.xml create mode 100644 src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom diff --git a/pom.xml b/pom.xml index fc75b7c3..0340c384 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 39 + 41 @@ -43,7 +43,7 @@ under the License. - ${mavenVersion} + 3.2.5 @@ -69,24 +69,24 @@ under the License. 8 - 3.2.5 + 3.9.6 - 1.7.5 + 1.7.36 - 1.0.0.v20140518 + 1.9.18 - 3.1.0 - 3.10.1 - 3.1.0 - 3.1.0 - 3.3.0 - 3.4.1 - ${maven.plugin.tools.version} - 3.3.0 - 3.2.1 - ${surefire.version} - 3.3.2 + ${version.maven-antrun-plugin} + ${version.maven-compiler-plugin} + ${version.maven-enforcer-plugin} + ${version.maven-install-plugin} + ${version.maven-jar-plugin} + ${version.maven-javadoc-plugin} + ${version.maven-plugin-tools} + ${version.maven-resources-plugin} + ${version.maven-source-plugin} + ${version.maven-surefire} + ${version.maven-war-plugin} 2023-03-21T14:38:01Z @@ -128,14 +128,18 @@ under the License. plexus-utils - org.eclipse.aether - aether-api + org.codehaus.plexus + plexus-xml + + + org.apache.maven.resolver + maven-resolver-api ${resolverVersion} provided - org.eclipse.aether - aether-util + org.apache.maven.resolver + maven-resolver-util ${resolverVersion} compile @@ -164,25 +168,25 @@ under the License. org.apache.maven - maven-aether-provider + maven-resolver-provider ${mavenVersion} test - org.eclipse.aether - aether-connector-basic + org.apache.maven.resolver + maven-resolver-connector-basic ${resolverVersion} test - org.eclipse.aether - aether-transport-file + org.apache.maven.resolver + maven-resolver-transport-file ${resolverVersion} test - org.eclipse.aether - aether-transport-http + org.apache.maven.resolver + maven-resolver-transport-http ${resolverVersion} test @@ -204,9 +208,21 @@ under the License. ${slf4jVersion} test - + + + + org.apache.maven.plugins + maven-compiler-plugin + + none + true + + + + + run-its diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy index 2b197b2d..181104aa 100644 --- a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy +++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy @@ -25,5 +25,5 @@ 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/mdeploy178/pom.xml as pomFile" ) -def pomProject = new XmlSlurper().parse( deployedPom ) -assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( pomProject.url.text() ) \ No newline at end of file +def pomProject = new groovy.xml.XmlParser().parse( deployedPom ) +assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( pomProject.get("url").text() ) \ No newline at end of file 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 aeaf5f77..7e6536f1 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -43,9 +43,9 @@ import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.WriterFactory; +import org.codehaus.plexus.util.xml.ReaderFactory; +import org.codehaus.plexus.util.xml.WriterFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; @@ -429,21 +429,14 @@ private void processModel(Model model) { * @throws MojoExecutionException If the file doesn't exist or cannot be read. */ Model readModel(File pomFile) throws MojoExecutionException { - Reader reader = null; - try { - reader = ReaderFactory.newXmlReader(pomFile); - final Model model = new MavenXpp3Reader().read(reader); - reader.close(); - reader = null; - return model; + try (Reader reader = ReaderFactory.newXmlReader(pomFile)) { + return new MavenXpp3Reader().read(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); } } @@ -456,23 +449,17 @@ Model readModel(File pomFile) throws MojoExecutionException { private File generatePomFile() throws MojoExecutionException { Model model = generateModel(); - Writer fw = null; try { File tempFile = File.createTempFile("mvndeploy", ".pom"); tempFile.deleteOnExit(); - fw = WriterFactory.newXmlWriter(tempFile); - - new MavenXpp3Writer().write(fw, model); - - fw.close(); - fw = null; + try (Writer fw = WriterFactory.newXmlWriter(tempFile)) { + new MavenXpp3Writer().write(fw, model); + } return tempFile; } catch (IOException e) { throw new MojoExecutionException("Error writing temporary pom file: " + e.getMessage(), e); - } finally { - IOUtil.close(fw); } } 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 c9b0d4a4..c3ea850a 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -38,8 +38,10 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifact; +import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.deployment.DeployRequest; import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.util.artifact.ArtifactIdUtils; /** * Deploys an artifact to remote repository. @@ -285,17 +287,35 @@ private boolean hasExecution(Plugin plugin) { } private void processProject(final MavenProject project, DeployRequest request) throws MojoExecutionException { + // always exists, as project exists + Artifact pomArtifact = RepositoryUtils.toArtifact(new ProjectArtifact(project)); + // always exists, but at "init" is w/o file (packaging plugin assigns file to this when packaged) + Artifact projectArtifact = RepositoryUtils.toArtifact(project.getArtifact()); + + // pom project: pomArtifact and projectArtifact are SAME + // jar project: pomArtifact and projectArtifact are DIFFERENT + // incomplete project: is not pom project and projectArtifact has no file + + // we must compare coordinates ONLY (as projectArtifact may not have file, and Artifact.equals factors it in) + // BUT if projectArtifact has file set, use that one + if (ArtifactIdUtils.equalsId(pomArtifact, projectArtifact)) { + if (isFile(projectArtifact.getFile())) { + pomArtifact = projectArtifact; + } + projectArtifact = null; + } - if (isFile(project.getFile())) { - request.addArtifact(RepositoryUtils.toArtifact(new ProjectArtifact(project))); + if (isFile(pomArtifact.getFile())) { + request.addArtifact(pomArtifact); } else { throw new MojoExecutionException("The project POM could not be attached"); } - if (!"pom".equals(project.getPackaging())) { - org.apache.maven.artifact.Artifact mavenMainArtifact = project.getArtifact(); - if (isFile(mavenMainArtifact.getFile())) { - request.addArtifact(RepositoryUtils.toArtifact(mavenMainArtifact)); + // is not packaged, is "incomplete" + boolean isIncomplete = projectArtifact != null && !isFile(projectArtifact.getFile()); + if (projectArtifact != null) { + if (!isIncomplete) { + request.addArtifact(projectArtifact); } else if (!project.getAttachedArtifacts().isEmpty()) { if (allowIncompleteProjects) { getLog().warn(""); 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 f36e6892..572d8e48 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -28,6 +28,7 @@ import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.ProjectBuildingRequest; import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.DefaultLocalPathComposer; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; import org.mockito.InjectMocks; @@ -86,8 +87,9 @@ public void testBasicDeployFile() throws Exception { 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))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -194,8 +196,9 @@ public void testDeployIfClassifierIsSet() throws Exception { 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))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -248,8 +251,9 @@ public void testDeployIfArtifactIsNotJar() throws Exception { 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))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); 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 c43bdf5c..3b0df77e 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -23,7 +23,6 @@ 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; @@ -37,11 +36,10 @@ 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.DefaultLocalPathComposer; 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; @@ -75,10 +73,11 @@ public void setUp() throws Exception { session = mock(MavenSession.class); when(session.getPluginContext(any(PluginDescriptor.class), any(MavenProject.class))) - .thenReturn(new ConcurrentHashMap()); + .thenReturn(new ConcurrentHashMap<>()); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(session.getRepositorySession()).thenReturn(repositorySession); remoteRepo = new File(REMOTE_REPO); @@ -124,8 +123,9 @@ public void testBasicDeploy() throws Exception { ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -300,8 +300,9 @@ public void testBasicDeployWithPackagingAsPom() throws Exception { ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -363,6 +364,82 @@ public void testBasicDeployWithPackagingAsPom() throws Exception { assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); } + public void testBasicDeployWithPackagingAsBom() throws Exception { + File testPom = new File(getBasedir(), "target/test-classes/unit/basic-deploy-bom/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(new DefaultLocalPathComposer()) + .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-bom/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-bom"); + + mojo.execute(); + + List expectedFiles = new ArrayList<>(); + List 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-bom"); + + File[] files = remoteRepo.listFiles(); + + for (File file : Objects.requireNonNull(files)) { + addFileToList(file, fileList); + } + + 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"); @@ -413,8 +490,9 @@ public void testDeployWithAttachedArtifacts() throws Exception { ProjectBuildingRequest buildingRequest = mock(ProjectBuildingRequest.class); when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory() - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + repositorySession.setLocalRepositoryManager( + new SimpleLocalRepositoryManagerFactory(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); when(session.getRepositorySession()).thenReturn(repositorySession); @@ -490,70 +568,6 @@ public void testDeployWithAttachedArtifacts() throws Exception { 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"); - - // FIX THE DAMN user.home BEFORE YOU DELETE IT!!! - File altHome = new File(getBasedir(), "target/ssh-user-home"); - altHome.mkdirs(); - - 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)); - - artifact = (DeployArtifactStub) project.getArtifact(); - - 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."); - } - - 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); - } - public void testLegacyAltDeploymentRepositoryWithDefaultLayout() throws Exception { DeployMojo mojo = new DeployMojo(); diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java new file mode 100644 index 00000000..b5c55a37 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.deploy.stubs; + +import org.apache.maven.artifact.handler.ArtifactHandler; +import org.apache.maven.artifact.handler.DefaultArtifactHandler; + +public class DeployBomArtifactStub extends DeployArtifactStub { + @Override + public String getType() { + return "bom"; + } + + public ArtifactHandler getArtifactHandler() { + return new DefaultArtifactHandler() { + public String getExtension() { + return "pom"; + } + }; + } +} diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java new file mode 100644 index 00000000..238bb286 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.plugins.deploy.stubs; + +import org.apache.maven.artifact.handler.ArtifactHandler; +import org.apache.maven.artifact.handler.DefaultArtifactHandler; + +public class DeployPomArtifactStub extends DeployArtifactStub { + @Override + public String getType() { + return "pom"; + } + + public ArtifactHandler getArtifactHandler() { + return new DefaultArtifactHandler() { + public String getExtension() { + return "pom"; + } + }; + } +} diff --git a/src/test/resources/unit/basic-deploy-bom/plugin-config.xml b/src/test/resources/unit/basic-deploy-bom/plugin-config.xml new file mode 100644 index 00000000..53bb8866 --- /dev/null +++ b/src/test/resources/unit/basic-deploy-bom/plugin-config.xml @@ -0,0 +1,39 @@ + + + + + + + maven-deploy-plugin + + + ${basedir}/src/test/resources/unit/basic-deploy-bom/plugin-config.xml + bom + + + + ${basedir} + + + + + + + diff --git a/src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom b/src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom new file mode 100644 index 00000000..9c7bc402 --- /dev/null +++ b/src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom @@ -0,0 +1,28 @@ + + + + + 4.0.0 + org.apache.maven.test + maven-deploy-file-test + 1.0 + bom + + \ No newline at end of file diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml index 8cf373c8..27d5f259 100644 --- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml @@ -26,7 +26,7 @@ under the License. ${basedir}/src/test/resources/unit/basic-deploy-pom/plugin-config.xml pom - + ${basedir} From edf85d72c5dd03f19fcf06b96b172573e8e4a696 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Mon, 1 Apr 2024 01:02:20 +0200 Subject: [PATCH 147/153] Add Dependabot --- .github/dependabot.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..778ea2af --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,27 @@ +# 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. + +version: 2 +updates: + - package-ecosystem: "maven" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" From de7cefbd3da75e28a4c49caa674d06cd32d820f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 31 Mar 2024 23:04:15 +0000 Subject: [PATCH 148/153] Bump apache/maven-gh-actions-shared from 3 to 4 Bumps [apache/maven-gh-actions-shared](https://github.com/apache/maven-gh-actions-shared) from 3 to 4. - [Commits](https://github.com/apache/maven-gh-actions-shared/compare/v3...v4) --- updated-dependencies: - dependency-name: apache/maven-gh-actions-shared dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/maven-verify.yml | 2 +- .github/workflows/release-drafter.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 4d67fdcf..932827cf 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@v3 + uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index b44872cf..1049eaa3 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -22,4 +22,4 @@ on: - master jobs: update_release_draft: - uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v3 + uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4 From ac9c49dd973ed2ca806066e4da8c296cc603b4e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:22:48 +0000 Subject: [PATCH 149/153] Bump org.mockito:mockito-core from 2.28.2 to 4.11.0 Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 2.28.2 to 4.11.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v2.28.2...v4.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0340c384..f8422a88 100644 --- a/pom.xml +++ b/pom.xml @@ -193,7 +193,7 @@ under the License. org.mockito mockito-core - 2.28.2 + 4.11.0 test From 74d331be89ed010b5d38dc6e755dcab327baf56c Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 24 Apr 2024 16:11:46 +0200 Subject: [PATCH 150/153] [MDEPLOY-316] Parent 42 and prerequisite 3.6.3 (#54) Update parent to 42 and prerequisite to Maven 3.6.3 --- https://issues.apache.org/jira/browse/MDEPLOY-316 --- .github/workflows/maven-verify.yml | 2 ++ pom.xml | 4 ++-- .../org/apache/maven/plugins/deploy/AbstractDeployMojo.java | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 932827cf..681f3d34 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -25,3 +25,5 @@ jobs: build: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 + with: + jdk-distribution-matrix: '[ "zulu" ]' diff --git a/pom.xml b/pom.xml index f8422a88..92c4bc03 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.maven.plugins maven-plugins - 41 + 42 @@ -43,7 +43,7 @@ under the License. - 3.2.5 + 3.6.3 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 2c5c1d9c..d8da6922 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -99,6 +99,7 @@ protected void warnIfAffectedPackagingAndMaven(final String packaging) { * Creates resolver {@link RemoteRepository} equipped with needed whistles and bells. */ protected RemoteRepository getRemoteRepository(final String repositoryId, final String url) { + // TODO: RepositorySystem#newDeploymentRepository does this very same thing! RemoteRepository result = new RemoteRepository.Builder(repositoryId, "default", url).build(); if (result.getAuthentication() == null || result.getProxy() == null) { From b9c1c8bc486c7defb92171e1ea9169075b76695c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20P=C3=A9teri?= Date: Mon, 20 Nov 2023 14:27:01 +0100 Subject: [PATCH 151/153] [MDEPLOY-314] Include artifactId in DeployMojo#processProject messages Enhance messages on deployAtEnd --- https://issues.apache.org/jira/browse/MDEPLOY-314 --- .../maven/plugins/deploy/DeployMojo.java | 14 +- .../maven/plugins/deploy/DeployMojoTest.java | 141 +++++++++++++++++- 2 files changed, 148 insertions(+), 7 deletions(-) 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 c3ea850a..79ee1d87 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -308,7 +308,8 @@ private void processProject(final MavenProject project, DeployRequest request) t if (isFile(pomArtifact.getFile())) { request.addArtifact(pomArtifact); } else { - throw new MojoExecutionException("The project POM could not be attached"); + throw new MojoExecutionException( + "The POM for project " + project.getArtifactId() + " could not be attached"); } // is not packaged, is "incomplete" @@ -319,18 +320,19 @@ private void processProject(final MavenProject project, DeployRequest request) t } else if (!project.getAttachedArtifacts().isEmpty()) { if (allowIncompleteProjects) { getLog().warn(""); - getLog().warn("The packaging plugin for this project did not assign"); + getLog().warn("The packaging plugin for project " + project.getArtifactId() + " did not assign"); getLog().warn("a main file to the project but it has attachments. Change packaging to 'pom'."); getLog().warn(""); getLog().warn("Incomplete projects like this will fail in future Maven versions!"); getLog().warn(""); } else { - 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'."); + throw new MojoExecutionException("The packaging plugin for project " + project.getArtifactId() + + " 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"); + throw new MojoExecutionException("The packaging plugin for project " + project.getArtifactId() + + " did not assign a file to the build artifact"); } } 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 3b0df77e..5884ae11 100644 --- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -23,6 +23,7 @@ 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; @@ -36,10 +37,12 @@ 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.DefaultLocalPathComposer; 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; @@ -470,10 +473,46 @@ public void testDeployIfArtifactFileIsNull() throws Exception { try { mojo.execute(); + fail("Did not throw mojo execution exception"); + } catch (MojoExecutionException e) { + // expected, message should include artifactId + assertEquals( + "The packaging plugin for project maven-deploy-test did not assign a file to the build artifact", + e.getMessage()); + } + } + + public void testDeployIfProjectFileIsNull() 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"); + + project.setFile(null); + assertNull(project.getFile()); + + setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(project)); + + try { + mojo.execute(); fail("Did not throw mojo execution exception"); } catch (MojoExecutionException e) { - // expected + // expected, message should include artifactId + assertEquals("The POM for project maven-deploy-test could not be attached", e.getMessage()); } } @@ -568,6 +607,106 @@ public void testDeployWithAttachedArtifacts() throws Exception { assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); } + public void testNonPomDeployWithAttachedArtifactsOnly() 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); + + 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); + + try { + mojo.execute(); + fail("Did not throw mojo execution exception"); + } catch (MojoExecutionException e) { + // expected, message should include artifactId + assertEquals( + "The packaging plugin for project maven-deploy-test did not assign a main file to the project " + + "but it has attachments. Change packaging to 'pom'.", + e.getMessage()); + } + } + + @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"); + altHome.mkdirs(); + + 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)); + + artifact = (DeployArtifactStub) project.getArtifact(); + + 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."); + } + + 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); + } + public void testLegacyAltDeploymentRepositoryWithDefaultLayout() throws Exception { DeployMojo mojo = new DeployMojo(); From 0ed18be3d93fa0f28886d47a664c8eff2590c944 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 25 Apr 2024 19:19:46 +0200 Subject: [PATCH 152/153] Remove workaround, handle it centrally --- .github/workflows/maven-verify.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 681f3d34..cd3c4512 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -25,5 +25,4 @@ jobs: build: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 - with: - jdk-distribution-matrix: '[ "zulu" ]' + From 4f016bce38dd9016f7c0357a75fbbe3427ed8b31 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 26 Apr 2024 12:30:28 +0200 Subject: [PATCH 153/153] [maven-release-plugin] prepare release maven-deploy-plugin-3.1.2 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 92c4bc03..a4363e37 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ under the License. maven-deploy-plugin - 3.1.2-SNAPSHOT + 3.1.2 maven-plugin Apache Maven Deploy Plugin @@ -49,7 +49,7 @@ under the License. scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git scm:git:https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git - HEAD + maven-deploy-plugin-3.1.2 https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} @@ -88,7 +88,7 @@ under the License. ${version.maven-surefire} ${version.maven-war-plugin} - 2023-03-21T14:38:01Z + 2024-04-26T10:30:22Z