diff --git a/.asf.yaml b/.asf.yaml new file mode 100644 index 00000000..d4bb4049 --- /dev/null +++ b/.asf.yaml @@ -0,0 +1,21 @@ +# 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 + enabled_merge_buttons: + squash: true + merge: false + rebase: true + autolink_jira: + - MDEPLOY +notifications: + commits: commits@maven.apache.org + issues: issues@maven.apache.org + pullrequests: issues@maven.apache.org + jira_options: link label comment 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 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" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..7f4ebfaa --- /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/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 `[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. + - [ ] 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/.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/maven-verify.yml b/.github/workflows/maven-verify.yml new file mode 100644 index 00000000..cd3c4512 --- /dev/null +++ b/.github/workflows/maven-verify.yml @@ -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. + +name: Verify + +on: + push: + pull_request: + +jobs: + build: + name: Verify + 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 new file mode 100644 index 00000000..1049eaa3 --- /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@v4 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/src/it/MDEPLOY-181/verify.groovy b/Jenkinsfile similarity index 83% rename from src/it/MDEPLOY-181/verify.groovy rename to Jenkinsfile index 0c55d6e1..e9f05f7d 100644 --- a/src/it/MDEPLOY-181/verify.groovy +++ b/Jenkinsfile @@ -1,21 +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. - */ - -def buildLog = new File ( basedir, "build.log") -assert !buildLog.text.contains( '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. + */ + +asfMavenTlpPlgnBuild() diff --git a/README.md b/README.md new file mode 100644 index 00000000..52b7b0fd --- /dev/null +++ b/README.md @@ -0,0 +1,100 @@ + +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/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] + + +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][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. + + 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][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 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 +[cla]: https://www.apache.org/licenses/#clas +[maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index +[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/ diff --git a/pom.xml b/pom.xml index 03b2d9c3..a4363e37 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,4 @@ - - + - 4.0.0 org.apache.maven.plugins maven-plugins - 25 - ../maven-plugins/pom.xml + 42 + maven-deploy-plugin - 2.8.2 + 3.1.2 maven-plugin Apache Maven Deploy Plugin Uploads the project artifacts to the internal remote repository. 2004 + + + + Hermann Josef Hill + + + - ${mavenVersion} + 3.6.3 - 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: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.2 + https://github.com/apache/maven-deploy-plugin/tree/${project.scm.tag} JIRA - http://jira.codehaus.org/browse/MDEPLOY + https://issues.apache.org/jira/browse/MDEPLOY + + Jenkins + https://ci-builds.apache.org/job/Maven/job/maven-box/job/maven-deploy-plugin/ + apache.website - scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/${maven.site.path} + scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path} - 2.2.1 - 3.2 + 8 + 3.9.6 + + 1.7.36 + + 1.9.18 + + + ${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} + + 2024-04-26T10:30:22Z @@ -67,90 +96,131 @@ under the License. org.apache.maven maven-plugin-api ${mavenVersion} + provided org.apache.maven - maven-project + maven-core ${mavenVersion} + provided org.apache.maven maven-model ${mavenVersion} + provided org.apache.maven maven-artifact ${mavenVersion} + provided - + - org.apache.maven.plugin-tools - maven-plugin-annotations - ${mavenPluginPluginVersion} + org.slf4j + slf4j-api + ${slf4jVersion} provided org.codehaus.plexus plexus-utils - 3.0.15 + + org.codehaus.plexus + plexus-xml + + + org.apache.maven.resolver + maven-resolver-api + ${resolverVersion} + provided + + + org.apache.maven.resolver + maven-resolver-util + ${resolverVersion} + + compile + + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + provided + + + org.apache.maven.plugin-testing maven-plugin-testing-harness - 1.2 + 3.3.0 + test + + + + org.apache.maven + maven-compat + ${mavenVersion} + test + + + org.apache.maven + maven-resolver-provider + ${mavenVersion} + test + + + org.apache.maven.resolver + maven-resolver-connector-basic + ${resolverVersion} + test + + + org.apache.maven.resolver + maven-resolver-transport-file + ${resolverVersion} + test + + + org.apache.maven.resolver + maven-resolver-transport-http + ${resolverVersion} test org.mockito mockito-core - 1.9.5 + 4.11.0 test junit junit - 3.8.2 + 4.13.2 + test + + + org.slf4j + slf4j-nop + ${slf4jVersion} test - - - - Hermann Josef Hill - - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - ${mavenPluginPluginVersion} - - true - - - - mojo-descriptor - process-classes - - descriptor - - - - help-goal - - helpmojo - - - - - - + + + org.apache.maven.plugins + maven-compiler-plugin + + none + true + + + @@ -164,6 +234,7 @@ under the License. maven-invoker-plugin true + true ${project.build.directory}/it true @@ -174,6 +245,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 @@ -183,31 +260,5 @@ under the License. - - reporting - - - - org.apache.maven.plugins - maven-changes-plugin - 2.3 - - - Type,Key,Summary,Assignee,Status,Resolution,Fix Version - true - Closed - Type,Key - - - - - jira-report - - - - - - - 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/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 00000000..2169f44a Binary files /dev/null and b/src/it/3rd-party-pom-with-extras/test-0.1-src.tar.gz differ diff --git a/src/it/3rd-party-pom-with-extras/test-0.1.pom b/src/it/3rd-party-pom-with-extras/test-0.1.pom new file mode 100644 index 00000000..83f1a8e7 --- /dev/null +++ b/src/it/3rd-party-pom-with-extras/test-0.1.pom @@ -0,0 +1,28 @@ + + + + + + 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 00000000..ad736b0d Binary files /dev/null and b/src/it/3rd-party-pom-with-extras/test-0.1.tar.gz differ diff --git a/src/it/3rd-party-pom-with-extras/test-0.1.zip b/src/it/3rd-party-pom-with-extras/test-0.1.zip new file mode 100644 index 00000000..226277c3 Binary files /dev/null and b/src/it/3rd-party-pom-with-extras/test-0.1.zip differ diff --git a/src/it/3rd-party-pom-with-extras/test.properties b/src/it/3rd-party-pom-with-extras/test.properties new file mode 100644 index 00000000..5c4d1159 --- /dev/null +++ b/src/it/3rd-party-pom-with-extras/test.properties @@ -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. + +file = test-0.1.pom +url = file:target/repo +groupId = org.apache.maven.its.deploy.tppwoc +artifactId = test +version = 1.0 +packaging = pom +files = test-0.1.zip,test-0.1-src.tar.gz,test-0.1.tar.gz +types = zip,tar.gz,tar.gz +classifiers = ,src, diff --git a/src/it/3rd-party-pom-with-extras/verify.bsh b/src/it/3rd-party-pom-with-extras/verify.bsh new file mode 100644 index 00000000..a477aa2a --- /dev/null +++ b/src/it/3rd-party-pom-with-extras/verify.bsh @@ -0,0 +1,57 @@ +/* + * 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/tppwoc/test/maven-metadata.xml", + "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0.pom", + "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0.zip", + "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0-src.tar.gz", + "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0.tar.gz", +}; + +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() ); + } +} + +String[] missing = +{ + "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0.jar", +}; + +for ( String path : missing ) +{ + File file = new File( new File( basedir, "target/repo" ), path ); + System.out.println( "Checking for absence of " + file ); + if ( file.exists() ) + { + throw new FileNotFoundException( "Existent: " + file.getAbsolutePath() ); + } +} + +return true; 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 b1913bd2..af8d8c2b 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 @@ -48,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -61,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 @@ -89,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 3e7d3cc7..8884e138 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 @@ -48,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -61,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 @@ -89,7 +88,7 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ 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..8ff44f4d --- /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://issues.apache.org/jira/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..181104aa --- /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 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/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/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 00000000..2fa3a242 Binary files /dev/null and b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.equinox.common.source_1.0.jar differ 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 00000000..2fa3a242 Binary files /dev/null and b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.equinox.common_1.0.jar differ 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 00000000..2fa3a242 Binary files /dev/null and b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.osgi.source_1.0.jar differ 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 00000000..2fa3a242 Binary files /dev/null and b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/lib/org.eclipse.osgi_1.0.jar differ 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..a9a99927 --- /dev/null +++ b/src/it/MDEPLOY-202_deployfile-with-multiple-executions/pom.xml @@ -0,0 +1,99 @@ + + + + + + 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 + + + + + + + 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..4232c455 --- /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 buildLog.text =~ /Uploading.*file:target\/repo\/org\/apache\/maven\/plugins\/deploy\/it\/org\.eclipse\.osgi\/1\.0\/org\.eclipse\.osgi-1\.0-sources\.jar/ diff --git a/src/it/MDEPLOY-181/test.properties b/src/it/MDEPLOY-212/invoker.properties similarity index 95% rename from src/it/MDEPLOY-181/test.properties rename to src/it/MDEPLOY-212/invoker.properties index fb658e56..a644cb7e 100644 --- a/src/it/MDEPLOY-181/test.properties +++ b/src/it/MDEPLOY-212/invoker.properties @@ -1,18 +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. - -deployAtEnd=false \ 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 package diff --git a/src/it/MDEPLOY-212/pom.xml b/src/it/MDEPLOY-212/pom.xml new file mode 100644 index 00000000..8bca65b1 --- /dev/null +++ b/src/it/MDEPLOY-212/pom.xml @@ -0,0 +1,79 @@ + + + + + + 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 + @mavenJavadocPluginVersion@ + + + 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/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java b/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java similarity index 68% rename from src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java rename to src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java index 3c8531f2..ed8b2ca7 100644 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/MavenProjectStub.java +++ b/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java @@ -1,4 +1,4 @@ -package org.apache.maven.plugin.deploy.stubs; +package org.apache.maven.test; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,17 +19,19 @@ * under the License. */ -import org.apache.maven.artifact.repository.ArtifactRepository; - -public class MavenProjectStub - extends org.apache.maven.plugin.testing.stubs.MavenProjectStub +/** + * Hello World class + */ +public class HelloWorld { - private ArtifactRepositoryStub deploymentRepository; - - public ArtifactRepository getDistributionManagementArtifactRepository() + /** + * Main method + * @param args Arguments + */ + public static void main( String[] args ) { - return deploymentRepository; + 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 00000000..ad736b0d Binary files /dev/null and b/src/it/MDEPLOY-212/test-1.0.tar.gz differ diff --git a/src/it/MDEPLOY-212/test-1.0.zip b/src/it/MDEPLOY-212/test-1.0.zip new file mode 100644 index 00000000..226277c3 Binary files /dev/null and b/src/it/MDEPLOY-212/test-1.0.zip differ diff --git a/src/it/MDEPLOY-212/verify.bsh b/src/it/MDEPLOY-212/verify.bsh new file mode 100644 index 00000000..f71e2520 --- /dev/null +++ b/src/it/MDEPLOY-212/verify.bsh @@ -0,0 +1,56 @@ +/* + * 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/mdeploy-212/test/1.0/test-1.0.pom", + "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0.tar.gz", + "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0-it.zip", +}; + +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() ); + } +} + +String[] missing = +{ + "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0.jar", + "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0-javadoc.jar", +}; + +for ( String path : missing ) +{ + File file = new File( new File( basedir, "target/repo" ), path ); + System.out.println( "Checking for absence of " + file ); + if ( file.exists() ) + { + throw new FileNotFoundException( "Existent: " + file.getAbsolutePath() ); + } +} + +return true; diff --git a/src/it/MDEPLOY-181/invoker.properties b/src/it/MDEPLOY-213/invoker.properties similarity index 89% rename from src/it/MDEPLOY-181/invoker.properties rename to src/it/MDEPLOY-213/invoker.properties index ac00f436..2035eadd 100644 --- a/src/it/MDEPLOY-181/invoker.properties +++ b/src/it/MDEPLOY-213/invoker.properties @@ -15,6 +15,4 @@ # 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 +invoker.goals = clean package deploy diff --git a/src/it/MDEPLOY-213/pom.xml b/src/it/MDEPLOY-213/pom.xml new file mode 100644 index 00000000..ff4574d6 --- /dev/null +++ b/src/it/MDEPLOY-213/pom.xml @@ -0,0 +1,87 @@ + + + + + + 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 + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + @mavenJavadocPluginVersion@ + + + 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 00000000..ad736b0d Binary files /dev/null and b/src/it/MDEPLOY-213/test-1.0.tar.gz differ diff --git a/src/it/MDEPLOY-213/test-1.0.zip b/src/it/MDEPLOY-213/test-1.0.zip new file mode 100644 index 00000000..226277c3 Binary files /dev/null and b/src/it/MDEPLOY-213/test-1.0.zip differ diff --git a/src/it/no-main-artifact-2/verify.bsh b/src/it/MDEPLOY-213/verify.bsh similarity index 78% rename from src/it/no-main-artifact-2/verify.bsh rename to src/it/MDEPLOY-213/verify.bsh index 4468ed8f..ae711422 100644 --- a/src/it/no-main-artifact-2/verify.bsh +++ b/src/it/MDEPLOY-213/verify.bsh @@ -22,9 +22,11 @@ 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", + "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0.pom", + "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0.tar.gz", + "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0-it.zip", + "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0.jar", + "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0-javadoc.jar", }; for ( String path : paths ) 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-181/module2/pom.xml b/src/it/MDEPLOY-224_deploy-at-end-only-modules/module2/pom.xml similarity index 89% rename from src/it/MDEPLOY-181/module2/pom.xml rename to src/it/MDEPLOY-224_deploy-at-end-only-modules/module2/pom.xml index d811568c..081edc5a 100644 --- a/src/it/MDEPLOY-181/module2/pom.xml +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/module2/pom.xml @@ -1,38 +1,38 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.mdeploy-170 - configperproject - 1.0 - - module2 - pom - - - - - org.apache.maven.plugins - maven-deploy-plugin - @project.version@ - - true - - - - - + + + + + + 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..063f2aee --- /dev/null +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +assert new File( basedir, "target/repo/org/apache/maven/its/mdeploy-224/parent/1.0/parent-1.0.pom" ).exists() +assert new File( basedir, "module1/target/repo/org/apache/maven/its/mdeploy-224/module1/1.0/module1-1.0.pom" ).exists() +assert new File( basedir, "module2/target/repo/org/apache/maven/its/mdeploy-224/module2/1.0/module2-1.0.pom" ).exists() + +def buildLog = new File ( basedir, "build.log").text + +assert ! buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:parent:1.0 at end') +assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module1:1.0 at end') +// Last module does not emit this misleading message, as it IS "the end", not deferring anymore +// assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module2:1.0 at end') diff --git a/src/it/MDEPLOY-225_deploy-at-end-skip-root/module1/pom.xml b/src/it/MDEPLOY-225_deploy-at-end-skip-root/module1/pom.xml new file mode 100644 index 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-181/pom.xml b/src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml similarity index 74% rename from src/it/MDEPLOY-181/pom.xml rename to src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml index 3e7d3cc7..8ac0f820 100644 --- a/src/it/MDEPLOY-181/pom.xml +++ b/src/it/MDEPLOY-225_deploy-at-end-skip-root/pom.xml @@ -1,101 +1,88 @@ - - - - - - 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 - - + + + + + + 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() 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-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/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-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/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/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/attach-release-jar/pom.xml b/src/it/attach-release-jar/pom.xml index 035707c5..916f2462 100644 --- a/src/it/attach-release-jar/pom.xml +++ b/src/it/attach-release-jar/pom.xml @@ -33,14 +33,12 @@ under the License. true - true it file:///${basedir}/target/repo - false @@ -49,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -59,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 @@ -83,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 92e45b05..ed5f9ba0 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 @@ -48,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -61,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 @@ -89,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-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/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/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/MDEPLOY-181/module1/pom.xml b/src/it/deploy-at-end-pass/module3/pom.xml similarity index 87% rename from src/it/MDEPLOY-181/module1/pom.xml rename to src/it/deploy-at-end-pass/module3/pom.xml index aecbca0b..48c9caa0 100644 --- a/src/it/MDEPLOY-181/module1/pom.xml +++ b/src/it/deploy-at-end-pass/module3/pom.xml @@ -1,25 +1,25 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.mdeploy-170 - configperproject - 1.0 - - module1 - - + + + + + + 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 8021f6a1..90ed655c 100644 --- a/src/it/deploy-at-end-pass/pom.xml +++ b/src/it/deploy-at-end-pass/pom.xml @@ -38,8 +38,7 @@ under the License. it - file:///${basedir}/target/repo - false + file:///@remoteRepo@/deploy-at-end-pass @@ -48,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -61,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 @@ -89,12 +88,15 @@ under the License. org.apache.maven.plugins maven-surefire-plugin - 2.3.1 + @mavenSurefirePluginVersion@ 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 d776935a..8db44909 100644 --- a/src/it/deploy-at-end-pass/verify.groovy +++ b/src/it/deploy-at-end-pass/verify.groovy @@ -17,10 +17,16 @@ * under the License. */ -assert new File( basedir, "target/repo/org/apache/maven/its/deploy/dae/pass/dae/1.0/dae-1.0.pom" ).exists() -assert new File( basedir, "module1/target/repo/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/dae/1.0/dae-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module1/1.0/module1-1.0.jar" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module3/1.0/module3-1.0.pom" ).exists() +assert new File( remoteRepo, "deploy-at-end-pass/org/apache/maven/its/deploy/dae/pass/module3/1.0/module3-1.0.jar" ).exists() File buildLog = new File( basedir, 'build.log' ) assert buildLog.exists() -assert buildLog.text.contains( "[INFO] 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" ) +assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module1:1.0 at end" ) +// Last module does not emit this misleading message, as it IS "the end", not deferring anymore +//assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module3:1.0 at end" ) diff --git a/src/it/deploy-attached-sources/pom.xml b/src/it/deploy-attached-sources/pom.xml index d0aac263..01a48240 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 @@ -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/deploy-default-packaging/pom.xml b/src/it/deploy-default-packaging/pom.xml index 6394e352..9440f68f 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 @@ -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/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/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/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/it/mdeploy-45-test/pom.xml b/src/it/mdeploy-45-test/pom.xml index 4cd030ed..cdefaade 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 + @mavenResourcesPluginVersion@ + + + + resources + + + + org.apache.maven.plugins maven-war-plugin - 2.0.2 + @mavenWarPluginVersion@ + + + + war + + + ${mdp45.artifact.classifier} + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + + mine::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..18944b67 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 @@ -48,14 +49,14 @@ under the License. org.apache.maven.plugins maven-antrun-plugin - 1.1 + @mavenAntrunPluginVersion@ - + - + @@ -70,7 +71,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -80,7 +81,7 @@ under the License. org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ it @@ -88,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-1/verify.groovy b/src/it/no-main-artifact-1/verify.groovy new file mode 100644 index 00000000..9442aa7d --- /dev/null +++ b/src/it/no-main-artifact-1/verify.groovy @@ -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. + */ + +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/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-2/verify.groovy b/src/it/no-main-artifact-2/verify.groovy new file mode 100644 index 00000000..9442aa7d --- /dev/null +++ b/src/it/no-main-artifact-2/verify.groovy @@ -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. + */ + +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..89c4fc99 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 @@ -48,7 +48,14 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ + + + + compile + + + org.apache.maven.plugins @@ -58,7 +65,14 @@ under the License. org.apache.maven.plugins maven-jar-plugin - 2.1 + @mavenJarPluginVersion@ + + + + jar + + + it @@ -66,17 +80,19 @@ under the License. org.apache.maven.plugins maven-install-plugin - 2.3 + @mavenInstallPluginVersion@ org.apache.maven.plugins maven-resources-plugin - 2.2 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.3.1 + @mavenResourcesPluginVersion@ + + + + resources + + + 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 c6043142..cdad63cf 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 @@ -48,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -58,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 a4e0eadc..1d275c9c 100644 --- a/src/it/release-jar/pom.xml +++ b/src/it/release-jar/pom.xml @@ -33,14 +33,12 @@ under the License. true - true it file:///${basedir}/target/repo - false @@ -49,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -59,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 ec19a46f..fe9c110e 100644 --- a/src/it/release-pom/pom.xml +++ b/src/it/release-pom/pom.xml @@ -33,14 +33,12 @@ under the License. true - true it file:///${basedir}/target/repo - false @@ -49,7 +47,7 @@ under the License. org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + @mavenCompilerPluginVersion@ org.apache.maven.plugins @@ -59,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/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/it/skip-release-jar/pom.xml b/src/it/skip-release-jar/pom.xml new file mode 100644 index 00000000..2774462e --- /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 + @mavenCompilerPluginVersion@ + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + releases + + + + 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@ + + + + + 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/no-main-artifact-1/verify.bsh b/src/it/skip-release-jar/verify.bsh similarity index 77% rename from src/it/no-main-artifact-1/verify.bsh rename to src/it/skip-release-jar/verify.bsh index c6d7a377..6fe57019 100644 --- a/src/it/no-main-artifact-1/verify.bsh +++ b/src/it/skip-release-jar/verify.bsh @@ -22,18 +22,18 @@ 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", + "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() ) + if ( file.isFile() ) { - throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() ); + throw new FileNotFoundException( "File has been deployed: " + file.getAbsolutePath() ); } } diff --git a/src/it/skip-snapshot-jar/pom.xml b/src/it/skip-snapshot-jar/pom.xml new file mode 100644 index 00000000..a0099041 --- /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 + @mavenCompilerPluginVersion@ + + + org.apache.maven.plugins + maven-deploy-plugin + @project.version@ + + snapshots + + + + 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@ + + + + + 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/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/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java deleted file mode 100644 index 33478746..00000000 --- a/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.apache.maven.plugin.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.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.layout.ArtifactRepositoryLayout; -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; - -/** - * @version $Id$ - */ -public abstract class AbstractDeployMojo - extends AbstractMojo -{ - /** - */ - @Component - private ArtifactDeployer deployer; - - /** - * Component used to create an artifact. - */ - @Component - protected ArtifactFactory artifactFactory; - - /** - * Component used to create a repository. - */ - @Component - ArtifactRepositoryFactory repositoryFactory; - - /** - * Map that contains the layouts. - */ - @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. - */ - @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. - * - * @since 2.7 - */ - @Parameter( property = "retryFailedDeploymentCount", defaultValue = "1" ) - private int retryFailedDeploymentCount; - - /* Setters and Getters */ - - public ArtifactDeployer getDeployer() - { - return deployer; - } - - 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 - { - if ( offline ) - { - throw new MojoFailureException( "Cannot deploy artifacts when Maven is in offline mode" ); - } - } - - 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; - } - - int getRetryFailedDeploymentCount() - { - return retryFailedDeploymentCount; - } - - /** - * Deploy an artifact from a particular file. - * - * @param source the file to deploy - * @param artifact the artifact definition - * @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 - */ - protected void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, - ArtifactRepository localRepository, int retryFailedDeploymentCount ) - throws ArtifactDeploymentException - { - int retryFailedDeploymentCounter = Math.max( 1, Math.min( 10, retryFailedDeploymentCount ) ); - ArtifactDeploymentException exception = null; - for ( int count = 0; count < retryFailedDeploymentCounter; count++ ) - { - try - { - if ( count > 0 ) - { - getLog().info( "Retrying deployment attempt " + ( count + 1 ) + " of " + retryFailedDeploymentCounter ); - } - getDeployer().deploy( source, artifact, deploymentRepository, localRepository ); - exception = null; - break; - } - catch ( ArtifactDeploymentException 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; - } - } -} diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java deleted file mode 100644 index 719e530b..00000000 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java +++ /dev/null @@ -1,610 +0,0 @@ -package org.apache.maven.plugin.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.FileNotFoundException; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.util.List; - -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.Model; -import org.apache.maven.model.Parent; -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.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.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; - -/** - * Installs the artifact in the remote repository. - * - * @author Allan Ramirez - */ -@Mojo( name = "deploy-file", requiresProject = false, threadSafe = true ) -public class DeployFileMojo - extends AbstractDeployMojo -{ - /** - * The default Maven project created when building the plugin - */ - @Parameter( defaultValue = "${project}", readonly = true, required = true ) - private MavenProject project; - - /** - * Used for attaching the source and javadoc jars to the project. - */ - @Component - private MavenProjectHelper projectHelper; - - /** - * GroupId of the artifact to be deployed. Retrieved from POM file if specified. - */ - @Parameter( property = "groupId" ) - private String groupId; - - /** - * ArtifactId of the artifact to be deployed. Retrieved from POM file if specified. - */ - @Parameter( property = "artifactId" ) - private String artifactId; - - /** - * Version of the artifact to be deployed. Retrieved from POM file if specified. - */ - @Parameter( property = "version" ) - private String version; - - /** - * Type of the artifact to be deployed. Retrieved from the <packaging> element of the POM file if a POM file - * specified. Defaults to the file extension if it is not specified via command line or POM.
- * 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" ) - private String packaging; - - /** - * Description passed to a generated POM file (in case of generatePom=true) - */ - @Parameter( property = "generatePom.description" ) - private String description; - - /** - * File to be deployed. - */ - @Parameter( property = "file", required = true ) - private File file; - - /** - * The bundled API docs for the artifact. - * - * @since 2.6 - */ - @Parameter( property = "javadoc" ) - private File javadoc; - - /** - * The bundled sources for the artifact. - * - * @since 2.6 - */ - @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 ) - private String repositoryId; - - /** - * The type of remote repository layout to deploy to. Try legacy for a Maven 1.x-style repository layout. - */ - @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 ) - */ - @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" ) - 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" ) - private boolean generatePom; - - /** - * Add classifier to the artifact - */ - @Parameter( property = "classifier" ) - private String classifier; - - /** - * Whether to deploy snapshots with a unique version or not. - */ - @Parameter( property = "uniqueVersion", defaultValue = "true" ) - 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. - */ - @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" ) - 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" ) - private String files; - - void initProperties() - throws MojoExecutionException - { - // Process the supplied POM (if there is one) - if ( pomFile != null ) - { - generatePom = false; - - Model model = readModel( pomFile ); - - processModel( model ); - } - - if ( packaging == null && file != null ) - { - packaging = FileUtils.getExtension( file.getName() ); - } - } - - public void execute() - throws MojoExecutionException, MojoFailureException - { - failIfOffline(); - - if ( !file.exists() ) - { - throw new MojoExecutionException( file.getPath() + " not found." ); - } - - initProperties(); - - validateArtifactInformation(); - - ArtifactRepositoryLayout layout = getLayout( repositoryLayout ); - - ArtifactRepository deploymentRepository = - repositoryFactory.createDeploymentArtifactRepository( repositoryId, url, layout, uniqueVersion ); - - String protocol = deploymentRepository.getProtocol(); - - if ( StringUtils.isEmpty( protocol ) ) - { - throw new MojoExecutionException( "No transfer protocol found." ); - } - - // Create the artifact - Artifact artifact = - artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, packaging, classifier ); - - if ( file.equals( getLocalRepoFile( artifact ) ) ) - { - throw new MojoFailureException( "Cannot deploy artifact from the local repository: " + file ); - } - - // Upload the POM if requested, generating one if need be - if ( !"pom".equals( packaging ) ) - { - if ( pomFile != null ) - { - ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); - artifact.addMetadata( metadata ); - } - else if ( generatePom ) - { - ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, generatePomFile() ); - artifact.addMetadata( metadata ); - } - } - - if ( updateReleaseInfo ) - { - artifact.setRelease( true ); - } - - project.setArtifact( artifact ); - - try - { - deploy( file, artifact, deploymentRepository, getLocalRepository(), getRetryFailedDeploymentCount() ); - } - catch ( ArtifactDeploymentException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } - - if ( sources != null ) - { - projectHelper.attachArtifact( project, "jar", "sources", sources ); - } - - if ( javadoc != null ) - { - projectHelper.attachArtifact( project, "jar", "javadoc", javadoc ); - } - - 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'" ); - } - 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 )" ); - } - int fi = 0; - int ti = 0; - int ci = 0; - 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 ) - { - nti = types.length(); - } - int nci = classifiers.indexOf( ',', ci ); - if ( nci == -1 ) - { - nci = classifiers.length(); - } - File file = new File( files.substring( fi, nfi ) ); - if ( !file.isFile() ) - { - // try relative to the project basedir just in case - file = new File( project.getBasedir(), files.substring( fi, nfi ) ); - } - if ( file.isFile() ) - { - if ( StringUtils.isWhitespace( classifiers.substring( ci, nci ) ) ) - { - projectHelper.attachArtifact( project, types.substring( ti, nti ).trim(), file ); - } - else - { - projectHelper.attachArtifact( project, types.substring( ti, nti ).trim(), - classifiers.substring( ci, nci ).trim(), 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'" ); - } - if ( classifiers != null ) - { - throw new MojoExecutionException( "You must specify 'files' if you specify 'classifiers'" ); - } - } - - @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 ); - } - } - - } - - /** - * Gets the path of the specified artifact 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 ) - { - String path = getLocalRepository().pathOf( artifact ); - return new File( 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 ) - { - Parent parent = model.getParent(); - - if ( this.groupId == null ) - { - this.groupId = model.getGroupId(); - if ( this.groupId == null && parent != null ) - { - this.groupId = parent.getGroupId(); - } - } - if ( this.artifactId == null ) - { - this.artifactId = model.getArtifactId(); - } - if ( this.version == null ) - { - this.version = model.getVersion(); - if ( this.version == null && parent != null ) - { - this.version = parent.getVersion(); - } - } - 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 - { - Reader reader = null; - try - { - 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 ); - } - } - - /** - * 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 - { - Model model = generateModel(); - - Writer fw = null; - try - { - File tempFile = File.createTempFile( "mvndeploy", ".pom" ); - tempFile.deleteOnExit(); - - 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 ); - } - } - - /** - * Validates the user-supplied artifact information. - * - * @throws MojoExecutionException If any artifact coordinate is invalid. - */ - private void validateArtifactInformation() - throws MojoExecutionException - { - Model model = generateModel(); - - ModelValidationResult result = modelValidator.validate( model ); - - if ( result.getMessageCount() > 0 ) - { - throw new MojoExecutionException( "The artifact information is incomplete or not valid:\n" - + result.render( " " ) ); - } - } - - /** - * Generates a minimal model from the user-supplied artifact information. - * - * @return The generated model, never null. - */ - private Model generateModel() - { - Model model = new Model(); - - model.setModelVersion( "4.0.0" ); - - model.setGroupId( groupId ); - model.setArtifactId( artifactId ); - model.setVersion( version ); - model.setPackaging( packaging ); - - model.setDescription( description ); - - return model; - } - - void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - void setVersion( String version ) - { - this.version = version; - } - - void setPackaging( String packaging ) - { - this.packaging = packaging; - } - - void setPomFile( File pomFile ) - { - this.pomFile = pomFile; - } - - String getGroupId() - { - return groupId; - } - - String getArtifactId() - { - return artifactId; - } - - String getVersion() - { - return version; - } - - String getPackaging() - { - return packaging; - } - - File getFile() - { - return file; - } - - String getClassifier() - { - return classifier; - } - - void setClassifier( String classifier ) - { - this.classifier = classifier; - } -} diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java deleted file mode 100644 index a70b3db6..00000000 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java +++ /dev/null @@ -1,349 +0,0 @@ -package org.apache.maven.plugin.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.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; -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. - * - * @author Emmanuel Venisse - * @author John Casey (refactoring only) - * @version $Id$ - */ -@Mojo( name = "deploy", defaultPhase = LifecyclePhase.DEPLOY, threadSafe = true ) -public class DeployMojo - extends AbstractDeployMojo -{ - - 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; - - /** - * 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" ) - 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> ).
- * Format: id::layout::url - *
- *
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
- *
- */ - @Parameter( property = "altDeploymentRepository" ) - private String altDeploymentRepository; - - /** - * The alternative repository to use when the project has a snapshot version. - * - * @since 2.8 - * @see DeployMojo#altDeploymentRepository - */ - @Parameter( property = "altSnapshotDeploymentRepository" ) - private String altSnapshotDeploymentRepository; - - /** - * The alternative repository to use when the project has a final version. - * - * @since 2.8 - * @see DeployMojo#altDeploymentRepository - */ - @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 - * - * @since 2.4 - */ - @Parameter( property = "maven.deploy.skip", defaultValue = "false" ) - private boolean skip; - - public void execute() - throws MojoExecutionException, MojoFailureException - { - boolean addedDeployRequest = false; - if ( skip ) - { - getLog().info( "Skipping artifact deployment" ); - } - else - { - failIfOffline(); - - DeployRequest currentExecutionDeployRequest = - new DeployRequest().setProject( project ).setUpdateReleaseInfo( isUpdateReleaseInfo() ).setRetryFailedDeploymentCount( getRetryFailedDeploymentCount() ).setAltReleaseDeploymentRepository( altReleaseDeploymentRepository ).setAltSnapshotDeploymentRepository( altSnapshotDeploymentRepository ).setAltDeploymentRepository( altDeploymentRepository ); - - if ( !deployAtEnd ) - { - deployProject( currentExecutionDeployRequest ); - } - else - { - deployRequests.add( currentExecutionDeployRequest ); - addedDeployRequest = true; - } - } - - boolean projectsReady = readyProjectsCounter.incrementAndGet() == reactorProjects.size(); - if ( projectsReady ) - { - synchronized ( deployRequests ) - { - while ( !deployRequests.isEmpty() ) - { - deployProject( deployRequests.remove( 0 ) ); - } - } - } - else if ( addedDeployRequest ) - { - getLog().info( "Deploying " + project.getGroupId() + ":" + project.getArtifactId() + ":" - + project.getVersion() + " at end" ); - } - } - - private void deployProject( DeployRequest request ) - throws MojoExecutionException, MojoFailureException - { - Artifact artifact = request.getProject().getArtifact(); - String packaging = request.getProject().getPackaging(); - File pomFile = request.getProject().getFile(); - - @SuppressWarnings( "unchecked" ) - 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 ) - { - ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pomFile ); - artifact.addMetadata( metadata ); - } - - if ( request.isUpdateReleaseInfo() ) - { - artifact.setRelease( true ); - } - - int retryFailedDeploymentCount = request.getRetryFailedDeploymentCount(); - - try - { - if ( isPomArtifact ) - { - deploy( pomFile, artifact, repo, getLocalRepository(), retryFailedDeploymentCount ); - } - else - { - File file = artifact.getFile(); - - if ( file != null && file.isFile() ) - { - deploy( file, artifact, repo, getLocalRepository(), retryFailedDeploymentCount ); - } - 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 ); - } - - deploy( pomFile, pomArtifact, repo, getLocalRepository(), retryFailedDeploymentCount ); - - // propagate the timestamped version to the main artifact for the attached artifacts to pick it up - artifact.setResolvedVersion( pomArtifact.getVersion() ); - } - else - { - String message = "The packaging for this project did not assign a file to the build artifact"; - throw new MojoExecutionException( message ); - } - } - - for ( Artifact attached : attachedArtifacts ) - { - deploy( attached.getFile(), attached, repo, getLocalRepository(), retryFailedDeploymentCount ); - } - } - catch ( ArtifactDeploymentException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } - } - - ArtifactRepository getDeploymentRepository( MavenProject project, String altDeploymentRepository, - String altReleaseDeploymentRepository, - String altSnapshotDeploymentRepository ) - throws MojoExecutionException, MojoFailureException - { - ArtifactRepository repo = null; - - String altDeploymentRepo; - if ( ArtifactUtils.isSnapshot( project.getVersion() ) && altSnapshotDeploymentRepository != null ) - { - altDeploymentRepo = altSnapshotDeploymentRepository; - } - else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploymentRepository != null ) - { - altDeploymentRepo = altReleaseDeploymentRepository; - } - else - { - altDeploymentRepo = altDeploymentRepository; - } - - if ( altDeploymentRepo != null ) - { - getLog().info( "Using alternate deployment repository " + altDeploymentRepo ); - - Matcher 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::layout::url\"." ); - } - else - { - String id = matcher.group( 1 ).trim(); - String layout = matcher.group( 2 ).trim(); - String url = matcher.group( 3 ).trim(); - - ArtifactRepositoryLayout repoLayout = getLayout( layout ); - - repo = repositoryFactory.createDeploymentArtifactRepository( id, url, repoLayout, true ); - } - } - - if ( repo == null ) - { - repo = project.getDistributionManagementArtifactRepository(); - } - - 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"; - - throw new MojoExecutionException( msg ); - } - - return repo; - } - -} diff --git a/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java b/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java deleted file mode 100644 index 02e96858..00000000 --- a/src/main/java/org/apache/maven/plugin/deploy/DeployRequest.java +++ /dev/null @@ -1,149 +0,0 @@ -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 - * 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. - */ - -/** - * - * @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/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java new file mode 100644 index 00000000..d8da6922 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java @@ -0,0 +1,157 @@ +/* + * 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 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.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; + +/** + * Abstract class for Deploy mojo's. + */ +public abstract class AbstractDeployMojo extends AbstractMojo { + /** + * Flag whether Maven is currently in online/offline mode. + */ + @Parameter(defaultValue = "${settings.offline}", readonly = true) + private boolean offline; + + /** + * 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) + protected MavenSession session; + + @Component + protected RepositorySystem repositorySystem; + + private static final String AFFECTED_MAVEN_PACKAGING = "maven-plugin"; + + private static final String FIXED_MAVEN_VERSION = "3.9.0"; + + /* Setters and Getters */ + + 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 { + 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 + } + } + } + + /** + * 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) { + 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; + } + + // I'm not sure if retries will work with deploying on client level ... + // Most repository managers block a duplicate artifacts. + + // Eg, when we have an artifact list, even simple pom and jar in one request with released version, + // next try can fail due to duplicate. + + protected void deploy(DeployRequest deployRequest) throws MojoExecutionException { + int retryFailedDeploymentCounter = Math.max(1, Math.min(10, retryFailedDeploymentCount)); + DeploymentException exception = null; + for (int count = 0; count < retryFailedDeploymentCounter; count++) { + try { + if (count > 0) { + getLog().info("Retrying deployment attempt " + (count + 1) + " of " + retryFailedDeploymentCounter); + } + + repositorySystem.deploy(session.getRepositorySession(), deployRequest); + exception = null; + break; + } catch (DeploymentException e) { + if (count + 1 < retryFailedDeploymentCounter) { + getLog().warn("Encountered issue during deployment: " + e.getLocalizedMessage()); + getLog().debug(e); + } + 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 new file mode 100644 index 00000000..7e6536f1 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java @@ -0,0 +1,585 @@ +/* + * 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.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.nio.file.Files; +import java.util.Enumeration; +import java.util.Objects; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Pattern; + +import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +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.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.StringUtils; +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; +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. + * + * @author Allan Ramirez + */ +@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") + private String groupId; + + /** + * ArtifactId of the artifact to be deployed. Retrieved from POM file if specified. + */ + @Parameter(property = "artifactId") + private String artifactId; + + /** + * Version of the artifact to be deployed. Retrieved from POM file if specified. + */ + @Parameter(property = "version") + private String version; + + /** + * Type of the artifact to be deployed. Retrieved from the <packaging> element of the POM file if a POM file + * specified. Defaults to the file extension if it is not specified via command line or POM.
+ * 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") + private String packaging; + + /** + * Description passed to a generated POM file (in case of generatePom=true) + */ + @Parameter(property = "generatePom.description") + private String description; + + /** + * File to be deployed. + */ + @Parameter(property = "file", required = true) + private File file; + + /** + * The bundled API docs for the artifact. + * + * @since 2.6 + */ + @Parameter(property = "javadoc") + private File javadoc; + + /** + * The bundled sources for the artifact. + * + * @since 2.6 + */ + @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) + 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) + private String url; + + /** + * Location of an existing POM file to be deployed alongside the main artifact, given by the ${file} parameter. + */ + @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") + private boolean generatePom; + + /** + * Add classifier to the artifact + */ + @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") + 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") + 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") + 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 { + if (pomFile == null) { + boolean foundPom = false; + try (JarFile jarFile = new JarFile(file)) { + Pattern pomEntry = Pattern.compile("META-INF/maven/.*/pom\\.xml"); + 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; + String base = file.getName(); + if (base.indexOf('.') > 0) { + base = base.substring(0, base.lastIndexOf('.')); + } + pomFile = new File(file.getParentFile(), base + ".pom"); + + try (InputStream pomInputStream = jarFile.getInputStream(entry)) { + try (OutputStream pomOutputStream = Files.newOutputStream(pomFile.toPath())) { + IOUtil.copy(pomInputStream, pomOutputStream); + } + processModel(readModel(pomFile)); + break; + } + } + } + + if (!foundPom) { + getLog().info("pom.xml not found in " + file.getName()); + } + } catch (IOException e) { + // ignore, artifact not packaged by Maven + } + } else { + processModel(readModel(pomFile)); + } + + 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"); + return; + } + + if (!file.exists()) { + throw new MojoExecutionException(file.getPath() + " not found."); + } + + initProperties(); + + RemoteRepository remoteRepository = getRemoteRepository(repositoryId, url); + + 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 (!isValidId(groupId) || !isValidId(artifactId) || !isValidVersion(version)) { + throw new MojoExecutionException("The artifact information is not valid: uses invalid characters."); + } + + failIfOffline(); + 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 + && (classifier == null || classifier.isEmpty()) + && !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); + } + + File temporaryPom = null; + 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"); + } + } + + if (sources != null) { + deployRequest.addArtifact(new SubArtifact(mainArtifact, "sources", "jar", sources)); + } + + 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 (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 )"); + } + 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) { + nfi = files.length(); + } + int nti = types.indexOf(',', ti); + if (nti == -1) { + nti = types.length(); + } + int nci = classifiers.indexOf(',', ci); + if (nci == -1) { + nci = classifiers.length(); + } + 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)); + } + 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"); + } + fi = nfi + 1; + ti = nti + 1; + ci = nci + 1; + } + } 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'"); + } + } + + try { + repositorySystem.deploy(session.getRepositorySession(), deployRequest); + } catch (DeploymentException e) { + throw new MojoExecutionException(e.getMessage(), e); + } finally { + if (temporaryPom != null) { + // noinspection ResultOfMethodCallIgnored + temporaryPom.delete(); + } + } + } + + /** + * 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); + } + + /** + * 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) { + Parent parent = model.getParent(); + + if (this.groupId == null) { + this.groupId = model.getGroupId(); + if (this.groupId == null && parent != null) { + this.groupId = parent.getGroupId(); + } + } + if (this.artifactId == null) { + this.artifactId = model.getArtifactId(); + } + if (this.version == null) { + this.version = model.getVersion(); + if (this.version == null && parent != null) { + this.version = parent.getVersion(); + } + } + 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 or cannot be read. + */ + Model readModel(File pomFile) throws MojoExecutionException { + 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); + } + } + + /** + * 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 { + Model model = generateModel(); + + try { + File tempFile = File.createTempFile("mvndeploy", ".pom"); + tempFile.deleteOnExit(); + + 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); + } + } + + /** + * Generates a minimal model from the user-supplied artifact information. + * + * @return The generated model, never null. + */ + private Model generateModel() { + Model model = new Model(); + + model.setModelVersion("4.0.0"); + + model.setGroupId(groupId); + model.setArtifactId(artifactId); + model.setVersion(version); + model.setPackaging(packaging); + + model.setDescription(description); + + return model; + } + + void setGroupId(String groupId) { + this.groupId = groupId; + } + + void setArtifactId(String artifactId) { + this.artifactId = artifactId; + } + + void setVersion(String version) { + this.version = version; + } + + void setPackaging(String packaging) { + this.packaging = packaging; + } + + void setPomFile(File pomFile) { + this.pomFile = pomFile; + } + + String getGroupId() { + return groupId; + } + + String getArtifactId() { + return artifactId; + } + + String getVersion() { + return version; + } + + String getPackaging() { + return packaging; + } + + File getFile() { + return file; + } + + String getClassifier() { + return classifier; + } + + 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 new file mode 100644 index 00000000..79ee1d87 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -0,0 +1,420 @@ +/* + * 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.util.ArrayList; +import java.util.LinkedHashMap; +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.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; +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.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. + * + * @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("(.+?)::(.+?)::(.+)"); + + private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile("(.+?)::(.+)"); + + @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. + * + * @since 2.8 + */ + @Parameter(defaultValue = "false", property = "deployAtEnd") + private boolean deployAtEnd; + + /** + * Specifies an alternative repository to which the project artifacts should be deployed (other than those specified + * in <distributionManagement>).
+ * 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: 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; + + /** + * The alternative repository to use when the project has a snapshot version. + * + * 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 + */ + @Parameter(property = "altSnapshotDeploymentRepository") + private String altSnapshotDeploymentRepository; + + /** + * The alternative repository to use when the project has a final version. + * + * 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 + */ + @Parameter(property = "altReleaseDeploymentRepository") + private String altReleaseDeploymentRepository; + + /** + * 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 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, + 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 = session.getPluginContext(pluginDescriptor, project); + return pluginContext.containsKey(DEPLOY_PROCESSED_MARKER); + } + + public void execute() throws MojoExecutionException, MojoFailureException { + State state; + if (Boolean.parseBoolean(skip) + || ("releases".equals(skip) && !ArtifactUtils.isSnapshot(project.getVersion())) + || ("snapshots".equals(skip) && ArtifactUtils.isSnapshot(project.getVersion()))) { + getLog().info("Skipping artifact deployment"); + state = State.SKIPPED; + } else { + failIfOffline(); + warnIfAffectedPackagingAndMaven(project.getPackaging()); + + if (!deployAtEnd) { + + RemoteRepository deploymentRepository = getDeploymentRepository( + project, + altSnapshotDeploymentRepository, + altReleaseDeploymentRepository, + altDeploymentRepository); + + DeployRequest request = new DeployRequest(); + request.setRepository(deploymentRepository); + processProject(project, request); + deploy(request); + state = State.DEPLOYED; + } else { + putPluginContextValue(DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY, altSnapshotDeploymentRepository); + putPluginContextValue(DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository); + putPluginContextValue(DEPLOY_ALT_DEPLOYMENT_REPOSITORY, altDeploymentRepository); + state = State.TO_BE_DEPLOYED; + } + } + + putState(state); + + List allProjectsUsingPlugin = getAllProjectsUsingPlugin(); + + if (allProjectsMarked(allProjectsUsingPlugin)) { + deployAllAtOnce(allProjectsUsingPlugin); + } else if (state == State.TO_BE_DEPLOYED) { + getLog().info("Deferring deploy for " + project.getGroupId() + ":" + project.getArtifactId() + ":" + + project.getVersion() + " at end"); + } + } + + private void deployAllAtOnce(List 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 boolean allProjectsMarked(List allProjectsUsingPlugin) { + for (MavenProject reactorProject : allProjectsUsingPlugin) { + if (!hasState(reactorProject)) { + return false; + } + } + return true; + } + + 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; + } + + 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(pomArtifact.getFile())) { + request.addArtifact(pomArtifact); + } else { + throw new MojoExecutionException( + "The POM for project " + project.getArtifactId() + " could not be attached"); + } + + // 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(""); + 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 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 plugin for project " + project.getArtifactId() + + " did not assign a file to the build artifact"); + } + } + + for (org.apache.maven.artifact.Artifact attached : project.getAttachedArtifacts()) { + getLog().debug("Attaching for deploy: " + attached.getId()); + request.addArtifact(RepositoryUtils.toArtifact(attached)); + } + } + + private boolean isFile(File file) { + return file != null && file.isFile(); + } + + /** + * Visible for testing. + */ + RemoteRepository getDeploymentRepository( + final MavenProject project, + final String altSnapshotDeploymentRepository, + final String altReleaseDeploymentRepository, + final String altDeploymentRepository) + throws MojoExecutionException { + RemoteRepository repo = null; + + String altDeploymentRepo; + if (ArtifactUtils.isSnapshot(project.getVersion()) && altSnapshotDeploymentRepository != null) { + altDeploymentRepo = altSnapshotDeploymentRepository; + } else if (!ArtifactUtils.isSnapshot(project.getVersion()) && altReleaseDeploymentRepository != null) { + altDeploymentRepo = altReleaseDeploymentRepository; + } else { + altDeploymentRepo = altDeploymentRepository; + } + + if (altDeploymentRepo != null) { + getLog().info("Using alternate deployment repository " + 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 ("default".equals(layout)) { + getLog().warn("Using legacy syntax for alternative repository. " + "Use \"" + id + "::" + url + + "\" instead."); + repo = getRemoteRepository(id, url); + } else { + throw new MojoExecutionException( + altDeploymentRepo, + "Invalid legacy syntax and layout for repository.", + "Invalid legacy syntax and layout for alternative repository. Use \"" + id + "::" + url + + "\" instead, and only default layout is supported."); + } + } else { + matcher = ALT_REPO_SYNTAX_PATTERN.matcher(altDeploymentRepo); + + if (!matcher.matches()) { + throw new MojoExecutionException( + altDeploymentRepo, + "Invalid syntax for repository.", + "Invalid syntax for alternative repository. Use \"id::url\"."); + } else { + String id = matcher.group(1).trim(); + String url = matcher.group(2).trim(); + + repo = getRemoteRepository(id, url); + } + } + } + + if (repo == null) { + repo = RepositoryUtils.toRepo(project.getDistributionManagementArtifactRepository()); + } + + if (repo == null) { + String msg = "Deployment failed: repository element was not specified in the POM inside" + + " distributionManagement element or in -DaltDeploymentRepository=id::url parameter"; + + throw new MojoExecutionException(msg); + } + + return repo; + } +} 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-network-issues.apt b/src/site/apt/examples/deploy-network-issues.apt new file mode 100644 index 00000000..90718919 --- /dev/null +++ b/src/site/apt/examples/deploy-network-issues.apt @@ -0,0 +1,129 @@ + ------ + 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, for example <<>>, + + 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 ++----+ + + or for older 2.x version of maven-deploy-plugin + ++----+ +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 + + <<>>'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 {{{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. + + It can be invoked fully from command line (renaming <<<-Dwagon.>>> with <<>> when + {{{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 <<>>: + ++----+ + + [...] + + + + org.codehaus.mojo + wagon-maven-plugin + 2.0.0 + + file:./target/staging-deploy + ${project.distributionManagement.repository.url} + ${project.distributionManagement.repository.id} + + + + + [...] + ++----+ diff --git a/src/site/apt/examples/deploy-ssh-external.apt b/src/site/apt/examples/deploy-ssh-external.apt index 65f3f45d..99849c92 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 @@ -45,7 +45,7 @@ Deployment of artifacts in an external SSH command - + org.apache.maven.wagon wagon-ssh-external @@ -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-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..ce3cb225 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 @@ -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 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 smaller + * <<>> 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/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 b86caf87..9e6654a8 100644 --- a/src/site/apt/examples/deploying-with-customed-pom.apt.vm +++ b/src/site/apt/examples/deploying-with-customized-pom.apt.vm @@ -3,7 +3,7 @@ ------ Allan Ramirez ------ - June 2006 + 2006-06-21 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one @@ -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 + 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 ee121408..ca21471b 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 @@ -32,14 +32,12 @@ 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}} * {{{./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 c053e1a7..1ad2e42a 100644 --- a/src/site/apt/index.apt.vm +++ b/src/site/apt/index.apt.vm @@ -78,22 +78,20 @@ ${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 + 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 + 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. 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}}. + {{{./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 @@ -106,18 +104,18 @@ ${project.name} * {{{./examples/deploy-ssh-external.html}Deployment with external SSH}} + * {{{./examples/deploy-network-issues.html}Workarounds when there are network issues}} + [] * {{{./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}} - * {{{./examples/disabling-timestamps-suffix.html}Disable timestamps suffix in an artifact}} - * {{{./examples/deploying-in-legacy-layout.html}Deploy an artifact in legacy layout}} [] diff --git a/src/site/apt/project-deployment.apt b/src/site/apt/project-deployment.apt index 39d33904..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 @@ -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 diff --git a/src/site/apt/usage.apt b/src/site/apt/usage.apt index 156e027a..baaf7a94 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 @@ -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 @@ -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 @@ -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/site/site.xml b/src/site/site.xml index d4d31b4c..6df80c46 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -22,26 +22,49 @@ under the License. + + https://maven.apache.org/images/apache-maven-project.png + https://www.apache.org/ + + + + https://maven.apache.org/images/maven-logo-black-on-white.png + https://maven.apache.org/ + + + org.apache.maven.skins + maven-fluido-skin + 1.10.0 + + + + + true + + maven.apache.org/plugins/maven-deploy-plugin/ + + + - - - + + - + + - + diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index 7186d93a..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.md5maven/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.

diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java deleted file mode 100644 index ef62a80b..00000000 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java +++ /dev/null @@ -1,355 +0,0 @@ -package org.apache.maven.plugin.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.util.ArrayList; -import java.util.List; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.model.Model; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; - -/** - * @author Allan Ramirez - */ -public class DeployFileMojoTest - extends AbstractMojoTestCase -{ - private List expectedFiles; - - private List fileList; - - private File remoteRepo; - - MavenProjectStub projectStub = new MavenProjectStub(); - - public void setUp() - throws Exception - { - super.setUp(); - - remoteRepo = new File( getBasedir(), "target/remote-repo" ); - - if ( !remoteRepo.exists() ) - { - remoteRepo.mkdirs(); - } - - projectStub.setAttachedArtifacts( new ArrayList() ); - } - - public void testDeployTestEnvironment() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml" ); - - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); - - assertNotNull( mojo ); - } - - public void testBasicDeployFile() - throws Exception - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml" ); - - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); - - assertNotNull( mojo ); - - setVariableValueToObject( mojo, "project", projectStub ); - - String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); - - String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" ); - - String version = (String) getVariableValueFromObject( mojo, "version" ); - - String packaging = (String) getVariableValueFromObject( mojo, "packaging" ); - - File file = (File) getVariableValueFromObject( mojo, "file" ); - - String repositoryId = (String) getVariableValueFromObject( mojo, "repositoryId" ); - - String url = (String) getVariableValueFromObject( mojo, "url" ); - - assertEquals( "org.apache.maven.test", groupId ); - - assertEquals( "maven-deploy-file-test", artifactId ); - - assertEquals( "1.0", version ); - - assertEquals( "jar", packaging ); - - assertTrue( file.exists() ); - - assertEquals( "deploy-test", repositoryId ); - - 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" ); - - assertTrue( pom.exists() ); - - Model model = mojo.readModel( pom ); - - assertEquals( "4.0.0", model.getModelVersion() ); - - assertEquals( groupId, model.getGroupId() ); - - assertEquals( artifactId, model.getArtifactId() ); - - assertEquals( version, model.getVersion() ); - - assertEquals( packaging, model.getPackaging() ); - - assertEquals( "POM was created from deploy:deploy-file", model.getDescription() ); - - //check the remote-repo - expectedFiles = new ArrayList(); - fileList = new ArrayList(); - - File repo = new File( remoteRepo, "deploy-file-test" ); - - File[] files = repo.listFiles(); - - for (File file1 : 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 ) ); - } - - 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 - { - File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-classifier/plugin-config.xml" ); - - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); - - assertNotNull( mojo ); - - setVariableValueToObject( mojo, "project", projectStub ); - - String classifier = ( String ) getVariableValueFromObject( mojo, "classifier" ); - - String groupId = ( String ) getVariableValueFromObject( mojo, "groupId" ); - - String artifactId = ( String ) getVariableValueFromObject( mojo, "artifactId" ); - - String version = ( String ) getVariableValueFromObject( mojo, "version" ); - - assertEquals( "bin", classifier ); - - mojo.execute(); - - File deployedArtifact = new File( remoteRepo, "deploy-file-classifier/" + groupId.replace( '.', '/' ) + - "/" + artifactId + "/" + version + "/" + artifactId + - "-" + version + "-" + classifier + ".jar"); - - assertTrue( deployedArtifact.exists() ); - - mojo.setClassifier( "prod" ); - - assertEquals( "prod", mojo.getClassifier() ); - - mojo.execute(); - - File prodDeployedArtifact = new File( remoteRepo, "deploy-file-classifier/" + groupId.replace( '.', '/' ) + - "/" + artifactId + "/" + version + "/" + artifactId + - "-" + version + "-" + mojo.getClassifier() + ".jar"); - - 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" ); - - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); - - assertNotNull( mojo ); - - setVariableValueToObject( mojo, "project", projectStub ); - - String groupId = (String) getVariableValueFromObject( mojo, "groupId" ); - - String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" ); - - 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( '.', '/' ) + - "/" + artifactId + "/" + version + "/" + artifactId + - "-" + version + ".zip"); - - 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" ); - - DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom ); - - assertNotNull( mojo ); - - setVariableValueToObject( mojo, "project", projectStub ); - - 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 ); - - 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); - } - - 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 ) - { - if ( !file.isDirectory() ) - { - fileList.add( file.getName() ); - } - else - { - fileList.add( file.getName() ); - - File[] files = file.listFiles(); - - for (File file1 : 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" ); - } - } - return expectedFiles.size(); - } - -} - diff --git a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoUnitTest.java b/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoUnitTest.java deleted file mode 100644 index b0cfd857..00000000 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoUnitTest.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.apache.maven.plugin.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 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 java.io.File; - -/** - * @author Jerome Lacoste - * @version $Id$ - */ -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; - - public void setUp() - { - Model pomModel = new Model(); - pomModel.setPackaging( null ); - - parent = new Parent(); - parent.setGroupId( "parentGroup" ); - parent.setArtifactId( "parentArtifact" ); - parent.setVersion( "parentVersion" ); - - mojo = new MockDeployFileMojo( pomModel ); - } - - public void tearDown() - { - mojo = null; - } - - class MockDeployFileMojo extends DeployFileMojo { - private Model model; - - public MockDeployFileMojo(Model model) { - this.model = model; - } - - public void setModel(Model model) { - this.model = model; - } - - protected Model readModel(File pomFile) throws MojoExecutionException { - return model; - } - } - - public void testProcessPomFromPomFileWithParent1() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - - setMojoModel( mojo.model, null, null, null, null, parent ); - - try { - mojo.initProperties(); - } catch (MojoExecutionException expected) { - assertTrue( true ); // missing artifactId and packaging - } - - checkMojoProperties("parentGroup", null, "parentVersion", null); - } - - public void testProcessPomFromPomFileWithParent2() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, null, "artifact", null, null, parent ); - - try { - mojo.initProperties(); - } catch (MojoExecutionException expected) { - assertTrue( true ); // missing packaging - } - - checkMojoProperties("parentGroup", "artifact", "parentVersion", null ); - - } - - public void testProcessPomFromPomFileWithParent3() throws MojoExecutionException - { - 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 - } - - checkMojoProperties( "parentGroup", "artifact", "version", null ); - } - - public void testProcessPomFromPomFileWithParent4() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, null, "artifact", "version", "packaging", parent ); - - mojo.initProperties(); - - checkMojoProperties("parentGroup", "artifact", "version", "packaging"); - } - - public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException - { - mojo.setPomFile( new File( "foo.bar" ) ); - setMojoModel( mojo.model, "group", "artifact", "version", "packaging", parent ); - - mojo.initProperties(); - - checkMojoProperties("group", "artifact", "version", "packaging"); - } - - 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"); - - } - - 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.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 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/plugin/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java deleted file mode 100644 index 26f76ee2..00000000 --- a/src/test/java/org/apache/maven/plugin/deploy/DeployMojoTest.java +++ /dev/null @@ -1,623 +0,0 @@ -package org.apache.maven.plugin.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 static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -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; -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.codehaus.plexus.util.FileUtils; - -/** - * @author Allan Ramirez - */ -public class DeployMojoTest - extends AbstractMojoTestCase -{ - private File remoteRepo; - - private File localRepo; - - private String LOCAL_REPO = getBasedir() + "/target/local-repo"; - - private String REMOTE_REPO = getBasedir() + "/target/remote-repo"; - - DeployArtifactStub artifact; - - MavenProjectStub project = new MavenProjectStub(); - - public void setUp() - throws Exception - { - super.setUp(); - - remoteRepo = new File( REMOTE_REPO ); - - remoteRepo.mkdirs(); - - localRepo = new File( LOCAL_REPO ); - - if ( localRepo.exists() ) - { - FileUtils.deleteDirectory( localRepo ); - } - - if ( remoteRepo.exists() ) - { - FileUtils.deleteDirectory( remoteRepo ); - } - } - - public void tearDown() - throws Exception - { - super.tearDown(); - - 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 testBasicDeploy() - 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 ); - - File file = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-test/target/" + - "deploy-test-file-1.0-SNAPSHOT.jar" ); - - assertTrue( file.exists() ); - - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - - 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() ); - - mojo.execute(); - - //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( "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" ); - - File localRepo = new File( LOCAL_REPO, "" ); - - File[] files = localRepo.listFiles(); - - for (File file2 : files) { - addFileToList(file2, fileList); - } - - assertEquals( expectedFiles.size(), fileList.size() ); - - assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); - - //check the artifact in remote repository - expectedFiles = new ArrayList(); - fileList = new ArrayList(); - - expectedFiles.add( "org" ); - expectedFiles.add( "apache" ); - expectedFiles.add( "maven" ); - expectedFiles.add( "test" ); - expectedFiles.add( "maven-deploy-test" ); - expectedFiles.add( "1.0-SNAPSHOT" ); - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.md5" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.sha1" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.md5" ); - expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.sha1" ); - // as we are in SNAPSHOT the file is here twice - expectedFiles.add( "maven-metadata.xml" ); - expectedFiles.add( "maven-metadata.xml.md5" ); - expectedFiles.add( "maven-metadata.xml.sha1" ); - - remoteRepo = new File( remoteRepo, "basic-deploy-test" ); - - files = remoteRepo.listFiles(); - - for (File file1 : files) { - addFileToList(file1, fileList); - } - - 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" ); - - DeployMojo mojo = (DeployMojo) lookupMojo( "deploy", testPom ); - - assertNotNull( mojo ); - - File file = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/target/" - + "deploy-test-file-1.0-SNAPSHOT.jar" ); - - assertTrue( file.exists() ); - - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - - 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() ); - - setVariableValueToObject( mojo, "skip", Boolean.TRUE ); - - mojo.execute(); - - File localRepo = new File( LOCAL_REPO, "" ); - - File[] files = localRepo.listFiles(); - - 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" ); - - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - 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 ); - - 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" ); - // 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" ); - - File[] files = remoteRepo.listFiles(); - - for (File file : files) { - addFileToList(file, fileList); - } - - assertEquals( expectedFiles.size(), fileList.size() ); - - 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" ); - - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - assertNotNull( mojo ); - - 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 - { - File testPom = new File( getBasedir(), - "target/test-classes/unit/basic-deploy-test/plugin-config.xml" ); - - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - assertNotNull( mojo ); - - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) ); - - artifact = (DeployArtifactStub) project.getArtifact(); - - artifact.setFile( null ); - - assertNull( artifact.getFile() ); - - try - { - mojo.execute(); - - 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" ); - - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - assertNotNull( mojo ); - - MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" ); - - 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 ); - - - @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(); - - 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" ); - // 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" ); - - File[] files = remoteRepo.listFiles(); - - for (File file1 : files) { - addFileToList(file1, fileList); - } - - assertEquals( expectedFiles.size(), fileList.size() ); - - assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) ); - } - - - 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" ); - - DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom ); - - assertNotNull( mojo ); - - ArtifactDeployerStub deployer = new ArtifactDeployerStub(); - - setVariableValueToObject( mojo, "deployer", deployer ); - - 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, "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 testAltSnapshotDeploymentRepository() throws Exception - { - DeployMojo mojo = 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 ); - - project.setVersion( "1.0-SNAPSHOT" ); - - assertEquals( repository, mojo.getDeploymentRepository( project, null, null, "altSnapshotDeploymentRepository::default::http://localhost" ) ); - } - - public void testAltReleaseDeploymentRepository() throws Exception - { - DeployMojo mojo = 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 ); - - project.setVersion( "1.0" ); - - assertEquals( repository, mojo.getDeploymentRepository( project, null, "altReleaseDeploymentRepository::default::http://localhost", null ) ); - } - - - 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 : files) { - addFileToList(file1, fileList); - } - } - } - - private int getSizeOfExpectedFiles( List fileList, List expectedFiles ) - { - for( String fileName : fileList ) - { - 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" ); - return (ArtifactRepositoryStub) project.getDistributionManagementArtifactRepository(); - } - -} 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 deleted file mode 100644 index 7fbad2f3..00000000 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactDeployerStub.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.maven.plugin.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.io.File; - -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; - -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 - { - // 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 deleted file mode 100644 index 099ba2b4..00000000 --- a/src/test/java/org/apache/maven/plugin/deploy/stubs/ArtifactRepositoryStub.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.apache.maven.plugin.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 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.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; - -public class ArtifactRepositoryStub - implements ArtifactRepository -{ - private boolean blacklisted; - - private ArtifactRepositoryLayout layout; - - private String url; - - private String basedir = System.getProperty( "basedir" ); - - 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 ) - { - this.url = "file://" + basedir + "/target/remote-repo/" + dir; - } - - public String getBasedir() - { - return basedir; - } - - public String getProtocol() - { - return "file"; - } - - 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 ) - { - return layout; - } - else - { - return new DefaultRepositoryLayout(); - } - } - - public String getKey() - { - return getId(); - } - - public boolean isUniqueVersion() - { - return false; - } - - public void setBlacklisted( boolean blackListed ) - { - this.blacklisted = blackListed; - } - - public boolean isBlacklisted() - { - return blacklisted; - } -} diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java new file mode 100644 index 00000000..572d8e48 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java @@ -0,0 +1,307 @@ +/* + * 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.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Model; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.project.ProjectBuildingRequest; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.DefaultLocalPathComposer; +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 static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * @author Allan Ramirez + */ +public class DeployFileMojoTest extends AbstractMojoTestCase { + private final String LOCAL_REPO = getBasedir() + "/target/local-repo"; + + private List expectedFiles; + + private List fileList; + + private File remoteRepo; + + @Mock + private MavenSession session; + + @InjectMocks + private DeployFileMojo mojo; + + public void setUp() throws Exception { + super.setUp(); + + remoteRepo = new File(getBasedir(), "target/remote-repo"); + + 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"); + + AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo("deploy-file", testPom); + + assertNotNull(mojo); + } + + 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); + + 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(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); + + String groupId = (String) getVariableValueFromObject(mojo, "groupId"); + + String artifactId = (String) getVariableValueFromObject(mojo, "artifactId"); + + String version = (String) getVariableValueFromObject(mojo, "version"); + + String packaging = (String) getVariableValueFromObject(mojo, "packaging"); + + File file = (File) getVariableValueFromObject(mojo, "file"); + + String repositoryId = (String) getVariableValueFromObject(mojo, "repositoryId"); + + String url = (String) getVariableValueFromObject(mojo, "url"); + + String skip = (String) getVariableValueFromObject(mojo, "skip"); + + assertEquals("org.apache.maven.test", groupId); + + assertEquals("maven-deploy-file-test", artifactId); + + assertEquals("1.0", version); + + assertEquals("jar", packaging); + + assertEquals("snapshots", skip); + + assertTrue(file.exists()); + + assertEquals("deploy-test", repositoryId); + + 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"); + + assertTrue(pom.exists()); + + Model model = mojo.readModel(pom); + + assertEquals("4.0.0", model.getModelVersion()); + + assertEquals(groupId, model.getGroupId()); + + assertEquals(artifactId, model.getArtifactId()); + + assertEquals(version, model.getVersion()); + + assertEquals(packaging, model.getPackaging()); + + assertEquals("POM was created from deploy:deploy-file", model.getDescription()); + + // check the remote-repo + expectedFiles = new ArrayList<>(); + fileList = new ArrayList<>(); + + File repo = new File(remoteRepo, "deploy-file-test"); + + File[] files = repo.listFiles(); + + 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)); + } + + 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); + + 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(new DefaultLocalPathComposer()) + .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); + when(buildingRequest.getRepositorySession()).thenReturn(repositorySession); + when(session.getRepositorySession()).thenReturn(repositorySession); + + String classifier = (String) getVariableValueFromObject(mojo, "classifier"); + + String groupId = (String) getVariableValueFromObject(mojo, "groupId"); + + String artifactId = (String) getVariableValueFromObject(mojo, "artifactId"); + + String version = (String) getVariableValueFromObject(mojo, "version"); + + assertEquals("bin", classifier); + + mojo.execute(); + + File deployedArtifact = new File( + remoteRepo, + "deploy-file-classifier/" + groupId.replace('.', '/') + "/" + + artifactId + "/" + version + "/" + artifactId + "-" + + version + "-" + classifier + ".jar"); + + assertTrue(deployedArtifact.exists()); + + mojo.setClassifier("prod"); + + assertEquals("prod", mojo.getClassifier()); + + mojo.execute(); + + File prodDeployedArtifact = new File( + remoteRepo, + "deploy-file-classifier/" + groupId.replace('.', '/') + "/" + + artifactId + "/" + version + "/" + artifactId + "-" + + version + "-" + mojo.getClassifier() + ".jar"); + + 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"); + + 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); + 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); + + String groupId = (String) getVariableValueFromObject(mojo, "groupId"); + + String artifactId = (String) getVariableValueFromObject(mojo, "artifactId"); + + String version = (String) getVariableValueFromObject(mojo, "version"); + + assertEquals("org.apache.maven.test", groupId); + + assertEquals("maven-deploy-file-test", artifactId); + + assertEquals("1.0", version); + + mojo.execute(); + + File file = new File( + remoteRepo, + "deploy-file-artifact-not-jar/" + groupId.replace('.', '/') + "/" + + artifactId + "/" + version + "/" + artifactId + "-" + + version + ".zip"); + + assertTrue(file.exists()); + } + + 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)) { + 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"); + } + } + 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 new file mode 100644 index 00000000..c368b365 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java @@ -0,0 +1,181 @@ +/* + * 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 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @author Jerome Lacoste + */ +public class DeployFileMojoUnitTest { + MockDeployFileMojo mojo; + Parent parent; + + @Before + public void setUp() { + Model pomModel = new Model(); + pomModel.setPackaging(null); + + parent = new Parent(); + parent.setGroupId("parentGroup"); + parent.setArtifactId("parentArtifact"); + parent.setVersion("parentVersion"); + + mojo = new MockDeployFileMojo(pomModel); + } + + @After + public void tearDown() { + mojo = null; + } + + static class MockDeployFileMojo extends DeployFileMojo { + private Model model; + + public MockDeployFileMojo(Model model) { + this.model = model; + } + + public void setModel(Model model) { + this.model = model; + } + + protected Model readModel(File pomFile) { + return model; + } + } + + @Test + public void testProcessPomFromPomFileWithParent1() { + mojo.setPomFile(new File("foo.bar")); + + setMojoModel(mojo.model, null, null, null, null, parent); + + try { + mojo.initProperties(); + } catch (MojoExecutionException expected) { + 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); + + try { + mojo.initProperties(); + } catch (MojoExecutionException expected) { + assertTrue(true); // missing packaging + } + + checkMojoProperties("parentGroup", "artifact", "parentVersion", null); + } + + @Test + 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 + } + + 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); + + mojo.initProperties(); + + checkMojoProperties("parentGroup", "artifact", "version", "packaging"); + } + + @Test + public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException { + mojo.setPomFile(new File("foo.bar")); + setMojoModel(mojo.model, "group", "artifact", "version", "packaging", parent); + + mojo.initProperties(); + + checkMojoProperties("group", "artifact", "version", "packaging"); + } + + @Test + 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); + + 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 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 new file mode 100644 index 00000000..5884ae11 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java @@ -0,0 +1,861 @@ +/* + * 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.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +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.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; + +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 { + 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 { + super.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(new DefaultLocalPathComposer()) + .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); + } + } + + public void tearDown() throws Exception { + super.tearDown(); + + 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 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(new DefaultLocalPathComposer()) + .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"); + + 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)); + + 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()); + + mojo.execute(); + + // 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( "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, ""); + + File[] files = localRepo.listFiles(); + + for (File file2 : Objects.requireNonNull(files)) { + addFileToList(file2, fileList); + } + + assertEquals(expectedFiles.size(), fileList.size()); + + assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles)); + + // check the artifact in remote repository + expectedFiles = new ArrayList<>(); + fileList = new ArrayList<>(); + + expectedFiles.add("org"); + expectedFiles.add("apache"); + expectedFiles.add("maven"); + expectedFiles.add("test"); + expectedFiles.add("maven-deploy-test"); + expectedFiles.add("1.0-SNAPSHOT"); + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar.md5"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.jar.sha1"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.md5"); + expectedFiles.add("maven-deploy-test-1.0-SNAPSHOT.pom.sha1"); + // as we are in SNAPSHOT the file is here twice + expectedFiles.add("maven-metadata.xml"); + expectedFiles.add("maven-metadata.xml.md5"); + expectedFiles.add("maven-metadata.xml.sha1"); + + remoteRepo = new File(remoteRepo, "basic-deploy-test"); + + files = remoteRepo.listFiles(); + + for (File file1 : Objects.requireNonNull(files)) { + addFileToList(file1, fileList); + } + + 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"); + + DeployMojo mojo = (DeployMojo) lookupMojo("deploy", testPom); + + assertNotNull(mojo); + + File file = new File( + getBasedir(), + "target/test-classes/unit/basic-deploy-test/target/" + "deploy-test-file-1.0-SNAPSHOT.jar"); + + 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(); + + 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()); + + setVariableValueToObject(mojo, "skip", Boolean.TRUE.toString()); + + mojo.execute(); + + File localRepo = new File(LOCAL_REPO, ""); + + File[] files = localRepo.listFiles(); + + 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); + 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-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"); + + 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-pom"); + + 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 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"); + + 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 { + 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, message should include artifactId + assertEquals("The POM for project maven-deploy-test could not be attached", e.getMessage()); + } + } + + 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(new DefaultLocalPathComposer()) + .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)); + + 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"); + + mojo.execute(); + + // 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"); + // 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"); + // 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"); + + File[] files = remoteRepo.listFiles(); + + for (File file1 : Objects.requireNonNull(files)) { + addFileToList(file1, fileList); + } + + assertEquals(expectedFiles.size(), fileList.size()); + + 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(); + + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject(mojo, "altDeploymentRepository", "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 { + 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 (MojoExecutionException e) { + assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); + assertEquals( + e.getLongMessage(), + "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported."); + } + } + + public void testInsaneAltDeploymentRepository() throws Exception { + 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 (MojoExecutionException e) { + assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); + assertEquals( + e.getLongMessage(), + "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported."); + } + } + + public void testDefaultScmSvnAltDeploymentRepository() throws Exception { + DeployMojo mojo = new DeployMojo(); + + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject( + mojo, "altDeploymentRepository", "altDeploymentRepository::default::scm:svn:http://localhost"); + + 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")); + } + + public void testLegacyScmSvnAltDeploymentRepository() throws Exception { + DeployMojo mojo = new DeployMojo(); + + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject( + mojo, "altDeploymentRepository", "altDeploymentRepository::legacy::scm:svn:http://localhost"); + + project.setVersion("1.0-SNAPSHOT"); + try { + mojo.getDeploymentRepository( + project, null, null, "altDeploymentRepository::legacy::scm:svn:http://localhost"); + fail("Should throw: Invalid legacy syntax and layout for repository."); + } catch (MojoExecutionException e) { + assertEquals(e.getMessage(), "Invalid legacy syntax and layout for repository."); + assertEquals( + e.getLongMessage(), + "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported."); + } + } + + public void testAltSnapshotDeploymentRepository() throws Exception { + DeployMojo mojo = new DeployMojo(); + + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject( + mojo, "altSnapshotDeploymentRepository", "altSnapshotDeploymentRepository::http://localhost"); + + project.setVersion("1.0-SNAPSHOT"); + + assertEquals( + new RemoteRepository.Builder("altSnapshotDeploymentRepository", "default", "http://localhost").build(), + mojo.getDeploymentRepository(project, "altSnapshotDeploymentRepository::http://localhost", null, null)); + } + + public void testAltReleaseDeploymentRepository() throws Exception { + DeployMojo mojo = new DeployMojo(); + + setVariableValueToObject(mojo, "project", project); + setVariableValueToObject(mojo, "session", session); + setVariableValueToObject( + mojo, "altReleaseDeploymentRepository", "altReleaseDeploymentRepository::http://localhost"); + + project.setVersion("1.0"); + + 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()); + + File[] files = file.listFiles(); + + 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"); + } + } + return expectedFiles.size(); + } + + 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/stubs/ArtifactRepositoryStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java new file mode 100644 index 00000000..9dd95400 --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java @@ -0,0 +1,119 @@ +/* + * 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.Artifact; +import org.apache.maven.artifact.metadata.ArtifactMetadata; +import org.apache.maven.artifact.repository.ArtifactRepository; +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 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() { + return url; + } + + public void setAppendToUrl(String dir) { + this.url = "file://" + basedir + "/target/remote-repo/" + dir; + } + + public String getBasedir() { + return basedir; + } + + public String getProtocol() { + return "file"; + } + + 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) { + return layout; + } else { + return new DefaultRepositoryLayout(); + } + } + + public String getKey() { + return getId(); + } + + public boolean isUniqueVersion() { + return false; + } + + public void setBlacklisted(boolean blackListed) { + this.blacklisted = blackListed; + } + + public boolean isBlacklisted() { + return blacklisted; + } + + // @Override + public boolean isBlocked() { + return false; + } + + // @Override + public void setBlocked(boolean b) {} +} 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 58% 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 2e17e458..96d43bb9 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,5 +1,3 @@ -package org.apache.maven.plugin.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,33 +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 String getUrl() - { - return "file://" + System.getProperty( "basedir" ) + "/target/remote-repo/basic-deploy-scp"; + + public ArtifactRepositoryStub2() { + super(); } - - public String getBasedir() - { - return System.getProperty( "basedir" ); + + public ArtifactRepositoryStub2(String dir) { + super(dir); + } + + public String getUrl() { + return "file://" + System.getProperty("basedir") + "/target/remote-repo/basic-deploy-scp"; } - - public String getProtocol() - { - if( this.protocol == null || this.protocol.equals("") ) - { + + public String getBasedir() { + return System.getProperty("basedir"); + } + + 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/plugin/deploy/stubs/AttachedArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java similarity index 64% 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..9226bdcf 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,5 +1,3 @@ -package org.apache.maven.plugin.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/plugin/deploy/stubs/DeployArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java similarity index 57% 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 e34c5879..7218fdf7 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,5 +1,3 @@ -package org.apache.maven.plugin.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,97 +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(); } - - public void setFile( File file ) - { + + @Override + public String getType() { + return "jar"; + } + + public void setFile(File file) { this.file = file; } - - public File getFile() - { + + public File getFile() { return file; } - - public ArtifactHandler getArtifactHandler() - { - return new DefaultArtifactHandler() - { - public String getExtension() - { - if( extension == null ) - { + + public ArtifactHandler getArtifactHandler() { + return new DefaultArtifactHandler() { + public String getExtension() { + if (extension == null) { extension = "jar"; } return extension; } }; } - - public void setArtifactHandlerExtension( String extension ) - { + + public void setArtifactHandlerExtension(String extension) { this.extension = extension; } - - public void addMetadata( ArtifactMetadata metadata ) - { - if ( metadataMap == null ) - { - metadataMap = new HashMap(); - } - ArtifactMetadata m = metadataMap.get( metadata.getKey() ); - if ( m != null ) - { - m.merge( metadata ); + public void addMetadata(ArtifactMetadata metadata) { + if (metadataMap == null) { + metadataMap = new HashMap<>(); } - else - { - metadataMap.put( metadata.getKey(), metadata ); + + ArtifactMetadata m = metadataMap.get(metadata.getKey()); + if (m != null) { + m.merge(metadata); + } else { + metadataMap.put(metadata.getKey(), metadata); } } - - public Collection getMetadataList() - { - return metadataMap == null ? Collections.emptyList() : metadataMap.values(); + + 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/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/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java new file mode 100644 index 00000000..646e09ad --- /dev/null +++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java @@ -0,0 +1,42 @@ +/* + * 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 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 { + + private ArtifactRepositoryStub deploymentRepository; + + public ArtifactRepository getDistributionManagementArtifactRepository() { + return deploymentRepository; + } + + @Override + public Build getBuild() { + Plugin plugin = new Plugin(); + Build build = new Build(); + build.setPlugins(Collections.singletonList(plugin)); + return build; + } +} diff --git a/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml b/src/test/resources/unit/basic-deploy-bom/plugin-config.xml similarity index 59% rename from src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml rename to src/test/resources/unit/basic-deploy-bom/plugin-config.xml index ed5e519d..53bb8866 100644 --- a/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-bom/plugin-config.xml @@ -23,17 +23,15 @@ under the License. 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 - true - ${localRepository} - legacy - true + + ${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 798927fa..27d5f259 100644 --- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml @@ -23,23 +23,15 @@ 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 pom - + - + ${basedir} - true 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 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..4b3a9bfe 100644 --- a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml +++ b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml @@ -23,22 +23,14 @@ 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 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 45f82a37..a98749b1 100644 Binary files a/src/test/resources/unit/basic-deploy-test/plugin-config.xml and b/src/test/resources/unit/basic-deploy-test/plugin-config.xml differ 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..417c54e2 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,27 +23,17 @@ 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 jar - + - + - + ${basedir} - true 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..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 @@ -26,13 +26,9 @@ 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 - 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..b77961b4 100644 --- a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-classifier/plugin-config.xml @@ -30,10 +30,7 @@ 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 - ${localRepository} bin - default 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 f8ed5438..3a4e2ce0 100644 Binary files a/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml and b/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml differ 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 501565d6..9f522553 100644 --- a/src/test/resources/unit/deploy-file-test/plugin-config.xml +++ b/src/test/resources/unit/deploy-file-test/plugin-config.xml @@ -31,10 +31,8 @@ under the License. deploy-test file://${basedir}/target/remote-repo/deploy-file-test POM was created from deploy:deploy-file - true - ${localRepository} - default true + snapshots