diff --git a/Java-base/maven-invoker-plugin/Dockerfile b/Java-base/maven-invoker-plugin/Dockerfile new file mode 100644 index 000000000..e208c4890 --- /dev/null +++ b/Java-base/maven-invoker-plugin/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:22.04 + +RUN export DEBIAN_FRONTEND=noninteractive \ + && apt-get update \ + && apt-get install -y software-properties-common \ + && add-apt-repository ppa:deadsnakes/ppa \ + && apt-get update \ + && apt-get install -y \ + build-essential \ + git \ + vim \ + jq \ + && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/list/* + +RUN apt-get -y install sudo \ + openjdk-8-jdk \ + maven + +RUN bash -c "echo 2 | update-alternatives --config java" + +COPY src /workspace +WORKDIR /workspace + +RUN mvn install -V -B -Denforcer.skip=true -Dcheckstyle.skip=true -Dcobertura.skip=true -Drat.skip=true -Dlicense.skip=true -Dfindbugs.skip=true -Dgpg.skip=true -Dskip.npm=true -Dskip.gulp=true -Dskip.bower=true -Drat.numUnapprovedLicenses=100 -DskipTests=true -DskipITs=true -Dtest=None -DfailIfNoTests=false + +RUN mvn test -V -B -Denforcer.skip=true -Dcheckstyle.skip=true -Dcobertura.skip=true -Drat.skip=true -Dlicense.skip=true -Dfindbugs.skip=true -Dgpg.skip=true -Dskip.npm=true -Dskip.gulp=true -Dskip.bower=true -Drat.numUnapprovedLicenses=100 + +ENV TZ=Asia/Seoul diff --git a/Java-base/maven-invoker-plugin/src/Jenkinsfile b/Java-base/maven-invoker-plugin/src/Jenkinsfile new file mode 100644 index 000000000..e9f05f7d9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/Jenkinsfile @@ -0,0 +1,20 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +asfMavenTlpPlgnBuild() diff --git a/Java-base/maven-invoker-plugin/src/README.md b/Java-base/maven-invoker-plugin/src/README.md new file mode 100644 index 000000000..bb8c0b369 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/README.md @@ -0,0 +1,99 @@ + +Contributing to [Apache Maven Invoker Plugin](https://maven.apache.org/plugins/maven-invoker-plugin/) +====================== + +[![ASF Jira](https://img.shields.io/endpoint?url=https%3A%2F%2Fmaven.apache.org%2Fbadges%2Fasf_jira-MINVOKER.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-invoker-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-invoker-plugin) +[![Jenkins Status](https://img.shields.io/jenkins/s/https/builds.apache.org/job/maven-box/job/maven-invoker-plugin/job/master.svg?)][build] +[![Jenkins tests](https://img.shields.io/jenkins/t/https/builds.apache.org/job/maven-box/job/maven-invoker-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. +``` +[MINVOKER-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 Invoker Plugin 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/MINVOKER/ +[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://builds.apache.org/job/maven-box/job/maven-invoker-plugin/job/master/lastCompletedBuild/testReport/ +[build]: https://builds.apache.org/job/maven-box/job/maven-invoker-plugin/job/master/ diff --git a/Java-base/maven-invoker-plugin/src/pom.xml b/Java-base/maven-invoker-plugin/src/pom.xml new file mode 100644 index 000000000..7926ad5db --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/pom.xml @@ -0,0 +1,408 @@ + + + + + + 4.0.0 + + + maven-plugins + org.apache.maven.plugins + 34 + ../../pom/maven/maven-plugins/pom.xml + + + maven-invoker-plugin + 3.2.2-SNAPSHOT + maven-plugin + + Apache Maven Invoker Plugin + + The Maven Invoker Plugin is used to run a set of Maven projects. The plugin can determine whether each project + execution is successful, and optionally can verify the output generated from a given project execution. + + + + ${mavenVersion} + + + + scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git + scm:git:https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git + https://github.com/apache/maven-invoker-plugin/tree/${project.scm.tag} + HEAD + + + jira + https://issues.apache.org/jira/browse/MINVOKER/issues + + + Jenkins + https://builds.apache.org/job/maven-box/job/maven-invoker-plugin/ + + + + apache.website + scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path} + + + + + 7 + 3.0 + 1.9.1 + 1.9.2 + org.beanshell + bsh + 2.0b4 + org.codehaus.groovy + groovy-all + 2.4.19 + 2.22.2 + 2020-02-22T16:40:59Z + + + + + org.apache.maven.shared + maven-invoker + 3.0.1 + + + org.apache.maven + maven-core + ${mavenVersion} + + + org.apache.maven + maven-model + ${mavenVersion} + + + org.apache.maven + maven-plugin-api + ${mavenVersion} + + + org.apache.maven + maven-artifact + ${mavenVersion} + + + org.apache.maven + maven-settings + ${mavenVersion} + + + org.apache.maven.reporting + maven-reporting-api + 3.0 + + + org.apache.maven.reporting + maven-reporting-impl + 3.0.0 + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + provided + + + + org.apache.maven.shared + maven-script-interpreter + 1.2 + + + + org.codehaus.groovy + groovy + + + + + + org.apache.maven.shared + maven-artifact-transfer + 0.11.0 + + + + + org.apache.maven.doxia + doxia-sink-api + ${doxiaVersion} + + + org.apache.maven.doxia + doxia-decoration-model + ${doxiaSitetoolsVersion} + + + org.apache.maven.doxia + doxia-core + ${doxiaVersion} + + + + + org.apache.maven.doxia + doxia-site-renderer + ${doxiaSitetoolsVersion} + + + org.codehaus.plexus + plexus-container-default + + + + + + ${beanshell-groupId} + ${beanshell-artifactId} + ${beanshell-version} + runtime + + + ${groovy-groupId} + ${groovy-artifactId} + ${groovy-version} + runtime + + + + org.codehaus.plexus + plexus-utils + 3.1.0 + + + commons-io + commons-io + 2.5 + + + org.codehaus.plexus + plexus-interpolation + 1.26 + + + org.codehaus.plexus + plexus-i18n + 1.0-beta-7 + + + org.codehaus.plexus + plexus-container-default + + + org.codehaus.plexus + plexus-component-api + + + + + org.apache.maven.shared + maven-shared-utils + 3.2.1 + + + + junit + junit + 4.13 + test + + + org.mockito + mockito-core + 2.28.2 + test + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + 2.1 + test + + + org.apache.maven + maven-compat + ${mavenVersion} + test + + + + + + + + + + org.apache.rat + apache-rat-plugin + + + src/it/staging-dependencies/repo/**/* + src/it/**/*.txt + src/test/**/*.txt + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + maven-enforcer-plugin + 3.0.0-M3 + + + maven-project-info-reports-plugin + 3.1.0 + + + + + + + org.apache.rat + apache-rat-plugin + + + org.codehaus.modello + modello-maven-plugin + + + standard + + + xpp3-reader + + xpp3-writer + + java + + + + site-docs + pre-site + + xdoc + + + + + + src/main/mdo/invocation.mdo + + 1.0.0 + true + + + + + + + + run-its + + 3.7.1 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + 3.2.1 + + ${project.build.directory}/it + setup + verify + ${project.build.directory}/local-repo + src/it/settings.xml + -Djava.io.tmpdir=${project.build.directory} + + + ${https.protocols} + ${maven.compiler.source} + ${maven.compiler.target} + + + ${project.version} + + + clean + initialize + + + + + + + + + + + windows-its + + + windows + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + -Djava.io.tmpdir="${project.build.directory}" + + + + + + + + dev + + + + + org.apache.maven.plugins + maven-invoker-plugin + ${project.version} + + true + true + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/pom.xml new file mode 100644 index 000000000..46237d98c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + project-cloning + 1.0-SNAPSHOT + pom + + Test to check for proper project cloning + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + + **/pom.xml + + ${project.build.directory}/it-logs + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/src/it/module/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/src/it/module/pom.xml new file mode 100644 index 000000000..5badb327b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/src/it/module/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + org.apache.maven.test + unit + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/verify.groovy new file mode 100644 index 000000000..514b93df2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-190-logDirectory/verify.groovy @@ -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. + */ + +assert !(new File(basedir,'target/it/module/build.log').exists()) +assert new File(basedir,'target/it-logs/module/build.log').exists() diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/invoker.properties new file mode 100644 index 000000000..bf50e934a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/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 = verify -T3 diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/pom.xml new file mode 100644 index 000000000..942b5b3be --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/pom.xml @@ -0,0 +1,40 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + MINVOKER-191-parent + 1.0-SNAPSHOT + + MINVOKER-191-java-a + + + + junit + junit + 4.12 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/src/main/java/org/apache/maven/plugins/foo/Hello.java b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/src/main/java/org/apache/maven/plugins/foo/Hello.java new file mode 100644 index 000000000..b235be8af --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/src/main/java/org/apache/maven/plugins/foo/Hello.java @@ -0,0 +1,28 @@ +package org.apache.maven.plugins.foo; + +/* + * 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. + */ + +public class Hello { + + public static String sayHello(String who) throws Exception { + return "Hello " + who; + } + +} \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/src/test/java/org/apache/maven/plugins/foo/HelloTest.java b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/src/test/java/org/apache/maven/plugins/foo/HelloTest.java new file mode 100644 index 000000000..ea1e4ff63 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-a/src/test/java/org/apache/maven/plugins/foo/HelloTest.java @@ -0,0 +1,32 @@ +package org.apache.maven.plugins.foo; + +/* + * 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.junit.Test; + +public class HelloTest { + + @Test + public void say_hello_test() throws Exception { + Hello.sayHello("foo"); + Thread.sleep(4000); + } + +} \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/pom.xml new file mode 100644 index 000000000..46cfd9257 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/pom.xml @@ -0,0 +1,40 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + MINVOKER-191-parent + 1.0-SNAPSHOT + + MINVOKER-191-java-b + + + + junit + junit + 4.12 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/src/main/java/org/apache/maven/plugins/foo/Hello.java b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/src/main/java/org/apache/maven/plugins/foo/Hello.java new file mode 100644 index 000000000..b235be8af --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/src/main/java/org/apache/maven/plugins/foo/Hello.java @@ -0,0 +1,28 @@ +package org.apache.maven.plugins.foo; + +/* + * 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. + */ + +public class Hello { + + public static String sayHello(String who) throws Exception { + return "Hello " + who; + } + +} \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/src/test/java/org/apache/maven/plugins/foo/HelloTest.java b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/src/test/java/org/apache/maven/plugins/foo/HelloTest.java new file mode 100644 index 000000000..f6c26db89 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/module-b/src/test/java/org/apache/maven/plugins/foo/HelloTest.java @@ -0,0 +1,32 @@ +package org.apache.maven.plugins.foo; + +/* + * 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.junit.Test; + +public class HelloTest { + + @Test + public void say_hello_test() throws Exception { + Hello.sayHello("foo"); + Thread.sleep(2000); + } + +} \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/pom.xml new file mode 100644 index 000000000..cf5b9fce0 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/pom.xml @@ -0,0 +1,62 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + MINVOKER-191-parent + 1.0-SNAPSHOT + + MINVOKER-191-plugin + maven-plugin + + + + org.apache.maven + maven-plugin-api + 2.0 + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + ${project.build.directory}/it + ${project.build.directory}/local-repo + + + + itests + + install + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/src/it/basic/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/src/it/basic/pom.xml new file mode 100644 index 000000000..6d3c05a62 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/src/it/basic/pom.xml @@ -0,0 +1,47 @@ + + + + + + 4.0.0 + foo.it + basic + 1.0-SNAPSHOT + pom + + + + + org.apache.maven.plugins.invoker + MINVOKER-191-plugin + 1.0-SNAPSHOT + + + touch + + touch + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java new file mode 100644 index 000000000..c225e4b99 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java @@ -0,0 +1,78 @@ +package org.apache.maven.it.plugins.dummy; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * @goal touch + * @phase process-sources + */ +public class MyMojo + extends AbstractMojo +{ + /** + * Location of the file. + * @parameter expression="${project.build.directory}" + * @required + */ + private File outputDirectory; + + public void execute() + throws MojoExecutionException + { + File f = outputDirectory; + + if ( !f.exists() ) + { + f.mkdirs(); + } + + File touch = new File( f, "touch.txt" ); + + FileWriter w = null; + try + { + w = new FileWriter( touch ); + + w.write( "touch.txt" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error creating file " + touch, e ); + } + finally + { + if ( w != null ) + { + try + { + w.close(); + } + catch ( IOException e ) + { + // ignore + } + } + } + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/pom.xml new file mode 100644 index 000000000..e556e9677 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-191/pom.xml @@ -0,0 +1,79 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + MINVOKER-191-parent + 1.0-SNAPSHOT + pom + + + Test of reported issue MINVOKER-191: install plugins try to install all reactors projects + even non dependendant projects which cause build using multi thread builds + + + + UTF-8 + + + + module-a + plugin + module-b + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + + org.apache.maven.plugins + maven-plugin-plugin + 2.9 + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + + + ${https.protocols} + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/pom.xml new file mode 100644 index 000000000..df2b064e6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/pom.xml @@ -0,0 +1,73 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + junit-report-file + 1.0-SNAPSHOT + jar + + + Test to check for proper generation of junit report files + + + + UTF-8 + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + true + verify + ${project.build.directory}/it-repo + src/it/settings.xml + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project/pom.xml new file mode 100644 index 000000000..0d15cde75 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test-junit-report + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project/verify.groovy new file mode 100644 index 000000000..6b8ec7420 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project/verify.groovy @@ -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. + */ + +// ensure script context contains localRepositoryPath +assert new File( basedir, "../../../target/it-repo" ).canonicalFile.equals( localRepositoryPath ) + +File interpolatedSettings = new File( basedir, "../interpolated-settings.xml" ) +assert interpolatedSettings.isFile() + +def filename = new File( basedir, "../../../../../local-repo" ).canonicalPath +// Convert URL, see org.apache.maven.plugins.invoker.AbstractInvokerMojo.toUrl(String) +String url = "file://" + new File( filename ).toURI().path +if ( url.endsWith( "/" ) ) +{ + url = url.substring( 0, url.length() - 1 ) +} + +def settings = new XmlSlurper().parse( interpolatedSettings ) + +// ensure right settings and mirror are picked up +def sandboxMirror = settings.mirrors.mirror[0] +assert sandboxMirror.id.text() == "sandbox" +assert sandboxMirror.url.text() != "@localRepositoryUrl@" + +// sandboxMirror.url is NOT filled with localRepositoryPath, but with the localRepository of the parent Settings +assert sandboxMirror.url.text() == url diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project_2/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project_2/pom.xml new file mode 100644 index 000000000..7234f6556 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project_2/pom.xml @@ -0,0 +1,71 @@ + + + + + + 4.0.0 + test + pom-filtering-junit-report + 0.1-SNAPSHOT + jar + + + UTF-8 + + ${project.version} + + @project.version@ + @propertyFromPluginConfig@ + @propertyFromPropertiesSection@ + + @project-is-not-the-pom.version@ + + @project.name@ + @pom.name@ + + @itProperty@ + + @project.nonExistingPomValue@ + + @basedir@ + @baseurl@ + @localRepository@ + @localRepositoryUrl@ + + + + + + + ${basedir} + false + + *.xml + + + + + + maven-resources-plugin + 2.2 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project_2/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project_2/verify.groovy new file mode 100644 index 000000000..af6082a93 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/project_2/verify.groovy @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +assert new File( basedir, "../../../target/it-repo_not_here" ).canonicalFile.equals( localRepositoryPath ) diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/settings.xml new file mode 100644 index 000000000..ca7b8ab93 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/src/it/settings.xml @@ -0,0 +1,31 @@ + + + + + + + + sandbox + A completely isolated repo to test the interpolation of "localRepositoryUrl" + @localRepositoryUrl@ + * + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/verify.groovy new file mode 100644 index 000000000..331b88481 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-196_junit_report_file/verify.groovy @@ -0,0 +1,52 @@ +/* + * 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 buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( '[INFO] run post-build script verify.groovy' ) + +File invokerReports = new File( new File(basedir, "target"), 'invoker-reports' ) +assert invokerReports.exists() + +// test on first project +def testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project.xml" ) ) + +assert testsuite.@name.text() != null +assert testsuite.@time.text() != null +assert testsuite.@tests.text() == "1" +assert testsuite.@errors.text() == "0" +assert testsuite.@skipped.text() == "0" +assert testsuite.@failures.text() == "0" + +assert testsuite.testcase.@name.text() == "project" +def systemOut = testsuite.testcase.'**'.findAll { node -> node.name() == 'system-out' }.get(0) +assert !systemOut.text().isEmpty() + + +// test on second project +testsuite = new XmlSlurper().parse( new File( invokerReports, "TEST-project_2.xml" ) ) + +assert testsuite.@name.text() != null +assert testsuite.@time.text() != null +assert testsuite.@tests.text() == "1" +assert testsuite.@errors.text() == "0" +assert testsuite.@skipped.text() == "0" +assert testsuite.@failures.text() == "1" + +assert testsuite.testcase.@name.text() == "project_2" +def failureMessage = testsuite.testcase.failure.@message +assert !failureMessage.text().isEmpty() diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/invoker.properties new file mode 100644 index 000000000..353946b69 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/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 = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/module-a/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/module-a/pom.xml new file mode 100644 index 000000000..6fbab1e09 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/module-a/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + minvoker251-parent + 1.0-SNAPSHOT + + minvoker251-a + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/module-b/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/module-b/pom.xml new file mode 100644 index 000000000..5eb478b3a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/module-b/pom.xml @@ -0,0 +1,39 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + minvoker251-parent + 1.0-SNAPSHOT + + minvoker251-b + + + + org.apache.maven.plugins.invoker + minvoker251-a + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/plugin/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/plugin/pom.xml new file mode 100644 index 000000000..66a42f384 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/plugin/pom.xml @@ -0,0 +1,59 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + minvoker251-parent + 1.0-SNAPSHOT + + minvoker251-plugin + + + + + org.apache.maven.plugins + maven-invoker-plugin + + ${project.build.directory}/it + ${project.build.directory}/local-repo + + + + itests + + install + + + + + + + + + + org.apache.maven.plugins.invoker + minvoker251-b + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/pom.xml new file mode 100644 index 000000000..21881e33a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/pom.xml @@ -0,0 +1,80 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + minvoker251-parent + 1.0-SNAPSHOT + pom + + https://issues.apache.org/jira/browse/MINVOKER-243 + + + UTF-8 + + + + + + org.apache.maven.plugins.invoker + minvoker251-a + ${project.version} + + + org.apache.maven.plugins.invoker + minvoker251-b + ${project.version} + + + org.apache.maven.plugins.invoker + minvoker251-plugin + ${project.version} + + + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + + ${https.protocols} + + + + + + + + + module-a + module-b + plugin + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/verify.groovy new file mode 100644 index 000000000..3f0631527 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/MINVOKER-243_install-reactor/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. + */ + +def localRepo = new File(basedir,'plugin/target/local-repo') + +assert new File(localRepo, 'org/apache/maven/plugins/invoker/minvoker251-a/1.0-SNAPSHOT/minvoker251-a-1.0-SNAPSHOT.pom').exists() +assert new File(localRepo, 'org/apache/maven/plugins/invoker/minvoker251-a/1.0-SNAPSHOT/minvoker251-a-1.0-SNAPSHOT.jar').exists() +assert new File(localRepo, 'org/apache/maven/plugins/invoker/minvoker251-b/1.0-SNAPSHOT/minvoker251-b-1.0-SNAPSHOT.pom').exists() +assert new File(localRepo, 'org/apache/maven/plugins/invoker/minvoker251-b/1.0-SNAPSHOT/minvoker251-b-1.0-SNAPSHOT.jar').exists() +assert new File(localRepo, 'org/apache/maven/plugins/invoker/minvoker251-parent/1.0-SNAPSHOT/minvoker251-parent-1.0-SNAPSHOT.pom').exists() +assert new File(localRepo, 'org/apache/maven/plugins/invoker/minvoker251-plugin/1.0-SNAPSHOT/minvoker251-plugin-1.0-SNAPSHOT.pom').exists() +assert new File(localRepo, 'org/apache/maven/plugins/invoker/minvoker251-plugin/1.0-SNAPSHOT/minvoker251-plugin-1.0-SNAPSHOT.jar').exists() + diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-clean/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/invoker.properties new file mode 100644 index 000000000..f45dd01ad --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/invoker.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. + +# NOTE: Don't clean here to be able to detect test failures +invoker.goals = initialize diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-clean/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/pom.xml new file mode 100644 index 000000000..c28592443 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + clone-clean-invocation + 1.0-SNAPSHOT + pom + + Test to check for cleaning of cloned project directories before execution. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it + true + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-clean/setup.bsh b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/setup.bsh new file mode 100644 index 000000000..b0296e205 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/setup.bsh @@ -0,0 +1,32 @@ +/* + * 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.*; + +try +{ + File itRoot = new File( basedir, "target/it/clone-clean" ); + itRoot.mkdirs(); + return new File(itRoot, "foobar.log").createNewFile(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-clean/src/it/clone-clean/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/src/it/clone-clean/pom.xml new file mode 100644 index 000000000..267fcdbbf --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/src/it/clone-clean/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + clone-clean + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-clean/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/verify.bsh new file mode 100644 index 000000000..f2ece44f2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-clean/verify.bsh @@ -0,0 +1,31 @@ +/* + * 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.*; + +try +{ + File itRoot = new File( basedir, "target/it/clone-clean" ); + return !new File( itRoot, "foobar.log" ).exists(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/invoker.properties new file mode 100644 index 000000000..f45dd01ad --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/invoker.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. + +# NOTE: Don't clean here to be able to detect test failures +invoker.goals = initialize diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/pom.xml new file mode 100644 index 000000000..d3f9f85ff --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + clone-maven-plugin-packaging + 1.0-SNAPSHOT + maven-plugin + + Test to check for cloned project of packaging maven-plugin. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it + true + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/src/it/clone-clean/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/src/it/clone-clean/pom.xml new file mode 100644 index 000000000..267fcdbbf --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/src/it/clone-clean/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + clone-clean + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/verify.bsh new file mode 100644 index 000000000..2ee728044 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/clone-maven-plugin-packaging/verify.bsh @@ -0,0 +1,31 @@ +/* + * 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.*; + +try +{ + File itRoot = new File( basedir, "target/it/clone-clean" ); + return itRoot.exists(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/invoker.properties new file mode 100644 index 000000000..43618d417 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/invoker.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. + +invoker.goals = verify +invoker.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/pom.xml new file mode 100644 index 000000000..3bcb75c71 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker + exec-timeout-invoker-level + 1.0-SNAPSHOT + maven-plugin + + + + org.apache.maven + maven-plugin-api + 2.0 + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + ${project.build.directory}/it + ${project.build.directory}/local-repo + + + ${https.protocols} + + + + + itests + + install + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/it/basic/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/it/basic/invoker.properties new file mode 100644 index 000000000..c049149c2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/it/basic/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.timeoutInSeconds = 2 diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/it/basic/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/it/basic/pom.xml new file mode 100644 index 000000000..eba22ebbe --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/it/basic/pom.xml @@ -0,0 +1,53 @@ + + + + + + 4.0.0 + foo.it + basic + 1.0-SNAPSHOT + pom + + + + + org.apache.maven.plugins.invoker + exec-timeout-invoker-level + 1.0-SNAPSHOT + + + + ${https.protocols} + + + + + touch + + touch + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java new file mode 100644 index 000000000..94971f0c5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java @@ -0,0 +1,89 @@ +package org.apache.maven.it.plugins.dummy; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * @goal touch + * @phase process-sources + */ +public class MyMojo + extends AbstractMojo +{ + /** + * Location of the file. + * @parameter expression="${project.build.directory}" + * @required + */ + private File outputDirectory; + + public void execute() + throws MojoExecutionException + { + + try + { + Thread.sleep(5000); + } + catch ( java.lang.Exception exception ) + { + exception.printStackTrace(); + throw new MojoExecutionException(exception.getMessage(), exception); + } + + File f = outputDirectory; + + if ( !f.exists() ) + { + f.mkdirs(); + } + + File touch = new File( f, "touch.txt" ); + + FileWriter w = null; + try + { + w = new FileWriter( touch ); + + w.write( "touch.txt" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error creating file " + touch, e ); + } + finally + { + if ( w != null ) + { + try + { + w.close(); + } + catch ( IOException e ) + { + // ignore + } + } + } + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/verify.groovy new file mode 100644 index 000000000..10a8d90d9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-invoker-level/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, 'target/it/basic/build.log' ) + +assert !buildLog.text.contains('Total time: ') +assert !buildLog.text.contains('Finished at: ') \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/invoker.properties new file mode 100644 index 000000000..43618d417 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/invoker.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. + +invoker.goals = verify +invoker.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/pom.xml new file mode 100644 index 000000000..3f02a9a73 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/pom.xml @@ -0,0 +1,66 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker + exec-timeout-invoker-level + 1.0-SNAPSHOT + maven-plugin + + + + org.apache.maven + maven-plugin-api + 2.0 + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + 2 + ${project.build.directory}/it + ${project.build.directory}/local-repo + + + ${https.protocols} + + + + + itests + + install + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/src/it/basic/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/src/it/basic/pom.xml new file mode 100644 index 000000000..eba22ebbe --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/src/it/basic/pom.xml @@ -0,0 +1,53 @@ + + + + + + 4.0.0 + foo.it + basic + 1.0-SNAPSHOT + pom + + + + + org.apache.maven.plugins.invoker + exec-timeout-invoker-level + 1.0-SNAPSHOT + + + + ${https.protocols} + + + + + touch + + touch + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java new file mode 100644 index 000000000..94971f0c5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java @@ -0,0 +1,89 @@ +package org.apache.maven.it.plugins.dummy; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * @goal touch + * @phase process-sources + */ +public class MyMojo + extends AbstractMojo +{ + /** + * Location of the file. + * @parameter expression="${project.build.directory}" + * @required + */ + private File outputDirectory; + + public void execute() + throws MojoExecutionException + { + + try + { + Thread.sleep(5000); + } + catch ( java.lang.Exception exception ) + { + exception.printStackTrace(); + throw new MojoExecutionException(exception.getMessage(), exception); + } + + File f = outputDirectory; + + if ( !f.exists() ) + { + f.mkdirs(); + } + + File touch = new File( f, "touch.txt" ); + + FileWriter w = null; + try + { + w = new FileWriter( touch ); + + w.write( "touch.txt" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error creating file " + touch, e ); + } + finally + { + if ( w != null ) + { + try + { + w.close(); + } + catch ( IOException e ) + { + // ignore + } + } + } + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/verify.groovy new file mode 100644 index 000000000..10a8d90d9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/exec-timeout-mojo-level/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, 'target/it/basic/build.log' ) + +assert !buildLog.text.contains('Total time: ') +assert !buildLog.text.contains('Finished at: ') \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/invoker.properties new file mode 100644 index 000000000..e64d99e02 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/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.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/pom.xml new file mode 100644 index 000000000..49ec32d74 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-build-streamLogsOnFailures + 1.0-SNAPSHOT + pom + + Test to check that a failure in the forked Maven build fails the parent build with streamed logs. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + false + ${project.build.directory}/it + + */pom.xml + + true + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/src/it/project/pom.xml new file mode 100644 index 000000000..cf9bbe951 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/src/it/project/pom.xml @@ -0,0 +1,35 @@ + + + + + + + 99.0.0 + test + fail-build + 0.1-SNAPSHOT + jar + + + UTF-8 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/verify.groovy new file mode 100644 index 000000000..06e686d54 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-streamLogsOnFailures/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. + */ + +def FS = File.separator +def buildLogOfProject = new File( basedir, 'target/it/project/build.log' ).text + +def buildLog = new File( basedir, 'build.log' ).text + +assert buildLog.contains( '*** begin build.log for: project' + FS + 'pom.xml ***' ) +assert buildLog.contains( buildLogOfProject ) +assert buildLog.contains( '*** end build.log for: project' + FS + 'pom.xml ***' ) + +assert buildLog.contains( 'ERROR] Failed to execute goal org.apache.maven.plugins:maven-invoker-plugin:' + projectVersion + ':run' ) diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/invoker.properties new file mode 100644 index 000000000..e64d99e02 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/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.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/pom.xml new file mode 100644 index 000000000..e366ff196 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-build-with-verify-streamLogsOnFailures + 1.0-SNAPSHOT + pom + + Test to check that a failure in the forked Maven build fails the parent build with streamed logs. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + false + ${project.build.directory}/it + + */pom.xml + + true + + + + integration-test + initialize + + integration-test + verify + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/src/it/project/pom.xml new file mode 100644 index 000000000..cf9bbe951 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/src/it/project/pom.xml @@ -0,0 +1,35 @@ + + + + + + + 99.0.0 + test + fail-build + 0.1-SNAPSHOT + jar + + + UTF-8 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/verify.groovy new file mode 100644 index 000000000..7d5bdd154 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify-streamLogsOnFailures/verify.groovy @@ -0,0 +1,31 @@ +/* + * 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 FS = File.separator +def buildLogOfProject = new File( basedir, 'target/it/project/build.log' ).text + +def buildLog = new File( basedir, 'build.log' ).text + +assert buildLog.contains( '*** begin build.log for: project' + FS + 'pom.xml ***' ) +assert buildLog.contains( buildLogOfProject ) +assert buildLog.contains( '*** end build.log for: project' + FS + 'pom.xml ***' ) + +assert buildLog.contains( 'maven-invoker-plugin:' + projectVersion + ':integration-test' ) +assert buildLog.contains( '[ERROR] Failed to execute goal org.apache.maven.plugins:maven-invoker-plugin:' + projectVersion + ':verify' ) + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/invoker.properties new file mode 100644 index 000000000..e64d99e02 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/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.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/pom.xml new file mode 100644 index 000000000..00ad86316 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/pom.xml @@ -0,0 +1,66 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-build + 1.0-SNAPSHOT + pom + + Test to check that a failure in the forked Maven build fails the parent build, too. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + validate + + + + + integration-test + initialize + + integration-test + verify + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/src/it/project/pom.xml new file mode 100644 index 000000000..cf9bbe951 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/src/it/project/pom.xml @@ -0,0 +1,35 @@ + + + + + + + 99.0.0 + test + fail-build + 0.1-SNAPSHOT + jar + + + UTF-8 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/src/it/project/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/src/it/project/prebuild.bsh new file mode 100644 index 000000000..3a93d1131 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/src/it/project/prebuild.bsh @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/verify.bsh new file mode 100644 index 000000000..b7d9d2e27 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build-with-verify/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +try +{ + // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else + File touchFile = new File( basedir, "target/it/project/touch.txt" ); + System.out.println( "Checking for existence of touch file: " + touchFile ); + if ( !touchFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-build/invoker.properties new file mode 100644 index 000000000..e64d99e02 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build/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.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-build/pom.xml new file mode 100644 index 000000000..10ec51d55 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build/pom.xml @@ -0,0 +1,66 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-build + 1.0-SNAPSHOT + pom + + Test to check that a failure in the forked Maven build fails the parent build, too. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + true + ${project.build.directory}/it + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-build/src/it/project/pom.xml new file mode 100644 index 000000000..cf9bbe951 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build/src/it/project/pom.xml @@ -0,0 +1,35 @@ + + + + + + + 99.0.0 + test + fail-build + 0.1-SNAPSHOT + jar + + + UTF-8 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build/src/it/project/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-build/src/it/project/prebuild.bsh new file mode 100644 index 000000000..3a93d1131 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build/src/it/project/prebuild.bsh @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-build/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-build/verify.bsh new file mode 100644 index 000000000..b7d9d2e27 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-build/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +try +{ + // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else + File touchFile = new File( basedir, "target/it/project/touch.txt" ); + System.out.println( "Checking for existence of touch file: " + touchFile ); + if ( !touchFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-ignore-with-verify/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-ignore-with-verify/pom.xml new file mode 100644 index 000000000..c0e4c8d85 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-ignore-with-verify/pom.xml @@ -0,0 +1,67 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-ignore + 1.0-SNAPSHOT + pom + + Test to check that a failure in the forked Maven builds is ignored. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + invalid-phase-to-fail-build + + true + + + + integration-test + initialize + + integration-test + verify + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-ignore-with-verify/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-ignore-with-verify/src/it/project/pom.xml new file mode 100644 index 000000000..b80df7601 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-ignore-with-verify/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + fail-ignore + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-ignore/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-ignore/pom.xml new file mode 100644 index 000000000..c34ec5dac --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-ignore/pom.xml @@ -0,0 +1,66 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-ignore + 1.0-SNAPSHOT + pom + + Test to check that a failure in the forked Maven builds is ignored. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + invalid-phase-to-fail-build + + true + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-ignore/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-ignore/src/it/project/pom.xml new file mode 100644 index 000000000..b80df7601 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-ignore/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + fail-ignore + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_integration-test/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_integration-test/pom.xml new file mode 100644 index 000000000..5e4d9d99a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_integration-test/pom.xml @@ -0,0 +1,61 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-noprojects_integration-test + 1.0-SNAPSHOT + + Test to check that the build succeeds during integration-test even if there are no projects + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + validate + + + + + integration-test + initialize + + integration-test + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_run/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_run/invoker.properties new file mode 100644 index 000000000..e64d99e02 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_run/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.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_run/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_run/pom.xml new file mode 100644 index 000000000..d4afd796a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_run/pom.xml @@ -0,0 +1,61 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-noprojects_run + 1.0-SNAPSHOT + + Test to check that the build fails if there are no projects + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_verify/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_verify/invoker.properties new file mode 100644 index 000000000..e64d99e02 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_verify/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.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_verify/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_verify/pom.xml new file mode 100644 index 000000000..b538f28b6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-noprojects_verify/pom.xml @@ -0,0 +1,62 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-noprojects_verify + 1.0-SNAPSHOT + + Test to check that the build fails if there are no projects + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + validate + + + + + integration-test + initialize + + integration-test + verify + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/invoker.properties new file mode 100644 index 000000000..e64d99e02 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/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.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/pom.xml new file mode 100644 index 000000000..4f6722fca --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-postbuild + 1.0-SNAPSHOT + pom + + Test to check that a failure of the post-build hook fails the parent build, too. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/pom.xml new file mode 100644 index 000000000..8c5bb2c00 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + fail-prebuild + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/postbuild.bsh new file mode 100644 index 000000000..9669e4bfe --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/postbuild.bsh @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +return false; diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/prebuild.bsh new file mode 100644 index 000000000..3a93d1131 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/src/it/project/prebuild.bsh @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/verify.bsh new file mode 100644 index 000000000..b7d9d2e27 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-postbuild/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +try +{ + // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else + File touchFile = new File( basedir, "target/it/project/touch.txt" ); + System.out.println( "Checking for existence of touch file: " + touchFile ); + if ( !touchFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/invoker.properties new file mode 100644 index 000000000..e64d99e02 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/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.buildResult = failure diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/pom.xml new file mode 100644 index 000000000..29e464b08 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-prebuild + 1.0-SNAPSHOT + pom + + Test to check that a failure of the pre-build hook fails the parent build, too. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/src/it/project/pom.xml new file mode 100644 index 000000000..8c5bb2c00 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + fail-prebuild + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/src/it/project/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/src/it/project/prebuild.bsh new file mode 100644 index 000000000..9c1a83bbe --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/src/it/project/prebuild.bsh @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ); +touchFile.createNewFile(); + +return false; diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/verify.bsh new file mode 100644 index 000000000..b7d9d2e27 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-prebuild/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +try +{ + // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else + File touchFile = new File( basedir, "target/it/project/touch.txt" ); + System.out.println( "Checking for existence of touch file: " + touchFile ); + if ( !touchFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/invoker.properties new file mode 100644 index 000000000..c19c7116f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/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.buildResult = failure \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/pom.xml new file mode 100644 index 000000000..474fa363b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-run-postbuild + 1.0-SNAPSHOT + pom + + Test to check in case of failure the post-build hook is running. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + package + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/pom.xml new file mode 100644 index 000000000..2dd41bdc8 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + fail-run-postbuild + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/postbuild.bsh new file mode 100644 index 000000000..3a93d1131 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/src/main/java/Foo.java b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/src/main/java/Foo.java new file mode 100644 index 000000000..ae2e8a126 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/src/it/project/src/main/java/Foo.java @@ -0,0 +1,24 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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. + */ + + + +Foo beer Maven rocks \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/verify.bsh new file mode 100644 index 000000000..b7d9d2e27 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/fail-run-postbuild/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +try +{ + // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else + File touchFile = new File( basedir, "target/it/project/touch.txt" ); + System.out.println( "Checking for existence of touch file: " + touchFile ); + if ( !touchFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/pom.xml new file mode 100644 index 000000000..2d72f148e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/pom.xml @@ -0,0 +1,70 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + pom-filtering + 1.0-SNAPSHOT + pom + + PASSED + Test to check for proper filtering of IT POMs + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + process-resources + + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/project/.mvn/extensions.xml b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/project/.mvn/extensions.xml new file mode 100644 index 000000000..582c50816 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/project/.mvn/extensions.xml @@ -0,0 +1,27 @@ + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/project/pom.xml new file mode 100644 index 000000000..88e03dbf1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/project/pom.xml @@ -0,0 +1,71 @@ + + + + + + 4.0.0 + test + pom-filtering + 0.1-SNAPSHOT + jar + + + UTF-8 + + ${project.version} + + @project.version@ + @propertyFromPluginConfig@ + @propertyFromPropertiesSection@ + + @project-is-not-the-pom.version@ + + @project.name@ + @pom.name@ + + @itProperty@ + + @project.nonExistingPomValue@ + + @basedir@ + @baseurl@ + @localRepository@ + @localRepositoryUrl@ + + + + + + + ${basedir} + false + + *.xml + + + + + + maven-resources-plugin + 2.2 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/settings.xml new file mode 100644 index 000000000..79c5dc163 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/src/it/settings.xml @@ -0,0 +1,55 @@ + + + + + + + + it-repo + + true + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/verify.bsh new file mode 100644 index 000000000..da0c8a483 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/filtering-extensions/verify.bsh @@ -0,0 +1,75 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; + +try +{ + File extensionsFile = new File( basedir, "target/it/project/.mvn/extensions.xml" ); + System.out.println( "Checking for existence of filtered extensions.xml" ); + if ( !extensionsFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String xml = FileUtils.fileRead( extensionsFile, "UTF-8" ); + + + String[] values = { + "org.apache.maven.plugins.invoker", + "pom-filtering", + "1.0-SNAPSHOT", + }; + for ( String value : values ) + { + System.out.println( "Checking for occurrence of: " + value ); + if ( xml.indexOf( value ) < 0 ) + { + System.out.println( "FAILED!" ); + return false; + } + } + + String[] badValues = { + "@project.groupId@", + "@project.artifactId@", + "@project.version@", + }; + for ( String value : badValues ) + { + System.out.println( "Checking for absence of: " + value ); + if ( xml.indexOf( value ) >= 0 ) + { + System.out.println( "FAILED!" ); + return false; + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/install-extra-artifacts/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/install-extra-artifacts/pom.xml new file mode 100644 index 000000000..55da1fa94 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/install-extra-artifacts/pom.xml @@ -0,0 +1,70 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + stage-extras + 1.0-SNAPSHOT + pom + + + Test to check for staging of external dependencies directly from local repository (MINVOKER-102). + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it-repo + + + junit:junit:3.8.2 + + org.apache.maven.plugins:maven-clean-plugin:2.4:maven-plugin + + org.apache.maven.plugins:maven-clean-plugin:2.4:jar:javadoc + + jdom:jdom:1.1 + + + + + integration-test + initialize + + install + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/install-extra-artifacts/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/install-extra-artifacts/verify.bsh new file mode 100644 index 000000000..ba95e3639 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/install-extra-artifacts/verify.bsh @@ -0,0 +1,69 @@ +/* + * 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 java.util.regex.*; + +try +{ + File itRepoDir = new File( basedir, "target/it-repo" ); + if ( !itRepoDir.isDirectory() ) + { + System.out.println( "IT local repository missing: " + itRepoDir ); + return false; + } + + String[] files = + { + "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4.jar", + "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4.pom", + "org/apache/maven/plugins/maven-clean-plugin/2.4/maven-clean-plugin-2.4-javadoc.jar", + "org/apache/maven/plugins/maven-plugins/16/maven-plugins-16.pom", + "org/apache/maven/maven-parent/15/maven-parent-15.pom", + "org/apache/apache/6/apache-6.pom", + "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar", + "org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom", + "junit/junit/3.8.2/junit-3.8.2.jar", + "junit/junit/3.8.2/junit-3.8.2.pom", + "jdom/jdom/1.1/jdom-1.1.pom", + "org/jdom/jdom/1.1/jdom-1.1.pom", + "org/jdom/jdom/1.1/jdom-1.1.jar", + }; + for ( String file : files ) + { + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + if ( !stagedFile.isFile() ) + { + throw new IllegalStateException( "Missing: " + stagedFile ); + } + if ( file.endsWith( "jdom-1.1.jar" ) && stagedFile.length() < 1024 * 10 ) + { + throw new IllegalStateException( "Corrupt: " + stagedFile ); + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/pom.xml new file mode 100644 index 000000000..3d0a2a79f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + integration-test-never-fails + 1.0-SNAPSHOT + pom + + Test to check that a failure in the forked Maven build does not fail the parent build. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + validate + + + + + integration-test + initialize + + integration-test + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/src/it/project/pom.xml new file mode 100644 index 000000000..125071873 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/src/it/project/pom.xml @@ -0,0 +1,33 @@ + + + + + + + 99.0.0 + test + fail-build + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/src/it/project/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/src/it/project/prebuild.bsh new file mode 100644 index 000000000..3a93d1131 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/src/it/project/prebuild.bsh @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/verify.bsh new file mode 100644 index 000000000..b7d9d2e27 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/integration-test-never-fails/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +try +{ + // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else + File touchFile = new File( basedir, "target/it/project/touch.txt" ); + System.out.println( "Checking for existence of touch file: " + touchFile ); + if ( !touchFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/pom.xml new file mode 100644 index 000000000..3a37ad2d0 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/pom.xml @@ -0,0 +1,61 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + invocation-cmdline-exclude + 1.0-SNAPSHOT + pom + + Test if the exclude can be used from commandline + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/src/it/minvoker-140/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/src/it/minvoker-140/pom.xml new file mode 100644 index 000000000..b01fa824b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/src/it/minvoker-140/pom.xml @@ -0,0 +1,54 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-138 + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.1.1 + + + + enforce + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/test.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/test.properties new file mode 100644 index 000000000..c27a0677d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-cmdline-exclude/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. + +invoker.test = !minvoker-140 diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/pom.xml new file mode 100644 index 000000000..4e89b8e11 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + invocation-debug + 1.0-SNAPSHOT + pom + + + Test to check for usage of debug mode. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + + validate + + false + verify + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/invoker.properties new file mode 100644 index 000000000..3d383e9dd --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/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.debug = true diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/pom.xml new file mode 100644 index 000000000..87c71423e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/pom.xml @@ -0,0 +1,58 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-142 + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.1.1 + + + + enforce + + + + + ${https.protocols} + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/verify.groovy new file mode 100644 index 000000000..417a89ef5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-debug/src/it/minvoker-142/verify.groovy @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( '[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.AlwaysPass' ) \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-emptyproperty/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-emptyproperty/pom.xml new file mode 100644 index 000000000..690cacaf9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-emptyproperty/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + invocation-emptyporperty + 1.0-SNAPSHOT + pom + + Test if the invocation succeeds even if there are empty/unresolved properties + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + + validate + + + value + ${example.property} + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml new file mode 100644 index 000000000..cd7234b5a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-emptyproperty/src/it/minvoker-118/pom.xml @@ -0,0 +1,58 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-118 + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.1.1 + + + + enforce + + + + + ${https.protocols} + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/pom.xml new file mode 100644 index 000000000..222982638 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/pom.xml @@ -0,0 +1,67 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + invocation-environmentvariable + 1.0-SNAPSHOT + pom + + Test if the environmentvariable is applied + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + verify + + validate + + + foobar + minvoker255_pom + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-145/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-145/pom.xml new file mode 100644 index 000000000..1f506efaf --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-145/pom.xml @@ -0,0 +1,58 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-145 + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + envTest + + + env.MINVOKER145 + !foobar + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.1.1 + + + + enforce + + + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-145/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-145/verify.groovy new file mode 100644 index 000000000..7cea0c180 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-145/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. + */ +def buildLog = new File( basedir, 'build.log' ) + +// on this level we try find some substring, +// if not found it will be logged and cause parent verify script to find required text +assert buildLog.text.contains('] BUILD SUCCESS') + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/invoker.properties new file mode 100644 index 000000000..2be833f12 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/invoker.properties @@ -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. + +invoker.name = Test Environment variable + +# override value from plugin config +invoker.environmentVariables.MINVOKER145 = minvoker_145 + +# add next value +invoker.environmentVariables.MINVOKER255_PROPERTIES = minvoker255_properties diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/pom.xml new file mode 100644 index 000000000..b67cef9e2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/pom.xml @@ -0,0 +1,61 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-145 + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M3 + + + + enforce + + + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/verify.groovy new file mode 100644 index 000000000..7cea0c180 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/src/it/minvoker-255/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. + */ +def buildLog = new File( basedir, 'build.log' ) + +// on this level we try find some substring, +// if not found it will be logged and cause parent verify script to find required text +assert buildLog.text.contains('] BUILD SUCCESS') + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/verify.groovy new file mode 100644 index 000000000..0ef60fd43 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-environmentvariable/verify.groovy @@ -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. + */ +def buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains('[INFO] BUILD SUCCESS') + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/pom.xml new file mode 100644 index 000000000..86b60d1eb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/pom.xml @@ -0,0 +1,69 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + invocation-project + 1.0-SNAPSHOT + pom + + + Test to check that invocations can use a different POM than the one that was selected via the pomInclude + parameter. This allows fine-grained control over the build of a multi-module project where the modules are + (intentionally) not collectively build by the reactor. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + src/it/projects + + */*/pom.xml + + + compile + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/invoker.properties new file mode 100644 index 000000000..c19c7116f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/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.buildResult = failure \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/invoker.properties new file mode 100644 index 000000000..fe3dca200 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/invoker.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. + +invoker.goals = validate +invoker.buildResult = success \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/pom.xml new file mode 100644 index 000000000..a509339e6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-1/pom.xml @@ -0,0 +1,52 @@ + + + + + + 4.0.0 + + test + sub-1 + 0.1-SNAPSHOT + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + enforce + initialize + + enforce + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-2/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-2/pom.xml new file mode 100644 index 000000000..faebe940f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-1/sub-2/pom.xml @@ -0,0 +1,52 @@ + + + + + + 4.0.0 + + test + sub-2 + 0.1-SNAPSHOT + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + enforce + initialize + + enforce + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/invoker.properties new file mode 100644 index 000000000..c19c7116f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/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.buildResult = failure \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/pom.xml new file mode 100644 index 000000000..a509339e6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-1/pom.xml @@ -0,0 +1,52 @@ + + + + + + 4.0.0 + + test + sub-1 + 0.1-SNAPSHOT + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + enforce + initialize + + enforce + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-2/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-2/pom.xml new file mode 100644 index 000000000..0424a64ec --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/group-2/sub-2/pom.xml @@ -0,0 +1,52 @@ + + + + + + 4.0.0 + + test + sub-2 + 0.1-SNAPSHOT + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + enforce + compile + + enforce + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/invoker.properties new file mode 100644 index 000000000..d16306984 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/src/it/projects/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 = initialize \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/verify.groovy new file mode 100644 index 000000000..7ba59ce6e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-group-properties/verify.groovy @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +return true \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/pom.xml new file mode 100644 index 000000000..67d1caa29 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/pom.xml @@ -0,0 +1,75 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + invocation-multiple + 1.0-SNAPSHOT + pom + + Test to check for proper support of multiple Maven invocations per project. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + src/it/settings.xml + + validate + + + ${invoker.repo.local} + + + ${maven.compiler.source} + ${maven.compiler.target} + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/invoker.properties new file mode 100644 index 000000000..89ca0884c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/invoker.properties @@ -0,0 +1,43 @@ +# 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. + +####################################### +# Default build +####################################### +invoker.goals = install +invoker.profiles = plugin,profile0 +invoker.systemPropertiesFile = system1.properties + +####################################### +# First build +####################################### +# goals should fall back to invoker.goals +invoker.profiles.1 = + +####################################### +# Second build +####################################### +invoker.goals.2 = test:test-maven-plugin:0.1-SNAPSHOT:test +invoker.profiles.2 = plugin,profile1 +# system properties file should fall back to invoker.systemPropertiesFile + +####################################### +# Third build +####################################### +invoker.goals.3 = test:test-maven-plugin:0.1-SNAPSHOT:test +# profiles should fall back to invoker.profiles +invoker.systemPropertiesFile.3 = system2.properties diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/pom.xml new file mode 100644 index 000000000..c313c74c5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/pom.xml @@ -0,0 +1,107 @@ + + + + + + 4.0.0 + test + test-maven-plugin + 0.1-SNAPSHOT + maven-plugin + + + 2.0 + + + + UTF-8 + + + + + org.apache.maven + maven-plugin-api + 2.0 + + + + + + + maven-compiler-plugin + 2.0.2 + + ${maven.compiler.source} + ${maven.compiler.target} + + + + maven-install-plugin + 2.2 + + + maven-jar-plugin + 2.2 + + + maven-plugin-plugin + 2.4.2 + + + maven-resources-plugin + 2.2 + + + maven-surefire-plugin + 2.4.3 + + + + + + + plugin + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + ${project.build.directory}/${testProperty}.txt + + + + + + + profile0 + + test0 + + + + profile1 + + test1 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/src/main/java/org/TestMojo.java b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/src/main/java/org/TestMojo.java new file mode 100644 index 000000000..ef83c5ad9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/src/main/java/org/TestMojo.java @@ -0,0 +1,69 @@ +package org; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import java.io.*; +import java.util.*; + +import org.apache.maven.plugin.*; + +/** + * @goal test + */ +public class TestMojo extends AbstractMojo { + + /** + * @parameter default-value="${project.build.directory}/test.txt" + */ + private File outputFile; + + /** + * @see org.apache.maven.plugin.AbstractMojo#execute() + */ + public void execute() throws MojoExecutionException, MojoFailureException { + outputFile.getParentFile().mkdirs(); + Writer writer = null; + try + { + writer = new OutputStreamWriter( new FileOutputStream( outputFile ), "UTF-8" ); + writer.write( System.getProperty( "maven.invoker.test", "null" ) ); + } + catch (IOException e) + { + throw new MojoExecutionException( "Failed", e ); + } + finally + { + if ( writer != null ) + { + try + { + writer.close(); + } + catch (IOException e) + { + // ignore + } + } + } + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/system1.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/system1.properties new file mode 100644 index 000000000..40defe0e2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/system1.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. + +maven.invoker.test = UTF-8 diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/system2.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/system2.properties new file mode 100644 index 000000000..efffc37e1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/project/system2.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. + +maven.invoker.test = ISO-8859-1 diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/settings.xml new file mode 100644 index 000000000..febb63261 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/src/it/settings.xml @@ -0,0 +1,60 @@ + + + + + + + + it-repo + + true + + + + + local.central + file://@invoker.repo.local@ + + true + + + true + + + + + + local.central + file://@invoker.repo.local@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/verify.bsh new file mode 100644 index 000000000..75237e92e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-multiple/verify.bsh @@ -0,0 +1,66 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; + +try +{ + File test0File = new File( basedir, "target/it/project/target/test0.txt" ); + System.out.println( "Checking for existence of first test file: " + test0File ); + if ( !test0File.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String test0 = FileUtils.fileRead( test0File, "UTF-8" ).trim(); + System.out.println( "Checking contents of first test file: " + test0 ); + if ( !"ISO-8859-1".equals( test0 ) ) + { + System.out.println( "FAILED!" ); + return false; + } + + File test1File = new File( basedir, "target/it/project/target/test1.txt" ); + System.out.println( "Checking for existence of second test file: " + test1File ); + if ( !test1File.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String test1 = FileUtils.fileRead( test1File, "UTF-8" ).trim(); + System.out.println( "Checking contents of second test file: " + test1 ); + if ( !"UTF-8".equals( test1 ) ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/pom.xml new file mode 100644 index 000000000..bb9efaf55 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/pom.xml @@ -0,0 +1,71 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + invocation-offline + 1.0-SNAPSHOT + pom + + + Test to check for usage of offline mode. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it-repo + + */pom.xml + + src/it/settings.xml + + validate + + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/project/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/project/invoker.properties new file mode 100644 index 000000000..5742a032d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/project/invoker.properties @@ -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. + +# First run if offline mode which should fail to download the Clean Plugin +invoker.goals.1 = clean +invoker.offline.1 = true +invoker.buildResult.1 = failure + +# Now again in online mode +invoker.goals.2 = clean diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/project/pom.xml new file mode 100644 index 000000000..c639174a2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/project/pom.xml @@ -0,0 +1,41 @@ + + + + + + 4.0.0 + test + invocation-offline + 0.1-SNAPSHOT + jar + + + UTF-8 + + + + + junit + junit + 3.8.2 + test + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/settings.xml new file mode 100644 index 000000000..febb63261 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/src/it/settings.xml @@ -0,0 +1,60 @@ + + + + + + + + it-repo + + true + + + + + local.central + file://@invoker.repo.local@ + + true + + + true + + + + + + local.central + file://@invoker.repo.local@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/verify.bsh new file mode 100644 index 000000000..00ac1d02a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-offline/verify.bsh @@ -0,0 +1,32 @@ +/* + * 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 java.util.regex.*; + +// sanity check to make sure the builds were actually run +File repoDir = new File( basedir, "target/it-repo" ); +System.out.println( "Checking for existence of test repo: " + repoDir ); +if ( !repoDir.exists() ) +{ + throw new FileNotFoundException( "Missing repository directory: " + repoDir ); +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/pom.xml new file mode 100644 index 000000000..4d09be0c9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/pom.xml @@ -0,0 +1,70 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + invocation-project + 1.0-SNAPSHOT + pom + + + Test to check that invocations can use a different POM than the one that was selected via the pomInclude + parameter. This allows fine-grained control over the build of a multi-module project where the modules are + (intentionally) not collectively build by the reactor. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + + */pom.xml + + src/it/settings.xml + setup.bsh + + clean + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/invoker.properties new file mode 100644 index 000000000..c4e026583 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/invoker.properties @@ -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. + +# path to POM +invoker.project.1 = sub-1/pom.xml + +# path to base directory +invoker.project.2 = sub-3 diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/pom.xml new file mode 100644 index 000000000..27c514aaa --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/pom.xml @@ -0,0 +1,35 @@ + + + + + + 4.0.0 + + test + aggregator + 0.1-SNAPSHOT + pom + + + sub-1 + sub-2 + sub-3 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/setup.bsh b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/setup.bsh new file mode 100644 index 000000000..5e6d0f07e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/setup.bsh @@ -0,0 +1,38 @@ +/* + * 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.*; + +String[] paths = +{ + "target", + "sub-1/target", + "sub-2/target", + "sub-3/target", +}; + +for ( String path : paths ) +{ + File dir = new File( basedir, path); + System.out.println( "Creating directory: " + dir ); + if ( !dir.mkdirs() ) + { + throw new IOException( "Failed to create directory: " + dir ); + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-1/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-1/pom.xml new file mode 100644 index 000000000..b56e1993f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-1/pom.xml @@ -0,0 +1,29 @@ + + + + + + 4.0.0 + + test + sub-1 + 0.1-SNAPSHOT + jar + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-2/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-2/pom.xml new file mode 100644 index 000000000..0f31f97ae --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-2/pom.xml @@ -0,0 +1,29 @@ + + + + + + 4.0.0 + + test + sub-2 + 0.1-SNAPSHOT + jar + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-3/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-3/pom.xml new file mode 100644 index 000000000..8dff9474f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/project/sub-3/pom.xml @@ -0,0 +1,29 @@ + + + + + + 4.0.0 + + test + sub-3 + 0.1-SNAPSHOT + jar + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/settings.xml new file mode 100644 index 000000000..febb63261 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/src/it/settings.xml @@ -0,0 +1,60 @@ + + + + + + + + it-repo + + true + + + + + local.central + file://@invoker.repo.local@ + + true + + + true + + + + + + local.central + file://@invoker.repo.local@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-project/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/verify.bsh new file mode 100644 index 000000000..b080a6c2f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-project/verify.bsh @@ -0,0 +1,54 @@ +/* + * 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.*; + +String[] unexpectedPaths = +{ + "sub-1/target", + "sub-3/target", +}; + +for ( String path : unexpectedPaths ) +{ + File file = new File( new File( basedir, "target/it/project" ), path); + System.out.println( "Checking for absence of: " + file ); + if ( file.exists() ) + { + throw new IOException( "Unexpected path found: " + file ); + } +} + +String[] expectedPaths = +{ + "target", + "sub-2/target", +}; + +for ( String path : expectedPaths ) +{ + File file = new File( new File( basedir, "target/it/project" ), path); + System.out.println( "Checking for existence of: " + file ); + if ( !file.exists() ) + { + throw new IOException( "Expected path not found: " + file ); + } +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/invoker.properties new file mode 100644 index 000000000..353946b69 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/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 = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/itests/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/itests/pom.xml new file mode 100644 index 000000000..cf5858b45 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/itests/pom.xml @@ -0,0 +1,62 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + MINVOKER-115-parent + 1.0-SNAPSHOT + + MINVOKER-115-itests + pom + + + + org.apache.maven.plugins.invoker + MINVOKER-115-plugin + 1.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + ${project.build.directory}/it + ${project.build.directory}/local-repo + + + + itests + + install + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/itests/src/it/basic/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/itests/src/it/basic/pom.xml new file mode 100644 index 000000000..e6c088688 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/itests/src/it/basic/pom.xml @@ -0,0 +1,47 @@ + + + + + + 4.0.0 + foo.it + basic + 1.0-SNAPSHOT + pom + + + + + org.apache.maven.plugins.invoker + MINVOKER-115-plugin + 1.0-SNAPSHOT + + + touch + + touch + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/plugin/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/plugin/pom.xml new file mode 100644 index 000000000..f443bffee --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/plugin/pom.xml @@ -0,0 +1,40 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + MINVOKER-115-parent + 1.0-SNAPSHOT + + MINVOKER-115-plugin + maven-plugin + + + + org.apache.maven + maven-plugin-api + 2.0 + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java new file mode 100644 index 000000000..c225e4b99 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java @@ -0,0 +1,78 @@ +package org.apache.maven.it.plugins.dummy; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * @goal touch + * @phase process-sources + */ +public class MyMojo + extends AbstractMojo +{ + /** + * Location of the file. + * @parameter expression="${project.build.directory}" + * @required + */ + private File outputDirectory; + + public void execute() + throws MojoExecutionException + { + File f = outputDirectory; + + if ( !f.exists() ) + { + f.mkdirs(); + } + + File touch = new File( f, "touch.txt" ); + + FileWriter w = null; + try + { + w = new FileWriter( touch ); + + w.write( "touch.txt" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error creating file " + touch, e ); + } + finally + { + if ( w != null ) + { + try + { + w.close(); + } + catch ( IOException e ) + { + // ignore + } + } + } + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/pom.xml new file mode 100644 index 000000000..6986e4d17 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-reactor-indirect/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + MINVOKER-115-parent + 1.0-SNAPSHOT + pom + + + Test of reported issue MINVOKER-115: install goal doesn't install plugins from the reactor + build to the local repo. + + + + UTF-8 + + + + plugin + itests + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + + org.apache.maven.plugins + maven-plugin-plugin + 2.9 + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + + ${https.protocols} + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/pom.xml new file mode 100644 index 000000000..7bfede6b4 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/pom.xml @@ -0,0 +1,76 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + invocation-spaces + 1.0-SNAPSHOT + pom + + Test to check for proper handling of Maven invocations that involve spaces on the command line. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + src/it projects + ${project.build.directory}/it projects + + */*pom.xml + + ${project.build.directory}/it repo + src/it projects/settings.xml + + install + + + + ${https.protocols} + value with spaces from cli + + + ${invoker.repo.local} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/project/spacy pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/project/spacy pom.xml new file mode 100644 index 000000000..530d19a83 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/project/spacy pom.xml @@ -0,0 +1,70 @@ + + + + + + 4.0.0 + test + spacy-pom + 0.1-SNAPSHOT + jar + + + UTF-8 + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + + org.apache.maven.plugins + maven-install-plugin + 2.2 + + + maven-jar-plugin + 2.2 + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.4.3 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/project/src/main/resources/test.txt b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/project/src/main/resources/test.txt new file mode 100644 index 000000000..755f558be --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/project/src/main/resources/test.txt @@ -0,0 +1,2 @@ +${propertyFromSettings} +${propertyFromCommandLine} diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/settings.xml new file mode 100644 index 000000000..2e77464fa --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/src/it projects/settings.xml @@ -0,0 +1,63 @@ + + + + + + + + it-repo + + true + + + value with spaces from settings + + + + + local.central + file://@invoker.repo.local@ + + true + + + true + + + + + + local.central + file://@invoker.repo.local@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/verify.bsh new file mode 100644 index 000000000..118fa20b2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invocation-spaces/verify.bsh @@ -0,0 +1,74 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; + +try +{ + File testFile = new File( basedir, "target/it projects/project/target/classes/test.txt" ); + System.out.println( "Checking for existence of test file: " + testFile ); + if ( !testFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String[] values = { + "value with spaces from settings", + "value with spaces from cli", + }; + + BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( testFile ), "UTF-8" ) ); + try + { + for ( String value : values ) + { + String line = reader.readLine(); + System.out.println( "Checking for occurrence of: " + value ); + if ( !value.equals( line ) ) + { + System.out.println( "FAILED!" ); + return false; + } + } + } + finally + { + reader.close(); + } + + File installedFile = new File( basedir, "target/it repo/test/spacy-pom/0.1-SNAPSHOT/spacy-pom-0.1-SNAPSHOT.jar" ); + System.out.println( "Checking for existence of installed file: " + installedFile ); + if ( !installedFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/invoker.properties new file mode 100644 index 000000000..09f3c90bc --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/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 = integration-test site diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/pom.xml new file mode 100644 index 000000000..dbc99085a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/pom.xml @@ -0,0 +1,81 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + invoker-report + 1.0-SNAPSHOT + pom + + Test + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + */pom.xml + + setup + verify + true + + validate + + + + + integration-test + initialize + + run + + + + + + org.apache.maven.plugins + maven-site-plugin + @sitePluginVersion@ + + + + + + true + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-build/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-build/pom.xml new file mode 100644 index 000000000..4f60e1aa1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-build/pom.xml @@ -0,0 +1,39 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + foo + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/invoker.properties new file mode 100644 index 000000000..ec7081832 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/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.description = A build job without name. diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/verify.bsh new file mode 100644 index 000000000..4720926b5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-post/verify.bsh @@ -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. + */ + +throw new IllegalStateException( "The post-build script failed as expected." ); + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/invoker.properties new file mode 100644 index 000000000..62558a3a7 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/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.name = No Description diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/setup.bsh b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/setup.bsh new file mode 100644 index 000000000..363e42611 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/failure-pre/setup.bsh @@ -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. + */ + +throw new IllegalStateException( "The pre-build script failed as expected." ); + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-jre/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-jre/invoker.properties new file mode 100644 index 000000000..db44ad51d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-jre/invoker.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. + +invoker.description = A build job skipped due to JRE version. +invoker.java.version = 1.0 diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-jre/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-jre/pom.xml new file mode 100644 index 000000000..cd7ec5d49 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-jre/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-maven/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-maven/invoker.properties new file mode 100644 index 000000000..79b5deea9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-maven/invoker.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. + +invoker.description = A build job skipped due to Maven version. +invoker.maven.version = 2.1.5 diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-maven/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-maven/pom.xml new file mode 100644 index 000000000..cd7ec5d49 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-maven/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-os/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-os/invoker.properties new file mode 100644 index 000000000..cc00c9bce --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-os/invoker.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. + +invoker.description = A build job skipped due to Operation System. +invoker.os.family = ties diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-os/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-os/pom.xml new file mode 100644 index 000000000..cd7ec5d49 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/skip-os/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/success/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/success/invoker.properties new file mode 100644 index 000000000..0a7e4f9ed --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/success/invoker.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. + +invoker.name = Success +invoker.description = A build job that should succeed. diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/success/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/success/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/src/it/success/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/invoker-report/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/verify.bsh new file mode 100644 index 000000000..745613ecb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/invoker-report/verify.bsh @@ -0,0 +1,32 @@ +/* + * 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.*; + +File reportFile = new File( basedir, "target/site/invoker-report.html"); + +System.out.println( "Checking for existence of report file: " + reportFile ); +if ( !reportFile.exists() ) +{ + System.out.println( "FAILED!" ); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/pom.xml new file mode 100644 index 000000000..ce1c1cffa --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/pom.xml @@ -0,0 +1,72 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + local-repo-default + 1.0-SNAPSHOT + pom + + + Test to check for MINVOKER-47, i.e. local repo path given by IT settings.xml must be ignored even if + plugin configuration does not specify a custom location. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/its + + */pom.xml + + src/it/settings.xml + + install + + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/project/pom.xml new file mode 100644 index 000000000..1a122979a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + local-repo-default + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/project/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/project/postbuild.bsh new file mode 100644 index 000000000..5be5e7b3b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/project/postbuild.bsh @@ -0,0 +1,39 @@ +/* + * 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 java.util.regex.*; + +try +{ + // just dump our local repo path for verification by the parent build + File textFile = new File( basedir, "target/local-repo-path.txt" ); + textFile.getParentFile().mkdirs(); + Writer writer = new OutputStreamWriter( new FileOutputStream( textFile ), "UTF-8" ); + writer.write( localRepositoryPath.getAbsolutePath() ); + writer.close(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/settings.xml new file mode 100644 index 000000000..a75e365fd --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/src/it/settings.xml @@ -0,0 +1,57 @@ + + + + + + + @project.build.directory@/bad-repo + + + it-repo + + true + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/verify.bsh new file mode 100644 index 000000000..249c645b1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-default/verify.bsh @@ -0,0 +1,71 @@ +/* + * 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 java.util.regex.*; + +try +{ + File badRepoDir = new File( basedir, "target/bad-repo" ); + if ( badRepoDir.exists() ) + { + System.out.println( "Sub build used wrong local repository (from its settings.xml): " + badRepoDir ); + return false; + } + + /* + * NOTE: This relies heavily on the Invoker Plugin's configuration of our parent build, not nice but until MINVOKER-49 + * is available here, we have no other way of getting the path. + */ + File localRepoPathOfThisBuild = new File( basedir.getParentFile().getParentFile(), "local-repo" ); + System.out.println("Local repository of this build: " + localRepoPathOfThisBuild); + + File textFile = new File( basedir, "target/its/project/target/local-repo-path.txt" ); + BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( textFile ), "UTF-8" ) ); + File localRepoPathOfSubBuild = new File( reader.readLine() ); + reader.close(); + System.out.println("Local repository of sub build: " + localRepoPathOfSubBuild); + + /* + * This is partly a sanity check of the Maven core (i.e. its MavenSettingsBuilder) which should ensure + * ${settings.localRepository} == ${maven.repo.local} + * This IT is run with maven.repo.local but the Invoker Plugin passes settings.localRepository down to the sub build + * so these paths must match. + */ + if ( !localRepoPathOfThisBuild.getCanonicalPath().equals( localRepoPathOfSubBuild.getCanonicalPath() ) ) + { + System.out.println( "Sub build used wrong local repository: " + localRepoPathOfSubBuild ); + return false; + } + + File installedFile = new File( localRepoPathOfThisBuild, "test/local-repo-default/0.1-SNAPSHOT/local-repo-default-0.1-SNAPSHOT.pom" ); + if ( !installedFile.isFile() ) + { + System.out.println( "Installed file missing in local repo: " + installedFile ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/pom.xml new file mode 100644 index 000000000..06a16ef84 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/pom.xml @@ -0,0 +1,71 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + local-repo-isolated + 1.0-SNAPSHOT + pom + + + Test to check for usage of an isolated local repository. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it-repo + + */pom.xml + + src/it/settings.xml + + install + + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/src/it/project/pom.xml new file mode 100644 index 000000000..52a7b5d25 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + local-repo-isolated + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/src/it/settings.xml new file mode 100644 index 000000000..a75e365fd --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/src/it/settings.xml @@ -0,0 +1,57 @@ + + + + + + + @project.build.directory@/bad-repo + + + it-repo + + true + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/verify.bsh new file mode 100644 index 000000000..1593cff79 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-isolated/verify.bsh @@ -0,0 +1,53 @@ +/* + * 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 java.util.regex.*; + +try +{ + File badRepoDir = new File( basedir, "target/bad-repo" ); + if ( badRepoDir.exists() ) + { + System.out.println( "IT used wrong local repository: " + badRepoDir ); + return false; + } + + File itRepoDir = new File( basedir, "target/it-repo" ); + if ( !itRepoDir.isDirectory() ) + { + System.out.println( "IT local repository missing: " + itRepoDir ); + return false; + } + + File installedFile = new File( itRepoDir, "test/local-repo-isolated/0.1-SNAPSHOT/local-repo-isolated-0.1-SNAPSHOT.pom" ); + if ( !installedFile.isFile() ) + { + System.out.println( "Installed file missing in local repo: " + installedFile ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/pom.xml new file mode 100644 index 000000000..85a773903 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + local-repo-path + 1.0-SNAPSHOT + jar + + + Test to check for proper filtering of "localRepository" token. + + + + UTF-8 + + + + + + + org.apache.maven.plugins + maven-clean-plugin + 2.2 + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it-repo + + */pom.xml + + src/it/settings.xml + + org.apache.maven.plugins:maven-clean-plugin:2.2:clean + + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/src/it/project/pom.xml new file mode 100644 index 000000000..63be41e21 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/src/it/settings.xml new file mode 100644 index 000000000..0150ddca1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/src/it/settings.xml @@ -0,0 +1,31 @@ + + + + + + + + sandbox + A completely isolated repo to test the interpolation of "localRepository" + file://@localRepository@ + * + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/verify.bsh new file mode 100644 index 000000000..00ac1d02a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-path/verify.bsh @@ -0,0 +1,32 @@ +/* + * 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 java.util.regex.*; + +// sanity check to make sure the builds were actually run +File repoDir = new File( basedir, "target/it-repo" ); +System.out.println( "Checking for existence of test repo: " + repoDir ); +if ( !repoDir.exists() ) +{ + throw new FileNotFoundException( "Missing repository directory: " + repoDir ); +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/pom.xml new file mode 100644 index 000000000..1e3914937 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/pom.xml @@ -0,0 +1,70 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + local-repo-url + 1.0-SNAPSHOT + jar + + + Test to check for proper filtering of "localRepositoryUrl" token. + + + + UTF-8 + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.2 + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it-repo + src/it/settings.xml + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/project/pom.xml new file mode 100644 index 000000000..63be41e21 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/project/postbuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/project/postbuild.groovy new file mode 100644 index 000000000..6b8ec7420 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/project/postbuild.groovy @@ -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. + */ + +// ensure script context contains localRepositoryPath +assert new File( basedir, "../../../target/it-repo" ).canonicalFile.equals( localRepositoryPath ) + +File interpolatedSettings = new File( basedir, "../interpolated-settings.xml" ) +assert interpolatedSettings.isFile() + +def filename = new File( basedir, "../../../../../local-repo" ).canonicalPath +// Convert URL, see org.apache.maven.plugins.invoker.AbstractInvokerMojo.toUrl(String) +String url = "file://" + new File( filename ).toURI().path +if ( url.endsWith( "/" ) ) +{ + url = url.substring( 0, url.length() - 1 ) +} + +def settings = new XmlSlurper().parse( interpolatedSettings ) + +// ensure right settings and mirror are picked up +def sandboxMirror = settings.mirrors.mirror[0] +assert sandboxMirror.id.text() == "sandbox" +assert sandboxMirror.url.text() != "@localRepositoryUrl@" + +// sandboxMirror.url is NOT filled with localRepositoryPath, but with the localRepository of the parent Settings +assert sandboxMirror.url.text() == url diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/settings.xml new file mode 100644 index 000000000..ca7b8ab93 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/src/it/settings.xml @@ -0,0 +1,31 @@ + + + + + + + + sandbox + A completely isolated repo to test the interpolation of "localRepositoryUrl" + @localRepositoryUrl@ + * + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/verify.groovy new file mode 100644 index 000000000..4e4f77455 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/local-repo-url/verify.groovy @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( '[INFO] run post-build script postbuild.groovy' ) \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/invoker.properties new file mode 100644 index 000000000..f45dd01ad --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/invoker.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. + +# NOTE: Don't clean here to be able to detect test failures +invoker.goals = initialize diff --git a/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/pom.xml new file mode 100644 index 000000000..4cf525c63 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + not-clone-not-a-plugin-invocation + 1.0-SNAPSHOT + pom + + Test to check for not cloning non maven plugin project. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/src/it/clone-clean/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/src/it/clone-clean/pom.xml new file mode 100644 index 000000000..267fcdbbf --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/src/it/clone-clean/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + clone-clean + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/verify.bsh new file mode 100644 index 000000000..b219ae535 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/not-clone-not-plugin/verify.bsh @@ -0,0 +1,31 @@ +/* + * 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.*; + +try +{ + File itRoot = new File( basedir, "target/it/clone-clean" ); + return !itRoot.exists(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/pom.xml new file mode 100644 index 000000000..72331d4ec --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + pom-filtering-encoding + 1.0-SNAPSHOT + pom + + Test to check for proper handling of file encoding during POM filtering. + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + process-resources + + + ©®ÄÖÜäöüß + + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/src/it/latin-1/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/src/it/latin-1/pom.xml new file mode 100644 index 000000000..be84a791d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/src/it/latin-1/pom.xml @@ -0,0 +1,54 @@ + + + + + + 4.0.0 + test + pom-filtering-encoding-latin1 + 0.1-SNAPSHOT + jar + + + + UTF-8 + ©®ÄÖÜäöüß + @latin1Chars@ + + + + + + + ${basedir} + false + + *.xml + + + + + + maven-resources-plugin + 2.2 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/src/it/utf-8/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/src/it/utf-8/pom.xml new file mode 100644 index 000000000..de59fae00 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/src/it/utf-8/pom.xml @@ -0,0 +1,54 @@ + + + + + + 4.0.0 + test + pom-filtering-encoding-utf8 + 0.1-SNAPSHOT + jar + + + + UTF-8 + ©®ÄÖÜäöüß + @latin1Chars@ + + + + + + + ${basedir} + false + + *.xml + + + + + + maven-resources-plugin + 2.2 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/verify.bsh new file mode 100644 index 000000000..db3c58da1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-encoding/verify.bsh @@ -0,0 +1,73 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; + +boolean check( String project, String encoding ) +{ + File pomFile = new File( basedir, "target/it/" + project + "/pom.xml" ); + System.out.println( "Checking for existence of original IT POM: " + pomFile ); + if ( !pomFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + pomFile = new File( basedir, "target/it/" + project + "/target/classes/pom.xml" ); + System.out.println( "Checking for existence of interpolated IT POM: " + pomFile ); + if ( !pomFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String xml = FileUtils.fileRead( pomFile, encoding ); + + String[] values = { + "", + "\u00A9\u00AE\u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF", + "\u00A9\u00AE\u00C4\u00D6\u00DC\u00E4\u00F6\u00FC\u00DF", + }; + for ( String value : values ) + { + System.out.println( "Checking for occurrence of: " + value ); + if ( xml.indexOf( value ) < 0 ) + { + System.out.println( "FAILED!" ); + return false; + } + } + return true; +} + +try +{ + return check( "latin-1", "ISO-8859-1" ) && check( "utf-8", "UTF-8" ); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/pom.xml new file mode 100644 index 000000000..79dac5f11 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + pom-filtering-reactor + 1.0-SNAPSHOT + pom + + Test to check that POM filtering includes all parents/modules of the invoked project and not only the execution root. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1-parent/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1-parent/pom.xml new file mode 100644 index 000000000..c43096ed9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1-parent/pom.xml @@ -0,0 +1,33 @@ + + + + + + 4.0.0 + test + mod1-parent + 0.1-SNAPSHOT + pom + + + UTF-8 + @pom.artifactId@ + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1/pom.xml new file mode 100644 index 000000000..d3a07bdd4 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1/pom.xml @@ -0,0 +1,40 @@ + + + + + + 4.0.0 + + + test + mod1-parent + 0.1-SNAPSHOT + ../mod1-parent + + + mod1 + 0.1-SNAPSHOT + pom + + + UTF-8 + @pom.artifactId@ + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1/src/it/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1/src/it/pom.xml new file mode 100644 index 000000000..2421ebe1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod1/src/it/pom.xml @@ -0,0 +1,35 @@ + + + + + + 4.0.0 + + test + unfiltered + 0.1-SNAPSHOT + pom + + + UTF-8 + + @pom.artifactId@ + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod2/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod2/pom.xml new file mode 100644 index 000000000..f24cf40ed --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod2/pom.xml @@ -0,0 +1,39 @@ + + + + + + 4.0.0 + + + test + mod2-parent + 0.1-SNAPSHOT + + + mod2 + 0.1-SNAPSHOT + pom + + + UTF-8 + @pom.artifactId@ + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod3/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod3/pom.xml new file mode 100644 index 000000000..99f9183df --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod3/pom.xml @@ -0,0 +1,40 @@ + + + + + + 4.0.0 + + + test + mod1-parent + 0.1-SNAPSHOT + ../mod1-parent + + + mod3 + 0.1-SNAPSHOT + pom + + + UTF-8 + @pom.artifactId@ + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod3/src/it/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod3/src/it/pom.xml new file mode 100644 index 000000000..2421ebe1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/mod3/src/it/pom.xml @@ -0,0 +1,35 @@ + + + + + + 4.0.0 + + test + unfiltered + 0.1-SNAPSHOT + pom + + + UTF-8 + + @pom.artifactId@ + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/pom.xml new file mode 100644 index 000000000..58b18cac0 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/src/it/mod2-parent/pom.xml @@ -0,0 +1,49 @@ + + + + + + 4.0.0 + + test + mod2-parent + 0.1-SNAPSHOT + pom + + + mod1 + mod2 + + + + UTF-8 + @pom.artifactId@ + + + + + minvoker-93 + + mod3 + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/verify.bsh new file mode 100644 index 000000000..d75e06d40 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering-reactor/verify.bsh @@ -0,0 +1,65 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; + +boolean check( String project, boolean filtered ) +{ + File pomFile = new File( basedir, "target/it/" + project + "/pom.xml" ); + System.out.println( "Checking for existence of " + ( filtered ? "" : "un" ) + "filtered POM: " + pomFile ); + if ( !pomFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String xml = FileUtils.fileRead( pomFile, "UTF-8" ); + + String[] values = { + "pom-filtering-reactor", + }; + for ( String value : values ) + { + System.out.println( "Checking for " + ( filtered ? "occurrence" : "absence" ) + " of: " + value ); + if ( ( filtered && xml.indexOf( value ) < 0 ) || ( !filtered && xml.indexOf( value ) >= 0 ) ) + { + System.out.println( "FAILED!" ); + return false; + } + } + return true; +} + +try +{ + return check( "mod2-parent", true ) && check( "mod2-parent/mod2", true ) && check( "mod2-parent/mod1-parent", true ) + && check( "mod2-parent/mod1", true ) && check( "mod2-parent/mod3", true) + && check( "mod2-parent/mod1/src/it", false ); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/pom.xml new file mode 100644 index 000000000..b43fd1d48 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/pom.xml @@ -0,0 +1,81 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + pom-filtering + 1.0-SNAPSHOT + pom + + PASSED + Test to check for proper filtering of IT POMs + + + UTF-8 + PROPERTY-FROM-PROPERTIES-SECTION + FAILED + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + process-resources + + + PROPERTY-FROM-PLUGIN-CONFIG + PASSED + FAILED + PASSED + PASSED + FAILED + FAILED + + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/src/it/project/pom.xml new file mode 100644 index 000000000..88e03dbf1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/src/it/project/pom.xml @@ -0,0 +1,71 @@ + + + + + + 4.0.0 + test + pom-filtering + 0.1-SNAPSHOT + jar + + + UTF-8 + + ${project.version} + + @project.version@ + @propertyFromPluginConfig@ + @propertyFromPropertiesSection@ + + @project-is-not-the-pom.version@ + + @project.name@ + @pom.name@ + + @itProperty@ + + @project.nonExistingPomValue@ + + @basedir@ + @baseurl@ + @localRepository@ + @localRepositoryUrl@ + + + + + + + ${basedir} + false + + *.xml + + + + + + maven-resources-plugin + 2.2 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/src/it/settings.xml new file mode 100644 index 000000000..79c5dc163 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/src/it/settings.xml @@ -0,0 +1,55 @@ + + + + + + + + it-repo + + true + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/verify.bsh new file mode 100644 index 000000000..a014c8acf --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-filtering/verify.bsh @@ -0,0 +1,93 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; + +try +{ + File pomFile = new File( basedir, "target/it/project/pom.xml" ); + System.out.println( "Checking for existence of original IT POM: " + pomFile ); + if ( !pomFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + pomFile = new File( basedir, "target/it/project/target/classes/pom.xml" ); + System.out.println( "Checking for existence of interpolated IT POM: " + pomFile ); + if ( !pomFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String xml = FileUtils.fileRead( pomFile, "UTF-8" ); + + String[] values = { + "${project.version}", + "1.0-SNAPSHOT", + "PROPERTY-FROM-PLUGIN-CONFIG", + "PROPERTY-FROM-PROPERTIES-SECTION", + "PASSED", + "PASSED", + "PASSED", + "PASSED", + "PASSED", + "file:///", + "file:///", + }; + for ( String value : values ) + { + System.out.println( "Checking for occurrence of: " + value ); + if ( xml.indexOf( value ) < 0 ) + { + System.out.println( "FAILED!" ); + return false; + } + } + + String[] badValues = { + "@basedir@", + "FAILED", + "@baseurl@", + "FAILED", + "@localRepository@", + "@localRepositoryUrl@", + }; + for ( String value : badValues ) + { + System.out.println( "Checking for absence of: " + value ); + if ( xml.indexOf( value ) >= 0 ) + { + System.out.println( "FAILED!" ); + return false; + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/pom.xml new file mode 100644 index 000000000..a9458c49c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + pom-less-invocation + 1.0-SNAPSHOT + pom + + Test to check for support to launch Maven on a mere directory, i.e. without a POM + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it + + no-pom + + + --version + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/src/it/no-pom/workaround.txt b/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/src/it/no-pom/workaround.txt new file mode 100644 index 000000000..8b04f6c31 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/src/it/no-pom/workaround.txt @@ -0,0 +1 @@ +This file ensures the directory is cloned, to be deleted once MINVOKER-48 is released. diff --git a/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/verify.bsh new file mode 100644 index 000000000..c471382e3 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/pom-less-invocation/verify.bsh @@ -0,0 +1,53 @@ +/* + * 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 java.util.regex.*; + +try +{ + File itDir = new File( basedir, "target/it" ); + if ( !itDir.isDirectory() ) + { + System.out.println( "IT directory not existent: " + itDir ); + return false; + } + + String[] paths = { + "no-pom", + "no-pom/build.log", + }; + for ( String path : paths ) + { + File file = new File( itDir, path ); + if ( !file.exists() ) + { + System.out.println( "Expected file/directory not existent: " + file ); + return false; + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/pom.xml new file mode 100644 index 000000000..0a9faa981 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/pom.xml @@ -0,0 +1,71 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + fail-postbuild + 1.0-SNAPSHOT + pom + + Test to check that a failure of the post-build hook fails the parent build, too. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + ${project.build.directory}/it + + */pom.xml + + + validate + + + ${maven.compiler.source} + ${maven.compiler.target} + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/invoker.properties new file mode 100644 index 000000000..307ca97af --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/invoker.properties @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals.1 = test +invoker.goals.2 = test +invoker.systemPropertiesFile.2 = system2.properties diff --git a/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/pom.xml new file mode 100644 index 000000000..01b4e1e76 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/pom.xml @@ -0,0 +1,69 @@ + + + + 4.0.0 + + org.apache.maven.plugins.invoker.it.post_executed_only_once + post_executed_only_once + 1.0-SNAPSHOT + jar + + post_executed_only_once + http://maven.apache.org + + + UTF-8 + false + + + + + junit + junit + 4.12 + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.21.0 + + + ${create_touch_file} + ${project.build.directory} + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/postbuild.bsh new file mode 100644 index 000000000..5cbc03eb2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/postbuild.bsh @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +try +{ + File touchFile = new File( basedir, "target/touch.txt" ); + System.out.println( "Checking for existence of touch file: " + touchFile ); + if ( !touchFile.exists() ) + { + System.out.println( "touch.txt not exists FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/src/main/java/org/apache/maven/plugins/invoker/it/post_executed_only_once/App.java b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/src/main/java/org/apache/maven/plugins/invoker/it/post_executed_only_once/App.java new file mode 100644 index 000000000..79bcfc535 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/src/main/java/org/apache/maven/plugins/invoker/it/post_executed_only_once/App.java @@ -0,0 +1,36 @@ +package org.apache.maven.plugins.invoker.it.post_executed_only_once; + +/* + * 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; + +public class App +{ + public boolean createFile() + throws Exception + { + if ( Boolean.getBoolean( "create_touch_file" ) ) + { + File touch = new File( System.getProperty( "touch_file_path" ), "touch.txt" ); + return touch.createNewFile(); + } + return false; + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/src/test/java/org/apache/maven/plugins/invoker/it/post_executed_only_once/AppTest.java b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/src/test/java/org/apache/maven/plugins/invoker/it/post_executed_only_once/AppTest.java new file mode 100644 index 000000000..e388290b4 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/src/test/java/org/apache/maven/plugins/invoker/it/post_executed_only_once/AppTest.java @@ -0,0 +1,35 @@ +package org.apache.maven.plugins.invoker.it.post_executed_only_once; + +/* + * 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.TestCase; +import org.junit.Test; + +public class AppTest + extends TestCase +{ + @Test + public void testApp() + throws Exception + { + new App().createFile(); + assertTrue( true ); + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/system2.properties b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/system2.properties new file mode 100644 index 000000000..bcd7772de --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/src/it/project/system2.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. + +create_touch_file = true diff --git a/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/verify.bsh new file mode 100644 index 000000000..e05fbff38 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/postbuild-executed-only-once/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +try +{ + // make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else + File touchFile = new File( basedir, "target/it/project/target/touch.txt" ); + System.out.println( "Checking for existence of touch file: " + touchFile ); + if ( !touchFile.exists() ) + { + System.out.println( "FAILED! no touchFile " + touchFile.toString() ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/pom.xml new file mode 100644 index 000000000..7da94c98c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + project-cloning-reactor + 1.0-SNAPSHOT + pom + + Test to check that project cloning includes all parents/modules of the invoked project and not only sub directories. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it + + + aggregator/pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/aggregator/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/aggregator/pom.xml new file mode 100644 index 000000000..34bed7d5e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/aggregator/pom.xml @@ -0,0 +1,38 @@ + + + + + + 4.0.0 + + test + aggregator + 0.1-SNAPSHOT + pom + + + ../module-a + ../module-b/pom.xml + + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/module-a/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/module-a/pom.xml new file mode 100644 index 000000000..05b90a7ce --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/module-a/pom.xml @@ -0,0 +1,39 @@ + + + + + + 4.0.0 + + + test + parent + 0.1-SNAPSHOT + ../parent + + + module-a + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/module-b/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/module-b/pom.xml new file mode 100644 index 000000000..73f423c81 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/module-b/pom.xml @@ -0,0 +1,39 @@ + + + + + + 4.0.0 + + + test + parent + 0.1-SNAPSHOT + ../parent + + + module-b + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/parent/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/parent/pom.xml new file mode 100644 index 000000000..ef023f12a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/src/it/parent/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + parent + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/verify.bsh new file mode 100644 index 000000000..22358c9fd --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning-reactor/verify.bsh @@ -0,0 +1,32 @@ +/* + * 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 java.util.regex.*; + +// sanity check to make sure the builds were actually run +File itDir = new File( basedir, "target/it" ); +System.out.println( "Checking for existence of clones: " + itDir ); +if ( !itDir.exists() ) +{ + throw new FileNotFoundException( "Missing IT directory: " + itDir ); +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/pom.xml new file mode 100644 index 000000000..1b7e9081c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + project-cloning + 1.0-SNAPSHOT + pom + + Test to check for proper project cloning + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it + + **/pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning/setup.bsh b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/setup.bsh new file mode 100644 index 000000000..ca4c31a51 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/setup.bsh @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +try +{ + File emptyDir = new File( basedir, "src/it/module-1/empty-dir" ); + emptyDir.mkdirs(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module-1/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module-1/pom.xml new file mode 100644 index 000000000..5badb327b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module-1/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + org.apache.maven.test + unit + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module-1/sub-module/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module-1/sub-module/pom.xml new file mode 100644 index 000000000..5badb327b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module-1/sub-module/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + org.apache.maven.test + unit + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module/pom.xml new file mode 100644 index 000000000..5badb327b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/src/it/module/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + org.apache.maven.test + unit + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-cloning/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/verify.bsh new file mode 100644 index 000000000..63b495a53 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-cloning/verify.bsh @@ -0,0 +1,59 @@ +/* + * 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 java.util.regex.*; + +try +{ + File itDir = new File( basedir, "target/it" ); + if ( !itDir.isDirectory() ) + { + System.out.println( "IT directory not existent: " + itDir ); + return false; + } + + // NOTE: It is part of the test design that "module" is a prefix of "module-1" + String[] paths = { + "module", + "module/pom.xml", + "module-1", + "module-1/pom.xml", + "module-1/empty-dir", + "module-1/sub-module", + "module-1/sub-module/pom.xml", + }; + for ( String path : paths ) + { + File file = new File( itDir, path ); + if ( !file.exists() ) + { + System.out.println( "Cloned file/directory not existent: " + file ); + return false; + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-setup/pom.xml new file mode 100644 index 000000000..0922bba0d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + project-setup + 1.0-SNAPSHOT + pom + + Test to check that setup projects are run ahead of the other ones. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it + + project3 + project6 + + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project1/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project1/invoker.properties new file mode 100644 index 000000000..d81ec8ff8 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project1/invoker.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. + +invoker.name = Foo +invoker.description = good foo diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project1/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project1/pom.xml new file mode 100644 index 000000000..f01b9156e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project1/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + project1 + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project2/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project2/pom.xml new file mode 100644 index 000000000..a747a1ee2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project2/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + project2 + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project3/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project3/invoker.properties new file mode 100644 index 000000000..be57c2e4c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project3/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.ordinal=100 diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project3/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project3/pom.xml new file mode 100644 index 000000000..d1090ccce --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project3/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + project3 + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project4/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project4/pom.xml new file mode 100644 index 000000000..f5735d02c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project4/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + project4 + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project5/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project5/pom.xml new file mode 100644 index 000000000..cc725c8d1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project5/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + project5 + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project6/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project6/invoker.properties new file mode 100644 index 000000000..081215ba3 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project6/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.ordinal=2 diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project6/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project6/pom.xml new file mode 100644 index 000000000..4be587409 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/src/it/project6/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + project6 + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/project-setup/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/project-setup/verify.bsh new file mode 100644 index 000000000..59a985d48 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/project-setup/verify.bsh @@ -0,0 +1,88 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; + +try +{ + File logFile = new File( basedir, "build.log" ); + System.out.println( "Checking for existence of build log: " + logFile ); + if ( !logFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String log = FileUtils.fileRead( logFile ); + + System.out.println( "Checking for first build" ); + int index = log.indexOf( "Building: project" ); + if ( !log.substring( index, index + 18 ).equals( "Building: project3" ) ) + { + System.out.println( "FAILED!\n" + log.substring( index, index + 18 ) ); + return false; + } + + System.out.println( "Checking for duplicate build" ); + index = log.indexOf( "Building: project3", index + 1 ); + if ( index >= 0 ) + { + System.out.println( "FAILED!" ); + return false; + } + + int indexProject3 = log.indexOf( "Building: project3" ); + int indexProject6 = log.indexOf( "Building: project6" ); + if(indexProject3 > indexProject6) + { + System.out.println( "FAILED! project3 should be build before project6" ); + return false; + } + + File reportFile = new File( basedir, "target/invoker-reports/BUILD-project1.xml" ); + if ( !reportFile.exists() ) + { + System.out.println( "reportFile not exists FAILED!" ); + return false; + } + String report = FileUtils.fileRead( reportFile, "UTF-8" ); + index = report.indexOf("name=\"Foo\""); + if ( index < 0 ) + { + System.out.println( "name missing in the report FAILED!" ); + return false; + } + index = report.indexOf("description=\"good foo\""); + if ( index < 0 ) + { + System.out.println( "description missing in the report FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/invoker.properties new file mode 100644 index 000000000..0659ac55b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/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 = compile diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/pom.xml new file mode 100644 index 000000000..808cf00e0 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + script-accessibility + 1.0-SNAPSHOT + jar + + + Test to check for accessibility of non-public fields/methods in hook scripts. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + + */pom.xml + + setup + verify + + validate + + true + + + + integration-test + compile + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/beanshell/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/beanshell/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/beanshell/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/beanshell/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/beanshell/verify.bsh new file mode 100644 index 000000000..7dede1931 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/beanshell/verify.bsh @@ -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. + */ + +import org.MyClass; + +System.out.println( MyClass.PUBLIC ); +System.out.println( MyClass.PROTECTED ); +System.out.println( MyClass.PACKAGE ); +System.out.println( MyClass.PRIVATE ); diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/groovy/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/groovy/pom.xml new file mode 100644 index 000000000..b1ba49ede --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/groovy/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + groovy + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/groovy/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/groovy/verify.groovy new file mode 100644 index 000000000..9cfcac93b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/it/groovy/verify.groovy @@ -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. + */ + +import org.MyClass; + +println MyClass.PUBLIC +println MyClass.PROTECTED +println MyClass.PACKAGE +println MyClass.PRIVATE diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/main/java/org/MyClass.java b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/main/java/org/MyClass.java new file mode 100644 index 000000000..010ec3434 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-accessibility/src/main/java/org/MyClass.java @@ -0,0 +1,34 @@ +package org; + +/* + * 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. + */ + + +public class MyClass +{ + + public static final String PUBLIC = "public"; + + protected static final String PROTECTED = "protected"; + + static final String PACKAGE = "package"; + + private static final String PRIVATE = "private"; + +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/pom.xml new file mode 100644 index 000000000..fbafe4feb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + script-additional-vars + 1.0-SNAPSHOT + pom + + + Test to check for usage of additional hook script variables. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + + */pom.xml + + + world + ${project.version} + + + validate + + + + + integration-test + initialize + + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/postbuild.bsh new file mode 100644 index 000000000..87a5c1383 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/postbuild.bsh @@ -0,0 +1,43 @@ +/* + * 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.*; + +try +{ + System.out.println( hello ); + if ( !hello.equals( "world" ) ) + { + System.out.println( "Additional script variable declared in mojo configuration not defined: hello" ); + return false; + } + + System.out.println( version ); + if ( !version.equals( "1.0-SNAPSHOT" ) ) + { + System.out.println( "Additional script variable declared in mojo configuration not defined: version" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/prebuild.bsh new file mode 100644 index 000000000..87a5c1383 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/prebuild.bsh @@ -0,0 +1,43 @@ +/* + * 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.*; + +try +{ + System.out.println( hello ); + if ( !hello.equals( "world" ) ) + { + System.out.println( "Additional script variable declared in mojo configuration not defined: hello" ); + return false; + } + + System.out.println( version ); + if ( !version.equals( "1.0-SNAPSHOT" ) ) + { + System.out.println( "Additional script variable declared in mojo configuration not defined: version" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/selector.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/selector.bsh new file mode 100644 index 000000000..4feb153ae --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/beanshell/selector.bsh @@ -0,0 +1,41 @@ +/* + * 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.*; + +try +{ + System.out.println( hello ); + if ( !hello.equals( "world" ) ) + { + throw new Exception( "Additional script variable declared in mojo configuration not defined: hello" ); + } + + System.out.println( version ); + if ( !version.equals( "1.0-SNAPSHOT" ) ) + { + throw new Exception( "Additional script variable declared in mojo configuration not defined: version" ); + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + throw t; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/postbuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/postbuild.groovy new file mode 100644 index 000000000..cdef4bc70 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/postbuild.groovy @@ -0,0 +1,43 @@ +/* + * 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.* + +try +{ + println hello + if ( !hello.equals( "world" ) ) + { + println "Additional script variable declared in mojo configuration not defined: hello" + return false + } + + println version + if ( !version.equals( "1.0-SNAPSHOT" ) ) + { + println "Additional script variable declared in mojo configuration not defined: version" + return false + } +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/prebuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/prebuild.groovy new file mode 100644 index 000000000..cdef4bc70 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/prebuild.groovy @@ -0,0 +1,43 @@ +/* + * 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.* + +try +{ + println hello + if ( !hello.equals( "world" ) ) + { + println "Additional script variable declared in mojo configuration not defined: hello" + return false + } + + println version + if ( !version.equals( "1.0-SNAPSHOT" ) ) + { + println "Additional script variable declared in mojo configuration not defined: version" + return false + } +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/selector.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/selector.groovy new file mode 100644 index 000000000..5ae43b31d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-additional-vars/src/it/groovy/selector.groovy @@ -0,0 +1,41 @@ +/* + * 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.* + +try +{ + println hello + if ( !hello.equals( "world" ) ) + { + throw new Exception( "Additional script variable declared in mojo configuration not defined: hello" ) + } + + println version + if ( !version.equals( "1.0-SNAPSHOT" ) ) + { + throw new Exception( "Additional script variable declared in mojo configuration not defined: version" ) + } +} +catch( Throwable t ) +{ + t.printStackTrace() + throw t +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/invoker.properties new file mode 100644 index 000000000..70fab92e1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/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 = test-compile diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/pom.xml new file mode 100644 index 000000000..d3c3c11c5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/pom.xml @@ -0,0 +1,77 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + script-class-loading + 1.0-SNAPSHOT + jar + + Test to check for proper class loading in hook scripts (i.e. project test class path before plugin class path) + + + UTF-8 + + + + + org.codehaus.plexus + plexus-utils + + 1.1 + test + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + + */pom.xml + + prebuild + postbuild + + validate + + true + + + + integration-test + test-compile + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/postbuild.bsh new file mode 100644 index 000000000..08415b33b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/postbuild.bsh @@ -0,0 +1,50 @@ +/* + * 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.lang.reflect.*; +import java.util.*; +import java.util.regex.*; + +import org.codehaus.plexus.util.*; + +try +{ + System.out.println( "Invoking class from project's test class path" ); + System.out.println( org.MyUtils.getNothing() ); + + System.out.println( "Trying to access method which is unavaible in old plexus-utils" ); + try + { + System.out.println( FileUtils.class.getMethod( "copyFileIfModified", new Class[] { File.class, File.class } ) ); + System.out.println( "FAILED!" ); + return false; + } + catch( NoSuchMethodException e ) + { + // expected + e.printStackTrace(); + } + +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/prebuild.bsh new file mode 100644 index 000000000..08415b33b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/beanshell/prebuild.bsh @@ -0,0 +1,50 @@ +/* + * 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.lang.reflect.*; +import java.util.*; +import java.util.regex.*; + +import org.codehaus.plexus.util.*; + +try +{ + System.out.println( "Invoking class from project's test class path" ); + System.out.println( org.MyUtils.getNothing() ); + + System.out.println( "Trying to access method which is unavaible in old plexus-utils" ); + try + { + System.out.println( FileUtils.class.getMethod( "copyFileIfModified", new Class[] { File.class, File.class } ) ); + System.out.println( "FAILED!" ); + return false; + } + catch( NoSuchMethodException e ) + { + // expected + e.printStackTrace(); + } + +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/pom.xml new file mode 100644 index 000000000..b1ba49ede --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + groovy + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/postbuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/postbuild.groovy new file mode 100644 index 000000000..b25d789d6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/postbuild.groovy @@ -0,0 +1,51 @@ +/* + * 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.lang.reflect.* +import java.util.* +import java.util.regex.* + +import org.codehaus.plexus.util.* + +try +{ + println "Invoking class from project's test class path" + println org.MyUtils.getNothing() + + println "Trying to access method which is unavaible in old plexus-utils" + try + { + Class[] types = [ File.class, File.class ]; + println FileUtils.class.getMethod( "copyFileIfModified", types ) + println "FAILED!" + return false + } + catch( NoSuchMethodException e ) + { + // expected + e.printStackTrace() + } + +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/prebuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/prebuild.groovy new file mode 100644 index 000000000..b25d789d6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/it/groovy/prebuild.groovy @@ -0,0 +1,51 @@ +/* + * 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.lang.reflect.* +import java.util.* +import java.util.regex.* + +import org.codehaus.plexus.util.* + +try +{ + println "Invoking class from project's test class path" + println org.MyUtils.getNothing() + + println "Trying to access method which is unavaible in old plexus-utils" + try + { + Class[] types = [ File.class, File.class ]; + println FileUtils.class.getMethod( "copyFileIfModified", types ) + println "FAILED!" + return false + } + catch( NoSuchMethodException e ) + { + // expected + e.printStackTrace() + } + +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/test/java/org/MyUtils.java b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/test/java/org/MyUtils.java new file mode 100644 index 000000000..14364b2c7 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-class-loading/src/test/java/org/MyUtils.java @@ -0,0 +1,31 @@ +package org; + +/* + * 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. + */ + + +public class MyUtils +{ + + public static String getNothing() + { + return "nothing"; + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/pom.xml new file mode 100644 index 000000000..3ae925029 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/pom.xml @@ -0,0 +1,81 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + script-classpath-duplicates + 1.0-SNAPSHOT + pom + + Test to check that script classpath entries duplicated between ${project.testClasspathElements} and ${plugin.artifacts} are removed + + + UTF-8 + + + + + @beanshell-groupId@ + @beanshell-artifactId@ + @beanshell-version@ + test + + + @groovy-groupId@ + @groovy-artifactId@ + @groovy-version@ + test + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + true + ${project.build.directory}/it + + * + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/postbuild.bsh new file mode 100644 index 000000000..c7acb758b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/postbuild.bsh @@ -0,0 +1,39 @@ +/* + * 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.lang.reflect.*; +import java.util.*; +import java.util.regex.*; + +try +{ + // create touch file so that the parent build can verify whether this script was called + File touchFile = new File( basedir, "target/created-by-postbuild.bsh" ); + System.out.println( "Creating touch file: " + touchFile ); + touchFile.getParentFile().mkdirs(); + touchFile.createNewFile(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/prebuild.bsh new file mode 100644 index 000000000..0c679ab56 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/beanshell/prebuild.bsh @@ -0,0 +1,39 @@ +/* + * 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.lang.reflect.*; +import java.util.*; +import java.util.regex.*; + +try +{ + // create touch file so that the parent build can verify whether this script was called + File touchFile = new File( basedir, "target/created-by-prebuild.bsh" ); + System.out.println( "Creating touch file: " + touchFile ); + touchFile.getParentFile().mkdirs(); + touchFile.createNewFile(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/pom.xml new file mode 100644 index 000000000..b1ba49ede --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + groovy + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/postbuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/postbuild.groovy new file mode 100644 index 000000000..d9fc6d8e5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/postbuild.groovy @@ -0,0 +1,39 @@ +/* + * 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.lang.reflect.* +import java.util.* +import java.util.regex.* + +try +{ + // create touch file so that the parent build can verify whether this script was called + File touchFile = new File( basedir, "target/created-by-postbuild.groovy" ) + println "Creating touch file: " + touchFile + touchFile.getParentFile().mkdirs() + touchFile.createNewFile() +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} + +return true diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/prebuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/prebuild.groovy new file mode 100644 index 000000000..677737751 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/src/it/groovy/prebuild.groovy @@ -0,0 +1,39 @@ +/* + * 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.lang.reflect.* +import java.util.* +import java.util.regex.* + +try +{ + // create touch file so that the parent build can verify whether this script was called + File touchFile = new File( basedir, "target/created-by-prebuild.groovy" ) + println "Creating touch file: " + touchFile + touchFile.getParentFile().mkdirs() + touchFile.createNewFile() +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} + +return true diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/verify.bsh new file mode 100644 index 000000000..e7a35e5d4 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-classpath-duplicates/verify.bsh @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +try +{ + String[] files = { + "target/it/beanshell/target/created-by-prebuild.bsh", + "target/it/beanshell/target/created-by-postbuild.bsh", + "target/it/groovy/target/created-by-prebuild.groovy", + "target/it/groovy/target/created-by-postbuild.groovy", + }; + for ( String file : files ) + { + File touchFile = new File( basedir, file ); + System.out.println( "Checking for existence of: " + touchFile ); + if ( !touchFile.isFile() ) + { + System.out.println( "FAILED!" ); + return false; + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-context/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-context/pom.xml new file mode 100644 index 000000000..6d35a68c6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-context/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + script-context + 1.0-SNAPSHOT + pom + + + Test that the hook scripts can share information via a map in the global variable "context" (MINVOKER-79). + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/its + + */pom.xml + + setup + verify + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/setup.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/setup.bsh new file mode 100644 index 000000000..572328ce2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/setup.bsh @@ -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. + */ + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +context.put( "touchFile", new File( basedir, "touch.txt" ) ); + +System.out.println( context ); diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/verify.bsh new file mode 100644 index 000000000..452ac9ae9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/beanshell/verify.bsh @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +System.out.println( context ); + +File touchFile = context.get( "touchFile" ); +touchFile.createNewFile(); + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/pom.xml new file mode 100644 index 000000000..b1ba49ede --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + groovy + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/setup.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/setup.groovy new file mode 100644 index 000000000..945674998 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/setup.groovy @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.* +import java.util.* +import java.util.regex.* + +context.put( "touchFile", new File( basedir, "touch.txt" ) ) + +println context diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/verify.groovy new file mode 100644 index 000000000..d11c416c3 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-context/src/it/groovy/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. + */ + +import java.io.* +import java.util.* +import java.util.regex.* + +println context + +File touchFile = context.get( "touchFile" ) +touchFile.createNewFile() + +return true diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-context/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-context/verify.bsh new file mode 100644 index 000000000..c4c51498c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-context/verify.bsh @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +File touchFile; + +touchFile = new File( basedir, "target/its/beanshell/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +if ( !touchFile.exists() ) +{ + throw new FileNotFoundException( "Did not find marker file: " + touchFile ); +} + +touchFile = new File( basedir, "target/its/groovy/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +if ( !touchFile.exists() ) +{ + throw new FileNotFoundException( "Did not find marker file: " + touchFile ); +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-errors/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-errors/pom.xml new file mode 100644 index 000000000..3d600d43b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-errors/pom.xml @@ -0,0 +1,71 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + script-errors + 1.0-SNAPSHOT + pom + + + Test to check that any kind of error from the script, i.e. both java.lang.Exception and java.lang.Error, + is caught by the interpreter facade and does not go up to the main build (MINVOKER-78). + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + ${project.build.directory}/its + + */pom.xml + + setup + verify + + validate + + true + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/beanshell/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/beanshell/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/beanshell/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/beanshell/setup.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/beanshell/setup.bsh new file mode 100644 index 000000000..59f8a6d11 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/beanshell/setup.bsh @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ); +touchFile.createNewFile(); + +// BeanShell does not allow us to simply throw an error, so will we try to trigger an OutOfMemoryError... +long[] arr = new long[ Integer.MAX_VALUE ]; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/groovy/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/groovy/pom.xml new file mode 100644 index 000000000..b1ba49ede --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/groovy/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + groovy + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/groovy/setup.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/groovy/setup.groovy new file mode 100644 index 000000000..7ab7535c1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-errors/src/it/groovy/setup.groovy @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ) +touchFile.createNewFile() + +if ( true ) throw new AssertionError( "This should not cause the main build to fail" ) + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-errors/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-errors/verify.bsh new file mode 100644 index 000000000..81ac2c8e1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-errors/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +// make sure the Invoker Plugin was indeed run and the build didn't fail somewhere else +File touchFile; + +touchFile = new File( basedir, "target/its/beanshell/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +if ( !touchFile.exists() ) +{ + throw new FileNotFoundException( "Did not find marker file: " + touchFile ); +} + +touchFile = new File( basedir, "target/its/groovy/touch.txt" ); +System.out.println( "Checking for existence of touch file: " + touchFile ); +if ( !touchFile.exists() ) +{ + throw new FileNotFoundException( "Did not find marker file: " + touchFile ); +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/pom.xml new file mode 100644 index 000000000..585b5b1bc --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/pom.xml @@ -0,0 +1,67 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + script-global-vars + 1.0-SNAPSHOT + pom + + + Test to check for existence of supported global script variables. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + + */pom.xml + + setup + verify + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/setup.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/setup.bsh new file mode 100644 index 000000000..2106fcca7 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/setup.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.*; +import java.util.regex.*; + +try +{ + System.out.println( basedir ); + if ( !( basedir instanceof File ) ) + { + System.out.println( "Global script variable not defined: basedir" ); + return false; + } + + System.out.println( localRepositoryPath ); + if ( !( localRepositoryPath instanceof File ) ) + { + System.out.println( "Global script variable not defined: localRepositoryPath" ); + return false; + } + + System.out.println( mavenVersion ); + if ( mavenVersion == null ) + { + System.out.println( "Global script variable not defined: mavenVersion" ); + return false; + } + if ( mavenVersion.trim().equals( "" ) ) + { + System.out.println( "Global script variable empty: mavenVersion" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/verify.bsh new file mode 100644 index 000000000..2106fcca7 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/beanshell/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.*; +import java.util.regex.*; + +try +{ + System.out.println( basedir ); + if ( !( basedir instanceof File ) ) + { + System.out.println( "Global script variable not defined: basedir" ); + return false; + } + + System.out.println( localRepositoryPath ); + if ( !( localRepositoryPath instanceof File ) ) + { + System.out.println( "Global script variable not defined: localRepositoryPath" ); + return false; + } + + System.out.println( mavenVersion ); + if ( mavenVersion == null ) + { + System.out.println( "Global script variable not defined: mavenVersion" ); + return false; + } + if ( mavenVersion.trim().equals( "" ) ) + { + System.out.println( "Global script variable empty: mavenVersion" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/pom.xml new file mode 100644 index 000000000..b1ba49ede --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + groovy + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/setup.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/setup.groovy new file mode 100644 index 000000000..d7c3171dd --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/setup.groovy @@ -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.* +import java.util.regex.* + +try +{ + println basedir + if ( !( basedir instanceof File ) ) + { + println "Global script variable not defined: basedir" + return false + } + + println localRepositoryPath + if ( !( localRepositoryPath instanceof File ) ) + { + println "Global script variable not defined: localRepositoryPath" + return false + } + + println mavenVersion + if ( !mavenVersion ) + { + println "Global script variable not defined: mavenVersion" + return false + } + if ( !mavenVersion?.trim() ) + { + println "Global script variable empty: mavenVersion" + return false + } +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/verify.groovy new file mode 100644 index 000000000..d7c3171dd --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-global-vars/src/it/groovy/verify.groovy @@ -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.* +import java.util.regex.* + +try +{ + println basedir + if ( !( basedir instanceof File ) ) + { + println "Global script variable not defined: basedir" + return false + } + + println localRepositoryPath + if ( !( localRepositoryPath instanceof File ) ) + { + println "Global script variable not defined: localRepositoryPath" + return false + } + + println mavenVersion + if ( !mavenVersion ) + { + println "Global script variable not defined: mavenVersion" + return false + } + if ( !mavenVersion?.trim() ) + { + println "Global script variable empty: mavenVersion" + return false + } +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/pom.xml new file mode 100644 index 000000000..b5d5ee1e2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/pom.xml @@ -0,0 +1,67 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + script-interpreter-detection + 1.0-SNAPSHOT + jar + + Test to check for detection of script interpreter from file extension. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/its + true + + */pom.xml + + prebuild + postbuild + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/pom.xml new file mode 100644 index 000000000..f8a5c6aeb --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + beanshell + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/postbuild.bsh new file mode 100644 index 000000000..be542798f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/postbuild.bsh @@ -0,0 +1,39 @@ +/* + * 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.lang.reflect.*; +import java.util.*; +import java.util.regex.*; + +try +{ + // create touch file so that the parent build can verify whether this script was called + File touchFile = new File( basedir, "target/postbuild.bsh" ); + System.out.println( "Creating touch file: " + touchFile ); + touchFile.getParentFile().mkdirs(); + touchFile.createNewFile(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/prebuild.bsh new file mode 100644 index 000000000..4b687a6b1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/beanshell/prebuild.bsh @@ -0,0 +1,39 @@ +/* + * 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.lang.reflect.*; +import java.util.*; +import java.util.regex.*; + +try +{ + // create touch file so that the parent build can verify whether this script was called + File touchFile = new File( basedir, "target/prebuild.bsh" ); + System.out.println( "Creating touch file: " + touchFile ); + touchFile.getParentFile().mkdirs(); + touchFile.createNewFile(); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/pom.xml new file mode 100644 index 000000000..b1ba49ede --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + groovy + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/postbuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/postbuild.groovy new file mode 100644 index 000000000..d4e1c69ef --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/postbuild.groovy @@ -0,0 +1,39 @@ +/* + * 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.lang.reflect.* +import java.util.* +import java.util.regex.* + +try +{ + // create touch file so that the parent build can verify whether this script was called + File touchFile = new File( basedir, "target/postbuild.groovy" ) + println "Creating touch file: " + touchFile + touchFile.getParentFile().mkdirs() + touchFile.createNewFile() +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} + +return true diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/prebuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/prebuild.groovy new file mode 100644 index 000000000..5b3ba9ce6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/src/it/groovy/prebuild.groovy @@ -0,0 +1,39 @@ +/* + * 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.lang.reflect.* +import java.util.* +import java.util.regex.* + +try +{ + // create touch file so that the parent build can verify whether this script was called + File touchFile = new File( basedir, "target/prebuild.groovy" ) + println "Creating touch file: " + touchFile + touchFile.getParentFile().mkdirs() + touchFile.createNewFile() +} +catch( Throwable t ) +{ + t.printStackTrace() + return false +} + +return true diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/verify.bsh new file mode 100644 index 000000000..8baef9fca --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-interpreter-detection/verify.bsh @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.*; +import java.util.*; +import java.util.regex.*; + +try +{ + String[] files = { + "target/its/beanshell/target/prebuild.bsh", + "target/its/beanshell/target/postbuild.bsh", + "target/its/groovy/target/prebuild.groovy", + "target/its/groovy/target/postbuild.groovy", + }; + for ( String file : files ) + { + File touchFile = new File( basedir, file ); + System.out.println( "Checking for existence of: " + touchFile ); + if ( !touchFile.isFile() ) + { + System.out.println( "FAILED!" ); + return false; + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/pom.xml new file mode 100644 index 000000000..db94d2996 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/pom.xml @@ -0,0 +1,61 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + script-verify-xml + 1.0-SNAPSHOT + pom + + Test if the XmlSlurper is still on the classpath. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + + validate + + + + + integration-test + initialize + + verify + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/src/it/minvoker-138/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/src/it/minvoker-138/pom.xml new file mode 100644 index 000000000..634dc5e23 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/src/it/minvoker-138/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-138 + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/verify.groovy new file mode 100644 index 000000000..c1409bf6c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/script-verify-xml/verify.groovy @@ -0,0 +1,67 @@ +/* + * 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. + */ + +// from http://groovy-lang.org/processing-xml.html +// A lot of examples covering xml assertions + +class XmlExamples { + static def CAR_RECORDS = ''' + + + Australia + Production Pickup Truck with speed of 271kph + + + Isle of Man + Smallest Street-Legal Car at 99cm wide and 59 kg in weight + + + France + Most Valuable Car at $15 million + + + ''' +} +def records = new XmlSlurper().parseText(XmlExamples.CAR_RECORDS) +def allRecords = records.car +assert 3 == allRecords.size() +def allNodes = records.depthFirst().collect{ it } +assert 10 == allNodes.size() +def firstRecord = records.car[0] +assert 'car' == firstRecord.name() +assert 'Holden' == firstRecord.@make.text() +assert 'Australia' == firstRecord.country.text() +def carsWith_e_InMake = records.car.findAll{ it.@make.text().contains('e') } +assert carsWith_e_InMake.size() == 2 +// alternative way to find cars with 'e' in make +assert 2 == records.car.findAll{ it.@make =~ '.*e.*' }.size() +// makes of cars that have an 's' followed by an 'a' in the country +assert ['Holden', 'Peel'] == records.car.findAll{ it.country =~ '.*s.*a.*' }.@make.collect{ it.text() } +def expectedRecordTypes = ['speed', 'size', 'price'] +assert expectedRecordTypes == records.depthFirst().grep{ it.@type != '' }.'@type'*.text() +assert expectedRecordTypes == records.'**'.grep{ it.@type != '' }.'@type'*.text() +def countryOne = records.car[1].country +assert 'Peel' == countryOne.parent().@make.text() +assert 'Peel' == countryOne.'..'.@make.text() +// names of cars with records sorted by year +def sortedNames = records.car.list().sort{ it.@year.toInteger() }.'@name'*.text() +assert ['Royale', 'P50', 'HSV Maloo'] == sortedNames +assert ['Australia', 'Isle of Man'] == records.'**'.grep{ it.@type =~ 's.*' }*.parent().country*.text() +assert 'co-re-co-re-co-re' == records.car.children().collect{ it.name()[0..1] }.join('-') +assert 'co-re-co-re-co-re' == records.car.'*'.collect{ it.name()[0..1] }.join('-') diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/pom.xml new file mode 100644 index 000000000..c73a245be --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/pom.xml @@ -0,0 +1,67 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + selector-conditions + 1.0-SNAPSHOT + maven-plugin + + Test to check for selection of builds based on OS and/or JRE. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + true + + + */pom.xml + + prebuild + postbuild + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/invoker.properties new file mode 100644 index 000000000..4156517ee --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/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.java.version = 1.4-, 1.4, 1.5+ diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-match/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/invoker.properties new file mode 100644 index 000000000..fff42af24 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/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.java.version = 1.2 diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/jre-version-mismatch/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/invoker.properties new file mode 100644 index 000000000..cd7465e1e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/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.maven.version = 2.0+ diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-match/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/invoker.properties new file mode 100644 index 000000000..8e0939639 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/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.maven.version = 1.2 diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/maven-version-mismatch/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/invoker.properties new file mode 100644 index 000000000..7b53a3b7c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/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.os.family = !nowhere diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-match/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/invoker.properties new file mode 100644 index 000000000..d25f3a4cc --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/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.os.family = nowhere diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/os-family-mismatch/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/invoker.properties new file mode 100644 index 000000000..b22a42507 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/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.toolchain.jdk.vendor = mycomp diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/src/it/toolchain-mismatch/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/verify.groovy new file mode 100644 index 000000000..68eb51e86 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-conditions/verify.groovy @@ -0,0 +1,38 @@ +/* + * 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 FS = System.getProperty('file.separator') + +assert new File(basedir, 'target/its/jre-version-match/build.log').exists() +assert !(new File(basedir, 'target/its/jre-version-mismatch/build.log').exists()) +assert new File(basedir, 'target/its/maven-version-match/build.log').exists() +assert !(new File(basedir, 'target/its/maven-version-mismatch/build.log').exists()) +assert new File(basedir, 'target/its/os-family-match/build.log').exists() +assert !(new File(basedir, 'target/its/os-family-mismatch/build.log').exists()) +assert !(new File(basedir, 'target/its/toolchain-mismatch/build.log').exists()) + +def log = new File( basedir, 'build.log').text + +assert log.contains("jre-version-match${FS}pom.xml ........................ SUCCESS") +assert log.contains("jre-version-mismatch${FS}pom.xml ..................... SKIPPED due to JRE version") +assert log.contains("maven-version-match${FS}pom.xml ...................... SUCCESS") +assert log.contains("maven-version-mismatch${FS}pom.xml ................... SKIPPED due to Maven version") +assert log.contains("os-family-match${FS}pom.xml .......................... SUCCESS") +assert log.contains("os-family-mismatch${FS}pom.xml ....................... SKIPPED due to OS") +assert log.contains("toolchain-mismatch${FS}pom.xml ....................... SKIPPED due to Toolchain") \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/pom.xml new file mode 100644 index 000000000..c3be520d8 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + selector-scripts + 1.0-SNAPSHOT + jar + + Test to check for selection of builds based on scripted conditions. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/its + true + + */pom.xml + + selector + true + postbuild + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/setup.groovy b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/setup.groovy new file mode 100644 index 000000000..ac7811587 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/setup.groovy @@ -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. + */ + +import org.apache.commons.io.FileUtils + +// Previous potential target 'content' has impact on IT execution +// (Some new file should be created by verify.sh) +FileUtils.deleteQuietly( new File( basedir, "target/invoker-reports" ) ); +FileUtils.deleteQuietly( new File( basedir, "src/it/script-ret-quiet/target" ) ); +FileUtils.deleteQuietly( new File( basedir, "src/it/script-ret-true/target" ) ); +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/selector.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/selector.bsh new file mode 100644 index 000000000..6244a5179 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-false/selector.bsh @@ -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. + */ + +import java.io.*; + +return false; diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/selector.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/selector.bsh new file mode 100644 index 000000000..7c7b48730 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-other/selector.bsh @@ -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. + */ + +import java.io.*; + +return "Some thing"; diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/selector.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/selector.bsh new file mode 100644 index 000000000..d239ceaaa --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-quiet/selector.bsh @@ -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. + */ + +import java.io.*; + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/postbuild.bsh new file mode 100644 index 000000000..feffcae60 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/selector.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/selector.bsh new file mode 100644 index 000000000..5c1254a96 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-ret-true/selector.bsh @@ -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. + */ + +import java.io.*; + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/pom.xml new file mode 100644 index 000000000..ea5c00f33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + test + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/postbuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/postbuild.bsh new file mode 100644 index 000000000..d2e394e1d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/postbuild.bsh @@ -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. + */ + +import java.io.*; + +// create touch file so that the parent build can verify whether this build was executed +File touchFile = new File( basedir, "target/touch.txt" ); +System.out.println( "Creating touch file: " + touchFile ); +touchFile.getParentFile().mkdirs(); +touchFile.createNewFile(); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/selector.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/selector.bsh new file mode 100644 index 000000000..9ee8f9fd2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/src/it/script-throw/selector.bsh @@ -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. + */ + +import java.io.*; + +throw new NullPointerException( "Bite me" ); diff --git a/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/verify.bsh new file mode 100644 index 000000000..422b5d926 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/selector-scripts/verify.bsh @@ -0,0 +1,115 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; + +try +{ + String[] expected = { + "target/its/script-ret-true/target/touch.txt", + "target/its/script-ret-quiet/target/touch.txt", + }; + for ( String file : expected ) + { + File touchFile = new File( basedir, file ); + System.out.println( "Checking for existence of: " + touchFile ); + if ( !touchFile.isFile() ) + { + System.out.println( "FAILED!" ); + return false; + } + } + + String[] unexpected = { + "target/its/script-ret-false/target/touch.txt", + "target/its/script-ret-other/target/touch.txt", + "target/its/script-throws/target/touch.txt", + }; + for ( String file : unexpected ) + { + File touchFile = new File( basedir, file ); + System.out.println( "Checking for absence of: " + touchFile ); + if ( touchFile.exists() ) + { + System.out.println( file + " should not be here -> FAILED!" ); + return false; + } + } + + String[] success = { + "target/invoker-reports/BUILD-script-ret-true.xml", + "target/invoker-reports/BUILD-script-ret-quiet.xml", + }; + for ( String file : success ) + { + File resultFile = new File( basedir, file ); + System.out.println( "Checking build result: " + resultFile ); + String xml = FileUtils.fileRead( resultFile, "UTF-8" ); + if ( xml.indexOf("result=\"success\"") < 0 && xml.indexOf("result='success'") < 0 ) + { + System.out.println( resultFile + " not success -> FAILED!" ); + return false; + } + } + + String[] skipped = { + "target/invoker-reports/BUILD-script-ret-false.xml", + "target/invoker-reports/BUILD-script-ret-other.xml", + }; + for ( String file : skipped ) + { + File resultFile = new File( basedir, file ); + System.out.println( "Checking build result: " + resultFile ); + String xml = FileUtils.fileRead( resultFile, "UTF-8" ); + if ( xml.indexOf("result=\"skipped\"") < 0 && xml.indexOf("result='skipped'") < 0 ) + { + System.out.println( resultFile + " not skipped -> FAILED!" ); + return false; + } + } + + + String[] inerror = { + "target/invoker-reports/BUILD-script-throw.xml", + }; + for ( String file : inerror ) + { + File resultFile = new File( basedir, file ); + System.out.println( "Checking build result: " + resultFile ); + String xml = FileUtils.fileRead( resultFile, "UTF-8" ); + if ( xml.indexOf("result=\"error\"") < 0 && xml.indexOf("result='error'") < 0 ) + { + System.out.println( resultFile + " not failed -> FAILED!" ); + return false; + } + } + + +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/pom.xml new file mode 100644 index 000000000..c3491c687 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/pom.xml @@ -0,0 +1,74 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + settings-auto-exclude + 1.0-SNAPSHOT + pom + + + Test to check that the custom settings.xml is automatically excluded from the project scanner. This is a convenience + feature to support the following common directory layout + src/it/ + project1/ + project2/ + settings.xml + in combination with the POM include pattern "*" required to select POM-less directories. Without excluding settings.xml, + it would be considered a POM and cause a build failure. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + + + * + + src/it/settings.xml + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/src/it/project/pom.xml new file mode 100644 index 000000000..dfa58edf5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/src/it/project/pom.xml @@ -0,0 +1,32 @@ + + + + + + 4.0.0 + test + project + 0.1-SNAPSHOT + pom + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/src/it/settings.xml new file mode 100644 index 000000000..79c5dc163 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-auto-exclude/src/it/settings.xml @@ -0,0 +1,55 @@ + + + + + + + + it-repo + + true + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + local.central + file://@localRepository@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/invoker.properties new file mode 100644 index 000000000..08b641652 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/invoker.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. + +# See https://issues.apache.org/jira/browse/MNG-5224 +invoker.maven.version = 3.0-,3.0.4+ diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/pom.xml new file mode 100644 index 000000000..068063d1b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/pom.xml @@ -0,0 +1,63 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + settings-inherit + 1.0-SNAPSHOT + pom + + Test to check that the settings.xml from the calling process is inherited. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + true + true + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/src/it/project/pom.xml new file mode 100644 index 000000000..a367a642c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-inherit/src/it/project/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + test + project + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.0.1 + + + enforce-property + + enforce + + + + + it.settings-inherit + Property not present - settings.xml from calling process not inherited! + (exists)$ + + + true + + + ${https.protocols} + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/invoker.properties new file mode 100644 index 000000000..08b641652 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/invoker.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. + +# See https://issues.apache.org/jira/browse/MNG-5224 +invoker.maven.version = 3.0-,3.0.4+ diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/pom.xml new file mode 100644 index 000000000..fe7c2aec6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + settings-merge-multiexecutions + 1.0-SNAPSHOT + pom + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + src/it/settings.xml + true + + + ${https.protocols} + + + + + first-run + initialize + + run + + + + second-run + initialize + + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/src/it/minvoker-133/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/src/it/minvoker-133/pom.xml new file mode 100644 index 000000000..b5c29179d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/src/it/minvoker-133/pom.xml @@ -0,0 +1,28 @@ + + + + + + 4.0.0 + test + minvoker-133 + 1.0-SNAPSHOT + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/src/it/settings.xml new file mode 100644 index 000000000..d403dfe20 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge-multiexecutions/src/it/settings.xml @@ -0,0 +1,55 @@ + + + + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/settings-merge/invoker.properties new file mode 100644 index 000000000..95855c7b1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge/invoker.properties @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# See https://issues.apache.org/jira/browse/MNG-5224 +invoker.maven.version = 3.0-,3.0.4+ +invoker.java.version = 9- \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge/pom.xml new file mode 100644 index 000000000..c7b89c6ad --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + settings-merge + 1.0-SNAPSHOT + pom + + Test to check that the settings.xml from the calling process is merged with the + one specified for m-invoker-p. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + true + src/it/settings.xml + true + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge/src/it/project/pom.xml new file mode 100644 index 000000000..d82048e71 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge/src/it/project/pom.xml @@ -0,0 +1,87 @@ + + + + + + 4.0.0 + test + project + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.0.1 + + + verify-properties + + enforce + + + + + it.settings-merge.1 + Property not present - settings.xml from calling process not merged! + (exists)$ + + + it.settings-merge.2 + Property not present - specified settings.xml not merged! + (exists)$ + + + true + + + + + + org.codehaus.gmaven + gmaven-plugin + 1.4 + + + verify-server + validate + + execute + + + + def server = settings.servers.find{ it.id.equals('dummy-it-settings-merge') } + if( !server.password.equals('overridden') ) + throw new org.apache.maven.plugin.MojoExecutionException("Incorrect server password - specified settings.xml not merged/dominant") + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge/src/it/settings.xml new file mode 100644 index 000000000..13266270e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge/src/it/settings.xml @@ -0,0 +1,42 @@ + + + + + + + + dummy-it-settings-merge + user + overridden + + + + + + it-properties + + true + + + exists + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/invoker.properties new file mode 100644 index 000000000..08b641652 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/invoker.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. + +# See https://issues.apache.org/jira/browse/MNG-5224 +invoker.maven.version = 3.0-,3.0.4+ diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/pom.xml new file mode 100644 index 000000000..9bc0316bf --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + settings-merge + 1.0-SNAPSHOT + pom + + Test to check that the settings.xml from the calling process is merged with the + one specified for m-invoker-p. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + true + src/it/settings.xml + true + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/project/pom.xml new file mode 100644 index 000000000..da45fb5e0 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/project/pom.xml @@ -0,0 +1,84 @@ + + + + + + 4.0.0 + test + project + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.0.1 + + + verify-properties + + enforce + + + + + it.settings-merge.1 + Property not present - settings.xml from calling process not merged! + (exists)$ + + + it.settings-merge.2 + Property not present - specified settings.xml not merged! + (exists)$ + + + true + + + + + + org.apache.maven.plugins + maven-help-plugin + 2.2 + + + effective-settings + validate + + effective-settings + + + effective-settings.xml + true + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/project/postbuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/project/postbuild.groovy new file mode 100644 index 000000000..19f538510 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/project/postbuild.groovy @@ -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. + */ + +File effectiveSettings = new File( basedir, "effective-settings.xml" ) +assert effectiveSettings.isFile() + +def settings = new XmlSlurper().parse( effectiveSettings ) +def server = settings.servers.server.find{ it.id.equals('dummy-it-settings-merge') } + +if( !server.password.equals('overridden') ) + throw new org.apache.maven.plugin.MojoExecutionException("Incorrect server password - specified settings.xml not merged/dominant " + server.password) diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/settings.xml new file mode 100644 index 000000000..00aee93e2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-merge_jdk9+/src/it/settings.xml @@ -0,0 +1,42 @@ + + + + + + + + dummy-it-settings-merge + user + overridden + + + + + + it-properties + + true + + + exists + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-override/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/settings-override/invoker.properties new file mode 100644 index 000000000..08b641652 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-override/invoker.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. + +# See https://issues.apache.org/jira/browse/MNG-5224 +invoker.maven.version = 3.0-,3.0.4+ diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-override/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-override/pom.xml new file mode 100644 index 000000000..b082fa088 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-override/pom.xml @@ -0,0 +1,63 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + settings-merge + 1.0-SNAPSHOT + pom + + Test to check that the settings.xml from the calling process is merged with the + one specified for m-invoker-p. + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + src/it/settings.xml + true + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/invoker.properties new file mode 100644 index 000000000..6ec72bdcd --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/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.settingsFile =src/it/settings-override.xml \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/pom.xml new file mode 100644 index 000000000..d21857d3b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/pom.xml @@ -0,0 +1,58 @@ + + + + + + 4.0.0 + test + project + 0.1-SNAPSHOT + pom + + + UTF-8 + true + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.0.1 + + + verify-properties + + enforce + + + + + + ${enforcer.fail} + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/postbuild.groovy b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/postbuild.groovy new file mode 100644 index 000000000..4b30e4644 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/project/postbuild.groovy @@ -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. + */ + +File interpolatedCustomSettings = new File( basedir, "../interpolated-settings-override.xml" ) +assert interpolatedCustomSettings.isFile() diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/settings-override.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/settings-override.xml new file mode 100644 index 000000000..6c916e42f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/settings-override.xml @@ -0,0 +1,34 @@ + + + + + + + + it-properties + + true + + + false + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/settings.xml new file mode 100644 index 000000000..a2d26c432 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings-override/src/it/settings.xml @@ -0,0 +1,34 @@ + + + + + + + + it-properties + + true + + + true + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/settings.xml b/Java-base/maven-invoker-plugin/src/src/it/settings.xml new file mode 100644 index 000000000..842301e5c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/settings.xml @@ -0,0 +1,94 @@ + + + + + + + + + dummy-it-settings-merge + user + password + + + + + + it-repo + + true + + + + @localRepository@ + + exists + + exists + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + apache.snapshots + Apache Snapshot Repository + http://repository.apache.org/content/groups/snapshots-group/ + + false + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + apache.snapshots + Apache Snapshot Repository + http://repository.apache.org/content/groups/snapshots-group/ + + false + + + true + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/skip-install/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/skip-install/pom.xml new file mode 100644 index 000000000..f82147e2b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/skip-install/pom.xml @@ -0,0 +1,58 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + skip-install + 1.0-SNAPSHOT + pom + + Test to check that invoker.skip=true will skip all installations + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it-repo + + + + integration-test + initialize + + install + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/skip-install/test.properties b/Java-base/maven-invoker-plugin/src/src/it/skip-install/test.properties new file mode 100644 index 000000000..55c971273 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/skip-install/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. + +# NOTE: Skipping from the CLI is the primary use case so we prefer the system property over the direct POM configuration +invoker.skip = true diff --git a/Java-base/maven-invoker-plugin/src/src/it/skip-install/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/skip-install/verify.bsh new file mode 100644 index 000000000..6e7049b7f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/skip-install/verify.bsh @@ -0,0 +1,32 @@ +/* + * 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 java.util.regex.*; + +File itRepoDir = new File( basedir, "target/it-repo" ); +System.out.println( "Checking for absence of: " + itRepoDir ); +if ( itRepoDir.isDirectory() ) +{ + throw new IllegalStateException( "Creation of staging repository was not skipped: " + itRepoDir ); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/skip-run/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/skip-run/pom.xml new file mode 100644 index 000000000..c09f1802c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/skip-run/pom.xml @@ -0,0 +1,66 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker + skip-run + 1.0-SNAPSHOT + pom + + Test to check that invoker.skip=true will skip all invocations + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + true + true + ${project.build.directory}/it + + */pom.xml + + + validate + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/skip-run/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/skip-run/src/it/project/pom.xml new file mode 100644 index 000000000..584300c98 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/skip-run/src/it/project/pom.xml @@ -0,0 +1,33 @@ + + + + + + + 99.0.0 + test + skip-invoker + 0.1-SNAPSHOT + jar + + + UTF-8 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/skip-run/src/it/project/prebuild.bsh b/Java-base/maven-invoker-plugin/src/src/it/skip-run/src/it/project/prebuild.bsh new file mode 100644 index 000000000..7391f5a33 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/skip-run/src/it/project/prebuild.bsh @@ -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. + */ + +import java.io.*; + +// marker for parent build that this sub build was indeed run +File touchFile = new File( basedir, "touch.txt" ); +touchFile.createNewFile(); + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/skip-run/test.properties b/Java-base/maven-invoker-plugin/src/src/it/skip-run/test.properties new file mode 100644 index 000000000..55c971273 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/skip-run/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. + +# NOTE: Skipping from the CLI is the primary use case so we prefer the system property over the direct POM configuration +invoker.skip = true diff --git a/Java-base/maven-invoker-plugin/src/src/it/skip-run/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/skip-run/verify.bsh new file mode 100644 index 000000000..718cf1f71 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/skip-run/verify.bsh @@ -0,0 +1,41 @@ +/* + * 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 java.util.regex.*; + +try +{ + // make sure the Invoker Plugin was indeed NOT run and the build didn't fail somewhere else + File touchFile = new File( basedir, "target/it/project/touch.txt" ); + System.out.println( "Checking for non-existence of touch file: " + touchFile ); + if ( touchFile.exists() ) + { + System.out.println( "FAILED!" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/invoker.properties new file mode 100644 index 000000000..800365493 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/invoker.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. + +invoker.goals = verify +invoker.os.family = !windows \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/pom.xml new file mode 100644 index 000000000..03e816359 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + basedir-with-spaces + 1.0-SNAPSHOT + pom + + + + Test to check for usage of spaces in folder names. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + validate + + verify + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/setup.groovy b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/setup.groovy new file mode 100644 index 000000000..829476f77 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/setup.groovy @@ -0,0 +1,32 @@ +/* + * 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 java.util.regex.* +import org.apache.commons.io.FileUtils + +File srcIt = new File (basedir, "src/it"); +File originalFolder = new File (srcIt, "minvoker-test"); +File destinationFolder = new File(srcIt, "test-\u00c9\u00e9\u00ea- & -\u00c9\u00e9\u00ea-test"); +FileUtils.deleteQuietly(destinationFolder); +// rename old one into new one with special characters. +if (!originalFolder.renameTo(destinationFolder)) { + throw new IOException("Rename didn't work.") +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/invoker.properties new file mode 100644 index 000000000..ccf4abf3e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/invoker.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. + +invoker.debug = true +invoker.goals = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/pom.xml new file mode 100644 index 000000000..fc1577ca2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/pom.xml @@ -0,0 +1,54 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-142 + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.1.1 + + + + enforce + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/verify.groovy new file mode 100644 index 000000000..066f05d26 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_non-windows/src/it/minvoker-test/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. + */ +File buildLog = new File( basedir, 'build.log' ) + +// if one of criteria matches +if( buildLog.exists() ) +{ + assert buildLog.text.contains( '[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.AlwaysPass' ) +} + diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/invoker.properties new file mode 100644 index 000000000..a7333d4ad --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/invoker.properties @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = verify +invoker.os.family = windows +invoker.maven.version = 3.5.0+ \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/pom.xml new file mode 100644 index 000000000..e111e1e3e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/pom.xml @@ -0,0 +1,64 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + basedir-with-spaces + 1.0-SNAPSHOT + pom + + + + Test to check for usage of spaces in folder names. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + validate + + verify + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/setup.groovy b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/setup.groovy new file mode 100644 index 000000000..829476f77 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/setup.groovy @@ -0,0 +1,32 @@ +/* + * 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 java.util.regex.* +import org.apache.commons.io.FileUtils + +File srcIt = new File (basedir, "src/it"); +File originalFolder = new File (srcIt, "minvoker-test"); +File destinationFolder = new File(srcIt, "test-\u00c9\u00e9\u00ea- & -\u00c9\u00e9\u00ea-test"); +FileUtils.deleteQuietly(destinationFolder); +// rename old one into new one with special characters. +if (!originalFolder.renameTo(destinationFolder)) { + throw new IOException("Rename didn't work.") +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/invoker.properties new file mode 100644 index 000000000..ccf4abf3e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/invoker.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. + +invoker.debug = true +invoker.goals = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/pom.xml new file mode 100644 index 000000000..fc1577ca2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/pom.xml @@ -0,0 +1,54 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-142 + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.1.1 + + + + enforce + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/verify.groovy new file mode 100644 index 000000000..066f05d26 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/spaces-should-work_windows/src/it/minvoker-test/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. + */ +File buildLog = new File( basedir, 'build.log' ) + +// if one of criteria matches +if( buildLog.exists() ) +{ + assert buildLog.text.contains( '[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.AlwaysPass' ) +} + diff --git a/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/invoker.properties new file mode 100644 index 000000000..353946b69 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/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 = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/pom.xml new file mode 100644 index 000000000..b5ecd4679 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + accents-debug + 1.0-SNAPSHOT + pom + + + Test to check for usage of accents in folder names. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + + validate + + false + verify + + + ${https.protocols} + + + + + integration-test + initialize + + run + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/setup.groovy b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/setup.groovy new file mode 100644 index 000000000..85f8a9826 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/setup.groovy @@ -0,0 +1,32 @@ +/* + * 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 java.util.regex.* +import org.apache.commons.io.FileUtils + +File srcIt = new File (basedir, "src/it"); +File originalFolder = new File (srcIt, "minvoker-test"); +File destinationFolder = new File(srcIt, "test-\u00c9\u00e9\u00ea-more-\u00c9\u00e9\u00ea-test"); +FileUtils.deleteQuietly(destinationFolder); +// rename old one into new one with special characters. +if (!originalFolder.renameTo(destinationFolder)) { + throw new IOException("Rename didn't work.") +} diff --git a/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/invoker.properties new file mode 100644 index 000000000..ccf4abf3e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/invoker.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. + +invoker.debug = true +invoker.goals = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/pom.xml new file mode 100644 index 000000000..fc1577ca2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/pom.xml @@ -0,0 +1,54 @@ + + + + + + 4.0.0 + org.apache.maven.plugins.invoker.its + minvoker-142 + 0.1-SNAPSHOT + pom + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.1.1 + + + + enforce + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/verify.groovy b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/verify.groovy new file mode 100644 index 000000000..417a89ef5 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/special-characters-should-work/src/it/minvoker-test/verify.groovy @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.text.contains( '[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.AlwaysPass' ) \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/invoker.properties new file mode 100644 index 000000000..353946b69 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/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 = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/pom.xml new file mode 100644 index 000000000..0c4a272d1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/pom.xml @@ -0,0 +1,100 @@ + + + + + + 4.0.0 + + test + staging-dependencies + 1.0-SNAPSHOT + + + Test to check for staging of (runtime) dependencies directly from local repository (MINVOKER-64, MINVOKER-70). + + + + + + junit + junit + 3.8.2 + + + + org.apache.maven.its + minvoker-70 + 1.0-SNAPSHOT + + + + org.apache.maven.its + pom + 0.3-SNAPSHOT + pom + + + + org.apache.maven.its + dep + 1.0 + tests + + + org.apache.maven.its + dep + 2.0 + + + + + + maven-invoker-plugin-it + file:///${basedir}/repo + + ignore + + + ignore + + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it-repo + + + + integration-test + + install + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/1.0/dep-1.0-tests.jar b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/1.0/dep-1.0-tests.jar new file mode 100644 index 000000000..264c88054 Binary files /dev/null and b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/1.0/dep-1.0-tests.jar differ diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/1.0/dep-1.0.pom b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/1.0/dep-1.0.pom new file mode 100644 index 000000000..f14ec2704 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/1.0/dep-1.0.pom @@ -0,0 +1,8 @@ + + + 4.0.0 + org.apache.maven.its + dep + jar + 1.0 + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/2.0/dep-2.0.jar b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/2.0/dep-2.0.jar new file mode 100644 index 000000000..264c88054 Binary files /dev/null and b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/2.0/dep-2.0.jar differ diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/2.0/dep-2.0.pom b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/2.0/dep-2.0.pom new file mode 100644 index 000000000..f49790185 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/2.0/dep-2.0.pom @@ -0,0 +1,8 @@ + + + 4.0.0 + org.apache.maven.its + dep + jar + 2.0 + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/maven-metadata.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/maven-metadata.xml new file mode 100644 index 000000000..c4c0303f6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/dep/maven-metadata.xml @@ -0,0 +1,34 @@ + + + + + + org.apache.maven.its + dep + + 2.0 + 2.0 + + 1.0 + 2.0 + + 20081020164906 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/maven-metadata.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/maven-metadata.xml new file mode 100644 index 000000000..ed2257db3 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,33 @@ + + + + + + org.apache.maven.its + minvoker-70 + 1.0-SNAPSHOT + + + 20081020.164906 + 1 + + 20081020164906 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.jar b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.jar new file mode 100644 index 000000000..264c88054 Binary files /dev/null and b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.jar differ diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.pom b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.pom new file mode 100644 index 000000000..61bbf6d4e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-20081020.164906-1.pom @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.apache.maven.its + parent-b + 0.1-SNAPSHOT + + minvoker-70 + jar + 1.0-SNAPSHOT + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/maven-metadata.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/maven-metadata.xml new file mode 100644 index 000000000..88d46d19e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/minvoker-70/maven-metadata.xml @@ -0,0 +1,32 @@ + + + + + + org.apache.maven.its + minvoker-70 + 1.0-SNAPSHOT + + + 1.0-SNAPSHOT + + 20081020164906 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml new file mode 100644 index 000000000..53d8c322c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,33 @@ + + + + + + org.apache.maven.its + parent-a + 0.1-SNAPSHOT + + + 20081020.164906 + 1 + + 20081020164906 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-20081020.164906-1.pom b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-20081020.164906-1.pom new file mode 100644 index 000000000..c74bf4f2c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-20081020.164906-1.pom @@ -0,0 +1,8 @@ + + + 4.0.0 + org.apache.maven.its + parent-a + pom + 0.1-SNAPSHOT + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml new file mode 100644 index 000000000..854ca1c22 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,33 @@ + + + + + + org.apache.maven.its + parent-b + 0.1-SNAPSHOT + + + 20081020.164906 + 1 + + 20081020164906 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-20081020.164906-1.pom b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-20081020.164906-1.pom new file mode 100644 index 000000000..78fd42453 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-20081020.164906-1.pom @@ -0,0 +1,12 @@ + + + 4.0.0 + + org.apache.maven.its + parent-a + 0.1-SNAPSHOT + + parent-b + pom + 0.1-SNAPSHOT + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml new file mode 100644 index 000000000..066d9e84c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,33 @@ + + + + + + org.apache.maven.its + pom + 0.3-SNAPSHOT + + + 20081020.164906 + 1 + + 20081020164906 + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-20081020.164906-1.pom b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-20081020.164906-1.pom new file mode 100644 index 000000000..3404c35b0 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/repo/org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-20081020.164906-1.pom @@ -0,0 +1,8 @@ + + + 4.0.0 + org.apache.maven.its + pom + pom + 0.3-SNAPSHOT + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/verify.bsh new file mode 100644 index 000000000..3495e4809 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-dependencies/verify.bsh @@ -0,0 +1,94 @@ +/* + * 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 java.util.regex.*; + +import org.codehaus.plexus.util.*; +import org.codehaus.plexus.util.xml.*; + +try +{ + File itRepoDir = new File( basedir, "target/it-repo" ); + System.out.println( "Checking for existence of: " + itRepoDir ); + if ( !itRepoDir.isDirectory() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String[] files = { + "junit/junit/3.8.2/junit-3.8.2.pom", + "junit/junit/3.8.2/junit-3.8.2.jar", + "junit/junit/maven-metadata-local.xml", + "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.pom", + "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/minvoker-70-1.0-SNAPSHOT.jar", + "org/apache/maven/its/minvoker-70/1.0-SNAPSHOT/maven-metadata-local.xml", + "org/apache/maven/its/minvoker-70/maven-metadata-local.xml", + "org/apache/maven/its/parent-b/0.1-SNAPSHOT/parent-b-0.1-SNAPSHOT.pom", + "org/apache/maven/its/parent-b/0.1-SNAPSHOT/maven-metadata-local.xml", + "org/apache/maven/its/parent-b/maven-metadata-local.xml", + "org/apache/maven/its/parent-a/0.1-SNAPSHOT/parent-a-0.1-SNAPSHOT.pom", + "org/apache/maven/its/parent-a/0.1-SNAPSHOT/maven-metadata-local.xml", + "org/apache/maven/its/parent-a/maven-metadata-local.xml", + "org/apache/maven/its/pom/0.3-SNAPSHOT/pom-0.3-SNAPSHOT.pom", + "org/apache/maven/its/pom/0.3-SNAPSHOT/maven-metadata-local.xml", + "org/apache/maven/its/pom/maven-metadata-local.xml", + "org/apache/maven/its/dep/1.0/dep-1.0.pom", + "org/apache/maven/its/dep/1.0/dep-1.0-tests.jar", + "org/apache/maven/its/dep/2.0/dep-2.0.pom", + "org/apache/maven/its/dep/2.0/dep-2.0.jar", + "org/apache/maven/its/dep/maven-metadata-local.xml", + }; + for ( String file : files ) + { + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + if ( !stagedFile.isFile() ) + { + throw new IllegalStateException( "Missing: " + stagedFile ); + } + } + + Reader reader = ReaderFactory.newXmlReader( new File( itRepoDir, "org/apache/maven/its/dep/maven-metadata-local.xml" ) ); + Xpp3Dom dom = Xpp3DomBuilder.build( reader ); + IOUtil.close( reader ); + + if ( dom.getChild( "versioning" ).getChild( "versions" ).getChildCount() != 2 ) + { + throw new IllegalStateException( "Invalid version number count in metadata" ); + } + + List versions = new ArrayList(); + versions.add( dom.getChild( "versioning" ).getChild( "versions" ).getChild( 0 ).getValue() ); + versions.add( dom.getChild( "versioning" ).getChild( "versions" ).getChild( 1 ).getValue() ); + Collections.sort( versions ); + if ( !versions.equals( Arrays.asList( new String[] { "1.0", "2.0" } ) ) ) + { + throw new IllegalStateException( "Invalid version numbers in metadata: " + versions ); + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-pom/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/staging-pom/invoker.properties new file mode 100644 index 000000000..353946b69 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-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 = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-pom/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-pom/pom.xml new file mode 100644 index 000000000..cf39252bc --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-pom/pom.xml @@ -0,0 +1,59 @@ + + + + + + 4.0.0 + + test + pom-packaging + 1.0-SNAPSHOT + pom + + + Test to check for MINVOKER-51, i.e. NPE when packaging is pom. + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @pom.version@ + + ${project.build.directory}/it-repo + + + + integration-test + + install + + + + + + org.apache.maven.plugins + maven-site-plugin + 2.0-beta-7 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-pom/src/site/site.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-pom/src/site/site.xml new file mode 100644 index 000000000..e4c4c48cc --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-pom/src/site/site.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-pom/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/staging-pom/verify.bsh new file mode 100644 index 000000000..8565933f6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-pom/verify.bsh @@ -0,0 +1,54 @@ +/* + * 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 java.util.regex.*; + +try +{ + File itRepoDir = new File( basedir, "target/it-repo" ); + System.out.println( "Checking for existence of: " + itRepoDir ); + if ( !itRepoDir.isDirectory() ) + { + System.out.println( "FAILED!" ); + return false; + } + + String[] files = { + "test/pom-packaging/1.0-SNAPSHOT/pom-packaging-1.0-SNAPSHOT.pom", + }; + for ( String file : files ) + { + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + if ( !stagedFile.isFile() ) + { + System.out.println( "FAILED!" ); + return false; + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/invoker.properties new file mode 100644 index 000000000..353946b69 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/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 = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod1-parent/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod1-parent/pom.xml new file mode 100644 index 000000000..9b026e607 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod1-parent/pom.xml @@ -0,0 +1,47 @@ + + + + + + 4.0.0 + + test + mod1-parent + 1.0-SNAPSHOT + pom + + + Test to check for proper staging during a multi module build, i.e. artifacts from the reactor need to be considered. + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-site-plugin + 2.0-beta-7 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod1/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod1/pom.xml new file mode 100644 index 000000000..fad9dc45c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod1/pom.xml @@ -0,0 +1,73 @@ + + + + + + 4.0.0 + + + test + mod1-parent + 1.0-SNAPSHOT + ../mod1-parent + + + mod1 + 1.0-SNAPSHOT + jar + + + Test to check for proper staging during a multi module build, i.e. artifacts from the reactor need to be considered. + + + + UTF-8 + + + + + test + mod2 + 1.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it-repo + + + + integration-test + + install + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod2/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod2/pom.xml new file mode 100644 index 000000000..0f33056f6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod2/pom.xml @@ -0,0 +1,59 @@ + + + + + + 4.0.0 + + + test + mod2-parent + 1.0-SNAPSHOT + + + mod2 + 1.0-SNAPSHOT + jar + + + Test to check for proper staging during a multi module build, i.e. artifacts from the reactor need to be considered. + + + + UTF-8 + + + + + + maven-source-plugin + 2.0.4 + + + attach-resources + + jar + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod2/src/main/resources/main.properties b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod2/src/main/resources/main.properties new file mode 100644 index 000000000..00ae6c00d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/mod2/src/main/resources/main.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. + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/pom.xml new file mode 100644 index 000000000..185925a70 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/pom.xml @@ -0,0 +1,52 @@ + + + + + + 4.0.0 + + test + mod2-parent + 1.0-SNAPSHOT + pom + + + Test to check for proper staging during a multi module build, i.e. artifacts from the reactor need to be considered. + + + + mod1 + mod2 + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-site-plugin + 2.0-beta-7 + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/src/site/site.xml b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/src/site/site.xml new file mode 100644 index 000000000..e4c4c48cc --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/src/site/site.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/verify.bsh b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/verify.bsh new file mode 100644 index 000000000..19f6fa831 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/staging-reactor/verify.bsh @@ -0,0 +1,69 @@ +/* + * 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 java.util.regex.*; + +try +{ + File itRepoDir = new File( basedir, "mod1/target/it-repo" ); + System.out.println( "Checking for existence of: " + itRepoDir ); + if ( !itRepoDir.isDirectory() ) + { + System.out.println( "FAILED!" ); + return false; + } + + // NOTE: Checking the metadata is included to guard against regression of MINVOKER-43 + String[] files = { + "test/mod1/maven-metadata-local.xml", + "test/mod1/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod1/1.0-SNAPSHOT/mod1-1.0-SNAPSHOT.pom", + "test/mod1/1.0-SNAPSHOT/mod1-1.0-SNAPSHOT.jar", + "test/mod1-parent/maven-metadata-local.xml", + "test/mod1-parent/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod1-parent/1.0-SNAPSHOT/mod1-parent-1.0-SNAPSHOT.pom", + "test/mod2/maven-metadata-local.xml", + "test/mod2/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.pom", + "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT.jar", + "test/mod2/1.0-SNAPSHOT/mod2-1.0-SNAPSHOT-sources.jar", + "test/mod2-parent/maven-metadata-local.xml", + "test/mod2-parent/1.0-SNAPSHOT/maven-metadata-local.xml", + "test/mod2-parent/1.0-SNAPSHOT/mod2-parent-1.0-SNAPSHOT.pom", + }; + for ( String file : files ) + { + File stagedFile = new File( itRepoDir, file ); + System.out.println( "Checking for existence of: " + stagedFile ); + if ( !stagedFile.isFile() ) + { + System.out.println( "FAILED!" ); + return false; + } + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/invoker.properties new file mode 100644 index 000000000..353946b69 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/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 = verify diff --git a/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/pom.xml new file mode 100644 index 000000000..537162790 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/pom.xml @@ -0,0 +1,63 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.invoker.its + maven-wrong-interpolation-test + 0.1-SNAPSHOT + Maven Property Interpolation Test + Maven Invoker tests for property interpolation + + https://issues.apache.org/jira/browse/MINVOKER-194 + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-invoker-plugin + @project.version@ + + ${project.build.directory}/it + verify + + + ${https.protocols} + + + + + + install + run + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/src/it/project/invoker.properties b/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/src/it/project/invoker.properties new file mode 100644 index 000000000..276151bb3 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/src/it/project/invoker.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. + +invoker.name=wrong property interpolation +invoker.goals=org.apache.maven.plugins:maven-project-info-reports-plugin:2.8:summary help:effective-pom -Doutput=effective-pom.xml diff --git a/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/src/it/project/pom.xml b/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/src/it/project/pom.xml new file mode 100644 index 000000000..2cc24eba9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/it/wrongPropertyInterpolation/src/it/project/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + org.apache.maven.invoker.its.it + maven-prop-interpolation + 0.1-SNAPSHOT + jar + + 1.3 + 1.3 + + + + + + com.soebes.maven.plugins + echo-maven-plugin + 0.2 + + + package + + echo + + + + + + maven.compiler.source: ${maven.compiler.source} + maven.compiler.target: ${maven.compiler.target} + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java new file mode 100644 index 000000000..deec2ccfe --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java @@ -0,0 +1,2876 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.execution.MavenSession; +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecution; +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.plugins.invoker.model.BuildJob; +import org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Writer; +import org.apache.maven.project.MavenProject; +import org.apache.maven.settings.Settings; +import org.apache.maven.settings.SettingsUtils; +import org.apache.maven.settings.TrackableBase; +import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; +import org.apache.maven.settings.building.SettingsBuilder; +import org.apache.maven.settings.building.SettingsBuildingException; +import org.apache.maven.settings.building.SettingsBuildingRequest; +import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; +import org.apache.maven.shared.invoker.CommandLineConfigurationException; +import org.apache.maven.shared.invoker.DefaultInvocationRequest; +import org.apache.maven.shared.invoker.InvocationRequest; +import org.apache.maven.shared.invoker.InvocationResult; +import org.apache.maven.shared.invoker.Invoker; +import org.apache.maven.shared.invoker.MavenCommandLineBuilder; +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.apache.maven.shared.scriptinterpreter.RunErrorException; +import org.apache.maven.shared.scriptinterpreter.RunFailureException; +import org.apache.maven.shared.scriptinterpreter.ScriptRunner; +import org.apache.maven.shared.utils.logging.MessageBuilder; +import org.apache.maven.toolchain.MisconfiguredToolchainException; +import org.apache.maven.toolchain.ToolchainManagerPrivate; +import org.apache.maven.toolchain.ToolchainPrivate; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.RegexBasedInterpolator; +import org.codehaus.plexus.util.DirectoryScanner; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.InterpolationFilterReader; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.ReflectionUtils; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.WriterFactory; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.codehaus.plexus.util.xml.Xpp3DomWriter; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeSet; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; + +/** + * Provides common code for mojos invoking sub builds. + * + * @author Stephen Connolly + * @since 15-Aug-2009 09:09:29 + */ +public abstract class AbstractInvokerMojo + extends AbstractMojo +{ + /** + * The zero-based column index where to print the invoker result. + */ + private static final int RESULT_COLUMN = 60; + + /** + * Flag used to suppress certain invocations. This is useful in tailoring the build using profiles. + * + * @since 1.1 + */ + @Parameter( property = "invoker.skip", defaultValue = "false" ) + private boolean skipInvocation; + + /** + * Flag used to suppress the summary output notifying of successes and failures. If set to true, the + * only indication of the build's success or failure will be the effect it has on the main build (if it fails, the + * main build should fail as well). If {@link #streamLogs} is enabled, the sub-build summary will also provide an + * indication. + */ + @Parameter( defaultValue = "false" ) + protected boolean suppressSummaries; + + /** + * Flag used to determine whether the build logs should be output to the normal mojo log. + */ + @Parameter( property = "invoker.streamLogs", defaultValue = "false" ) + private boolean streamLogs; + + /** + * The local repository for caching artifacts. It is strongly recommended to specify a path to an isolated + * repository like ${project.build.directory}/it-repo. Otherwise, your ordinary local repository will + * be used, potentially soiling it with broken artifacts. + */ + @Parameter( property = "invoker.localRepositoryPath", defaultValue = "${settings.localRepository}" ) + private File localRepositoryPath; + + /** + * Directory to search for integration tests. + */ + @Parameter( property = "invoker.projectsDirectory", defaultValue = "${basedir}/src/it/" ) + private File projectsDirectory; + + /** + * Base directory where all build reports are written to. Every execution of an integration test will produce an XML + * file which contains the information about success or failure of that particular build job. The format of the + * resulting XML file is documented in the given build-job reference. + * + * @since 1.4 + */ + @Parameter( property = "invoker.reportsDirectory", defaultValue = "${project.build.directory}/invoker-reports" ) + private File reportsDirectory; + + /** + * A flag to disable the generation of build reports. + * + * @since 1.4 + */ + @Parameter( property = "invoker.disableReports", defaultValue = "false" ) + private boolean disableReports; + + /** + * Directory to which projects should be cloned prior to execution. If set to {@code null}, each integration test + * will be run in the directory in which the corresponding IT POM was found. In this case, you most likely want to + * configure your SCM to ignore target and build.log in the test's base directory. + * + * @since 1.1 + */ + @Parameter( property = "invoker.cloneProjectsTo" ) + private File cloneProjectsTo; + + // CHECKSTYLE_OFF: LineLength + /** + * Some files are normally excluded when copying the IT projects from the directory specified by the parameter + * projectsDirectory to the directory given by cloneProjectsTo (e.g. .svn, CVS, + * *~, etc: see + * reference for full list). Setting this parameter to true will cause all files to be copied to + * the cloneProjectsTo directory. + * + * @since 1.2 + */ + @Parameter( defaultValue = "false" ) + private boolean cloneAllFiles; + // CHECKSTYLE_ON: LineLength + + /** + * Ensure the {@link #cloneProjectsTo} directory is not polluted with files from earlier invoker runs. + * + * @since 1.6 + */ + @Parameter( defaultValue = "true" ) + private boolean cloneClean; + + /** + * A single POM to build, skipping any scanning parameters and behavior. + */ + @Parameter( property = "invoker.pom" ) + private File pom; + + /** + * Include patterns for searching the integration test directory for projects. This parameter is meant to be set + * from the POM. If this parameter is not set, the plugin will search for all pom.xml files one + * directory below {@link #projectsDirectory} (i.e. */pom.xml).
+ *
+ * Starting with version 1.3, mere directories can also be matched by these patterns. For example, the include + * pattern * will run Maven builds on all immediate sub directories of {@link #projectsDirectory}, + * regardless if they contain a pom.xml. This allows to perform builds that need/should not depend on + * the existence of a POM. + */ + @Parameter + private List pomIncludes = Collections.singletonList( "*/pom.xml" ); + + /** + * Exclude patterns for searching the integration test directory. This parameter is meant to be set from the POM. By + * default, no POM files are excluded. For the convenience of using an include pattern like *, the + * custom settings file specified by the parameter {@link #settingsFile} will always be excluded automatically. + */ + @Parameter + private List pomExcludes = Collections.emptyList(); + + /** + * Include patterns for searching the projects directory for projects that need to be run before the other projects. + * This parameter allows to declare projects that perform setup tasks like installing utility artifacts into the + * local repository. Projects matched by these patterns are implicitly excluded from the scan for ordinary projects. + * Also, the exclusions defined by the parameter {@link #pomExcludes} apply to the setup projects, too. Default + * value is: setup*/pom.xml. + * + * @since 1.3 + */ + @Parameter + private List setupIncludes = Collections.singletonList( "setup*/pom.xml" ); + + /** + * The list of goals to execute on each project. Default value is: package. + */ + @Parameter + private List goals = Collections.singletonList( "package" ); + + /** + */ + @Component + private Invoker invoker; + + @Component + private SettingsBuilder settingsBuilder; + + @Component + private ToolchainManagerPrivate toolchainManagerPrivate; + + /** + * Relative path of a selector script to run prior in order to decide if the build should be executed. This script + * may be written with either BeanShell or Groovy. If the file extension is omitted (e.g. selector), + * the plugin searches for the file by trying out the well-known extensions .bsh and + * .groovy. If this script exists for a particular project but returns any non-null value different + * from true, the corresponding build is flagged as skipped. In this case, none of the pre-build hook + * script, Maven nor the post-build hook script will be invoked. If this script throws an exception, the + * corresponding build is flagged as in error, and none of the pre-build hook script, Maven not the post-build hook + * script will be invoked. + * + * @since 1.5 + */ + @Parameter( property = "invoker.selectorScript", defaultValue = "selector" ) + private String selectorScript; + + /** + * Relative path of a pre-build hook script to run prior to executing the build. This script may be written with + * either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. prebuild), the plugin + * searches for the file by trying out the well-known extensions .bsh and .groovy. If this + * script exists for a particular project but returns any non-null value different from true or throws + * an exception, the corresponding build is flagged as a failure. In this case, neither Maven nor the post-build + * hook script will be invoked. + */ + @Parameter( property = "invoker.preBuildHookScript", defaultValue = "prebuild" ) + private String preBuildHookScript; + + /** + * Relative path of a cleanup/verification hook script to run after executing the build. This script may be written + * with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. verify), the + * plugin searches for the file by trying out the well-known extensions .bsh and .groovy. + * If this script exists for a particular project but returns any non-null value different from true or + * throws an exception, the corresponding build is flagged as a failure. + */ + @Parameter( property = "invoker.postBuildHookScript", defaultValue = "postbuild" ) + private String postBuildHookScript; + + /** + * Location of a properties file that defines CLI properties for the test. + */ + @Parameter( property = "invoker.testPropertiesFile", defaultValue = "test.properties" ) + private String testPropertiesFile; + + /** + * Common set of properties to pass in on each project's command line, via -D parameters. + * + * @since 1.1 + */ + @Parameter + private Map properties; + + /** + * Whether to show errors in the build output. + */ + @Parameter( property = "invoker.showErrors", defaultValue = "false" ) + private boolean showErrors; + + /** + * Whether to show debug statements in the build output. + */ + @Parameter( property = "invoker.debug", defaultValue = "false" ) + private boolean debug; + + /** + * Suppress logging to the build.log file. + */ + @Parameter( property = "invoker.noLog", defaultValue = "false" ) + private boolean noLog; + + /** + * By default a {@code build.log} is created in the root of the project. By setting this folder + * files are written to a different folder, respecting the structure of the projectsDirectory. + * + * @since 3.2.0 + */ + @Parameter + private File logDirectory; + + /** + * List of profile identifiers to explicitly trigger in the build. + * + * @since 1.1 + */ + @Parameter + private List profiles; + + /** + * A list of additional properties which will be used to filter tokens in POMs and goal files. + * + * @since 1.3 + */ + @Parameter + private Map filterProperties; + + /** + * The Maven Project Object + * + * @since 1.1 + */ + @Parameter( defaultValue = "${project}", readonly = true, required = true ) + private MavenProject project; + + @Parameter( defaultValue = "${session}", readonly = true, required = true ) + private MavenSession session; + + @Parameter( defaultValue = "${mojoExecution}", readonly = true, required = true ) + private MojoExecution mojoExecution; + + /** + * A comma separated list of projectname patterns to run. Specify this parameter to run individual tests by file + * name, overriding the {@link #setupIncludes}, {@link #pomIncludes} and {@link #pomExcludes} parameters. Each + * pattern you specify here will be used to create an include/exclude pattern formatted like + * ${projectsDirectory}/pattern. To exclude a test, prefix the pattern with a '!'. + * So you can just type -Dinvoker.test=SimpleTest,Comp*Test,!Compare* to run builds in + * ${projectsDirectory}/SimpleTest and ${projectsDirectory}/ComplexTest, but not + * ${projectsDirectory}/CompareTest + * + * @since 1.1 (exclusion since 1.8) + */ + @Parameter( property = "invoker.test" ) + private String invokerTest; + + /** + * Path to an alternate settings.xml to use for Maven invocation with all ITs. Note that the + * <localRepository> element of this settings file is always ignored, i.e. the path given by the + * parameter {@link #localRepositoryPath} is dominant. + * + * @since 1.2 + */ + @Parameter( property = "invoker.settingsFile" ) + private File settingsFile; + + /** + * The MAVEN_OPTS environment variable to use when invoking Maven. This value can be overridden for + * individual integration tests by using {@link #invokerPropertiesFile}. + * + * @since 1.2 + */ + @Parameter( property = "invoker.mavenOpts" ) + private String mavenOpts; + + /** + * The home directory of the Maven installation to use for the forked builds. Defaults to the current Maven + * installation. + * + * @since 1.3 + */ + @Parameter( property = "invoker.mavenHome" ) + private File mavenHome; + + /** + * mavenExecutable can either be a file relative to ${maven.home}/bin/ or an absolute file. + * + * @since 1.8 + * @see Invoker#setMavenExecutable(File) + */ + @Parameter( property = "invoker.mavenExecutable" ) + private String mavenExecutable; + + /** + * The JAVA_HOME environment variable to use for forked Maven invocations. Defaults to the current Java + * home directory. + * + * @since 1.3 + */ + @Parameter( property = "invoker.javaHome" ) + private File javaHome; + + /** + * The file encoding for the pre-/post-build scripts and the list files for goals and profiles. + * + * @since 1.2 + */ + @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" ) + private String encoding; + + /** + * The current user system settings for use in Maven. + * + * @since 1.2 + */ + @Parameter( defaultValue = "${settings}", readonly = true, required = true ) + private Settings settings; + + /** + * A flag whether the test class path of the project under test should be included in the class path of the + * pre-/post-build scripts. If set to false, the class path of script interpreter consists only of the + * runtime dependencies of the Maven Invoker Plugin. If set the true, + * the project's test class path will be prepended to the interpreter class path. Among others, this feature allows + * the scripts to access utility classes from the test sources of your project. + * + * @since 1.2 + */ + @Parameter( property = "invoker.addTestClassPath", defaultValue = "false" ) + private boolean addTestClassPath; + + /** + * The test class path of the project under test. + */ + @Parameter( defaultValue = "${project.testClasspathElements}", readonly = true ) + private List testClassPath; + + /** + * The name of an optional project-specific file that contains properties used to specify settings for an individual + * Maven invocation. Any property present in the file will override the corresponding setting from the plugin + * configuration. The values of the properties are filtered and may use expressions like + * ${project.version} to reference project properties or values from the parameter + * {@link #filterProperties}.

+ * + *

+ * As of 3.2.0 it is possible to put this folder in any of the ancestor folders, where properties will be inherited. + * This way you can provide a single properties file for a group of projects + *

+ * + * The snippet below describes the supported properties: + *
+     * # A comma or space separated list of goals/phases to execute, may
+     * # specify an empty list to execute the default goal of the IT project.
+     * # Environment variables used by maven plugins can be added here
+     * invoker.goals = clean install -Dplugin.variable=value
+     *
+     * # Or you can give things like this if you need.
+     * invoker.goals = -T2 clean verify
+     *
+     * # Optionally, a list of goals to run during further invocations of Maven
+     * invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:run
+     *
+     * # A comma or space separated list of profiles to activate
+     * invoker.profiles = its,jdk15
+     *
+     * # The path to an alternative POM or base directory to invoke Maven on, defaults to the
+     * # project that was originally specified in the plugin configuration
+     * # Since plugin version 1.4
+     * invoker.project = sub-module
+     *
+     * # The value for the environment variable MAVEN_OPTS
+     * invoker.mavenOpts = -Dfile.encoding=UTF-16 -Xms32m -Xmx256m
+     *
+     * # Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
+     * invoker.failureBehavior = fail-never
+     *
+     * # The expected result of the build, possible values are "success" (default) and "failure"
+     * invoker.buildResult = failure
+     *
+     * # A boolean value controlling the aggregator mode of Maven, defaults to "false"
+     * invoker.nonRecursive = true
+     *
+     * # A boolean value controlling the network behavior of Maven, defaults to "false"
+     * # Since plugin version 1.4
+     * invoker.offline = true
+     *
+     * # The path to the properties file from which to load system properties, defaults to the
+     * # filename given by the plugin parameter testPropertiesFile
+     * # Since plugin version 1.4
+     * invoker.systemPropertiesFile = test.properties
+     *
+     * # An optional human friendly name for this build job to be included in the build reports.
+     * # Since plugin version 1.4
+     * invoker.name = Test Build 01
+     *
+     * # An optional description for this build job to be included in the build reports.
+     * # Since plugin version 1.4
+     * invoker.description = Checks the support for build reports.
+     *
+     * # A comma separated list of JRE versions on which this build job should be run.
+     * # Since plugin version 1.4
+     * invoker.java.version = 1.4+, !1.4.1, 1.7-
+     * 
+     * # A comma separated list of OS families on which this build job should be run.
+     * # Since plugin version 1.4
+     * invoker.os.family = !windows, unix, mac
+     *
+     * # A comma separated list of Maven versions on which this build should be run.
+     * # Since plugin version 1.5
+     * invoker.maven.version = 2.0.10+, !2.1.0, !2.2.0
+     * 
+     * # A mapping for toolchain to ensure it exists
+     * # Since plugin version 3.2.0
+     * invoker.toolchain.<type>.<provides> = value
+     * invoker.toolchain.jdk.version = 11
+     * 
+     * # For java.version, maven.version, os.family and toolchain it is possible to define multiple selectors.
+     * # If one of the indexed selectors matches, the test is executed.
+     * # With the invoker.x.y equivalents you can specify global matchers.  
+     * selector.1.java.version = 1.8+
+     * selector.1.maven.version = 3.2.5+
+     * selector.1.os.family = !windows
+     * selector.2.maven.version = 3.0+
+     * selector.3.java.version = 9+
+     * 
+     * # A boolean value controlling the debug logging level of Maven, , defaults to "false"
+     * # Since plugin version 1.8
+     * invoker.debug = true
+     * 
+     * # Path to an alternate settings.xml to use for Maven invocation with this IT.
+     * # Since plugin version 3.0.1
+     * invoker.settingsFile = ../
+     *
+     * # An integer value to control run order of projects. sorted in the descending order of the ordinal.
+     * # In other words, the BuildJobs with the highest numbers will be executed first
+     * # Since plugin version 3.2.1
+     * invoker.ordinal = 3
+     * invoker.ordinal = 1
+     *
+     * # The additional value for the environment variable.
+     * # Since plugin version 3.2.2
+     * invoker.environmentVariables.<variableName> = variableValue
+     * invoker.environmentVariables.MY_ENV_NAME = myEnvValue
+     *
+     * 
+ * + * @since 1.2 + */ + @Parameter( property = "invoker.invokerPropertiesFile", defaultValue = "invoker.properties" ) + private String invokerPropertiesFile; + + /** + * flag to enable show mvn version used for running its (cli option : -V,--show-version ) + * + * @since 1.4 + */ + @Parameter( property = "invoker.showVersion", defaultValue = "false" ) + private boolean showVersion; + + /** + *

Number of threads for running tests in parallel. This will be the number of maven forked process in parallel. + * When terminated with "C", the number part is multiplied by the number of processors (cores) available + * to the Java virtual machine. Floating point value are only accepted together with "C".

+ * + *

Example values: "1.5C", "4"

+ * + * @since 1.6 + */ + @Parameter( property = "invoker.parallelThreads", defaultValue = "1" ) + private String parallelThreads; + + /** + * @since 1.6 + */ + @Parameter( property = "plugin.artifacts", required = true, readonly = true ) + private List pluginArtifacts; + + /** + * If enable and if you have a settings file configured for the execution, it will be merged with your user + * settings. + * + * @since 1.6 + */ + @Parameter( property = "invoker.mergeUserSettings", defaultValue = "false" ) + private boolean mergeUserSettings; + + /** + * Additional environment variables to set on the command line. + * + * @since 1.8 + */ + @Parameter + private Map environmentVariables; + + /** + * Additional variables for use in the hook scripts. + * + * @since 1.9 + */ + @Parameter + private Map scriptVariables; + + /** + * + * @since 3.0.2 + */ + @Parameter( defaultValue = "0", property = "invoker.timeoutInSeconds" ) + private int timeoutInSeconds; + + /** + * Write test result in junit format. + * @since 3.1.2 + */ + @Parameter( defaultValue = "false", property = "invoker.writeJunitReport" ) + private boolean writeJunitReport; + + /** + * The package name use in junit report + * @since 3.1.2 + */ + @Parameter( defaultValue = "maven.invoker.it", property = "invoker.junitPackageName" ) + private String junitPackageName = "maven.invoker.it"; + + /** + * The scripter runner that is responsible to execute hook scripts. + */ + private ScriptRunner scriptRunner; + + /** + * A string used to prefix the file name of the filtered POMs in case the POMs couldn't be filtered in-place (i.e. + * the projects were not cloned to a temporary directory), can be null. This will be set to + * null if the POMs have already been filtered during cloning. + */ + private String filteredPomPrefix = "interpolated-"; + + /** + * The format for elapsed build time. + */ + private final DecimalFormat secFormat = new DecimalFormat( "(0.0 s)", new DecimalFormatSymbols( Locale.ENGLISH ) ); + + /** + * The version of Maven which is used to run the builds + */ + private String actualMavenVersion; + + /** + * Invokes Maven on the configured test projects. + * + * @throws org.apache.maven.plugin.MojoExecutionException If the goal encountered severe errors. + * @throws org.apache.maven.plugin.MojoFailureException If any of the Maven builds failed. + */ + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( skipInvocation ) + { + getLog().info( "Skipping invocation per configuration." + + " If this is incorrect, ensure the skipInvocation parameter is not set to true." ); + return; + } + + if ( StringUtils.isEmpty( encoding ) ) + { + getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING + + ", i.e. build is platform dependent!" ); + } + + // done it here to prevent issues with concurrent access in case of parallel run + if ( !disableReports ) + { + setupReportsFolder(); + } + + List buildJobs; + if ( pom == null ) + { + try + { + buildJobs = getBuildJobs(); + } + catch ( final IOException e ) + { + throw new MojoExecutionException( "Error retrieving POM list from includes, " + + "excludes, and projects directory. Reason: " + e.getMessage(), e ); + } + } + else + { + try + { + projectsDirectory = pom.getCanonicalFile().getParentFile(); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to discover projectsDirectory from " + + "pom File parameter. Reason: " + e.getMessage(), e ); + } + + buildJobs = Collections.singletonList( new BuildJob( pom.getName(), BuildJob.Type.NORMAL ) ); + } + + if ( buildJobs.isEmpty() ) + { + doFailIfNoProjects(); + + getLog().info( "No projects were selected for execution." ); + return; + } + + handleScriptRunnerWithScriptClassPath(); + + Collection collectedProjects = new LinkedHashSet<>(); + for ( BuildJob buildJob : buildJobs ) + { + collectProjects( projectsDirectory, buildJob.getProject(), collectedProjects, true ); + } + + File projectsDir = projectsDirectory; + + if ( cloneProjectsTo != null ) + { + cloneProjects( collectedProjects ); + projectsDir = cloneProjectsTo; + } + else if ( cloneProjectsTo == null && "maven-plugin".equals( project.getPackaging() ) ) + { + cloneProjectsTo = new File( project.getBuild().getDirectory(), "its" ); + cloneProjects( collectedProjects ); + projectsDir = cloneProjectsTo; + } + else + { + getLog().warn( "Filtering of parent/child POMs is not supported without cloning the projects" ); + } + + // First run setup jobs. + List setupBuildJobs = null; + try + { + setupBuildJobs = getSetupBuildJobsFromFolders(); + } + catch ( IOException e ) + { + getLog().error( "Failure during scanning of folders.", e ); + // TODO: Check shouldn't we fail in case of problems? + } + + if ( !setupBuildJobs.isEmpty() ) + { + // Run setup jobs in single thread + // mode. + // + // Some Idea about ordering? + getLog().info( "Running " + setupBuildJobs.size() + " setup job" + + ( ( setupBuildJobs.size() < 2 ) ? "" : "s" ) + ":" ); + runBuilds( projectsDir, setupBuildJobs, 1 ); + getLog().info( "Setup done." ); + } + + // Afterwards run all other jobs. + List nonSetupBuildJobs = getNonSetupJobs( buildJobs ); + // We will run the non setup jobs with the configured + // parallelThreads number. + runBuilds( projectsDir, nonSetupBuildJobs, getParallelThreadsCount() ); + + writeSummaryFile( nonSetupBuildJobs ); + + processResults( new InvokerSession( nonSetupBuildJobs ) ); + + } + + /** + * This will create the necessary folders for the reports. + * + * @throws MojoExecutionException in case of failure during creation of the reports folder. + */ + private void setupReportsFolder() + throws MojoExecutionException + { + // If it exists from previous run... + if ( reportsDirectory.exists() ) + { + try + { + FileUtils.deleteDirectory( reportsDirectory ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failure while trying to delete " + + reportsDirectory.getAbsolutePath(), e ); + } + } + if ( !reportsDirectory.mkdirs() ) + { + throw new MojoExecutionException( "Failure while creating the " + reportsDirectory.getAbsolutePath() ); + } + } + + private List getNonSetupJobs( List buildJobs ) + { + List result = new LinkedList<>(); + for ( BuildJob buildJob : buildJobs ) + { + if ( !buildJob.getType().equals( BuildJob.Type.SETUP ) ) + { + result.add( buildJob ); + } + } + return result; + } + + private void handleScriptRunnerWithScriptClassPath() + { + final List scriptClassPath; + if ( addTestClassPath ) + { + scriptClassPath = new ArrayList<>( testClassPath ); + for ( Artifact pluginArtifact : pluginArtifacts ) + { + scriptClassPath.remove( pluginArtifact.getFile().getAbsolutePath() ); + } + } + else + { + scriptClassPath = null; + } + scriptRunner = new ScriptRunner( getLog() ); + scriptRunner.setScriptEncoding( encoding ); + scriptRunner.setGlobalVariable( "localRepositoryPath", localRepositoryPath ); + if ( scriptVariables != null ) + { + for ( Entry entry : scriptVariables.entrySet() ) + { + scriptRunner.setGlobalVariable( entry.getKey(), entry.getValue() ); + } + } + scriptRunner.setClassPath( scriptClassPath ); + } + + private void writeSummaryFile( List buildJobs ) + throws MojoExecutionException + { + + File summaryReportFile = new File( reportsDirectory, "invoker-summary.txt" ); + + try ( Writer writer = new BufferedWriter( new FileWriter( summaryReportFile ) ) ) + { + for ( BuildJob buildJob : buildJobs ) + { + if ( !buildJob.getResult().equals( BuildJob.Result.SUCCESS ) ) + { + writer.append( buildJob.getResult() ); + writer.append( " [" ); + writer.append( buildJob.getProject() ); + writer.append( "] " ); + if ( buildJob.getFailureMessage() != null ) + { + writer.append( " " ); + writer.append( buildJob.getFailureMessage() ); + } + writer.append( "\n" ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write summary report " + summaryReportFile, e ); + } + } + + protected void doFailIfNoProjects() + throws MojoFailureException + { + // should only be used during run and verify + } + + /** + * Processes the results of invoking the build jobs. + * + * @param invokerSession The session with the build jobs, must not be null. + * @throws MojoFailureException If the mojo had failed as a result of invoking the build jobs. + * @since 1.4 + */ + abstract void processResults( InvokerSession invokerSession ) + throws MojoFailureException; + + /** + * Creates a new reader for the specified file, using the plugin's {@link #encoding} parameter. + * + * @param file The file to create a reader for, must not be null. + * @return The reader for the file, never null. + * @throws java.io.IOException If the specified file was not found or the configured encoding is not supported. + */ + private Reader newReader( File file ) + throws IOException + { + if ( StringUtils.isNotEmpty( encoding ) ) + { + return ReaderFactory.newReader( file, encoding ); + } + else + { + return ReaderFactory.newPlatformReader( file ); + } + } + + /** + * Collects all projects locally reachable from the specified project. The method will as such try to read the POM + * and recursively follow its parent/module elements. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param projectPath The relative path of the current project, can denote either the POM or its base directory, + * must not be null. + * @param projectPaths The set of already collected projects to add new projects to, must not be null. + * This set will hold the relative paths to either a POM file or a project base directory. + * @param included A flag indicating whether the specified project has been explicitly included via the parameter + * {@link #pomIncludes}. Such projects will always be added to the result set even if there is no + * corresponding POM. + * @throws org.apache.maven.plugin.MojoExecutionException If the project tree could not be traversed. + */ + private void collectProjects( File projectsDir, String projectPath, Collection projectPaths, + boolean included ) + throws MojoExecutionException + { + projectPath = projectPath.replace( '\\', '/' ); + File pomFile = new File( projectsDir, projectPath ); + if ( pomFile.isDirectory() ) + { + pomFile = new File( pomFile, "pom.xml" ); + if ( !pomFile.exists() ) + { + if ( included ) + { + projectPaths.add( projectPath ); + } + return; + } + if ( !projectPath.endsWith( "/" ) ) + { + projectPath += '/'; + } + projectPath += "pom.xml"; + } + else if ( !pomFile.isFile() ) + { + return; + } + if ( !projectPaths.add( projectPath ) ) + { + return; + } + getLog().debug( "Collecting parent/child projects of " + projectPath ); + + Model model = PomUtils.loadPom( pomFile ); + + try + { + String projectsRoot = projectsDir.getCanonicalPath(); + String projectDir = pomFile.getParent(); + + String parentPath = "../pom.xml"; + if ( model.getParent() != null && StringUtils.isNotEmpty( model.getParent().getRelativePath() ) ) + { + parentPath = model.getParent().getRelativePath(); + } + String parent = relativizePath( new File( projectDir, parentPath ), projectsRoot ); + if ( parent != null ) + { + collectProjects( projectsDir, parent, projectPaths, false ); + } + + Collection modulePaths = new LinkedHashSet<>(); + + modulePaths.addAll( model.getModules() ); + + for ( Profile profile : model.getProfiles() ) + { + modulePaths.addAll( profile.getModules() ); + } + + for ( String modulePath : modulePaths ) + { + String module = relativizePath( new File( projectDir, modulePath ), projectsRoot ); + if ( module != null ) + { + collectProjects( projectsDir, module, projectPaths, false ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to analyze POM: " + pomFile, e ); + } + } + + /** + * Copies the specified projects to the directory given by {@link #cloneProjectsTo}. A project may either be denoted + * by a path to a POM file or merely by a path to a base directory. During cloning, the POM files will be filtered. + * + * @param projectPaths The paths to the projects to clone, relative to the projects directory, must not be + * null nor contain null elements. + * @throws org.apache.maven.plugin.MojoExecutionException If the the projects could not be copied/filtered. + */ + private void cloneProjects( Collection projectPaths ) + throws MojoExecutionException + { + if ( !cloneProjectsTo.mkdirs() && cloneClean ) + { + try + { + FileUtils.cleanDirectory( cloneProjectsTo ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not clean the cloneProjectsTo directory. Reason: " + + e.getMessage(), e ); + } + } + + // determine project directories to clone + Collection dirs = new LinkedHashSet<>(); + for ( String projectPath : projectPaths ) + { + if ( !new File( projectsDirectory, projectPath ).isDirectory() ) + { + projectPath = getParentPath( projectPath ); + } + dirs.add( projectPath ); + } + + boolean filter; + + // clone project directories + try + { + filter = !cloneProjectsTo.getCanonicalFile().equals( projectsDirectory.getCanonicalFile() ); + + List clonedSubpaths = new ArrayList<>(); + + for ( String subpath : dirs ) + { + // skip this project if its parent directory is also scheduled for cloning + if ( !".".equals( subpath ) && dirs.contains( getParentPath( subpath ) ) ) + { + continue; + } + + // avoid copying subdirs that are already cloned. + if ( !alreadyCloned( subpath, clonedSubpaths ) ) + { + // avoid creating new files that point to dir/. + if ( ".".equals( subpath ) ) + { + String cloneSubdir = relativizePath( cloneProjectsTo, projectsDirectory.getCanonicalPath() ); + + // avoid infinite recursion if the cloneTo path is a subdirectory. + if ( cloneSubdir != null ) + { + File temp = File.createTempFile( "pre-invocation-clone.", "" ); + temp.delete(); + temp.mkdirs(); + + copyDirectoryStructure( projectsDirectory, temp ); + + FileUtils.deleteDirectory( new File( temp, cloneSubdir ) ); + + copyDirectoryStructure( temp, cloneProjectsTo ); + } + else + { + copyDirectoryStructure( projectsDirectory, cloneProjectsTo ); + } + } + else + { + File srcDir = new File( projectsDirectory, subpath ); + File dstDir = new File( cloneProjectsTo, subpath ); + copyDirectoryStructure( srcDir, dstDir ); + } + + clonedSubpaths.add( subpath ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to clone projects from: " + projectsDirectory + " to: " + + cloneProjectsTo + ". Reason: " + e.getMessage(), e ); + } + + // filter cloned POMs + if ( filter ) + { + for ( String projectPath : projectPaths ) + { + File pomFile = new File( cloneProjectsTo, projectPath ); + if ( pomFile.isFile() ) + { + buildInterpolatedFile( pomFile, pomFile ); + } + + // MINVOKER-186 + // The following is a temporary solution to support Maven 3.3.1 (.mvn/extensions.xml) filtering + // Will be replaced by MINVOKER-117 with general filtering mechanism + File baseDir = pomFile.getParentFile(); + File mvnDir = new File( baseDir, ".mvn" ); + if ( mvnDir.isDirectory() ) + { + File extensionsFile = new File( mvnDir, "extensions.xml" ); + if ( extensionsFile.isFile() ) + { + buildInterpolatedFile( extensionsFile, extensionsFile ); + } + } + // END MINVOKER-186 + } + filteredPomPrefix = null; + } + } + + /** + * Gets the parent path of the specified relative path. + * + * @param path The relative path whose parent should be retrieved, must not be null. + * @return The parent path or "." if the specified path has no parent, never null. + */ + private String getParentPath( String path ) + { + int lastSep = Math.max( path.lastIndexOf( '/' ), path.lastIndexOf( '\\' ) ); + return ( lastSep < 0 ) ? "." : path.substring( 0, lastSep ); + } + + /** + * Copied a directory structure with default exclusions (.svn, CVS, etc) + * + * @param sourceDir The source directory to copy, must not be null. + * @param destDir The target directory to copy to, must not be null. + * @throws java.io.IOException If the directory structure could not be copied. + */ + private void copyDirectoryStructure( File sourceDir, File destDir ) + throws IOException + { + DirectoryScanner scanner = new DirectoryScanner(); + scanner.setBasedir( sourceDir ); + if ( !cloneAllFiles ) + { + scanner.addDefaultExcludes(); + } + scanner.scan(); + + /* + * NOTE: Make sure the destination directory is always there (even if empty) to support POM-less ITs. + */ + destDir.mkdirs(); + // Create all the directories, including any symlinks present in source + FileUtils.mkDirs( sourceDir, scanner.getIncludedDirectories(), destDir ); + + for ( String includedFile : scanner.getIncludedFiles() ) + { + File sourceFile = new File( sourceDir, includedFile ); + File destFile = new File( destDir, includedFile ); + FileUtils.copyFile( sourceFile, destFile ); + + // ensure clone project must be writable for additional changes + destFile.setWritable( true ); + } + } + + /** + * Determines whether the specified sub path has already been cloned, i.e. whether one of its ancestor directories + * was already cloned. + * + * @param subpath The sub path to check, must not be null. + * @param clonedSubpaths The list of already cloned paths, must not be null nor contain + * null elements. + * @return true if the specified path has already been cloned, false otherwise. + */ + static boolean alreadyCloned( String subpath, List clonedSubpaths ) + { + for ( String path : clonedSubpaths ) + { + if ( ".".equals( path ) || subpath.equals( path ) || subpath.startsWith( path + File.separator ) ) + { + return true; + } + } + + return false; + } + + /** + * Runs the specified build jobs. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param buildJobs The build jobs to run must not be null nor contain null elements. + * @throws org.apache.maven.plugin.MojoExecutionException If any build could not be launched. + */ + private void runBuilds( final File projectsDir, List buildJobs, int runWithParallelThreads ) + throws MojoExecutionException + { + if ( !localRepositoryPath.exists() ) + { + localRepositoryPath.mkdirs(); + } + + // ----------------------------------------------- + // interpolate settings file + // ----------------------------------------------- + + File interpolatedSettingsFile = interpolateSettings( settingsFile ); + + final File mergedSettingsFile = mergeSettings( interpolatedSettingsFile ); + + if ( mavenHome != null ) + { + actualMavenVersion = SelectorUtils.getMavenVersion( mavenHome ); + } + else + { + actualMavenVersion = SelectorUtils.getMavenVersion(); + } + scriptRunner.setGlobalVariable( "mavenVersion", actualMavenVersion ); + + final CharSequence actualJreVersion; + // @todo if ( javaVersions ) ... to be picked up from toolchains + if ( javaHome != null ) + { + actualJreVersion = resolveExternalJreVersion(); + } + else + { + actualJreVersion = SelectorUtils.getJreVersion(); + } + + final Path projectsPath = this.projectsDirectory.toPath(); + + Set folderGroupSet = new HashSet<>(); + folderGroupSet.add( Paths.get( "." ) ); + for ( BuildJob buildJob : buildJobs ) + { + Path p = Paths.get( buildJob.getProject() ); + + if ( Files.isRegularFile( projectsPath.resolve( p ) ) ) + { + p = p.getParent(); + } + + if ( p != null ) + { + p = p.getParent(); + } + + while ( p != null && folderGroupSet.add( p ) ) + { + p = p.getParent(); + } + } + + List folderGroup = new ArrayList<>( folderGroupSet ); + Collections.sort( folderGroup ); + + final Map globalInvokerProperties = new HashMap<>(); + + for ( Path path : folderGroup ) + { + Properties ancestorProperties = globalInvokerProperties.get( projectsPath.resolve( path ).getParent() ); + + Path currentInvokerProperties = projectsPath.resolve( path ).resolve( invokerPropertiesFile ); + + Properties currentProperties; + if ( Files.isRegularFile( currentInvokerProperties ) ) + { + if ( ancestorProperties != null ) + { + currentProperties = new Properties( ancestorProperties ); + + } + else + { + currentProperties = new Properties(); + } + } + else + { + currentProperties = ancestorProperties; + } + + if ( Files.isRegularFile( currentInvokerProperties ) ) + { + try ( InputStream in = new FileInputStream( currentInvokerProperties.toFile() ) ) + { + currentProperties.load( in ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read invoker properties: " + + currentInvokerProperties ); + } + } + + if ( currentProperties != null ) + { + globalInvokerProperties.put( projectsPath.resolve( path ).normalize(), currentProperties ); + } + } + + try + { + if ( runWithParallelThreads > 1 ) + { + getLog().info( "use parallelThreads " + runWithParallelThreads ); + + ExecutorService executorService = Executors.newFixedThreadPool( runWithParallelThreads ); + for ( final BuildJob job : buildJobs ) + { + executorService.execute( new Runnable() + { + public void run() + { + try + { + Path ancestorFolder = getAncestorFolder( projectsPath.resolve( job.getProject() ) ); + + runBuild( projectsDir, job, mergedSettingsFile, javaHome, actualJreVersion, + globalInvokerProperties.get( ancestorFolder ) ); + } + catch ( MojoExecutionException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + } + } ); + } + + try + { + executorService.shutdown(); + // TODO add a configurable time out + executorService.awaitTermination( Long.MAX_VALUE, TimeUnit.MILLISECONDS ); + } + catch ( InterruptedException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } + else + { + for ( BuildJob job : buildJobs ) + { + Path ancestorFolder = getAncestorFolder( projectsPath.resolve( job.getProject() ) ); + + runBuild( projectsDir, job, mergedSettingsFile, javaHome, actualJreVersion, + globalInvokerProperties.get( ancestorFolder ) ); + } + } + } + finally + { + if ( interpolatedSettingsFile != null && cloneProjectsTo == null ) + { + interpolatedSettingsFile.delete(); + } + if ( mergedSettingsFile != null && mergedSettingsFile.exists() ) + { + mergedSettingsFile.delete(); + } + } + } + + private Path getAncestorFolder( Path p ) + { + Path ancestor = p; + if ( Files.isRegularFile( ancestor ) ) + { + ancestor = ancestor.getParent(); + } + if ( ancestor != null ) + { + ancestor = ancestor.getParent(); + } + return ancestor; + } + + /** + * Interpolate settings.xml file. + * @param settingsFile a settings file + * + * @return The interpolated settings.xml file. + * @throws MojoExecutionException in case of a problem. + */ + private File interpolateSettings( File settingsFile ) + throws MojoExecutionException + { + File interpolatedSettingsFile = null; + if ( settingsFile != null ) + { + if ( cloneProjectsTo != null ) + { + interpolatedSettingsFile = new File( cloneProjectsTo, "interpolated-" + settingsFile.getName() ); + } + else + { + interpolatedSettingsFile = + new File( settingsFile.getParentFile(), "interpolated-" + settingsFile.getName() ); + } + buildInterpolatedFile( settingsFile, interpolatedSettingsFile ); + } + return interpolatedSettingsFile; + } + + /** + * Merge the settings file + * + * @param interpolatedSettingsFile The interpolated settings file. + * @return The merged settings file. + * @throws MojoExecutionException Fail the build in case the merged settings file can't be created. + */ + private File mergeSettings( File interpolatedSettingsFile ) + throws MojoExecutionException + { + File mergedSettingsFile; + Settings mergedSettings = this.settings; + if ( mergeUserSettings ) + { + if ( interpolatedSettingsFile != null ) + { + // Have to merge the specified settings file (dominant) and the one of the invoking Maven process + try + { + SettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); + request.setGlobalSettingsFile( interpolatedSettingsFile ); + + Settings dominantSettings = settingsBuilder.build( request ).getEffectiveSettings(); + Settings recessiveSettings = cloneSettings(); + SettingsUtils.merge( dominantSettings, recessiveSettings, TrackableBase.USER_LEVEL ); + + mergedSettings = dominantSettings; + getLog().debug( "Merged specified settings file with settings of invoking process" ); + } + catch ( SettingsBuildingException e ) + { + throw new MojoExecutionException( "Could not read specified settings file", e ); + } + } + } + + if ( this.settingsFile != null && !mergeUserSettings ) + { + mergedSettingsFile = interpolatedSettingsFile; + } + else + { + try + { + mergedSettingsFile = writeMergedSettingsFile( mergedSettings ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not create temporary file for invoker settings.xml", e ); + } + } + return mergedSettingsFile; + } + + private File writeMergedSettingsFile( Settings mergedSettings ) + throws IOException + { + File mergedSettingsFile; + mergedSettingsFile = File.createTempFile( "invoker-settings", ".xml" ); + + SettingsXpp3Writer settingsWriter = new SettingsXpp3Writer(); + + + try ( FileWriter fileWriter = new FileWriter( mergedSettingsFile ) ) + { + settingsWriter.write( fileWriter, mergedSettings ); + } + + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Created temporary file for invoker settings.xml: " + + mergedSettingsFile.getAbsolutePath() ); + } + return mergedSettingsFile; + } + + private Settings cloneSettings() + { + Settings recessiveSettings = SettingsUtils.copySettings( this.settings ); + + // MINVOKER-133: reset sourceLevelSet + resetSourceLevelSet( recessiveSettings ); + for ( org.apache.maven.settings.Mirror mirror : recessiveSettings.getMirrors() ) + { + resetSourceLevelSet( mirror ); + } + for ( org.apache.maven.settings.Server server : recessiveSettings.getServers() ) + { + resetSourceLevelSet( server ); + } + for ( org.apache.maven.settings.Proxy proxy : recessiveSettings.getProxies() ) + { + resetSourceLevelSet( proxy ); + } + for ( org.apache.maven.settings.Profile profile : recessiveSettings.getProfiles() ) + { + resetSourceLevelSet( profile ); + } + + return recessiveSettings; + } + + private void resetSourceLevelSet( org.apache.maven.settings.TrackableBase trackable ) + { + try + { + ReflectionUtils.setVariableValueInObject( trackable, "sourceLevelSet", Boolean.FALSE ); + getLog().debug( "sourceLevelSet: " + + ReflectionUtils.getValueIncludingSuperclasses( "sourceLevelSet", trackable ) ); + } + catch ( IllegalAccessException e ) + { + // noop + } + } + + private CharSequence resolveExternalJreVersion() + { + Artifact pluginArtifact = mojoExecution.getMojoDescriptor().getPluginDescriptor().getPluginArtifact(); + pluginArtifact.getFile(); + + Commandline commandLine = new Commandline(); + commandLine.setExecutable( new File( javaHome, "bin/java" ).getAbsolutePath() ); + commandLine.createArg().setValue( "-cp" ); + commandLine.createArg().setFile( pluginArtifact.getFile() ); + commandLine.createArg().setValue( SystemPropertyPrinter.class.getName() ); + commandLine.createArg().setValue( "java.version" ); + + final StringBuilder actualJreVersion = new StringBuilder(); + StreamConsumer consumer = new StreamConsumer() + { + public void consumeLine( String line ) + { + actualJreVersion.append( line ); + } + }; + try + { + CommandLineUtils.executeCommandLine( commandLine, consumer, null ); + } + catch ( CommandLineException e ) + { + getLog().warn( e.getMessage() ); + } + return actualJreVersion; + } + + /** + * Interpolate the pom file. + * + * @param pomFile The pom file. + * @param basedir The base directory. + * @return interpolated pom file location in case we have interpolated the pom file otherwise the original pom file + * will be returned. + * @throws MojoExecutionException + */ + private File interpolatePomFile( File pomFile, File basedir ) + throws MojoExecutionException + { + File interpolatedPomFile = null; + if ( pomFile != null ) + { + if ( StringUtils.isNotEmpty( filteredPomPrefix ) ) + { + interpolatedPomFile = new File( basedir, filteredPomPrefix + pomFile.getName() ); + buildInterpolatedFile( pomFile, interpolatedPomFile ); + } + else + { + interpolatedPomFile = pomFile; + } + } + return interpolatedPomFile; + } + + /** + * Runs the specified project. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param buildJob The build job to run, must not be null. + * @param settingsFile The (already interpolated) user settings file for the build, may be null to use + * the current user settings. + * @param globalInvokerProperties + * @throws org.apache.maven.plugin.MojoExecutionException If the project could not be launched. + */ + private void runBuild( File projectsDir, BuildJob buildJob, File settingsFile, File actualJavaHome, + CharSequence actualJreVersion, Properties globalInvokerProperties ) + throws MojoExecutionException + { + // FIXME: Think about the following code part -- START + File pomFile = new File( projectsDir, buildJob.getProject() ); + File basedir; + if ( pomFile.isDirectory() ) + { + basedir = pomFile; + pomFile = new File( basedir, "pom.xml" ); + if ( !pomFile.exists() ) + { + pomFile = null; + } + else + { + buildJob.setProject( buildJob.getProject() + File.separator + "pom.xml" ); + } + } + else + { + basedir = pomFile.getParentFile(); + } + + File interpolatedPomFile = interpolatePomFile( pomFile, basedir ); + // FIXME: Think about the following code part -- ^^^^^^^ END + + getLog().info( buffer().a( "Building: " ).strong( buildJob.getProject() ).toString() ); + + InvokerProperties invokerProperties = getInvokerProperties( basedir, globalInvokerProperties ); + + // let's set what details we can + buildJob.setName( invokerProperties.getJobName() ); + buildJob.setDescription( invokerProperties.getJobDescription() ); + + try + { + int selection = getSelection( invokerProperties, actualJreVersion ); + if ( selection == 0 ) + { + long milliseconds = System.currentTimeMillis(); + boolean executed; + + FileLogger buildLogger = setupBuildLogFile( basedir ); + if ( buildLogger != null ) + { + buildJob.setBuildlog( buildLogger.getOutputFile().getAbsolutePath() ); + } + + try + { + executed = runBuild( basedir, interpolatedPomFile, settingsFile, actualJavaHome, + invokerProperties, buildLogger ); + } + finally + { + milliseconds = System.currentTimeMillis() - milliseconds; + buildJob.setTime( milliseconds / 1000.0 ); + + if ( buildLogger != null ) + { + buildLogger.close(); + } + } + + if ( executed ) + { + buildJob.setResult( BuildJob.Result.SUCCESS ); + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).success( "SUCCESS" ).a( ' ' ) + + formatTime( buildJob.getTime() ) ); + } + } + else + { + buildJob.setResult( BuildJob.Result.SKIPPED ); + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).warning( "SKIPPED" ).a( ' ' ) + + formatTime( buildJob.getTime() ) ); + } + } + } + else + { + buildJob.setResult( BuildJob.Result.SKIPPED ); + + StringBuilder message = new StringBuilder(); + if ( selection == Selector.SELECTOR_MULTI ) + { + message.append( "non-matching selectors" ); + } + else + { + if ( ( selection & Selector.SELECTOR_MAVENVERSION ) != 0 ) + { + message.append( "Maven version" ); + } + if ( ( selection & Selector.SELECTOR_JREVERSION ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "JRE version" ); + } + if ( ( selection & Selector.SELECTOR_OSFAMILY ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "OS" ); + } + if ( ( selection & Selector.SELECTOR_TOOLCHAIN ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "Toolchain" ); + } + } + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).warning( "SKIPPED" ) + " due to " + message.toString() ); + } + + // Abuse failureMessage, the field in the report which should contain the reason for skipping + // Consider skipCode + I18N + buildJob.setFailureMessage( "Skipped due to " + message.toString() ); + } + } + catch ( RunErrorException e ) + { + buildJob.setResult( BuildJob.Result.ERROR ); + buildJob.setFailureMessage( e.getMessage() ); + + if ( !suppressSummaries ) + { + getLog().info( " " + e.getMessage() ); + getLog().info( pad( buildJob ).failure( "ERROR" ).a( ' ' ) + formatTime( buildJob.getTime() ) ); + } + } + catch ( RunFailureException e ) + { + buildJob.setResult( e.getType() ); + buildJob.setFailureMessage( e.getMessage() ); + + if ( !suppressSummaries ) + { + getLog().info( " " + e.getMessage() ); + getLog().info( pad( buildJob ).failure( "FAILED" ).a( ' ' ) + formatTime( buildJob.getTime() ) ); + } + } + finally + { + deleteInterpolatedPomFile( interpolatedPomFile ); + writeBuildReport( buildJob ); + } + } + + private MessageBuilder pad( BuildJob buildJob ) + { + MessageBuilder buffer = buffer( 128 ); + + buffer.a( " " ); + buffer.a( buildJob.getProject() ); + + int l = 10 + buildJob.getProject().length(); + + if ( l < RESULT_COLUMN ) + { + buffer.a( ' ' ); + l++; + + if ( l < RESULT_COLUMN ) + { + for ( int i = RESULT_COLUMN - l; i > 0; i-- ) + { + buffer.a( '.' ); + } + } + } + + return buffer.a( ' ' ); + } + + /** + * Delete the interpolated pom file if it has been created before. + * + * @param interpolatedPomFile The interpolated pom file. + */ + private void deleteInterpolatedPomFile( File interpolatedPomFile ) + { + if ( interpolatedPomFile != null && StringUtils.isNotEmpty( filteredPomPrefix ) ) + { + interpolatedPomFile.delete(); + } + } + + /** + * Determines whether selector conditions of the specified invoker properties match the current environment. + * + * @param invokerProperties The invoker properties to check, must not be null. + * @return 0 if the job corresponding to the properties should be run, otherwise a bitwise value + * representing the reason why it should be skipped. + */ + private int getSelection( InvokerProperties invokerProperties, CharSequence actualJreVersion ) + { + return new Selector( actualMavenVersion, actualJreVersion.toString(), + getToolchainPrivateManager() ).getSelection( invokerProperties ); + } + + private ToolchainPrivateManager getToolchainPrivateManager() + { + return new ToolchainPrivateManager( toolchainManagerPrivate, session ); + } + + /** + * Writes the XML report for the specified build job unless report generation has been disabled. + * + * @param buildJob The build job whose report should be written, must not be null. + * @throws org.apache.maven.plugin.MojoExecutionException If the report could not be written. + */ + private void writeBuildReport( BuildJob buildJob ) + throws MojoExecutionException + { + if ( disableReports ) + { + return; + } + + String safeFileName = buildJob.getProject().replace( '/', '_' ).replace( '\\', '_' ).replace( ' ', '_' ); + if ( safeFileName.endsWith( "_pom.xml" ) ) + { + safeFileName = safeFileName.substring( 0, safeFileName.length() - "_pom.xml".length() ); + } + + File reportFile = new File( reportsDirectory, "BUILD-" + safeFileName + ".xml" ); + try ( FileOutputStream fos = new FileOutputStream( reportFile ); + Writer osw = new OutputStreamWriter( fos, buildJob.getModelEncoding() ) ) + { + BuildJobXpp3Writer writer = new BuildJobXpp3Writer(); + + writer.write( osw, buildJob ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write build report " + reportFile, e ); + } + + if ( writeJunitReport ) + { + writeJunitReport( buildJob, safeFileName ); + } + } + + private void writeJunitReport( BuildJob buildJob, String safeFileName ) + throws MojoExecutionException + { + File reportFile = new File( reportsDirectory, "TEST-" + safeFileName + ".xml" ); + Xpp3Dom testsuite = new Xpp3Dom( "testsuite" ); + testsuite.setAttribute( "name", junitPackageName + "." + safeFileName ); + testsuite.setAttribute( "time", Double.toString( buildJob.getTime() ) ); + + // set default value for required attributes + testsuite.setAttribute( "tests", "1" ); + testsuite.setAttribute( "errors", "0" ); + testsuite.setAttribute( "skipped", "0" ); + testsuite.setAttribute( "failures", "0" ); + + Xpp3Dom testcase = new Xpp3Dom( "testcase" ); + testsuite.addChild( testcase ); + switch ( buildJob.getResult() ) + { + case BuildJob.Result.SUCCESS: + break; + case BuildJob.Result.SKIPPED: + testsuite.setAttribute( "skipped", "1" ); + // adding the failure element + Xpp3Dom skipped = new Xpp3Dom( "skipped" ); + testcase.addChild( skipped ); + skipped.setValue( buildJob.getFailureMessage() ); + break; + case BuildJob.Result.ERROR: + testsuite.setAttribute( "errors", "1" ); + break; + default: + testsuite.setAttribute( "failures", "1" ); + // adding the failure element + Xpp3Dom failure = new Xpp3Dom( "failure" ); + testcase.addChild( failure ); + failure.setAttribute( "message", buildJob.getFailureMessage() ); + } + testcase.setAttribute( "classname", junitPackageName + "." + safeFileName ); + testcase.setAttribute( "name", safeFileName ); + testcase.setAttribute( "time", Double.toString( buildJob.getTime() ) ); + Xpp3Dom systemOut = new Xpp3Dom( "system-out" ); + testcase.addChild( systemOut ); + + + File buildLogFile = buildJob.getBuildlog() != null ? new File( buildJob.getBuildlog() ) : null; + + if ( buildLogFile != null && buildLogFile.exists() ) + { + getLog().debug( "fileLogger:" + buildLogFile ); + try + { + systemOut.setValue( FileUtils.fileRead( buildLogFile ) ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read logfile " + buildLogFile, e ); + } + } + else + { + getLog().debug( safeFileName + "not exists buildLogFile = " + buildLogFile ); + } + + try ( FileOutputStream fos = new FileOutputStream( reportFile ); + Writer osw = new OutputStreamWriter( fos, buildJob.getModelEncoding() ) ) + { + Xpp3DomWriter.write( osw, testsuite ); + } catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write JUnit build report " + reportFile, e ); + } + } + + /** + * Formats the specified build duration time. + * + * @param seconds The duration of the build. + * @return The formatted time, never null. + */ + private String formatTime( double seconds ) + { + return secFormat.format( seconds ); + } + + /** + * Runs the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @param pomFile The (already interpolated) POM file, may be null for a POM-less Maven invocation. + * @param settingsFile The (already interpolated) user settings file for the build, may be null. Will + * be merged with the settings file of the invoking Maven process. + * @param invokerProperties The properties to use. + * @param logger file logger to write execution build.log + * @return true if the project was launched or false if the selector script indicated that + * the project should be skipped. + * @throws org.apache.maven.plugin.MojoExecutionException If the project could not be launched. + * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException If either a hook script or the build itself + * failed. + */ + private boolean runBuild( File basedir, File pomFile, File settingsFile, File actualJavaHome, + InvokerProperties invokerProperties, FileLogger logger ) + throws MojoExecutionException, RunFailureException + { + if ( getLog().isDebugEnabled() && !invokerProperties.getProperties().isEmpty() ) + { + Properties props = invokerProperties.getProperties(); + getLog().debug( "Using invoker properties:" ); + for ( String key : new TreeSet( props.stringPropertyNames() ) ) + { + String value = props.getProperty( key ); + getLog().debug( " " + key + " = " + value ); + } + } + + List goals = getGoals( basedir ); + + List profiles = getProfiles( basedir ); + + Map context = new LinkedHashMap<>(); + + boolean selectorResult = true; + + try + { + try + { + scriptRunner.run( "selector script", basedir, selectorScript, context, logger, BuildJob.Result.SKIPPED, + false ); + } + catch ( RunErrorException e ) + { + selectorResult = false; + throw e; + } + catch ( RunFailureException e ) + { + selectorResult = false; + return false; + } + + scriptRunner.run( "pre-build script", basedir, preBuildHookScript, context, logger, + BuildJob.Result.FAILURE_PRE_HOOK, false ); + + final InvocationRequest request = new DefaultInvocationRequest(); + + request.setLocalRepositoryDirectory( localRepositoryPath ); + + request.setBatchMode( true ); + + request.setShowErrors( showErrors ); + + request.setDebug( debug ); + + request.setShowVersion( showVersion ); + + setupLoggerForBuildJob( logger, request ); + + if ( mavenHome != null ) + { + invoker.setMavenHome( mavenHome ); + // FIXME: Should we really take care of M2_HOME? + request.addShellEnvironment( "M2_HOME", mavenHome.getAbsolutePath() ); + } + + if ( mavenExecutable != null ) + { + invoker.setMavenExecutable( new File( mavenExecutable ) ); + } + + if ( actualJavaHome != null ) + { + request.setJavaHome( actualJavaHome ); + } + + if ( environmentVariables != null ) + { + for ( Map.Entry variable : environmentVariables.entrySet() ) + { + request.addShellEnvironment( variable.getKey(), variable.getValue() ); + } + } + + for ( int invocationIndex = 1;; invocationIndex++ ) + { + if ( invocationIndex > 1 && !invokerProperties.isInvocationDefined( invocationIndex ) ) + { + break; + } + + request.setBaseDirectory( basedir ); + + request.setPomFile( pomFile ); + + request.setGoals( goals ); + + request.setProfiles( profiles ); + + request.setMavenOpts( mavenOpts ); + + request.setOffline( false ); + + int timeOut = invokerProperties.getTimeoutInSeconds( invocationIndex ); + // not set so we use the one at the mojo level + request.setTimeoutInSeconds( timeOut < 0 ? timeoutInSeconds : timeOut ); + + String customSettingsFile = invokerProperties.getSettingsFile( invocationIndex ); + if ( customSettingsFile != null ) + { + File interpolateSettingsFile = interpolateSettings( new File( customSettingsFile ) ); + File mergeSettingsFile = mergeSettings( interpolateSettingsFile ); + + request.setUserSettingsFile( mergeSettingsFile ); + } + else + { + request.setUserSettingsFile( settingsFile ); + } + + Properties systemProperties = + getSystemProperties( basedir, invokerProperties.getSystemPropertiesFile( invocationIndex ) ); + request.setProperties( systemProperties ); + + invokerProperties.configureInvocation( request, invocationIndex ); + + if ( getLog().isDebugEnabled() ) + { + try + { + getLog().debug( "Using MAVEN_OPTS: " + request.getMavenOpts() ); + getLog().debug( "Executing: " + new MavenCommandLineBuilder().build( request ) ); + } + catch ( CommandLineConfigurationException e ) + { + getLog().debug( "Failed to display command line: " + e.getMessage() ); + } + } + + try + { + InvocationResult result = invoker.execute( request ); + verify( result, invocationIndex, invokerProperties, logger ); + } + catch ( final MavenInvocationException e ) + { + getLog().debug( "Error invoking Maven: " + e.getMessage(), e ); + throw new RunFailureException( "Maven invocation failed. " + e.getMessage(), + BuildJob.Result.FAILURE_BUILD ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + finally + { + if ( selectorResult ) + { + runPostBuildHook( basedir, context, logger ); + } + } + return true; + } + + int getParallelThreadsCount() + { + if ( parallelThreads.endsWith( "C" ) ) + { + double parallelThreadsMultiple = Double.parseDouble( + parallelThreads.substring( 0, parallelThreads.length() - 1 ) ); + return (int) ( parallelThreadsMultiple * Runtime.getRuntime().availableProcessors() ); + } + else + { + return Integer.parseInt( parallelThreads ); + } + } + + private void runPostBuildHook( File basedir, Map context, FileLogger logger ) + throws MojoExecutionException, RunFailureException + { + try + { + scriptRunner.run( "post-build script", basedir, postBuildHookScript, context, logger, + BuildJob.Result.FAILURE_POST_HOOK, true ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } + private void setupLoggerForBuildJob( FileLogger logger, final InvocationRequest request ) + { + if ( logger != null ) + { + request.setErrorHandler( logger ); + + request.setOutputHandler( logger ); + } + } + + /** + * Initializes the build logger for the specified project. This will write the logging information into + * {@code build.log}. + * + * @param basedir The base directory of the project, must not be null. + * @return The build logger or null if logging has been disabled. + * @throws org.apache.maven.plugin.MojoExecutionException If the log file could not be created. + */ + private FileLogger setupBuildLogFile( File basedir ) + throws MojoExecutionException + { + FileLogger logger = null; + + if ( !noLog ) + { + Path projectLogDirectory; + if ( logDirectory == null ) + { + projectLogDirectory = basedir.toPath(); + } + else if ( cloneProjectsTo != null ) + { + projectLogDirectory = + logDirectory.toPath().resolve( cloneProjectsTo.toPath().relativize( basedir.toPath() ) ); + } + else + { + projectLogDirectory = + logDirectory.toPath().resolve( projectsDirectory.toPath().relativize( basedir.toPath() ) ); + } + + try + { + if ( streamLogs ) + { + logger = new FileLogger( projectLogDirectory.resolve( "build.log" ).toFile(), getLog() ); + } + else + { + logger = new FileLogger( projectLogDirectory.resolve( "build.log" ).toFile() ); + } + + getLog().debug( "Build log initialized in: " + projectLogDirectory ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error initializing build logfile in: " + projectLogDirectory, e ); + } + } + + return logger; + } + + /** + * Gets the system properties to use for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @param filename The filename to the properties file to load, may be null to use the default path + * given by {@link #testPropertiesFile}. + * @return The system properties to use, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the properties file exists but could not be read. + */ + private Properties getSystemProperties( final File basedir, final String filename ) + throws MojoExecutionException + { + Properties collectedTestProperties = new Properties(); + + if ( properties != null ) + { + // MINVOKER-118: property can have empty value, which is not accepted by collectedTestProperties + for ( Map.Entry entry : properties.entrySet() ) + { + if ( entry.getValue() != null ) + { + collectedTestProperties.put( entry.getKey(), entry.getValue() ); + } + } + } + + File propertiesFile = null; + if ( filename != null ) + { + propertiesFile = new File( basedir, filename ); + } + else if ( testPropertiesFile != null ) + { + propertiesFile = new File( basedir, testPropertiesFile ); + } + + if ( propertiesFile != null && propertiesFile.isFile() ) + { + + try ( InputStream fin = new FileInputStream( propertiesFile ) ) + { + Properties loadedProperties = new Properties(); + loadedProperties.load( fin ); + collectedTestProperties.putAll( loadedProperties ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error reading system properties from " + propertiesFile ); + } + } + + return collectedTestProperties; + } + + /** + * Verifies the invocation result. + * + * @param result The invocation result to check, must not be null. + * @param invocationIndex The index of the invocation for which to check the exit code, must not be negative. + * @param invokerProperties The invoker properties used to check the exit code, must not be null. + * @param logger The build logger, may be null if logging is disabled. + * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException If the invocation result indicates a build + * failure. + */ + private void verify( InvocationResult result, int invocationIndex, InvokerProperties invokerProperties, + FileLogger logger ) + throws RunFailureException + { + if ( result.getExecutionException() != null ) + { + throw new RunFailureException( "The Maven invocation failed. " + + result.getExecutionException().getMessage(), BuildJob.Result.ERROR ); + } + else if ( !invokerProperties.isExpectedResult( result.getExitCode(), invocationIndex ) ) + { + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( "The build exited with code " ).append( result.getExitCode() ).append( ". " ); + if ( logger != null ) + { + buffer.append( "See " ); + buffer.append( logger.getOutputFile().getAbsolutePath() ); + buffer.append( " for details." ); + } + else + { + buffer.append( "See console output for details." ); + } + throw new RunFailureException( buffer.toString(), BuildJob.Result.FAILURE_BUILD ); + } + } + + /** + * Gets the goal list for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @return The list of goals to run when building the project, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the profile file could not be read. + */ + List getGoals( final File basedir ) + throws MojoExecutionException + { + try + { + // FIXME: Currently we have null for goalsFile which has been removed. + // This might mean we can remove getGoals() at all ? Check this. + return getTokens( basedir, null, goals ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "error reading goals", e ); + } + } + + /** + * Gets the profile list for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @return The list of profiles to activate when building the project, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the profile file could not be read. + */ + List getProfiles( File basedir ) + throws MojoExecutionException + { + try + { + return getTokens( basedir, null, profiles ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "error reading profiles", e ); + } + } + + private List calculateExcludes() + throws IOException + { + List excludes = + ( pomExcludes != null ) ? new ArrayList<>( pomExcludes ) : new ArrayList(); + if ( this.settingsFile != null ) + { + String exclude = relativizePath( this.settingsFile, projectsDirectory.getCanonicalPath() ); + if ( exclude != null ) + { + excludes.add( exclude.replace( '\\', '/' ) ); + getLog().debug( "Automatically excluded " + exclude + " from project scanning" ); + } + } + return excludes; + + } + + /** + * @return The list of setupUp jobs. + * @throws IOException + * @see {@link #setupIncludes} + */ + private List getSetupBuildJobsFromFolders() + throws IOException, MojoExecutionException + { + List excludes = calculateExcludes(); + + List setupPoms = scanProjectsDirectory( setupIncludes, excludes, BuildJob.Type.SETUP ); + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Setup projects: " + setupPoms ); + } + + return setupPoms; + } + + private static class OrdinalComparator implements Comparator + { + private static final OrdinalComparator INSTANCE = new OrdinalComparator(); + + @Override + public int compare( Object o1, Object o2 ) + { + return Integer.compare( ( ( BuildJob ) o2 ).getOrdinal(), ( ( BuildJob ) o1 ).getOrdinal() ); + } + } + + /** + * Gets the build jobs that should be processed. Note that the order of the returned build jobs is significant. + * + * @return The build jobs to process, may be empty but never null. + * @throws java.io.IOException If the projects directory could not be scanned. + */ + List getBuildJobs() + throws IOException, MojoExecutionException + { + List buildJobs; + + if ( invokerTest == null ) + { + List excludes = calculateExcludes(); + + List setupPoms = scanProjectsDirectory( setupIncludes, excludes, BuildJob.Type.SETUP ); + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Setup projects: " + Arrays.asList( setupPoms ) ); + } + + List normalPoms = scanProjectsDirectory( pomIncludes, excludes, BuildJob.Type.NORMAL ); + + Map uniquePoms = new LinkedHashMap<>(); + for ( BuildJob setupPom : setupPoms ) + { + uniquePoms.put( setupPom.getProject(), setupPom ); + } + for ( BuildJob normalPom : normalPoms ) + { + if ( !uniquePoms.containsKey( normalPom.getProject() ) ) + { + uniquePoms.put( normalPom.getProject(), normalPom ); + } + } + + buildJobs = new ArrayList<>( uniquePoms.values() ); + } + else + { + String[] testRegexes = StringUtils.split( invokerTest, "," ); + List includes = new ArrayList<>( testRegexes.length ); + List excludes = new ArrayList<>(); + + for ( String regex : testRegexes ) + { + // user just use -Dinvoker.test=MWAR191,MNG111 to use a directory thats the end is not pom.xml + if ( regex.startsWith( "!" ) ) + { + excludes.add( regex.substring( 1 ) ); + } + else + { + includes.add( regex ); + } + } + + // it would be nice if we could figure out what types these are... but perhaps + // not necessary for the -Dinvoker.test=xxx t + buildJobs = scanProjectsDirectory( includes, excludes, BuildJob.Type.DIRECT ); + } + + relativizeProjectPaths( buildJobs ); + + return buildJobs; + } + + /** + * Scans the projects directory for projects to build. Both (POM) files and mere directories will be matched by the + * scanner patterns. If the patterns match a directory which contains a file named "pom.xml", the results will + * include the path to this file rather than the directory path in order to avoid duplicate invocations of the same + * project. + * + * @param includes The include patterns for the scanner, may be null. + * @param excludes The exclude patterns for the scanner, may be null to exclude nothing. + * @param type The type to assign to the resulting build jobs, must not be null. + * @return The build jobs matching the patterns, never null. + * @throws java.io.IOException If the project directory could not be scanned. + */ + private List scanProjectsDirectory( List includes, List excludes, String type ) + throws IOException, MojoExecutionException + { + if ( !projectsDirectory.isDirectory() ) + { + return Collections.emptyList(); + } + + DirectoryScanner scanner = new DirectoryScanner(); + scanner.setBasedir( projectsDirectory.getCanonicalFile() ); + scanner.setFollowSymlinks( false ); + if ( includes != null ) + { + scanner.setIncludes( includes.toArray( new String[includes.size()] ) ); + } + if ( excludes != null ) + { + scanner.setExcludes( excludes.toArray( new String[excludes.size()] ) ); + } + scanner.addDefaultExcludes(); + scanner.scan(); + + Map matches = new LinkedHashMap<>(); + + for ( String includedFile : scanner.getIncludedFiles() ) + { + matches.put( includedFile, new BuildJob( includedFile, type ) ); + } + + for ( String includedDir : scanner.getIncludedDirectories() ) + { + String includedFile = includedDir + File.separatorChar + "pom.xml"; + if ( new File( scanner.getBasedir(), includedFile ).isFile() ) + { + matches.put( includedFile, new BuildJob( includedFile, type ) ); + } + else + { + matches.put( includedDir, new BuildJob( includedDir, type ) ); + } + } + + List projects = new ArrayList<>( matches.size() ); + + // setup ordinal values to have an order here + for ( BuildJob buildJob : matches.values() ) + { + InvokerProperties invokerProperties = + getInvokerProperties( new File( projectsDirectory, buildJob.getProject() ).getParentFile(), + null ); + buildJob.setOrdinal( invokerProperties.getOrdinal() ); + projects.add( buildJob ); + } + Collections.sort( projects, OrdinalComparator.INSTANCE ); + return projects; + } + + /** + * Relativizes the project paths of the specified build jobs against the directory specified by + * {@link #projectsDirectory} (if possible). If a project path does not denote a sub path of the projects directory, + * it is returned as is. + * + * @param buildJobs The build jobs whose project paths should be relativized, must not be null nor + * contain null elements. + * @throws java.io.IOException If any path could not be relativized. + */ + private void relativizeProjectPaths( List buildJobs ) + throws IOException + { + String projectsDirPath = projectsDirectory.getCanonicalPath(); + + for ( BuildJob buildJob : buildJobs ) + { + String projectPath = buildJob.getProject(); + + File file = new File( projectPath ); + + if ( !file.isAbsolute() ) + { + file = new File( projectsDirectory, projectPath ); + } + + String relativizedPath = relativizePath( file, projectsDirPath ); + + if ( relativizedPath == null ) + { + relativizedPath = projectPath; + } + + buildJob.setProject( relativizedPath ); + } + } + + /** + * Relativizes the specified path against the given base directory. Besides relativization, the returned path will + * also be normalized, e.g. directory references like ".." will be removed. + * + * @param path The path to relativize, must not be null. + * @param basedir The (canonical path of the) base directory to relativize against, must not be null. + * @return The relative path in normal form or null if the input path does not denote a sub path of the + * base directory. + * @throws java.io.IOException If the path could not be relativized. + */ + private String relativizePath( File path, String basedir ) + throws IOException + { + String relativizedPath = path.getCanonicalPath(); + + if ( relativizedPath.startsWith( basedir ) ) + { + relativizedPath = relativizedPath.substring( basedir.length() ); + if ( relativizedPath.startsWith( File.separator ) ) + { + relativizedPath = relativizedPath.substring( File.separator.length() ); + } + + return relativizedPath; + } + else + { + return null; + } + } + + /** + * Returns the map-based value source used to interpolate POMs and other stuff. + * + * @param escapeXml {@code true}, to escape any XML special characters in the property values; {@code false}, to not + * escape any property values. + * + * @return The map-based value source for interpolation, never null. + */ + private Map getInterpolationValueSource( final boolean escapeXml ) + { + Map props = new HashMap<>(); + + if ( filterProperties != null ) + { + props.putAll( filterProperties ); + } + props.put( "basedir", this.project.getBasedir().getAbsolutePath() ); + props.put( "baseurl", toUrl( this.project.getBasedir().getAbsolutePath() ) ); + if ( settings.getLocalRepository() != null ) + { + props.put( "localRepository", settings.getLocalRepository() ); + props.put( "localRepositoryUrl", toUrl( settings.getLocalRepository() ) ); + } + + return new CompositeMap( this.project, props, escapeXml ); + } + + /** + * Converts the specified filesystem path to a URL. The resulting URL has no trailing slash regardless whether the + * path denotes a file or a directory. + * + * @param filename The filesystem path to convert, must not be null. + * @return The file: URL for the specified path, never null. + */ + private static String toUrl( String filename ) + { + /* + * NOTE: Maven fails to properly handle percent-encoded "file:" URLs (WAGON-111) so don't use File.toURI() here + * as-is but use the decoded path component in the URL. + */ + String url = "file://" + new File( filename ).toURI().getPath(); + if ( url.endsWith( "/" ) ) + { + url = url.substring( 0, url.length() - 1 ); + } + return url; + } + + /** + * Gets goal/profile names for the specified project, either directly from the plugin configuration or from an + * external token file. + * + * @param basedir The base directory of the test project, must not be null. + * @param filename The (simple) name of an optional file in the project base directory from which to read + * goals/profiles, may be null. + * @param defaultTokens The list of tokens to return in case the specified token file does not exist, may be + * null. + * @return The list of goal/profile names, may be empty but never null. + * @throws java.io.IOException If the token file exists but could not be parsed. + */ + private List getTokens( File basedir, String filename, List defaultTokens ) + throws IOException + { + List tokens = ( defaultTokens != null ) ? defaultTokens : new ArrayList(); + + if ( StringUtils.isNotEmpty( filename ) ) + { + File tokenFile = new File( basedir, filename ); + + if ( tokenFile.exists() ) + { + tokens = readTokens( tokenFile ); + } + } + + return tokens; + } + + /** + * Reads the tokens from the specified file. Tokens are separated either by line terminators or commas. During + * parsing, the file contents will be interpolated. + * + * @param tokenFile The file to read the tokens from, must not be null. + * @return The list of tokens, may be empty but never null. + * @throws java.io.IOException If the token file could not be read. + */ + private List readTokens( final File tokenFile ) + throws IOException + { + List result = new ArrayList<>(); + + Map composite = getInterpolationValueSource( false ); + + try ( BufferedReader reader = + new BufferedReader( new InterpolationFilterReader( newReader( tokenFile ), composite ) ) ) + { + for ( String line = reader.readLine(); line != null; line = reader.readLine() ) + { + result.addAll( collectListFromCSV( line ) ); + } + } + + return result; + } + + /** + * Gets a list of comma separated tokens from the specified line. + * + * @param csv The line with comma separated tokens, may be null. + * @return The list of tokens from the line, may be empty but never null. + */ + private List collectListFromCSV( final String csv ) + { + final List result = new ArrayList<>(); + + if ( ( csv != null ) && ( csv.trim().length() > 0 ) ) + { + final StringTokenizer st = new StringTokenizer( csv, "," ); + + while ( st.hasMoreTokens() ) + { + result.add( st.nextToken().trim() ); + } + } + + return result; + } + + /** + * Interpolates the specified POM/settings file to a temporary file. The destination file may be same as the input + * file, i.e. interpolation can be performed in-place. + *

+ * Note:This methods expects the file to be a XML file and applies special XML escaping during interpolation. + *

+ * + * @param originalFile The XML file to interpolate, must not be null. + * @param interpolatedFile The target file to write the interpolated contents of the original file to, must not be + * null. + * + * @throws org.apache.maven.plugin.MojoExecutionException If the target file could not be created. + */ + void buildInterpolatedFile( File originalFile, File interpolatedFile ) + throws MojoExecutionException + { + getLog().debug( "Interpolate " + originalFile.getPath() + " to " + interpolatedFile.getPath() ); + + try + { + String xml; + + Map composite = getInterpolationValueSource( true ); + + // interpolation with token @...@ + try ( Reader reader = + new InterpolationFilterReader( ReaderFactory.newXmlReader( originalFile ), composite, "@", "@" ) ) + { + xml = IOUtil.toString( reader ); + } + + try ( Writer writer = WriterFactory.newXmlWriter( interpolatedFile ) ) + { + interpolatedFile.getParentFile().mkdirs(); + + writer.write( xml ); + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to interpolate file " + originalFile.getPath(), e ); + } + } + + /** + * Gets the (interpolated) invoker properties for an integration test. + * + * @param projectDirectory The base directory of the IT project, must not be null. + * @return The invoker properties, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If an I/O error occurred during reading the properties. + */ + private InvokerProperties getInvokerProperties( final File projectDirectory, Properties globalInvokerProperties ) + throws MojoExecutionException + { + Properties props; + if ( globalInvokerProperties != null ) + { + props = new Properties( globalInvokerProperties ); + } + else + { + props = new Properties(); + } + + File propertiesFile = new File( projectDirectory, invokerPropertiesFile ); + if ( propertiesFile.isFile() ) + { + try ( InputStream in = new FileInputStream( propertiesFile ) ) + { + props.load( in ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read invoker properties: " + propertiesFile, e ); + } + } + + Interpolator interpolator = new RegexBasedInterpolator(); + interpolator.addValueSource( new MapBasedValueSource( getInterpolationValueSource( false ) ) ); + // CHECKSTYLE_OFF: LineLength + for ( String key : props.stringPropertyNames() ) + { + String value = props.getProperty( key ); + try + { + value = interpolator.interpolate( value, "" ); + } + catch ( InterpolationException e ) + { + throw new MojoExecutionException( "Failed to interpolate invoker properties: " + propertiesFile, + e ); + } + props.setProperty( key, value ); + } + return new InvokerProperties( props ); + } + + static class ToolchainPrivateManager + { + private ToolchainManagerPrivate manager; + + private MavenSession session; + + ToolchainPrivateManager( ToolchainManagerPrivate manager, MavenSession session ) + { + this.manager = manager; + this.session = session; + } + + ToolchainPrivate[] getToolchainPrivates( String type ) throws MisconfiguredToolchainException + { + return manager.getToolchainsForType( type, session ); + } + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/CompositeMap.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/CompositeMap.java new file mode 100644 index 000000000..13b902c20 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/CompositeMap.java @@ -0,0 +1,258 @@ +package org.apache.maven.plugins.invoker; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.util.introspection.ReflectionValueExtractor; + +/** + * A map-like source to interpolate expressions. + * + * @author Olivier Lamy + * @since 1.1 + */ +class CompositeMap + implements Map +{ + + /** + * The Maven project from which to extract interpolated values, never null. + */ + private MavenProject mavenProject; + + /** + * The set of additional properties from which to extract interpolated values, never null. + */ + private Map properties; + + /** + * Flag indicating to escape XML special characters. + */ + private final boolean escapeXml; + + /** + * Creates a new interpolation source backed by the specified Maven project and some user-specified properties. + * + * @param mavenProject The Maven project from which to extract interpolated values, must not be null. + * @param properties The set of additional properties from which to extract interpolated values, may be + * null. + * @param escapeXml {@code true}, to escape any XML special characters; {@code false}, to not perform any escaping. + */ + protected CompositeMap( MavenProject mavenProject, Map properties, boolean escapeXml ) + { + if ( mavenProject == null ) + { + throw new IllegalArgumentException( "no project specified" ); + } + this.mavenProject = mavenProject; + this.properties = properties == null ? new HashMap() : properties; + this.escapeXml = escapeXml; + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#clear() + */ + public void clear() + { + // nothing here + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#containsKey(java.lang.Object) + */ + public boolean containsKey( Object key ) + { + if ( !( key instanceof String ) ) + { + return false; + } + + String expression = (String) key; + if ( expression.startsWith( "project." ) || expression.startsWith( "pom." ) ) + { + try + { + Object evaluated = ReflectionValueExtractor.evaluate( expression, this.mavenProject ); + if ( evaluated != null ) + { + return true; + } + } + catch ( Exception e ) + { + // uhm do we have to throw a RuntimeException here ? + } + } + + return properties.containsKey( key ) || mavenProject.getProperties().containsKey( key ); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#containsValue(java.lang.Object) + */ + public boolean containsValue( Object value ) + { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#entrySet() + */ + public Set> entrySet() + { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#get(java.lang.Object) + */ + public Object get( Object key ) + { + if ( !( key instanceof String ) ) + { + return null; + } + + Object value = null; + String expression = (String) key; + if ( expression.startsWith( "project." ) || expression.startsWith( "pom." ) ) + { + try + { + Object evaluated = ReflectionValueExtractor.evaluate( expression, this.mavenProject ); + if ( evaluated != null ) + { + value = evaluated; + } + } + catch ( Exception e ) + { + // uhm do we have to throw a RuntimeException here ? + } + } + + if ( value == null ) + { + value = properties.get( key ); + } + + if ( value == null ) + { + value = this.mavenProject.getProperties().get( key ); + } + + if ( value != null && this.escapeXml ) + { + value = value.toString(). + replaceAll( "\"", """ ). + replaceAll( "<", "<" ). + replaceAll( ">", ">" ). + replaceAll( "&", "&" ); + + } + + return value; + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#isEmpty() + */ + public boolean isEmpty() + { + return this.mavenProject.getProperties().isEmpty() && this.properties.isEmpty(); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#keySet() + */ + public Set keySet() + { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#put(java.lang.Object, java.lang.Object) + */ + public Object put( String key, Object value ) + { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#putAll(java.util.Map) + */ + public void putAll( Map t ) + { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#remove(java.lang.Object) + */ + public Object remove( Object key ) + { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#size() + */ + public int size() + { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + * + * @see java.util.Map#values() + */ + public Collection values() + { + throw new UnsupportedOperationException(); + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/FileLogger.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/FileLogger.java new file mode 100644 index 000000000..9e67115b6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/FileLogger.java @@ -0,0 +1,62 @@ +package org.apache.maven.plugins.invoker; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; + +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.shared.invoker.InvocationOutputHandler; +import org.apache.maven.shared.scriptinterpreter.ExecutionLogger; + +/** + * + */ +class FileLogger + extends org.apache.maven.shared.scriptinterpreter.FileLogger + implements InvocationOutputHandler, ExecutionLogger +{ + + /** + * Creates a new logger that writes to the specified file. + * + * @param outputFile The path to the output file, must not be null. + * @throws IOException If the output file could not be created. + */ + FileLogger( File outputFile ) + throws IOException + { + super( outputFile, null ); + } + + /** + * Creates a new logger that writes to the specified file and optionally mirrors messages to the given mojo logger. + * + * @param outputFile The path to the output file, must not be null. + * @param log The mojo logger to additionally output messages to, may be null if not used. + * @throws IOException If the output file could not be created. + */ + FileLogger( File outputFile, Log log ) + throws IOException + { + super( outputFile, log ); + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java new file mode 100644 index 000000000..bf9b72173 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java @@ -0,0 +1,661 @@ +package org.apache.maven.plugins.invoker; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter; +import org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller; +import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult; +import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver; +import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException; +import org.apache.maven.shared.transfer.repository.RepositoryManager; +import org.codehaus.plexus.util.FileUtils; + +/** + * Installs the project artifacts of the main build into the local repository as a preparation to run the sub projects. + * More precisely, all artifacts of the project itself, all its locally reachable parent POMs and all its dependencies + * from the reactor will be installed to the local repository. + * + * @since 1.2 + * @author Paul Gier + * @author Benjamin Bentmann + * + */ +// CHECKSTYLE_OFF: LineLength +@Mojo( name = "install", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) +// CHECKSTYLE_ON: LineLength +public class InstallMojo + extends AbstractMojo +{ + + /** + * Maven artifact install component to copy artifacts to the local repository. + */ + @Component + private ArtifactInstaller installer; + + @Component + private RepositoryManager repositoryManager; + + /** + * The component used to create artifacts. + */ + @Component + private ArtifactFactory artifactFactory; + + /** + */ + @Parameter( property = "localRepository", required = true, readonly = true ) + private ArtifactRepository localRepository; + + /** + * The path to the local repository into which the project artifacts should be installed for the integration tests. + * If not set, the regular local repository will be used. To prevent soiling of your regular local repository with + * possibly broken artifacts, it is strongly recommended to use an isolated repository for the integration tests + * (e.g. ${project.build.directory}/it-repo). + */ + @Parameter( property = "invoker.localRepositoryPath", + defaultValue = "${session.localRepository.basedir}", required = true ) + private File localRepositoryPath; + + /** + * The current Maven project. + */ + @Parameter( defaultValue = "${project}", readonly = true, required = true ) + private MavenProject project; + + @Parameter( defaultValue = "${session}", readonly = true, required = true ) + private MavenSession session; + + /** + * The set of Maven projects in the reactor build. + */ + @Parameter( defaultValue = "${reactorProjects}", readonly = true ) + private Collection reactorProjects; + + /** + * A flag used to disable the installation procedure. This is primarily intended for usage from the command line to + * occasionally adjust the build. + * + * @since 1.4 + */ + @Parameter( property = "invoker.skip", defaultValue = "false" ) + private boolean skipInstallation; + + /** + * The identifiers of already installed artifacts, used to avoid multiple installation of the same artifact. + */ + private Collection installedArtifacts; + + /** + * The identifiers of already copied artifacts, used to avoid multiple installation of the same artifact. + */ + private Collection copiedArtifacts; + + /** + * Extra dependencies that need to be installed on the local repository.
+ * Format: + * + *
+     * groupId:artifactId:version:type:classifier
+     * 
+ * + * Examples: + * + *
+     * org.apache.maven.plugins:maven-clean-plugin:2.4:maven-plugin
+     * org.apache.maven.plugins:maven-clean-plugin:2.4:jar:javadoc
+     * 
+ * + * If the type is 'maven-plugin' the plugin will try to resolve the artifact using plugin remote repositories, + * instead of using artifact remote repositories. + * + * @since 1.6 + */ + @Parameter + private String[] extraArtifacts; + + /** + */ + @Component + private DependencyResolver resolver; + + + /** + * if the local repository is not used as test repo, the parameter can force get artifacts from local repo + * if available instead of download the artifacts again. + * @since 3.2.1 + */ + @Parameter( property = "invoker.useLocalRepository", defaultValue = "false" ) + private boolean useLocalRepository; + + private ProjectBuildingRequest projectBuildingRequest; + + /** + * Performs this mojo's tasks. + * + * @throws MojoExecutionException If the artifacts could not be installed. + */ + public void execute() + throws MojoExecutionException + { + if ( skipInstallation ) + { + getLog().info( "Skipping artifact installation per configuration." ); + return; + } + + createTestRepository(); + + installedArtifacts = new HashSet<>(); + copiedArtifacts = new HashSet<>(); + + installProjectDependencies( project, reactorProjects ); + installProjectParents( project ); + installProjectArtifacts( project ); + + installExtraArtifacts( extraArtifacts ); + } + + /** + * Creates the local repository for the integration tests. If the user specified a custom repository location, the + * custom repository will have the same identifier, layout and policies as the real local repository. That means + * apart from the location, the custom repository will be indistinguishable from the real repository such that its + * usage is transparent to the integration tests. + * + * @throws MojoExecutionException If the repository could not be created. + */ + private void createTestRepository() + throws MojoExecutionException + { + + if ( !localRepositoryPath.exists() && !localRepositoryPath.mkdirs() ) + { + throw new MojoExecutionException( "Failed to create directory: " + localRepositoryPath ); + } + projectBuildingRequest = + repositoryManager.setLocalRepositoryBasedir( session.getProjectBuildingRequest(), localRepositoryPath ); + } + + /** + * Installs the specified artifact to the local repository. Note: This method should only be used for artifacts that + * originate from the current (reactor) build. Artifacts that have been grabbed from the user's local repository + * should be installed to the test repository via {@link #copyArtifact(File, Artifact)}. + * + * @param file The file associated with the artifact, must not be null. This is in most cases the value + * of artifact.getFile() with the exception of the main artifact from a project with + * packaging "pom". Projects with packaging "pom" have no main artifact file. They have however artifact + * metadata (e.g. site descriptors) which needs to be installed. + * @param artifact The artifact to install, must not be null. + * @throws MojoExecutionException If the artifact could not be installed (e.g. has no associated file). + */ + private void installArtifact( File file, Artifact artifact ) + throws MojoExecutionException + { + try + { + if ( file == null ) + { + throw new IllegalStateException( "Artifact has no associated file: " + artifact.getId() ); + } + if ( !file.isFile() ) + { + throw new IllegalStateException( "Artifact is not fully assembled: " + file ); + } + + if ( installedArtifacts.add( artifact.getId() ) ) + { + artifact.setFile( file ); + installer.install( projectBuildingRequest, localRepositoryPath, + Collections.singletonList( artifact ) ); + } + else + { + getLog().debug( "Not re-installing " + artifact + ", " + file ); + } + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Failed to install artifact: " + artifact, e ); + } + } + + /** + * Installs the specified artifact to the local repository. This method serves basically the same purpose as + * {@link #installArtifact(File, Artifact)} but is meant for artifacts that have been resolved + * from the user's local repository (and not the current build outputs). The subtle difference here is that + * artifacts from the repository have already undergone transformations and these manipulations should not be redone + * by the artifact installer. For this reason, this method performs plain copy operations to install the artifacts. + * + * @param file The file associated with the artifact, must not be null. + * @param artifact The artifact to install, must not be null. + * @throws MojoExecutionException If the artifact could not be installed (e.g. has no associated file). + */ + private void copyArtifact( File file, Artifact artifact ) + throws MojoExecutionException + { + try + { + if ( file == null ) + { + throw new IllegalStateException( "Artifact has no associated file: " + artifact.getId() ); + } + if ( !file.isFile() ) + { + throw new IllegalStateException( "Artifact is not fully assembled: " + file ); + } + + if ( copiedArtifacts.add( artifact.getId() ) ) + { + File destination = + new File( localRepositoryPath, + repositoryManager.getPathForLocalArtifact( projectBuildingRequest, artifact ) ); + + getLog().debug( "Installing " + file + " to " + destination ); + + copyFileIfDifferent( file, destination ); + + MetadataUtils.createMetadata( destination, artifact ); + } + else + { + getLog().debug( "Not re-installing " + artifact + ", " + file ); + } + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Failed to stage artifact: " + artifact, e ); + } + } + + private void copyFileIfDifferent( File src, File dst ) + throws IOException + { + if ( src.lastModified() != dst.lastModified() || src.length() != dst.length() ) + { + FileUtils.copyFile( src, dst ); + dst.setLastModified( src.lastModified() ); + } + } + + /** + * Installs the main artifact and any attached artifacts of the specified project to the local repository. + * + * @param mvnProject The project whose artifacts should be installed, must not be null. + * @throws MojoExecutionException If any artifact could not be installed. + */ + private void installProjectArtifacts( MavenProject mvnProject ) + throws MojoExecutionException + { + try + { + // Install POM (usually attached as metadata but that happens only as a side effect of the Install Plugin) + installProjectPom( mvnProject ); + + // Install the main project artifact (if the project has one, e.g. has no "pom" packaging) + Artifact mainArtifact = mvnProject.getArtifact(); + if ( mainArtifact.getFile() != null ) + { + installArtifact( mainArtifact.getFile(), mainArtifact ); + } + + // Install any attached project artifacts + Collection attachedArtifacts = mvnProject.getAttachedArtifacts(); + for ( Artifact attachedArtifact : attachedArtifacts ) + { + installArtifact( attachedArtifact.getFile(), attachedArtifact ); + } + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Failed to install project artifacts: " + mvnProject, e ); + } + } + + /** + * Installs the (locally reachable) parent POMs of the specified project to the local repository. The parent POMs + * from the reactor must be installed or the forked IT builds will fail when using a clean repository. + * + * @param mvnProject The project whose parent POMs should be installed, must not be null. + * @throws MojoExecutionException If any POM could not be installed. + */ + private void installProjectParents( MavenProject mvnProject ) + throws MojoExecutionException + { + try + { + for ( MavenProject parent = mvnProject.getParent(); parent != null; parent = parent.getParent() ) + { + if ( parent.getFile() == null ) + { + copyParentPoms( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() ); + break; + } + installProjectPom( parent ); + } + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Failed to install project parents: " + mvnProject, e ); + } + } + + /** + * Installs the POM of the specified project to the local repository. + * + * @param mvnProject The project whose POM should be installed, must not be null. + * @throws MojoExecutionException If the POM could not be installed. + */ + private void installProjectPom( MavenProject mvnProject ) + throws MojoExecutionException + { + try + { + Artifact pomArtifact = null; + if ( "pom".equals( mvnProject.getPackaging() ) ) + { + pomArtifact = mvnProject.getArtifact(); + } + if ( pomArtifact == null ) + { + pomArtifact = + artifactFactory.createProjectArtifact( mvnProject.getGroupId(), mvnProject.getArtifactId(), + mvnProject.getVersion() ); + } + installArtifact( mvnProject.getFile(), pomArtifact ); + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Failed to install POM: " + mvnProject, e ); + } + } + + /** + * Installs the dependent projects from the reactor to the local repository. The dependencies on other modules from + * the reactor must be installed or the forked IT builds will fail when using a clean repository. + * + * @param mvnProject The project whose dependent projects should be installed, must not be null. + * @param reactorProjects The set of projects in the reactor build, must not be null. + * @throws MojoExecutionException If any dependency could not be installed. + */ + private void installProjectDependencies( MavenProject mvnProject, Collection reactorProjects ) + throws MojoExecutionException + { + // ... into dependencies that were resolved from reactor projects ... + Collection dependencyProjects = new LinkedHashSet<>(); + collectAllProjectReferences( mvnProject, dependencyProjects ); + + // index available reactor projects + Map projects = new HashMap<>( reactorProjects.size() ); + for ( MavenProject reactorProject : reactorProjects ) + { + String projectId = + reactorProject.getGroupId() + ':' + reactorProject.getArtifactId() + ':' + reactorProject.getVersion(); + + projects.put( projectId, reactorProject ); + } + + // group transitive dependencies (even those that don't contribute to the class path like POMs) ... + Collection artifacts = mvnProject.getArtifacts(); + // ... and those that were resolved from the (local) repo + Collection dependencyArtifacts = new LinkedHashSet<>(); + + for ( Artifact artifact : artifacts ) + { + // workaround for MNG-2961 to ensure the base version does not contain a timestamp + artifact.isSnapshot(); + + String projectId = artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion(); + + if ( !projects.containsKey( projectId ) ) + { + dependencyArtifacts.add( artifact ); + } + } + + // install dependencies + try + { + // copy dependencies that where resolved from the local repo + for ( Artifact artifact : dependencyArtifacts ) + { + copyArtifact( artifact ); + } + + // install dependencies that were resolved from the reactor + for ( String projectId : dependencyProjects ) + { + MavenProject dependencyProject = projects.get( projectId ); + if ( dependencyProject == null ) + { + getLog().warn( "skip dependencyProject null for projectId=" + projectId ); + continue; + } + installProjectArtifacts( dependencyProject ); + installProjectParents( dependencyProject ); + } + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Failed to install project dependencies: " + mvnProject, e ); + } + } + + protected void collectAllProjectReferences( MavenProject project, Collection dependencyProjects ) + { + for ( MavenProject reactorProject : project.getProjectReferences().values() ) + { + String projectId = + reactorProject.getGroupId() + ':' + reactorProject.getArtifactId() + ':' + reactorProject.getVersion(); + if ( dependencyProjects.add( projectId ) ) + { + collectAllProjectReferences( reactorProject, dependencyProjects ); + } + } + } + + private void copyArtifact( Artifact artifact ) + throws MojoExecutionException + { + copyPoms( artifact ); + + Artifact depArtifact = + artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(), + artifact.getBaseVersion(), artifact.getType(), + artifact.getClassifier() ); + + File artifactFile = artifact.getFile(); + + copyArtifact( artifactFile, depArtifact ); + } + + private void copyPoms( Artifact artifact ) + throws MojoExecutionException + { + Artifact pomArtifact = + artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), + artifact.getBaseVersion() ); + + File pomFile = new File( localRepository.getBasedir(), localRepository.pathOf( pomArtifact ) ); + + if ( pomFile.isFile() ) + { + copyArtifact( pomFile, pomArtifact ); + copyParentPoms( pomFile ); + } + } + + /** + * Installs all parent POMs of the specified POM file that are available in the local repository. + * + * @param pomFile The path to the POM file whose parents should be installed, must not be null. + * @throws MojoExecutionException If any (existing) parent POM could not be installed. + */ + private void copyParentPoms( File pomFile ) + throws MojoExecutionException + { + Model model = PomUtils.loadPom( pomFile ); + Parent parent = model.getParent(); + if ( parent != null ) + { + copyParentPoms( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() ); + } + } + + /** + * Installs the specified POM and all its parent POMs to the local repository. + * + * @param groupId The group id of the POM which should be installed, must not be null. + * @param artifactId The artifact id of the POM which should be installed, must not be null. + * @param version The version of the POM which should be installed, must not be null. + * @throws MojoExecutionException If any (existing) parent POM could not be installed. + */ + private void copyParentPoms( String groupId, String artifactId, String version ) + throws MojoExecutionException + { + Artifact pomArtifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); + + if ( installedArtifacts.contains( pomArtifact.getId() ) || copiedArtifacts.contains( pomArtifact.getId() ) ) + { + getLog().debug( "Not re-installing " + pomArtifact ); + return; + } + + File pomFile = new File( localRepository.getBasedir(), localRepository.pathOf( pomArtifact ) ); + if ( pomFile.isFile() ) + { + copyArtifact( pomFile, pomArtifact ); + copyParentPoms( pomFile ); + } + } + + private void installExtraArtifacts( String[] extraArtifacts ) + throws MojoExecutionException + { + if ( extraArtifacts == null ) + { + return; + } + + for ( String extraArtifact : extraArtifacts ) + { + String[] gav = extraArtifact.split( ":" ); + if ( gav.length < 3 || gav.length > 5 ) + { + throw new MojoExecutionException( "Invalid artifact " + extraArtifact ); + } + + String groupId = gav[0]; + String artifactId = gav[1]; + String version = gav[2]; + + String type = "jar"; + if ( gav.length > 3 ) + { + type = gav[3]; + } + + String classifier = null; + if ( gav.length == 5 ) + { + classifier = gav[4]; + } + + DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate(); + try + { + coordinate.setGroupId( groupId ); + coordinate.setArtifactId( artifactId ); + coordinate.setVersion( version ); + coordinate.setType( type ); + coordinate.setClassifier( classifier ); + + + if ( !localRepository.getBasedir().equals( localRepositoryPath.getPath() ) && useLocalRepository ) + { + String previousId = localRepository.getId(); + try + { + // using another request with the correct target repo + ProjectBuildingRequest projectBuildingRequest = repositoryManager + .setLocalRepositoryBasedir( session.getProjectBuildingRequest(), + localRepositoryPath ); + projectBuildingRequest.setRemoteRepositories( Arrays.asList( localRepository ) ); + resolver.resolveDependencies( projectBuildingRequest, coordinate, + new PatternExclusionsFilter( Collections.emptyList() ) ); + } + finally + { + localRepository.setId( previousId ); + } + } + else + { + resolver.resolveDependencies( projectBuildingRequest, coordinate, + new PatternExclusionsFilter( Collections.emptyList() ) ); + } + } + catch ( DependencyResolverException e ) + { + throw new MojoExecutionException( "Unable to resolve dependencies for: " + coordinate, e ); + } + } + } + + // FIXME could be simplify with using lambda... maybe in the next century... :P + private List toArtifactsList( Iterable artifactResults ) + { + List artifacts = new ArrayList<>( ); + for ( ArtifactResult artifactResult : artifactResults ) + { + artifacts.add( artifactResult.getArtifact() ); + } + return artifacts; + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/IntegrationTestMojo.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/IntegrationTestMojo.java new file mode 100644 index 000000000..8e8021b0f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/IntegrationTestMojo.java @@ -0,0 +1,47 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; + +/** + * Searches for integration test Maven projects, and executes each, collecting a log in the project directory, will + * never fail the build, designed to be used in conjunction with the verify mojo. + * + * @since 1.4 + * @author Stephen Connolly + */ +// CHECKSTYLE_OFF: LineLength +@Mojo( name = "integration-test", defaultPhase = LifecyclePhase.INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true ) +public class IntegrationTestMojo + extends AbstractInvokerMojo +{ + + void processResults( InvokerSession invokerSession ) + throws MojoFailureException + { + // do nothing + } + +} +// CHECKSTYLE_ON: LineLength diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerMojo.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerMojo.java new file mode 100644 index 000000000..6dbbbd48d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerMojo.java @@ -0,0 +1,94 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.plugin.MojoFailureException; +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.plugins.annotations.ResolutionScope; + +/** + * Searches for integration test Maven projects, and executes each, collecting a log in the project directory, and + * outputting the results to the command line. + * + * @since 1.0 + * @author Kenney Westerhof + * @author John Casey + */ +// CHECKSTYLE_OFF: LineLength +@Mojo( name = "run", defaultPhase = LifecyclePhase.INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true ) +// CHECKSTYLE_ON: LineLength +public class InvokerMojo + extends AbstractInvokerMojo +{ + + /** + * A flag controlling whether failures of the sub builds should fail the main build, too. If set to + * true, the main build will proceed even if one or more sub builds failed. + * + * @since 1.3 + */ + @Parameter( property = "maven.test.failure.ignore", defaultValue = "false" ) + private boolean ignoreFailures; + + /** + * Set this to true to cause a failure if there are no projects to invoke. + * + * @since 1.9 + */ + @Parameter( property = "invoker.failIfNoProjects" ) + private Boolean failIfNoProjects; + + /** + * Set to true to output build.log to mojo log in case of failed jobs. + * + * @since 3.2.2 + */ + @Parameter( property = "invoker.streamLogsOnFailures", defaultValue = "false" ) + private boolean streamLogsOnFailures; + + void processResults( InvokerSession invokerSession ) + throws MojoFailureException + { + if ( !suppressSummaries ) + { + invokerSession.logSummary( getLog(), ignoreFailures ); + } + + if ( streamLogsOnFailures ) + { + invokerSession.logFailedBuildLog( getLog(), ignoreFailures ); + } + + invokerSession.handleFailures( getLog(), ignoreFailures ); + } + + @Override + protected void doFailIfNoProjects() + throws MojoFailureException + { + if ( Boolean.TRUE.equals( failIfNoProjects ) ) + { + throw new MojoFailureException( "No projects to invoke!" ); + } + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java new file mode 100644 index 000000000..8dd77427e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java @@ -0,0 +1,484 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.maven.shared.invoker.InvocationRequest; +import org.apache.maven.shared.invoker.InvocationRequest.ReactorFailureBehavior; +import org.codehaus.plexus.util.StringUtils; + +/** + * Provides a convenient facade around the invoker.properties. + * + * @author Benjamin Bentmann + */ +class InvokerProperties +{ + private static final String SELECTOR_PREFIX = "selector."; + + private static final Pattern ENVIRONMENT_VARIABLES_PATTERN = + Pattern.compile( "invoker\\.environmentVariables\\.([A-Za-z][^.]+)(\\.([0-9]+))?" ); + + private enum InvocationProperty + { + PROJECT( "invoker.project" ), + GOALS( "invoker.goals" ), + PROFILES( "invoker.profiles" ), + MAVEN_OPTS( "invoker.mavenOpts" ), + FAILURE_BEHAVIOR( "invoker.failureBehavior" ), + NON_RECURSIVE( "invoker.nonRecursive" ), + OFFLINE( "invoker.offline" ), + SYSTEM_PROPERTIES_FILE( "invoker.systemPropertiesFile" ), + DEBUG( "invoker.debug" ), + SETTINGS_FILE( "invoker.settingsFile" ), + TIMEOUT_IN_SECONDS( "invoker.timeoutInSeconds" ), + ORDINAL( "invoker.ordinal" ); + + private final String key; + + InvocationProperty( final String s ) + { + this.key = s; + } + + @Override + public String toString() + { + return key; + } + } + + private enum SelectorProperty + { + JAVA_VERSION( ".java.version" ), + MAVEN_VERSION( ".maven.version" ), + OS_FAMLY( ".os.family" ); + + private final String suffix; + + SelectorProperty( String suffix ) + { + this.suffix = suffix; + } + + @Override + public String toString() + { + return suffix; + } + } + + /** + * The invoker properties being wrapped. + */ + private final Properties properties; + + /** + * Creates a new facade for the specified invoker properties. The properties will not be copied, so any changes to + * them will be reflected by the facade. + * + * @param properties The invoker properties to wrap, may be null if none. + */ + InvokerProperties( Properties properties ) + { + this.properties = ( properties != null ) ? properties : new Properties(); + } + + /** + * Gets the invoker properties being wrapped. + * + * @return The invoker properties being wrapped, never null. + */ + public Properties getProperties() + { + return this.properties; + } + + /** + * Gets the name of the corresponding build job. + * + * @return The name of the build job or an empty string if not set. + */ + public String getJobName() + { + return this.properties.getProperty( "invoker.name", "" ); + } + + /** + * Gets the description of the corresponding build job. + * + * @return The description of the build job or an empty string if not set. + */ + public String getJobDescription() + { + return this.properties.getProperty( "invoker.description", "" ); + } + + /** + * Get the corresponding ordinal value + * + * @return The ordinal value + */ + public int getOrdinal() + { + return Integer.parseInt( this.properties.getProperty( "invoker.ordinal", "0" ) ); + } + + /** + * Gets the specification of JRE versions on which this build job should be run. + * + * @return The specification of JRE versions or an empty string if not set. + */ + public String getJreVersion() + { + return this.properties.getProperty( "invoker.java.version", "" ); + } + + /** + * Gets the specification of JRE versions on which this build job should be run. + * + * @return The specification of JRE versions or an empty string if not set. + */ + public String getJreVersion( int index ) + { + return this.properties.getProperty( SELECTOR_PREFIX + index + SelectorProperty.JAVA_VERSION, + getJreVersion() ); + } + + /** + * Gets the specification of Maven versions on which this build job should be run. + * + * @return The specification of Maven versions on which this build job should be run. + * @since 1.5 + */ + public String getMavenVersion() + { + return this.properties.getProperty( "invoker.maven.version", "" ); + } + + /** + * @param index the selector index + * @return The specification of Maven versions on which this build job should be run. + * @since 3.0.0 + */ + public String getMavenVersion( int index ) + { + return this.properties.getProperty( SELECTOR_PREFIX + index + SelectorProperty.MAVEN_VERSION, + getMavenVersion() ); + } + + /** + * Gets the specification of OS families on which this build job should be run. + * + * @return The specification of OS families or an empty string if not set. + */ + public String getOsFamily() + { + return this.properties.getProperty( "invoker.os.family", "" ); + } + + /** + * Gets the specification of OS families on which this build job should be run. + * + * @param index the selector index + * @return The specification of OS families or an empty string if not set. + * @since 3.0.0 + */ + public String getOsFamily( int index ) + { + return this.properties.getProperty( SELECTOR_PREFIX + index + SelectorProperty.OS_FAMLY, getOsFamily() ); + } + + public Collection getToolchains() + { + return getToolchains( Pattern.compile( "invoker\\.toolchain\\.([^.]+)\\.(.+)" ) ); + } + + public Collection getToolchains( int index ) + { + return getToolchains( Pattern.compile( "selector\\." + index + "\\.invoker\\.toolchain\\.([^.]+)\\.(.+)" ) ); + } + + private Collection getToolchains( Pattern p ) + { + Map toolchains = new HashMap<>(); + for ( Map.Entry entry : this.properties.entrySet() ) + { + Matcher m = p.matcher( entry.getKey().toString() ); + if ( m.matches() ) + { + String type = m.group( 1 ); + String providesKey = m.group( 2 ); + String providesValue = entry.getValue().toString(); + + InvokerToolchain tc = toolchains.get( type ); + if ( tc == null ) + { + tc = new InvokerToolchain( type ); + toolchains.put( type, tc ); + } + tc.addProvides( providesKey, providesValue ); + } + } + return toolchains.values(); + } + + /** + * Extract environment variable from properties for given index. + * Every environment variable without index is also returned. + * + * @param index index to lookup + * @return map of environment name and value + */ + + private Map getEnvironmentVariables( int index ) + { + + Map envItems = new HashMap<>(); + + for ( Map.Entry entry : properties.entrySet() ) + { + Matcher matcher = ENVIRONMENT_VARIABLES_PATTERN.matcher( entry.getKey().toString() ); + if ( matcher.matches() ) + { + + if ( String.valueOf( index ).equals( matcher.group( 3 ) ) ) + { + // variables with index has higher priority, so override + envItems.put( matcher.group( 1 ), entry.getValue().toString() ); + } + else if ( matcher.group( 3 ) == null ) + { + // variables without index has lower priority, so check if exist + if ( !envItems.containsKey( matcher.group( 1 ) ) ) + { + envItems.put( matcher.group( 1 ), entry.getValue().toString() ); + } + } + } + } + return envItems; + } + + /** + * Determines whether these invoker properties contain a build definition for the specified invocation index. + * + * @param index The one-based index of the invocation to check for, must not be negative. + * @return true if the invocation with the specified index is defined, false otherwise. + */ + public boolean isInvocationDefined( int index ) + { + for ( InvocationProperty prop : InvocationProperty.values() ) + { + if ( properties.getProperty( prop.toString() + '.' + index ) != null ) + { + return true; + } + } + return false; + } + + /** + * Determines whether these invoker properties contain a build definition for the specified selector index. + * + * @param index the index + * @return true if the selector with the specified index is defined, false otherwise. + * @since 3.0.0 + */ + public boolean isSelectorDefined( int index ) + { + for ( SelectorProperty prop : SelectorProperty.values() ) + { + if ( properties.getProperty( SELECTOR_PREFIX + index + prop.suffix ) != null ) + { + return true; + } + } + return false; + } + + /** + * Configures the specified invocation request from these invoker properties. Settings not present in the invoker + * properties will be left unchanged in the invocation request. + * + * @param request The invocation request to configure, must not be null. + * @param index The one-based index of the invocation to configure, must not be negative. + */ + public void configureInvocation( InvocationRequest request, int index ) + { + String project = get( InvocationProperty.PROJECT, index ); + if ( project != null ) + { + File file = new File( request.getBaseDirectory(), project ); + if ( file.isFile() ) + { + request.setBaseDirectory( file.getParentFile() ); + request.setPomFile( file ); + } + else + { + request.setBaseDirectory( file ); + request.setPomFile( null ); + } + } + + String goals = get( InvocationProperty.GOALS, index ); + if ( goals != null ) + { + request.setGoals( new ArrayList<>( Arrays.asList( StringUtils.split( goals, ", \t\n\r\f" ) ) ) ); + } + + String profiles = get( InvocationProperty.PROFILES, index ); + if ( profiles != null ) + { + // CHECKSTYLE_OFF: LineLength + request.setProfiles( new ArrayList<>( Arrays.asList( StringUtils.split( profiles, + ", \t\n\r\f" ) ) ) ); + // CHECKSTYLE_ON: LineLength + } + + String mvnOpts = get( InvocationProperty.MAVEN_OPTS, index ); + if ( mvnOpts != null ) + { + request.setMavenOpts( mvnOpts ); + } + + String failureBehavior = get( InvocationProperty.FAILURE_BEHAVIOR, index ); + if ( failureBehavior != null ) + { + ReactorFailureBehavior valueOf = + InvocationRequest.ReactorFailureBehavior.valueOfByLongOption( failureBehavior ); + request.setReactorFailureBehavior( valueOf ); + } + + String nonRecursive = get( InvocationProperty.NON_RECURSIVE, index ); + if ( nonRecursive != null ) + { + request.setRecursive( !Boolean.parseBoolean( nonRecursive ) ); + } + + String offline = get( InvocationProperty.OFFLINE, index ); + if ( offline != null ) + { + request.setOffline( Boolean.parseBoolean( offline ) ); + } + + String debug = get( InvocationProperty.DEBUG, index ); + if ( debug != null ) + { + request.setDebug( Boolean.parseBoolean( debug ) ); + } + + for ( Map.Entry envItem : getEnvironmentVariables( index ).entrySet() ) + { + request.addShellEnvironment( envItem.getKey(), envItem.getValue() ); + } + } + + /** + * Checks whether the specified exit code matches the one expected for the given invocation. + * + * @param exitCode The exit code of the Maven invocation to check. + * @param index The index of the invocation for which to check the exit code, must not be negative. + * @return true if the exit code is zero and a success was expected or if the exit code is non-zero and + * a failue was expected, false otherwise. + */ + public boolean isExpectedResult( int exitCode, int index ) + { + boolean nonZeroExit = "failure".equalsIgnoreCase( get( "invoker.buildResult", index ) ); + return ( exitCode != 0 ) == nonZeroExit; + } + + /** + * Gets the path to the properties file used to set the system properties for the specified invocation. + * + * @param index The index of the invocation, must not be negative. + * @return The path to the properties file or null if not set. + */ + public String getSystemPropertiesFile( int index ) + { + return get( InvocationProperty.SYSTEM_PROPERTIES_FILE, index ); + } + + /** + * Gets the settings file used for the specified invocation. + * + * @param index The index of the invocation, must not be negative. + * @return the value for the settings file or null if not set. + */ + public String getSettingsFile( int index ) + { + return get( InvocationProperty.SETTINGS_FILE, index ); + } + + /** + * Get timeout to execute the project + * @param index index The index of the invocation, must not be negative. + * @return the value for the timeout or -1 + */ + public int getTimeoutInSeconds( int index ) + { + String timeoutInSecondsStr = get( InvocationProperty.TIMEOUT_IN_SECONDS, index ); + if ( StringUtils.isEmpty( timeoutInSecondsStr ) ) + { + return -1; + } + // catch NumberFormatException? well we assume users knows what they do :-) + return Integer.parseInt( timeoutInSecondsStr ); + } + /** + * Gets a value from the invoker properties. The invoker properties are intended to describe the invocation settings + * for multiple builds of the same project. For this reason, the properties are indexed. First, a property named + * key.index will be queried. If this property does not exist, the value of the property named + * key will finally be returned. + * + * @param key The (base) key for the invoker property to lookup, must not be null. + * @param index The index of the invocation for which to retrieve the value, must not be negative. + * @return The value for the requested invoker property or null if not defined. + */ + String get( String key, int index ) + { + if ( index < 0 ) + { + throw new IllegalArgumentException( "invalid invocation index: " + index ); + } + + String value = properties.getProperty( key + '.' + index ); + if ( value == null ) + { + value = properties.getProperty( key ); + } + return value; + } + + private String get( InvocationProperty prop, int index ) + { + return get( prop.toString(), index ); + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java new file mode 100644 index 000000000..063ac648e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java @@ -0,0 +1,359 @@ +package org.apache.maven.plugins.invoker; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.doxia.siterenderer.Renderer; +import org.apache.maven.plugins.invoker.model.BuildJob; +import org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Reader; +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.reporting.AbstractMavenReport; +import org.apache.maven.reporting.MavenReportException; +import org.codehaus.plexus.i18n.I18N; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.XmlStreamReader; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +/** + * Generate a report based on the results of the Maven invocations. Note: This mojo doesn't fork any + * lifecycle, if you have a clean working copy, you have to use a command like + * mvn clean integration-test site to ensure the build results are present when this goal is invoked. + * + * @author Olivier Lamy + * @since 1.4 + */ +@Mojo( name = "report", threadSafe = true ) +public class InvokerReport + extends AbstractMavenReport +{ + + /** + * The Maven Project. + */ + @Parameter( defaultValue = "${project}", readonly = true, required = true ) + protected MavenProject project; + + /** + * Doxia Site Renderer component. + */ + @Component + protected Renderer siteRenderer; + + /** + * Internationalization component. + */ + @Component + protected I18N i18n; + + /** + * The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from + * the command line. If the goal is run indirectly as part of a site generation, the output directory configured in + * the Maven Site Plugin is used instead. + */ + @Parameter( defaultValue = "${project.reporting.outputDirectory}", required = true ) + protected File outputDirectory; + + /** + * Base directory where all build reports have been written to. + */ + @Parameter( defaultValue = "${project.build.directory}/invoker-reports", property = "invoker.reportsDirectory" ) + private File reportsDirectory; + + /** + * The number format used to print percent values in the report locale. + */ + private NumberFormat percentFormat; + + /** + * The number format used to print time values in the report locale. + */ + private NumberFormat secondsFormat; + + protected void executeReport( Locale locale ) + throws MavenReportException + { + DecimalFormatSymbols symbols = new DecimalFormatSymbols( locale ); + percentFormat = new DecimalFormat( getText( locale, "report.invoker.format.percent" ), symbols ); + secondsFormat = new DecimalFormat( getText( locale, "report.invoker.format.seconds" ), symbols ); + + Sink sink = getSink(); + + sink.head(); + + sink.title(); + sink.text( getText( locale, "report.invoker.result.title" ) ); + sink.title_(); + + sink.head_(); + + sink.body(); + + sink.section1(); + sink.sectionTitle1(); + sink.text( getText( locale, "report.invoker.result.title" ) ); + sink.sectionTitle1_(); + sink.paragraph(); + sink.text( getText( locale, "report.invoker.result.description" ) ); + sink.paragraph_(); + sink.section1_(); + + // ---------------------------------- + // build buildJob beans + // ---------------------------------- + File[] reportFiles = ReportUtils.getReportFiles( reportsDirectory ); + if ( reportFiles.length <= 0 ) + { + getLog().info( "no invoker report files found, skip report generation" ); + return; + } + + BuildJobXpp3Reader buildJobReader = new BuildJobXpp3Reader(); + + List buildJobs = new ArrayList<>( reportFiles.length ); + for ( File reportFile : reportFiles ) + { + try ( XmlStreamReader xmlReader = ReaderFactory.newXmlReader( reportFile ) ) + { + buildJobs.add( buildJobReader.read( xmlReader ) ); + } + catch ( XmlPullParserException e ) + { + throw new MavenReportException( "Failed to parse report file: " + reportFile, e ); + } + catch ( IOException e ) + { + throw new MavenReportException( "Failed to read report file: " + reportFile, e ); + } + } + + // ---------------------------------- + // summary + // ---------------------------------- + + constructSummarySection( buildJobs, locale ); + + // ---------------------------------- + // per file/it detail + // ---------------------------------- + + sink.section2(); + sink.sectionTitle2(); + + sink.text( getText( locale, "report.invoker.detail.title" ) ); + + sink.sectionTitle2_(); + + sink.section2_(); + + // detail tests table header + sink.table(); + + sink.tableRow(); + // ------------------------------------------- + // name | Result | time | message + // ------------------------------------------- + sinkTableHeader( sink, getText( locale, "report.invoker.detail.name" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.detail.result" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.detail.time" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.detail.message" ) ); + + sink.tableRow_(); + + for ( BuildJob buildJob : buildJobs ) + { + renderBuildJob( buildJob, locale ); + } + + sink.table_(); + + sink.body_(); + + sink.flush(); + sink.close(); + } + + private void constructSummarySection( List buildJobs, Locale locale ) + { + Sink sink = getSink(); + + sink.section2(); + sink.sectionTitle2(); + + sink.text( getText( locale, "report.invoker.summary.title" ) ); + + sink.sectionTitle2_(); + sink.section2_(); + + // ------------------------------------------------------------------------ + // Building a table with + // it number | succes nb | failed nb | Success rate | total time | avg time + // ------------------------------------------------------------------------ + + sink.table(); + sink.tableRow(); + + sinkTableHeader( sink, getText( locale, "report.invoker.summary.number" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.summary.success" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.summary.failed" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.summary.skipped" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.summary.success.rate" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.summary.time.total" ) ); + sinkTableHeader( sink, getText( locale, "report.invoker.summary.time.avg" ) ); + + int number = buildJobs.size(); + int success = 0; + int failed = 0; + int skipped = 0; + double totalTime = 0; + + for ( BuildJob buildJob : buildJobs ) + { + if ( BuildJob.Result.SUCCESS.equals( buildJob.getResult() ) ) + { + success++; + } + else if ( BuildJob.Result.SKIPPED.equals( buildJob.getResult() ) ) + { + skipped++; + } + else + { + failed++; + } + totalTime += buildJob.getTime(); + } + + sink.tableRow_(); + sink.tableRow(); + + sinkCell( sink, Integer.toString( number ) ); + sinkCell( sink, Integer.toString( success ) ); + sinkCell( sink, Integer.toString( failed ) ); + sinkCell( sink, Integer.toString( skipped ) ); + + if ( success + failed > 0 ) + { + sinkCell( sink, percentFormat.format( (double) success / ( success + failed ) ) ); + } + else + { + sinkCell( sink, "" ); + } + + sinkCell( sink, secondsFormat.format( totalTime ) ); + + sinkCell( sink, secondsFormat.format( totalTime / number ) ); + + sink.tableRow_(); + sink.table_(); + + } + + private void renderBuildJob( BuildJob buildJob, Locale locale ) + { + Sink sink = getSink(); + sink.tableRow(); + StringBuilder buffer = new StringBuilder(); + if ( !StringUtils.isEmpty( buildJob.getName() ) && !StringUtils.isEmpty( buildJob.getDescription() ) ) + { + buffer.append( buildJob.getName() ); + buffer.append( " : " ); + buffer.append( buildJob.getDescription() ); + } + else + { + buffer.append( buildJob.getProject() ); + } + sinkCell( sink, buffer.toString() ); + // FIXME image + sinkCell( sink, buildJob.getResult() ); + sinkCell( sink, secondsFormat.format( buildJob.getTime() ) ); + sinkCell( sink, buildJob.getFailureMessage() ); + sink.tableRow_(); + } + + protected String getOutputDirectory() + { + return outputDirectory.getAbsolutePath(); + } + + protected MavenProject getProject() + { + return project; + } + + protected Renderer getSiteRenderer() + { + return siteRenderer; + } + + public String getDescription( Locale locale ) + { + return getText( locale, "report.invoker.result.description" ); + } + + public String getName( Locale locale ) + { + return getText( locale, "report.invoker.result.name" ); + } + + public String getOutputName() + { + return "invoker-report"; + } + + public boolean canGenerateReport() + { + return ReportUtils.getReportFiles( reportsDirectory ).length > 0; + } + + private String getText( Locale locale, String key ) + { + return i18n.getString( "invoker-report", locale, key ); + } + + private void sinkTableHeader( Sink sink, String header ) + { + sink.tableHeaderCell(); + sink.text( header ); + sink.tableHeaderCell_(); + } + + private void sinkCell( Sink sink, String text ) + { + sink.tableCell(); + sink.text( text ); + sink.tableCell_(); + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java new file mode 100644 index 000000000..1cba4a0a3 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerSession.java @@ -0,0 +1,342 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.apache.maven.shared.utils.logging.MessageUtils.buffer; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.invoker.model.BuildJob; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.shared.utils.io.IOUtil; + +/** + * Tracks a set of build jobs and their results. + * + * @author Benjamin Bentmann + */ +class InvokerSession +{ + private static final String SEPARATOR = buffer().strong( + "-------------------------------------------------" ).toString(); + + private List buildJobs; + + private List failedJobs; + + private List errorJobs; + + private List successfulJobs; + + private List skippedJobs; + + /** + * Creates a new empty session. + */ + InvokerSession() + { + buildJobs = new ArrayList<>(); + } + + /** + * Creates a session that initially contains the specified build jobs. + * + * @param buildJobs The build jobs to set, must not be null. + */ + InvokerSession( List buildJobs ) + { + this.buildJobs = new ArrayList<>( buildJobs ); + } + + /** + * Adds the specified build job to this session. + * + * @param buildJob The build job to add, must not be null. + */ + public void addJob( BuildJob buildJob ) + { + buildJobs.add( buildJob ); + + resetStats(); + } + + /** + * Sets the build jobs of this session. + * + * @param buildJobs The build jobs to set, must not be null. + */ + public void setJobs( List buildJobs ) + { + this.buildJobs = new ArrayList<>( buildJobs ); + + resetStats(); + } + + /** + * Gets the build jobs in this session. + * + * @return The build jobs in this session, can be empty but never null. + */ + public List getJobs() + { + return buildJobs; + } + + /** + * Gets the successful build jobs in this session. + * + * @return The successful build jobs in this session, can be empty but never null. + */ + public List getSuccessfulJobs() + { + updateStats(); + + return successfulJobs; + } + + /** + * Gets the failed build jobs in this session. + * + * @return The failed build jobs in this session, can be empty but never null. + */ + public List getFailedJobs() + { + updateStats(); + + return failedJobs; + } + + /** + * Gets the build jobs which had errors for this session. + * + * @return The build jobs in error for this session, can be empty but never null. + */ + public List getErrorJobs() + { + updateStats(); + + return errorJobs; + } + + /** + * Gets the skipped build jobs in this session. + * + * @return The skipped build jobs in this session, can be empty but never null. + */ + public List getSkippedJobs() + { + updateStats(); + + return skippedJobs; + } + + private void resetStats() + { + successfulJobs = null; + failedJobs = null; + skippedJobs = null; + errorJobs = null; + } + + private void updateStats() + { + if ( successfulJobs != null && skippedJobs != null && failedJobs != null && errorJobs != null ) + { + return; + } + + successfulJobs = new ArrayList<>(); + failedJobs = new ArrayList<>(); + skippedJobs = new ArrayList<>(); + errorJobs = new ArrayList<>(); + + for ( BuildJob buildJob : buildJobs ) + { + if ( BuildJob.Result.SUCCESS.equals( buildJob.getResult() ) ) + { + successfulJobs.add( buildJob ); + } + else if ( BuildJob.Result.SKIPPED.equals( buildJob.getResult() ) ) + { + skippedJobs.add( buildJob ); + } + else if ( BuildJob.Result.ERROR.equals( buildJob.getResult() ) ) + { + errorJobs.add( buildJob ); + } + else if ( buildJob.getResult() != null ) + { + failedJobs.add( buildJob ); + } + } + } + + /** + * Prints a summary of this session to the specified logger. + * + * @param logger The mojo logger to output messages to, must not be null. + * @param ignoreFailures A flag whether failures should be ignored or whether a build failure should be signaled. + */ + public void logSummary( Log logger, boolean ignoreFailures ) + { + updateStats(); + + logger.info( SEPARATOR ); + logger.info( "Build Summary:" ); + logger.info( " Passed: " + successfulJobs.size() + + ", Failed: " + failedJobs.size() + + ", Errors: " + errorJobs.size() + + ", Skipped: " + skippedJobs.size() ); + logger.info( SEPARATOR ); + + logBuildJobList( logger, ignoreFailures, "The following builds failed:", failedJobs ); + logBuildJobList( logger, ignoreFailures, "The following builds finished with error:", errorJobs ); + logBuildJobList( logger, ignoreFailures, "The following builds was skipped:", skippedJobs ); + } + + public void logFailedBuildLog( Log logger, boolean ignoreFailures ) + throws MojoFailureException + { + List jobToLogs = new ArrayList<>( failedJobs ); + jobToLogs.addAll( errorJobs ); + + for ( BuildJob buildJob: jobToLogs ) + { + File buildLogFile = buildJob.getBuildlog() != null ? new File( buildJob.getBuildlog() ) : null; + if ( buildLogFile != null && buildLogFile.exists() ) + { + try + { + // prepare message with build.log in one string to omit begin [ERROR], [WARN] + // so whole log will be displayed without decoration + StringBuilder buildLogMessage = new StringBuilder( ); + buildLogMessage.append( System.lineSeparator() ); + buildLogMessage.append( System.lineSeparator() ); + buildLogMessage.append( "*** begin build.log for: " + buildJob.getProject() + " ***" ); + buildLogMessage.append( System.lineSeparator() ); + buildLogMessage.append( IOUtil.toString( new FileReader( buildLogFile ) ) ); + buildLogMessage.append( "*** end build.log for: " + buildJob.getProject() + " ***" ); + buildLogMessage.append( System.lineSeparator() ); + + logWithLevel( logger, ignoreFailures, SEPARATOR ); + logWithLevel( logger, ignoreFailures, buildLogMessage.toString() ); + logWithLevel( logger, ignoreFailures, SEPARATOR ); + logWithLevel( logger, ignoreFailures, "" ); + + } + catch ( IOException e ) + { + throw new MojoFailureException( e.getMessage(), e ); + } + } + } + } + + + /** + * Handles the build failures in this session. + * + * @param logger The mojo logger to output messages to, must not be null. + * @param ignoreFailures A flag whether failures should be ignored or whether a build failure should be signaled. + * @throws MojoFailureException If failures are present and not ignored. + */ + public void handleFailures( Log logger, boolean ignoreFailures ) + throws MojoFailureException + { + updateStats(); + + if ( !failedJobs.isEmpty() ) + { + String message = failedJobs.size() + " build" + ( failedJobs.size() == 1 ? "" : "s" ) + " failed."; + + if ( ignoreFailures ) + { + logger.warn( "Ignoring that " + message ); + } + else + { + throw new MojoFailureException( message + " See console output above for details." ); + } + } + + if ( !errorJobs.isEmpty() ) + { + String message = errorJobs.size() + " build" + ( errorJobs.size() == 1 ? "" : "s" ) + " in error."; + + if ( ignoreFailures ) + { + logger.warn( "Ignoring that " + message ); + } + else + { + throw new MojoFailureException( message + " See console output above for details." ); + } + } + } + + /** + * Log list of jobs. + * + * @param logger logger to write + * @param warn flag indicate log level + * @param buildJobs jobs to list + */ + private void logBuildJobList( Log logger, boolean warn, String header, List buildJobs ) + { + if ( buildJobs.isEmpty() ) + { + return; + } + + logWithLevel( logger, warn, header ); + + for ( BuildJob buildJob : buildJobs ) + { + logWithLevel( logger, warn, "* " + buildJob.getProject() ); + } + + logger.info( SEPARATOR ); + } + + /** + * Log message in correct level depends on flag. + * + * @param logger logger to write + * @param warn flag indicate log level + * @param message message to write + */ + private void logWithLevel( Log logger, boolean warn, String message ) + { + + if ( warn ) + { + logger.warn( message ); + } + else + { + logger.error( message ); + } + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerToolchain.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerToolchain.java new file mode 100644 index 000000000..c2381fec1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/InvokerToolchain.java @@ -0,0 +1,55 @@ +package org.apache.maven.plugins.invoker; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author Robert Scholte + * @since 3.2.0 + */ +public class InvokerToolchain +{ + private final String type; + + private Map provides = new HashMap<>(); + + public InvokerToolchain( String type ) + { + this.type = type; + } + + public String getType() + { + return type; + } + + public void addProvides( String key, String value ) + { + provides.put( key, value ); + } + + public Map getProvides() + { + return provides; + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/MetadataUtils.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/MetadataUtils.java new file mode 100644 index 000000000..726af155e --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/MetadataUtils.java @@ -0,0 +1,168 @@ +package org.apache.maven.plugins.invoker; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.TimeZone; + +import org.apache.maven.artifact.Artifact; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.WriterFactory; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.codehaus.plexus.util.xml.Xpp3DomBuilder; +import org.codehaus.plexus.util.xml.Xpp3DomUtils; +import org.codehaus.plexus.util.xml.Xpp3DomWriter; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +/** + * Provides utility methods for artifact metadata processing. + * + * @author Benjamin Bentmann + */ +class MetadataUtils +{ + + /** + * Creates local metadata files for the specified artifact. The goal is to simulate the installation of the artifact + * by a local build, thereby decoupling the forked builds from the inderministic collection of remote repositories + * that are available to the main build and from which the artifact was originally resolved. + * + * @param file The artifact's file in the local test repository, must not be null. + * @param artifact The artifact to create metadata for, must not be null. + * @throws IOException If the metadata could not be created. + */ + public static void createMetadata( File file, Artifact artifact ) + throws IOException + { + TimeZone tz = java.util.TimeZone.getTimeZone( "UTC" ); + SimpleDateFormat fmt = new SimpleDateFormat( "yyyyMMddHHmmss" ); + fmt.setTimeZone( tz ); + String timestamp = fmt.format( new Date() ); + + if ( artifact.isSnapshot() ) + { + File metadataFile = new File( file.getParentFile(), "maven-metadata-local.xml" ); + + Xpp3Dom metadata = new Xpp3Dom( "metadata" ); + addChild( metadata, "groupId", artifact.getGroupId() ); + addChild( metadata, "artifactId", artifact.getArtifactId() ); + addChild( metadata, "version", artifact.getBaseVersion() ); + Xpp3Dom versioning = new Xpp3Dom( "versioning" ); + versioning.addChild( addChild( new Xpp3Dom( "snapshot" ), "localCopy", "true" ) ); + addChild( versioning, "lastUpdated", timestamp ); + metadata.addChild( versioning ); + + writeMetadata( metadataFile, metadata ); + } + + File metadataFile = new File( file.getParentFile().getParentFile(), "maven-metadata-local.xml" ); + + Set allVersions = new LinkedHashSet(); + + Xpp3Dom metadata = readMetadata( metadataFile ); + + if ( metadata != null ) + { + Xpp3Dom versioning = metadata.getChild( "versioning" ); + if ( versioning != null ) + { + Xpp3Dom versions = versioning.getChild( "versions" ); + if ( versions != null ) + { + + Xpp3Dom[] children = versions.getChildren( "version" ); + for ( Xpp3Dom aChildren : children ) + { + allVersions.add( aChildren.getValue() ); + } + } + } + } + + allVersions.add( artifact.getBaseVersion() ); + + metadata = new Xpp3Dom( "metadata" ); + addChild( metadata, "groupId", artifact.getGroupId() ); + addChild( metadata, "artifactId", artifact.getArtifactId() ); + Xpp3Dom versioning = new Xpp3Dom( "versioning" ); + versioning.addChild( addChildren( new Xpp3Dom( "versions" ), "version", allVersions ) ); + addChild( versioning, "lastUpdated", timestamp ); + metadata.addChild( versioning ); + + metadata = Xpp3DomUtils.mergeXpp3Dom( metadata, readMetadata( metadataFile ) ); + + writeMetadata( metadataFile, metadata ); + } + + private static Xpp3Dom addChild( Xpp3Dom parent, String childName, String childValue ) + { + Xpp3Dom child = new Xpp3Dom( childName ); + child.setValue( childValue ); + parent.addChild( child ); + return parent; + } + + private static Xpp3Dom addChildren( Xpp3Dom parent, String childName, Collection childValues ) + { + for ( String childValue : childValues ) + { + addChild( parent, childName, childValue ); + } + return parent; + } + + private static Xpp3Dom readMetadata( File metadataFile ) + throws IOException + { + if ( !metadataFile.isFile() ) + { + return null; + } + + try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) ) + { + return Xpp3DomBuilder.build( reader ); + } + catch ( XmlPullParserException e ) + { + throw (IOException) new IOException( e.getMessage() ).initCause( e ); + } + } + + private static void writeMetadata( File metadataFile, Xpp3Dom metadata ) + throws IOException + { + metadataFile.getParentFile().mkdirs(); + + try ( Writer writer = WriterFactory.newXmlWriter( metadataFile ) ) + { + Xpp3DomWriter.write( writer, metadata ); + } + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/PomUtils.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/PomUtils.java new file mode 100644 index 000000000..83eba4ea7 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/PomUtils.java @@ -0,0 +1,64 @@ +package org.apache.maven.plugins.invoker; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.io.Reader; + +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +/** + * Provides utility methods for POM processing. + * + * @author Benjamin Bentmann + */ +class PomUtils +{ + + /** + * Loads the (raw) model from the specified POM file. + * + * @param pomFile The path to the POM file to load, must not be null. + * @return The raw model, never null. + * @throws MojoExecutionException If the POM file could not be loaded. + */ + public static Model loadPom( File pomFile ) + throws MojoExecutionException + { + try ( Reader reader = ReaderFactory.newXmlReader( pomFile ) ) + { + return new MavenXpp3Reader().read( reader, false ); + } + catch ( XmlPullParserException e ) + { + throw new MojoExecutionException( "Failed to parse POM: " + pomFile, e ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read POM: " + pomFile, e ); + } + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/ReportUtils.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/ReportUtils.java new file mode 100644 index 000000000..9f4207c72 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/ReportUtils.java @@ -0,0 +1,63 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.FilenameFilter; + +/** + * Provides utility methods for invoker report processing. + * + * @author Benjamin Bentmann + */ +class ReportUtils +{ + + private static class FileFilterOnlyXmlFile + implements FilenameFilter + { + + public boolean accept( File dir, String name ) + { + return name.startsWith( "BUILD-" ) && name.endsWith( ".xml" ); + } + + } + + /** + * Gets the paths to the invoker reports available in the specified directory. + * + * @param reportsDirectory The base directory where the invoker reports are located in, may be null. + * @return The paths to the invoker reports, can be empty but never null. + */ + public static File[] getReportFiles( File reportsDirectory ) + { + File[] reportFiles = + ( reportsDirectory != null ) ? reportsDirectory.listFiles( new FileFilterOnlyXmlFile() ) : null; + + if ( reportFiles == null ) + { + reportFiles = new File[0]; + } + + return reportFiles; + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/Selector.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/Selector.java new file mode 100644 index 000000000..0391dd332 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/Selector.java @@ -0,0 +1,131 @@ +package org.apache.maven.plugins.invoker; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager; + +/** + * + * @author Robert Scholte + * + */ +class Selector +{ + static final int SELECTOR_MAVENVERSION = 1; + + static final int SELECTOR_JREVERSION = 2; + + static final int SELECTOR_OSFAMILY = 4; + + static final int SELECTOR_TOOLCHAIN = 8; + + static final int SELECTOR_MULTI = 16; + + private final String actualMavenVersion; + + private final String actualJavaVersion; + + private final ToolchainPrivateManager toolchainPrivateManager; + + Selector( String actualMavenVersion, String actualJavaVersion, ToolchainPrivateManager toolchainPrivateManager ) + { + this.actualMavenVersion = actualMavenVersion; + this.actualJavaVersion = actualJavaVersion; + this.toolchainPrivateManager = toolchainPrivateManager; + } + + public int getSelection( InvokerProperties invokerProperties ) + { + if ( !invokerProperties.isSelectorDefined( 1 ) ) + { + return getGlobal( invokerProperties ); + } + + for ( int selectorIndex = 1;; selectorIndex++ ) + { + if ( selectorIndex > 1 && !invokerProperties.isSelectorDefined( selectorIndex ) ) + { + break; + } + + int selection = 0; + if ( !SelectorUtils.isMavenVersion( invokerProperties.getMavenVersion( selectorIndex ), + actualMavenVersion ) ) + { + selection |= SELECTOR_MAVENVERSION; + } + + if ( !SelectorUtils.isJreVersion( invokerProperties.getJreVersion( selectorIndex ), actualJavaVersion ) ) + { + selection |= SELECTOR_JREVERSION; + } + + if ( !SelectorUtils.isOsFamily( invokerProperties.getOsFamily( selectorIndex ) ) ) + { + selection |= SELECTOR_OSFAMILY; + } + + if ( !SelectorUtils.isToolchain( toolchainPrivateManager, + invokerProperties.getToolchains( selectorIndex ) ) ) + { + selection |= SELECTOR_TOOLCHAIN; + } + + if ( selection == 0 ) + { + return 0; + } + } + return SELECTOR_MULTI; + } + + /** + * Determines whether selector conditions of the specified invoker properties match the current environment. + * + * @param invokerProperties The invoker properties to check, must not be null. + * @return 0 if the job corresponding to the properties should be run, otherwise a bitwise value + * representing the reason why it should be skipped. + */ + private int getGlobal( InvokerProperties invokerProperties ) + { + int selection = 0; + if ( !SelectorUtils.isMavenVersion( invokerProperties.getMavenVersion(), actualMavenVersion ) ) + { + selection |= SELECTOR_MAVENVERSION; + } + + if ( !SelectorUtils.isJreVersion( invokerProperties.getJreVersion(), actualJavaVersion.toString() ) ) + { + selection |= SELECTOR_JREVERSION; + } + + if ( !SelectorUtils.isOsFamily( invokerProperties.getOsFamily() ) ) + { + selection |= SELECTOR_OSFAMILY; + } + + if ( !SelectorUtils.isToolchain( toolchainPrivateManager, invokerProperties.getToolchains() ) ) + { + selection |= SELECTOR_TOOLCHAIN; + } + + return selection; + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java new file mode 100644 index 000000000..eeae0f7a2 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java @@ -0,0 +1,327 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.FilenameFilter; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager; +import org.apache.maven.project.MavenProject; +import org.apache.maven.toolchain.MisconfiguredToolchainException; +import org.apache.maven.toolchain.ToolchainPrivate; +import org.codehaus.plexus.util.Os; +import org.codehaus.plexus.util.StringUtils; + +/** + * Provides utility methods for selecting build jobs based on environmental conditions. + * + * @author Benjamin Bentmann + */ +class SelectorUtils +{ + + static void parseList( String list, Collection includes, Collection excludes ) + { + String[] tokens = ( list != null ) ? StringUtils.split( list, "," ) : new String[0]; + + for ( String token1 : tokens ) + { + String token = token1.trim(); + + if ( token.startsWith( "!" ) ) + { + excludes.add( token.substring( 1 ) ); + } + else + { + includes.add( token ); + } + } + } + + static boolean isOsFamily( String osSpec ) + { + List includes = new ArrayList<>(); + List excludes = new ArrayList<>(); + parseList( osSpec, includes, excludes ); + + return isOsFamily( includes, true ) && !isOsFamily( excludes, false ); + } + + static boolean isOsFamily( List families, boolean defaultMatch ) + { + if ( families != null && !families.isEmpty() ) + { + for ( String family : families ) + { + if ( Os.isFamily( family ) ) + { + return true; + } + } + + return false; + } + else + { + return defaultMatch; + } + } + + /** + * Retrieves the current Maven version. + * + * @return The current Maven version. + */ + static String getMavenVersion() + { + try + { + // This relies on the fact that MavenProject is the in core classloader + // and that the core classloader is for the maven-core artifact + // and that should have a pom.properties file + // if this ever changes, we will have to revisit this code. + Properties properties = new Properties(); + // CHECKSTYLE_OFF: LineLength + properties.load( MavenProject.class.getClassLoader().getResourceAsStream( "META-INF/maven/org.apache.maven/maven-core/pom.properties" ) ); + // CHECKSTYLE_ON: LineLength + return StringUtils.trim( properties.getProperty( "version" ) ); + } + catch ( Exception e ) + { + return null; + } + } + + static String getMavenVersion( File mavenHome ) + { + File mavenLib = new File( mavenHome, "lib" ); + File[] jarFiles = mavenLib.listFiles( new FilenameFilter() + { + public boolean accept( File dir, String name ) + { + return name.endsWith( ".jar" ); + } + } ); + + for ( File file : jarFiles ) + { + try + { + @SuppressWarnings( "deprecation" ) + URL url = + new URL( "jar:" + file.toURL().toExternalForm() + + "!/META-INF/maven/org.apache.maven/maven-core/pom.properties" ); + + Properties properties = new Properties(); + properties.load( url.openStream() ); + String version = StringUtils.trim( properties.getProperty( "version" ) ); + if ( version != null ) + { + return version; + } + } + catch ( MalformedURLException e ) + { + // ignore + } + catch ( IOException e ) + { + // ignore + } + } + return null; + } + + static boolean isMavenVersion( String mavenSpec ) + { + return isMavenVersion( mavenSpec, getMavenVersion() ); + } + + static boolean isMavenVersion( String mavenSpec, String actualVersion ) + { + List includes = new ArrayList<>(); + List excludes = new ArrayList<>(); + parseList( mavenSpec, includes, excludes ); + + List mavenVersionList = parseVersion( actualVersion ); + + return isJreVersion( mavenVersionList, includes, true ) && !isJreVersion( mavenVersionList, excludes, false ); + } + + static String getJreVersion() + { + return System.getProperty( "java.version", "" ); + } + + static String getJreVersion( File javaHome ) + { + // @todo detect actual version + return null; + } + + static boolean isJreVersion( String jreSpec ) + { + return isJreVersion( jreSpec, getJreVersion() ); + } + + static boolean isJreVersion( String jreSpec, String actualJreVersion ) + { + List includes = new ArrayList(); + List excludes = new ArrayList(); + parseList( jreSpec, includes, excludes ); + + List jreVersion = parseVersion( actualJreVersion ); + + return isJreVersion( jreVersion, includes, true ) && !isJreVersion( jreVersion, excludes, false ); + } + + static boolean isJreVersion( List jreVersion, List versionPatterns, boolean defaultMatch ) + { + if ( versionPatterns != null && !versionPatterns.isEmpty() ) + { + for ( String versionPattern : versionPatterns ) + { + if ( isJreVersion( jreVersion, versionPattern ) ) + { + return true; + } + } + + return false; + } + else + { + return defaultMatch; + } + } + + static boolean isJreVersion( List jreVersion, String versionPattern ) + { + List checkVersion = parseVersion( versionPattern ); + + if ( versionPattern.endsWith( "+" ) ) + { + // 1.5+ <=> [1.5,) + return compareVersions( jreVersion, checkVersion ) >= 0; + } + else if ( versionPattern.endsWith( "-" ) ) + { + // 1.5- <=> (,1.5) + return compareVersions( jreVersion, checkVersion ) < 0; + } + else + { + // 1.5 <=> [1.5,1.6) + return checkVersion.size() <= jreVersion.size() + && checkVersion.equals( jreVersion.subList( 0, checkVersion.size() ) ); + } + } + + static List parseVersion( String version ) + { + version = version.replaceAll( "[^0-9]", "." ); + + String[] tokens = StringUtils.split( version, "." ); + + List numbers = new ArrayList(); + + for ( String token : tokens ) + { + numbers.add( Integer.valueOf( token ) ); + } + + return numbers; + } + + static int compareVersions( List version1, List version2 ) + { + for ( Iterator it1 = version1.iterator(), it2 = version2.iterator();; ) + { + if ( !it1.hasNext() ) + { + return it2.hasNext() ? -1 : 0; + } + if ( !it2.hasNext() ) + { + return it1.hasNext() ? 1 : 0; + } + + Integer num1 = it1.next(); + Integer num2 = it2.next(); + + int rel = num1.compareTo( num2 ); + if ( rel != 0 ) + { + return rel; + } + } + } + + /** + * @param toolchainPrivateManager + * @param invokerToolchains + * @return {@code true} if all invokerToolchains are available, otherwise {@code false} + */ + static boolean isToolchain( ToolchainPrivateManager toolchainPrivateManager, + Collection invokerToolchains ) + { + for ( InvokerToolchain invokerToolchain : invokerToolchains ) + { + boolean found = false; + try + { + for ( ToolchainPrivate tc : toolchainPrivateManager.getToolchainPrivates( invokerToolchain.getType() ) ) + { + if ( !invokerToolchain.getType().equals( tc.getType() ) ) + { + // useful because of MNG-5716 + continue; + } + + if ( tc.matchesRequirements( invokerToolchain.getProvides() ) ) + { + found = true; + continue; + } + } + } + catch ( MisconfiguredToolchainException e ) + { + return false; + } + + if ( !found ) + { + return false; + } + } + + return true; + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/SystemPropertyPrinter.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/SystemPropertyPrinter.java new file mode 100644 index 000000000..9c28b1d9d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/SystemPropertyPrinter.java @@ -0,0 +1,42 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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. + */ + +/** + * Print specified system properties to the output stream. Useful to detect certain values from a JVM different to the + * default JAVA_HOME. + * + * @author Robert Scholte + * @since 1.8 + */ +public class SystemPropertyPrinter +{ + /** + * @param args system properties to print + */ + public static void main( String[] args ) + { + for ( String arg : args ) + { + System.out.println( System.getProperty( arg, "" ) ); + } + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/VerifyMojo.java b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/VerifyMojo.java new file mode 100644 index 000000000..bc4abc468 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/java/org/apache/maven/plugins/invoker/VerifyMojo.java @@ -0,0 +1,156 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Reader; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +import java.io.File; +import java.io.IOException; +import java.io.Reader; + +/** + * Checks the results of maven-invoker-plugin based integration tests and fails the build if any tests failed. + * + * @author Olivier Lamy + * @since 1.4 + */ +@Mojo( name = "verify", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true ) +public class VerifyMojo + extends AbstractMojo +{ + + /** + * Flag used to suppress certain invocations. This is useful in tailoring the build using profiles. + * + * @since 1.1 + */ + @Parameter( property = "invoker.skip", defaultValue = "false" ) + private boolean skipInvocation; + + /** + * Base directory where all build reports are read from. + * + * @since 1.4 + */ + @Parameter( property = "invoker.reportsDirectory", defaultValue = "${project.build.directory}/invoker-reports" ) + private File reportsDirectory; + + /** + * A flag controlling whether failures of the sub builds should fail the main build, too. If set to + * true, the main build will proceed even if one or more sub builds failed. + * + * @since 1.3 + */ + @Parameter( property = "maven.test.failure.ignore", defaultValue = "false" ) + private boolean ignoreFailures; + + /** + * Flag used to suppress the summary output notifying of successes and failures. If set to true, the + * only indication of the build's success or failure will be the effect it has on the main build (if it fails, the + * main build should fail as well). + */ + @Parameter( defaultValue = "false" ) + private boolean suppressSummaries; + + /** + * Set this to true to cause a failure if there are no projects to invoke. + * + * @since 1.9 + */ + @Parameter( property = "invoker.failIfNoProjects" ) + private Boolean failIfNoProjects; + + /** + * Set to true to output build.log to mojo log in case of failed jobs. + * + * @since 3.2.2 + */ + @Parameter( property = "invoker.streamLogsOnFailures", defaultValue = "false" ) + private boolean streamLogsOnFailures; + + /** + * Invokes Maven on the configured test projects. + * + * @throws org.apache.maven.plugin.MojoExecutionException If the goal encountered severe errors. + * @throws org.apache.maven.plugin.MojoFailureException If any of the Maven builds failed. + */ + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( skipInvocation ) + { + getLog().info( "Skipping invocation per configuration." + + " If this is incorrect, ensure the skipInvocation parameter is not set to true." ); + return; + } + + File[] reportFiles = ReportUtils.getReportFiles( reportsDirectory ); + if ( reportFiles.length <= 0 ) + { + if ( Boolean.TRUE.equals( failIfNoProjects ) ) + { + throw new MojoFailureException( "No projects to invoke!" ); + } + getLog().info( "No invoker report files found, nothing to check." ); + return; + } + + BuildJobXpp3Reader reader = new BuildJobXpp3Reader(); + + InvokerSession invokerSession = new InvokerSession(); + + for ( File reportFile : reportFiles ) + { + try ( Reader xmlReader = ReaderFactory.newXmlReader( reportFile ) ) + { + invokerSession.addJob( reader.read( xmlReader ) ); + } + catch ( XmlPullParserException e ) + { + throw new MojoExecutionException( "Failed to parse report file: " + reportFile, e ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read report file: " + reportFile, e ); + } + } + + if ( !suppressSummaries ) + { + invokerSession.logSummary( getLog(), ignoreFailures ); + } + + if ( streamLogsOnFailures ) + { + invokerSession.logFailedBuildLog( getLog(), ignoreFailures ); + } + + invokerSession.handleFailures( getLog(), ignoreFailures ); + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/main/mdo/invocation.mdo b/Java-base/maven-invoker-plugin/src/src/main/mdo/invocation.mdo new file mode 100644 index 000000000..bc488f4c9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/mdo/invocation.mdo @@ -0,0 +1,226 @@ + + + + + + build-job + BuildJob + reportsDirectory.]]> + + + + package + org.apache.maven.plugins.invoker.model + + + + namespace + + + + BuildJob + + Describes a build job processed by the Maven Invoker Plugin. A build job can consist of a pre-build hook script, + one ore more invocations of Maven and a post-build hook script. + + 1.0.0 + + + project + 1.0.0 + true + String + The path to the project to build. This path is usually relative and can denote both a POM file or a project directory. + + + name + 1.0.0 + false + String + The name of this build job. + + + description + 1.0.0 + false + String + The description of this build job. + + + result + 1.0.0 + true + String + The result of this build job. + + + failureMessage + 1.0.0 + false + String + Any failure message(s) in case this build job failed. + + + time + 1.0.0 + true + double + The number of seconds that this build job took to complete. + + + type + 1.0.0 + true + String + The type of the build job. + + + ordinal + 1.0.0 + false + int + BuildJobs will be sorted in the descending order of the ordinal. In other words, the BuildJobs with the highest numbers will be executed first + + + buildlog + 1.0.0 + false + String + The build log filename + + + + + 1.0.0+ + + + + 1.0.0+ + + + + 1.0.0+ + -Dinvoker.test=xxx,yyy parameter. + */ + public static final String DIRECT = "direct"; + + } + ]]> + + + 1.0.0+ + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report.properties b/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report.properties new file mode 100644 index 000000000..a174ec8f6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report.properties @@ -0,0 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +report.invoker.result.description = The results of the Maven invocations. +report.invoker.result.name = Invoker Build Results +report.invoker.result.title = Invoker Report +report.invoker.summary.title = Summary +report.invoker.summary.number = Builds +report.invoker.summary.success = Success +report.invoker.summary.failed = Failures +report.invoker.summary.skipped = Skipped +report.invoker.summary.success.rate = Success Rate +report.invoker.summary.time.total = Total Time +report.invoker.summary.time.avg = Avg Time +report.invoker.detail.title = Build Details +report.invoker.detail.name = Name +report.invoker.detail.result = Result +report.invoker.detail.time = Time +report.invoker.detail.message = Message +report.invoker.format.percent = 0.0% +report.invoker.format.seconds = 0.0\u00A0s diff --git a/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_de.properties b/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_de.properties new file mode 100644 index 000000000..d1016e305 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_de.properties @@ -0,0 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +report.invoker.result.description = Die Ergebnisse der Maven-Ausf\u00FChrungen. +report.invoker.result.name = Invoker-Build-Ergebnisse +report.invoker.result.title = Invoker-Bericht +report.invoker.summary.title = Zusammenfassungen +report.invoker.summary.number = Builds +report.invoker.summary.success = Erfolge +report.invoker.summary.failed = Fehlschl\u00E4ge +report.invoker.summary.skipped = Ausgelassen +report.invoker.summary.success.rate = Erfolgsrate +report.invoker.summary.time.total = Gesamtzeit +report.invoker.summary.time.avg = Durchschnittszeit +report.invoker.detail.title = Build-Details +report.invoker.detail.name = Name +report.invoker.detail.result = Ergebnis +report.invoker.detail.time = Zeit +report.invoker.detail.message = Meldung +report.invoker.format.percent = 0.0\u00A0% +report.invoker.format.seconds = 0.0\u00A0s diff --git a/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_en.properties b/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_en.properties new file mode 100644 index 000000000..e1bb9d4b1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_en.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. + +# NOTE: +# This bundle is intentionally empty because English strings are provided by the base bundle via the parent chain. It +# must be provided nevertheless such that a request for locale "en" will not erroneously pick up the bundle for the +# JVM's default locale (which need not be "en"). See the method javadoc about +# ResourceBundle.getBundle(String, Locale, ClassLoader) +# for a full description of the lookup strategy. \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_fr.properties b/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_fr.properties new file mode 100644 index 000000000..64e4a5a99 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/main/resources/invoker-report_fr.properties @@ -0,0 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +report.invoker.result.description = Résultat des invocations de Maven +report.invoker.result.name = Invoker Résultat de builds +report.invoker.result.title = Invoker Rapport +report.invoker.summary.title = Sommaire +report.invoker.summary.number = Builds +report.invoker.summary.success = Réussis +report.invoker.summary.failed = Echecs +report.invoker.summary.skipped = Ignorés +report.invoker.summary.success.rate = Taux de réussite +report.invoker.summary.time.total = Durée totale +report.invoker.summary.time.avg = Durée moyenne +report.invoker.detail.title = Détails de Build +report.invoker.detail.name = Nom +report.invoker.detail.result = Résultat +report.invoker.detail.time = Durée +report.invoker.detail.message = Message +report.invoker.format.percent = 0.0% +report.invoker.format.seconds = 0.0\u00A0s diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/access-test-classes.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/access-test-classes.apt.vm new file mode 100644 index 000000000..74fabd4ef --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/access-test-classes.apt.vm @@ -0,0 +1,64 @@ + ------ + Accessing Test Classes + ------ + Benjamin Bentmann + ------ + 2008-08-02 + ------ + + ~~ 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 + +Accessing Test Classes + + In case your pre-/post-build scripts perform complex operations that you would rather like to refactor out into some + utility class instead of copy&pasting them in each script, you can use the parameter <<>>: + ++---- + + + + + maven-invoker-plugin + ${project.version} + + true + + + + integration-test + + run + + + + + + + ++---- + + Setting <<>> to <<>> will prepend the directories <<<$\{project.build.testOutputDirectory\}>>>, + <<<$\{project.build.outputDirectory\}>>> and all dependencies of your project to the class path of the script + interpreter. Among others, this allows you to create some utility classes in your test source tree and use this code + for the hook scripts. + + Of course, this requires your test classes to be compiled before running the integration tests but this is + usually the case if you employ the Invoker Plugin during the lifecycle phase <<>>. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/clone-projects.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/clone-projects.apt.vm new file mode 100644 index 000000000..0c52bffa1 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/clone-projects.apt.vm @@ -0,0 +1,72 @@ + ------ + Cloning Projects + ------ + Paul Gier + ------ + 2008-08-02 + ------ + + ~~ 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 + +Cloning Projects + + By default the projects will be executed in the same directory where they are found. + This means that build output will be generated with the project files. It may be + helpful to copy the projects to another directory before running them, for example + <<>>. This will allow <<>> to remove the output generated + by all of the test projects. + ++------------------ + + ... + + + + maven-invoker-plugin + ${project.version} + + src/it + \${project.build.directory}/it + + + + integration-test + + run + + + + + + + ... + ++------------------ + + There is another benefit of cloning the projects to a temporary location besides keeping the source tree free of build + output. When the projects are not cloned, the plugin must use temporary POMs to perform their filtering. In contrast, + cloning the projects enables the plugin to simply filter the cloned POMs in-place. Since a POM's file name remains + unchanged this way, the inter-project dependencies expressed in the POMs via <<<\>>> and <<<\>>> + elements remain intact, too. This in turn allows the plugin to filter all POMs that participate in a forked build + rather than only the root POM of the execution. + + Last but not least, once the projects have been cloned and filtered by an execution of <<>>, you can + browse to a cloned project and manually invoke Maven on it. This can be useful to debug the build. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/fast-use.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/fast-use.apt.vm new file mode 100644 index 000000000..c6076628a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/fast-use.apt.vm @@ -0,0 +1,143 @@ + ------ + Fast Build Configuration + ------ + Olivier Lamy + ------ + 2008-08-02 + ------ + + ~~ 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 + +Fast Build Configuration + + If you follow the recommended approach and use a dedicated local repository for the integration tests (e.g. + <<>>), you will likely encounter long build times. If the test repository has been cleaned, the + plugin needs to re-download all artifacts from the central repo and the resulting network traffic slows the test + execution down. + + But you can configure the plugin to download released artifacts from your local repo. + This will work without optional settings with Maven >= 2.0.9 because many plugins + versions are locked in the super POM. For older versions, you have to lock plugins versions. + + To enable this feature, you have to add a <<>> file in your project (for example in <<>>) + and modify the plugin configuration as this: + ++------------------ + + ... + + + + org.apache.maven.plugins + maven-invoker-plugin + ${project.version} + + ... + src/it/settings.xml + ... + + + + + ... + ++------------------ + + The settings must contain the following content which effectively tells Maven to use the local repository as a remote + repository: + ++------------------ + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + ++------------------ + + The token <<<@localRepositoryUrl@>>> will be automatically replaced by the Invoker Plugin with the URL to the local + repository used for the Maven invocation. + +Fast Build Configuration - mergeUserSettings and mirrors + + When you want to use Fast Build Configuration with options <<>> + you should take care for your mirror setting. + + If you have in <<<~/.m2/settings.xml>>> something like: + ++------------------ + + + mirrorId + Public Mirrors + url_to_my_mirror + *,!repo1,!repo2 + + ++------------------ + + Please look at <<>> tag, single <<<*>>> means match all repositories for mirroring + - also repository with id <<>> will be mirrored. + In effective Fast Build Configuration will not work as expected. + + You should change this to similar: + ++------------------ + + + mirrorId + Public Mirrors + url_to_my_mirror + external:*,!repo1,!repo2 + + ++------------------ + + Where <<>> - matches all repositories except those using localhost or file based repositories. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/filtering.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/filtering.apt.vm new file mode 100644 index 000000000..0f5c09e41 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/filtering.apt.vm @@ -0,0 +1,136 @@ + ------ + Filtering Files + ------ + Benjamin Bentmann + ------ + 2008-08-30 + ------ + + ~~ 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 + +Filtering Files + + Some files of the sub projects can be filtered, i.e. special tokens will be replaced by some other string before the + actual build is started. In detail, the following files will be filtered: + + * POM files selected by the include/exclude patterns. The tokens to be filtered must be enclosed in <<<@...@>>> to + avoid interferences with Maven's normal POM interpolation, i.e. use <<<@project.version@>>> instead of + <<<$\{project.version\}>>>. Starting with version 1.3, the plugin will also (recursively) filter all POM files + referenced via <<<\>>> or <<<\>>> tags, if the projects are cloned to a temporary location. + + * The custom user setting file. Again, the tokens to be filtered in this file must be enclosed in <<<@...@>>>. + + * The invoker properties, the goals file and the profiles file. Tokens in these files must use the usual Maven syntax + <<<$\{...\}>>>. + + [] + + The following example directory structure highlights the files which are filtered by the Invoker Plugin: + ++------------------ +./ ++- pom.xml ++- src/ + +- it/ + +- settings.xml <- Filtered + +- aggregator-project/ + +- child-module-1/ + | +- pom.xml <- Filtered + +- child-module-2/ + | +- pom.xml <- Filtered + +- pom.xml <- Filtered + +- invoker.properties <- Filtered + +- goals.txt <- Filtered + +- profiles.txt <- Filtered ++------------------ + + Below is the corresponding POM snippet for the plugin configuration: + ++------------------ + + + another-value + + ... + + + + maven-invoker-plugin + ${project.version} + + src/it + \${project.build.directory}/it + + */pom.xml + + src/it/settings.xml + + some-value + + + + + integration-test + + run + + + + + + + ++------------------ + + When filtering the files, the plugin searches various data sources for a token's replacement value in the order + indicated below. The search terminates as soon as an existing replacement value has been found, i.e. the value + is not <<>>. + + [[1]] Tokens of the form <<>> and <<>> will be expanded to the referenced POM value if possible, + e.g. <<>> refers to the version given in the <<>> that executed the Invoker Plugin. + If no such POM element exists, the value lookup continues as outlined next. + + [[2]] Built-in properties defined by the Invoker Plugin will be processed. See this table for a list of available + built-in properties: + +*--------------------------+----------------------------------------------------------------------------------+--------+ +|| Built-in Property || Value || Since | +*--------------------------+----------------------------------------------------------------------------------+--------+ +| <<>> | The absolute path to the project base directory of the main build. | 1.1 | +*--------------------------+----------------------------------------------------------------------------------+--------+ +| <<>> | The <<>> URL to the project base directory of the main build. | 1.4 | +*--------------------------+----------------------------------------------------------------------------------+--------+ +| <<>> | The absolute path to the local repository used for the main build. | 1.2 | +*--------------------------+----------------------------------------------------------------------------------+--------+ +| <<>> | The <<>> URL to the local repository used for the main build. | 1.3 | +*--------------------------+----------------------------------------------------------------------------------+--------+ + + [[3]] The properties given by the parameter <<>> in the plugin configuration will be consulted for + a property whose key equals the token. For the example POM shown above, the value <<>> has been + associated with the token <<>>. + + [[4]] The properties given by the POM's <<<\>>> section will be searched for a property whose key equals + the token. Regarding the example POM, the value <<>> has been associated with the token + <<>>. + + [] + + Tokens for which no replacement value could be determined will be left unchanged. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/install-artifacts.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/install-artifacts.apt.vm new file mode 100644 index 000000000..26f620e31 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/install-artifacts.apt.vm @@ -0,0 +1,66 @@ + ------ + Installing Artifacts + ------ + Paul Gier + ------ + 2008-08-02 + ------ + + ~~ 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 + +Installing Artifacts + + The following example shows a plugin configuration using the <<<{{{../install-mojo.html}invoker:install}}>>> + goal. This will cause the project artifact(s) to be installed to a dedicated local + repository before executing the projects. This can be helpful if you + want to build your project and test the new artifact(s) in a single step instead of + installing first and then running tests. + ++------------------ + + ... + + + + maven-invoker-plugin + ${project.version} + + src/it + target/local-repo + + + + integration-test + + install + run + + + + + + + ... + ++------------------ + + + \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/integration-test-verify.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/integration-test-verify.apt.vm new file mode 100644 index 000000000..c5a363e7d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/integration-test-verify.apt.vm @@ -0,0 +1,60 @@ + ------ + Using with other integration test frameworks + ------ + Stephen Connolly + ------ + 2009-08-15 + ------ + + ~~ 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 + +Using with other integration test frameworks + + If you are using other integration test frameworks, or if you need to setup an integration test enviroment prior to + test execution and tear that envronment down afterwards, then you need to use the <<>> and + <<>> goals in place of <<>>. For example: + ++---- + + + + + org.apache.maven.plugins + maven-invoker-plugin + ${project.version} + + + integration-test + + + integration-test + verify + + + + + + + ++---- + + This will allow any plugins bound to the <<>> phase to execute before the <<>> phase + executes the <<>> goal that we have just bound. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/invoker-properties.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/invoker-properties.apt.vm new file mode 100644 index 000000000..f226aa950 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/invoker-properties.apt.vm @@ -0,0 +1,93 @@ + ------ + Invoker Properties + ------ + Benjamin Bentmann + ------ + 2008-08-09 + ------ + + ~~ 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 + +Invoker Properties + + The various parameters in the plugin configuration provide a means to globally configure the goals, profiles etc. + used to run a Maven build on the projects. However, for certain projects you might want to specify different settings. + To avoid the hassle of multiple plugin executions, you can simply use a file named <<>> to + control the build settings on a per project basis or in one of its ancestor folders to apply it for a group of projects. + The exact name of this properties file is configurable but it needs to reside in the base directory of the respective + project as shown below: + + ++------------------ +./ ++- src/ + +- it/ + +- group-1 + +- invoker.properties + +- test-project/ + +- pom.xml + +- invoker.properties + +- src/ ++------------------ + + There are only a few keys supported in this file and their names typically match the corresponding parameters in the + plugin configuration. For a complete overview of supported properties, see the example given in the documentation of + the plugin parameter <<<{{{../run-mojo.html#invokerPropertiesFile}invokerPropertiesFile}}>>>. + + The comments given in the example should be rather self-explanatory. Looking closely, you can also notice that the + syntax <<<$\{expression\}>>> can be used to filter the property values. What deserves some more description is the + possibility to perform several Maven builds on the same project. By default, the Invoker Plugin will perform the + following steps for each project: + + * Run the pre build hook script if existent + + * Invoke Maven in the project directory + + * Run the post build hook script if existent + + [] + + Since plugin version 1.3, you can append a one-based index to the invoker properties in order to enable/configure + further invocations of Maven. More precisely, <<>> specifies the goals for the first build, + <<>> lists the goals for the second build and so on. These builds will be performed one after the + other: + + * Run the pre build hook script if existent + + * Invoke Maven in the project directory + + * Invoke Maven in the project directory + + * ... + + * Invoke Maven in the project directory + + * Run the post build hook script if existent + + [] + + Most of the properties can be indexed this way, e.g. <<>> would specify the profiles to use for + the third invocation. If the property <<>> was not defined, the plugin would query the property + <<>> as a fallback to determine the profiles for the third build. This build loop ends after + invocation if no property <<>> is defined. + + The invoker properties can also be used to skip projects based on the current JRE version or OS family. For more + information on this feature, please see {{{./selector-conditions.html}Selector Conditions}}. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/logs-for-failed-tests.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/logs-for-failed-tests.apt.vm new file mode 100644 index 000000000..57e3f6291 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/logs-for-failed-tests.apt.vm @@ -0,0 +1,56 @@ + ------ + Inspect logs for failed tests + ------ + Slawomir Jaranowski + ------ + 2020-05-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 + +Inspect logs for failed tests + + In the usual build all tests pass as we expect, + so printing logs from all tests to project build log make our standard build log illegible. + The problem begin when some of test was failed, + especially when happened on CI system when access to files from build workspace is difficult. + + In order to help investigation on failed test we can use option: <<>>. + Now logs from all failed test will be printed to project build log when all test will have finished. + ++---+ + + ... + + + + org.apache.maven.plugins + maven-invoker-plugin + ${project.version} + + true + + + + + ... + ++---+ diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/post-build-script.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/post-build-script.apt.vm new file mode 100644 index 000000000..a58bda52b --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/post-build-script.apt.vm @@ -0,0 +1,97 @@ + ------ + Using a Post-Build Script + ------ + Paul Gier + ------ + 2008-08-02 + ------ + + ~~ 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 + +Using a Post-Build Script + + Here is an example of how the Invoker Plugin can be used to run a set of Maven projects and then verify their output + with a {{{http://www.beanshell.org/}BeanShell}} or {{{http://groovy-lang.org/}Groovy}} script. The name of the + script file in this case is <<>>. + ++------------------ + + + + + maven-invoker-plugin + ${project.version} + + true + src/it + setup.bsh + verify.bsh + + + + integration-test + + run + + + + + + + ++------------------ + + Below is an example post-build BeanShell script (<<>>) that checks for the existence of a JAR file after + the build has run. If the JAR file does not exist, the script throws an exception which causes the Invoker Plugin to + log that the build failed. More precisely, any non-null return value which does not equal <<>> will be interpreted + as a failure condition. And of course, if the script exists abnormally due to an exception, the plugin will flag the + corresponding build as a failure, too. + ++------------------ +import java.io.*; + +File file = new File( basedir, "target/my-test-project-1.0-SNAPSHOT.jar" ); +if ( !file.isFile() ) +{ + throw new FileNotFoundException( "Could not find generated JAR: " + file ); +} ++------------------ + + Complementary to the post-build hook script, you can also create a pre-build hook script that will be run before + the invocation of Maven. This can be used to do some preparations for the build. + + To allow the scripts to access some useful data about the test project, the following global variables will be + defined by the Invoker Plugin before running the script: + +*--------------------------+----------------------+-----------------------------------------------------------+--------+ +|| Name || Type || Description || Since | +*--------------------------+----------------------+-----------------------------------------------------------+--------+ +| <<>> | <<>> | The absolute path to the base directory of the test project. | 1.0 | +*--------------------------+----------------------+-----------------------------------------------------------+--------+ +| <<>>| <<>> | The absolute path to the local repository used for the Maven invocation on the test project. | 1.3 | +*--------------------------+----------------------+-----------------------------------------------------------+--------+ +| <<>> | <<>> | The storage of key-value pairs used to pass data from the pre-build hook script to the post-build hook script. | 1.4 | +*--------------------------+----------------------+-----------------------------------------------------------+--------+ +| <<>> | <<>> | The version of Maven executing on the test project. | 1.9 | +*--------------------------+----------------------+-----------------------------------------------------------+--------+ + + Additional variables that can be accessed in the hook scripts can be defined through the + <<<{{{../run-mojo.html#scriptVariables}scriptVariables}}>>> parameter in the Invoker Plugin's configuration. \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/prepare-build-env.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/prepare-build-env.apt.vm new file mode 100644 index 000000000..f99683d0c --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/prepare-build-env.apt.vm @@ -0,0 +1,75 @@ + ------ + Preparing the Build Environment + ------ + Benjamin Bentmann + ------ + 2008-08-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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +Preparing the Build Environment + + In general, the plugin assumes that the projects to build are unrelated to one other such that their build order does + not matter. However, you might sometimes want to ensure that certain projects are build before others. As a + motivation, imagine that a project performs some kind of common setup for the other projects, e.g. installing utility + artifacts into the local repository. + + Starting with plugin version 1.3, you can declare a group of setup projects that must be run before all the other + projects by means of the parameter <<<\>>> as shown in the following example: + ++---- + + + + + maven-invoker-plugin + ${project.version} + + + utility-plugin/pom.xml + + + */pom.xml + + + + + integration-test + + run + + + + + + + ++---- + + This tells the plugin that the project <<>> must be run before the other projects selected by + the pattern <<<*/pom.xml>>>. Please note that although the pattern <<<*/pom.xml>>> also matches the path + <<>>, this project will not be run twice. In other words, any project selected by both + <<<\>>> and <<<\>>> will only be run once, namely during the setup phase. + + The build order of several such setup projects is still undefined. So if the setup projects have inter-dependencies + that require a certain build order, you should group them by an aggregator POM and feed that into the Invoker Plugin + such that the correct build order will be determined by Maven's multi-module reactor. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/selector-conditions.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/selector-conditions.apt.vm new file mode 100644 index 000000000..d16561932 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/selector-conditions.apt.vm @@ -0,0 +1,67 @@ + ------ + Selector Conditions + ------ + Benjamin Bentmann + ------ + 2009-09-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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +Selector Conditions + + Starting with plugin version 1.4, some keys of the {{{./invoker-properties.html}Invoker Properties}} can be used to + skip individual projects based on the current JRE version or OS family as illustrated in the example below: + ++------------------ +# build project if JRE version is 1.4 or higher, but exclude version 1.4.1 +invoker.java.version = 1.4+, !1.4.1 + +# build project if OS family is not Windows +invoker.os.family = !windows ++------------------ + + In addition, with plugin version 1.5, there is the ability to skip individual projects based on the current Maven + version as illustrated in the example below: + ++------------------ +# build project if Maven version is 2.0.10 or higher, but exclude versions 2.1.0 and 2.2.0 +invoker.maven.version = 2.0.10+, !2.1.0, !2.2.0 ++------------------ + + The values of these keys are comma separated tokens. A token prefixed with "!" denotes an exclusion, otherwise it + denotes an inclusion. A project is build if no exclusion matches and if no inclusions are given or at least one of + them matches the current environment. + + The tokens to describe versions can be suffixed with "+" or "-". The table below shows how the different styles + of version tokens translate to a version range: + +*----------------+----------------------------+ +|| Version Token || Equivalent Version Range | +*----------------+----------------------------+ +| 1.5 | [1.5,1.6) | +*----------------+----------------------------+ +| 1.5+ | [1.5,) | +*----------------+----------------------------+ +| 1.5- | (,1.5) | +*----------------+----------------------------+ + + For the OS family, the tokens "windows", "unix" and "mac" are supported. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/selector-scripts.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/selector-scripts.apt.vm new file mode 100644 index 000000000..43072dfe9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/selector-scripts.apt.vm @@ -0,0 +1,88 @@ + ------ + Selector Scripts + ------ + Stephen Connolly + ------ + 2009-10-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 + +Selector Scripts + + Starting with plugin version 1.5, a custom script can be used to skip individual projects based on + whatever criteria expressed in the script as illustrated in the following example. Assume the + following directory structure: + ++------------------ +./ ++- pom.xml ++- src/ + +- it/ + +- settings.xml + +- conditional-it/ + +- pom.xml + +- check-assumptions.bsh + +- src/ ++------------------ + + The plugin configuration for this example would look like this: + ++------------------ + + ... + + + + maven-invoker-plugin + ${project.version} + + src/it + \${project.build.directory}/it + + */pom.xml + + src/it/settings.xml + \${project.build.directory}/local-repo + check-assumptions.bsh + + + + integration-test + + install + run + + + + + + + ... + ++------------------ + + If the check-assumptions.bsh script returns <<>> or does not return a value, then the project will be executed. + + If the script returns any value other than <<>>, then the project will not be executed. + + If the script throws an exception, then the project will be marked as being in ERROR. + diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/examples/skipping.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/skipping.apt.vm new file mode 100644 index 000000000..064bc5b10 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/examples/skipping.apt.vm @@ -0,0 +1,62 @@ + ------ + Skipping Invocations + ------ + Mark Struberg + ------ + 2009-12-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 + +Skipping Invocations + + The Invoker Plugin usually performs an installation setup and runs the configured Maven invocations. Since version + 1.4 of the plugin all these steps may be skipped. + + To skip running the invocations for a particular project, set the <<>> property to <<>>. The + artifact staging to a local repository can be skipped by setting the parameter <<>> to <<>>. + ++---+ + + ... + + + + org.apache.maven.plugins + maven-invoker-plugin + ${project.version} + + true + true + + + + + ... + ++---+ + + All these steps can also be omited via the command line by use of the <<>> property: + ++---+ +mvn install -Dinvoker.skip=true ++---+ + diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/index.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/index.apt.vm new file mode 100644 index 000000000..59e665ef9 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/index.apt.vm @@ -0,0 +1,105 @@ + ------ + Introduction + ------ + Jason van Zyl + ------ + 2013-07-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. + + ~~ NOTE: For help with the syntax of this file, see: + ~~ http://maven.apache.org/doxia/references/apt-format.html + +${project.name} + + The Invoker Plugin is used to run a set of Maven projects. The plugin can determine whether each project execution + is successful, and optionally can verify the output generated from a given project execution. + + This plugin is in particular handy to perform integration tests for other Maven plugins. The Invoker Plugin can be + employed to run a set of test projects that have been designed to assert certain features of the plugin under test. + +* Goals Overview + + The plugin has four goals meant to participate in the default build lifecycle: + + * {{{./install-mojo.html}invoker:install}} copies the project artifacts and dependencies of the main build into a + dedicated local repository to prepare the execution of the selected sub projects in an isolated environment. + + * {{{./integration-test-mojo.html}invoker:integration-test}} runs a set of Maven projects in a directory. + + * {{{./verify-mojo.html}invoker:verify}} verifies the result of <<>>. + + * {{{./run-mojo.html}invoker:run}} runs a set of Maven projects in a directory and verifies the result. This is + equivalent to running both <<>> and <<>>. + + [] + + This last goal is intended for usage with the site lifecycle: + + * {{{./report-mojo.html}invoker:report}} integrates the results from previous builds into the site. + + [] + +* Usage + + General instructions on how to use the Invoker Plugin can be found on the {{{./usage.html}usage page}}. Some more + 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 {{{./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 {{{./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-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 + {{{./scm.html}source repository}} and will find supplementary information in the + {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. + +* Examples + + The following example configurations are available to illustrate selected use cases in more detail: + + * {{{./examples/clone-projects.html}Clone projects}} to a temporary directory before running. + + * {{{./examples/filtering.html}Filter files}} to introduce some updates before starting the build. + + * {{{./examples/install-artifacts.html}Install}} projects artifacts to a local repository before running. + + * {{{./examples/post-build-script.html}Run a BeanShell or Groovy script}} to verify project output. + + * {{{./examples/fast-use.html}Fast Invoker Plugin configuration}} to accelerate project execution. + + * {{{./examples/access-test-classes.html}Access test classes}} to share code between hook scripts. + + * {{{./examples/invoker-properties.html}Use Invoker Properties}} to configure goals, profiles etc. for individual projects. + + * {{{./examples/selector-conditions.html}Use Selector Conditions}} to skip projects based on JRE version or OS family. + + * {{{./examples/prepare-build-env.html}Prepare the Build Environment}} by building some setup projects before other projects. + + * {{{./examples/integration-test-verify.html}Using with other integration test frameworks}} by decoupling checking + the results of the integration tests from executing the integration tests. + + [] + + You can also study some real-life usages of the Invoker Plugin by browsing its own integration tests which are located + in the directory <<>> of the {{{./scm.html}project source tree}}. diff --git a/Java-base/maven-invoker-plugin/src/src/site/apt/usage.apt.vm b/Java-base/maven-invoker-plugin/src/src/site/apt/usage.apt.vm new file mode 100644 index 000000000..8269569f4 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/apt/usage.apt.vm @@ -0,0 +1,137 @@ + ------ + Usage + ------ + Jason van Zyl + ------ + 2008-08-02 + ------ + + ~~ 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 + +Usage + + This page provides general usage information along with a basic example. The plugin + is commonly used to run and verify integration tests for a project, say a Maven plugin. This is done using + the <<<{{{./run-mojo.html} invoker:run }}>>> goal. And as a preparation for the integration tests, one usually wants to + stage the artifacts under tests into a testing repository. For this job, the + <<<{{{./install-mojo.html} invoker:install }}>>> goal can be used. + +* Basic Example + + The following example demonstrates a basic plugin configuration for running integration tests. Let's assume the following + directory structure of your project: + ++------------------ +./ ++- pom.xml ++- src/ + +- it/ + +- settings.xml + +- first-it/ + | +- pom.xml + | +- src/ + +- second-it/ + +- pom.xml + +- invoker.properties + +- test.properties + +- verify.bsh + +- src/ ++------------------ + + In this example, the directory <<>> is the location where all the IT projects reside. You simply put each + integration test into a distinct sub directory, like shown by <<>> and <<>>. The plugin + configuration for this example would look like this: + ++------------------ + + ... + + + + maven-invoker-plugin + ${project.version} + + \${project.build.directory}/it + src/it/settings.xml + \${project.build.directory}/local-repo + verify + + + + integration-test + + install + run + + + + + + + ... + ++------------------ + + Now, to get things going, just tell Maven to execute the lifecycle phase <<>>: + ++------------------ + mvn integration-test ++------------------ + + First, the <<>> goal will be executed during the phase <<>> and will copy the + main artifact of the project along with any attached artifacts over to <<>>. Furthermore, any + locally reachable parent POMs of the project will be copied to the staging repository. Last but not least, if you are + running a reactor build, all project dependencies that reside in the reactor will be staged, too. + + Next up, the <<>> goal will execute during the phase <<>> and will use the configured + include/exclude patterns to search the directory <<>> for IT POMs. Every directory where an IT POM is found + will be copied over to <<>>. Additionally, the IT POMs will be filtered, i.e. expressions like + <<<@project.version@>>> will be replaced with the corresponding values from the project's POM. This is especially + handy to make sure your IT POMs always reference the currently built version of the project artifact. You can also + define other properties via the plugin configuration that you wish to use for filtering. + + Once the IT POMs have been filtered, a Maven build will be started on them. By default, the Invoker Plugin will execute the + phase <<>> on the IT POMs but that can be changed globally in the plugin configuration or for an individual + integration test by using the <<<{{{./examples/invoker-properties.html}invoker.properties}}>>> as done in the example + for <<>>. Likewise, system properties can be passed to the IT builds via the file <<>>. + And the file <<>> can be used to specify custom user settings for the tests. Among others, this + allows you to make the integration tests use your local repository as a remote repository, avoiding time-consuming + downloads from <<>> in order to fill up the initially empty staging repository. Please see the example + {{{./examples/fast-use.html}Fast Invoker Plugin Configuration}} for more details on this technique. The output of the + IT builds is written to a log file named <<>> (e.g. <<>>) and allows + diagnostics in case an integration test fails. + + When an integration test has finished, the plugin will invoke an optional post build hook script. In the example, + this is the case for <<>> where <<>> will be run. The purpose of this script is usually to + check that the build of the integration test did not only succeed but also produced the intended output. Have a look + at the example {{{./examples/post-build-script.html}Using a Post Build Script}} for a code snippet. + +* Running Only Some Tests + + The plugin also supports a parameter <<<-Dinvoker.test>>> to run only ITs in the directories matched by the patterns + used in the parameter. This enables you to quickly rerun individual tests. See this example command line: + ++--- + mvn invoker:run -Dinvoker.test=*MWAR*,simple* ++--- + + Assuming the base directory of the sub projects is <<>>, the plugin will only run projects from directories + matching the path <<>> and <<>>. diff --git a/Java-base/maven-invoker-plugin/src/src/site/fml/faq.fml b/Java-base/maven-invoker-plugin/src/src/site/fml/faq.fml new file mode 100644 index 000000000..a8f093579 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/fml/faq.fml @@ -0,0 +1,76 @@ + + + + + + + + Why do I need to use this plugin? + +

+ It is essential that you provide some form of integration testing for your projects and the Invoker Plugin + tries to make is easy for you to create integration tests for your Maven Plugins, new Lifecycles, or any other + type of Maven component that you've created. Currently the Invoker Plugin forks Maven to execute the specified + projects, but it is hoped that soon we will integrate the Maven Embedder into the mix to allow you run your + projects in process for great speed. +

+
+
+ + How can I assert that the build of an IT project fails? + +

+ Sometimes you might want to test that error conditions are properly dealt with, i.e. fail a build. To assert + a failure for a particular IT project, put the following setting into the properties file denoted by the + plugin's invokerPropertiesFile parameter: + invoker.buildResult=failure. + Now, the failure of the IT build will be interpreted as a test success. Likewise, a successful IT build will + be considered a test failure. +

+
+
+ + How can I share common code between the pre-/post-build scripts? + +

+ If you want to avoid copy&paste of lengthy code snippets within the hook scripts, you can move this code + into a regular Java class. More precisely, you would place this utility code somewhere in your test source + tree and set the plugin parameter addTestClassPath + to true. For more details, please see the example + Accessing Test Classes. +

+
+
+ + How can I invoke multiple Maven builds on the same IT project? + +

+ This is not supported in the plugin configuration but rather on a per project basis by means of the invoker + properties. This way, you use properties like invoker.goals.2 to configure the goals for a second + invocation of Maven. Have a look at the example about using + Invoker Properties. +

+
+
+
+
diff --git a/Java-base/maven-invoker-plugin/src/src/site/resources/download.cgi b/Java-base/maven-invoker-plugin/src/src/site/resources/download.cgi new file mode 100644 index 000000000..1b178d2e6 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/resources/download.cgi @@ -0,0 +1,22 @@ +#!/bin/sh +# +# 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. +# +# Just call the standard mirrors.cgi script. It will use download.html +# as the input template. +exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $* \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/site/site.xml b/Java-base/maven-invoker-plugin/src/src/site/site.xml new file mode 100644 index 000000000..5c9f2c2ef --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/site.xml @@ -0,0 +1,82 @@ + + + + + + + + http://maven.apache.org/images/apache-maven-project.png + http://www.apache.org/ + + + + http://maven.apache.org/images/maven-logo-black-on-white.png + http://maven.apache.org/ + + + org.apache.maven.skins + maven-fluido-skin + 1.6 + + + + + true + + + maven.apache.org/plugins/maven-invoker-plugin/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Java-base/maven-invoker-plugin/src/src/site/xdoc/download.xml.vm b/Java-base/maven-invoker-plugin/src/src/site/xdoc/download.xml.vm new file mode 100644 index 000000000..3f710359a --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/site/xdoc/download.xml.vm @@ -0,0 +1,126 @@ + + + + + + + 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} is distributed under the Apache License, version 2.0.

+ +

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

+ + + + +

+ [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. +

+ +
+ Other mirrors: + + +
+ +

+ 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)maven/plugins/${project.artifactId}-${project.version}-source-release.zipmaven/plugins/${project.artifactId}-${project.version}-source-release.zip.sha512maven/plugins/${project.artifactId}-${project.version}-source-release.zip.asc
+
+ + + +

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

+ +
+
+ +
+ diff --git a/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java new file mode 100644 index 000000000..50c624591 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/ExtendedMavenProjectStub.java @@ -0,0 +1,57 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.model.Scm; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; + +import java.util.Properties; + +/** + * @author Olivier Lamy + * @since 22 nov. 07 + */ +public class ExtendedMavenProjectStub + extends MavenProjectStub +{ + private Scm scm; + + private Properties properties; + + public Scm getScm() + { + return scm; + } + + public void setScm( Scm scm ) + { + this.scm = scm; + } + + public Properties getProperties() + { + return properties; + } + + public void setProperties( Properties properties ) + { + this.properties = properties; + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java new file mode 100644 index 000000000..1edcdb105 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InterpolationTest.java @@ -0,0 +1,126 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.Reader; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.apache.maven.model.Scm; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.apache.maven.settings.Settings; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.ReaderFactory; + +/** + * @author Olivier Lamy + * @since 22 nov. 07 + */ +public class InterpolationTest + extends AbstractMojoTestCase +{ + + protected MavenProjectStub buildMavenProjectStub() + { + ExtendedMavenProjectStub project = new ExtendedMavenProjectStub(); + project.setVersion( "1.0-SNAPSHOT" ); + project.setArtifactId( "foo" ); + project.setGroupId( "bar" ); + Properties properties = new Properties(); + properties.put( "fooOnProject", "barOnProject" ); + project.setProperties( properties ); + Scm scm = new Scm(); + scm.setConnection( "http://blabla" ); + project.setScm( scm ); + return project; + } + + public void testCompositeMap() + throws Exception + { + + Properties properties = new Properties(); + properties.put( "foo", "bar" ); + properties.put( "version", "2.0-SNAPSHOT" ); + CompositeMap compositeMap = new CompositeMap( buildMavenProjectStub(), (Map) properties, false ); + assertEquals( "1.0-SNAPSHOT", compositeMap.get( "pom.version" ) ); + assertEquals( "bar", compositeMap.get( "foo" ) ); + assertEquals( "bar", compositeMap.get( "pom.groupId" ) ); + assertEquals( "http://blabla", compositeMap.get( "pom.scm.connection" ) ); + assertEquals( "barOnProject", compositeMap.get( "fooOnProject" ) ); + } + + public void testPomInterpolation() + throws Exception + { + Reader reader = null; + File interpolatedPomFile; + try + { + InvokerMojo invokerMojo = new InvokerMojo(); + setVariableValueToObject( invokerMojo, "project", buildMavenProjectStub() ); + setVariableValueToObject( invokerMojo, "settings", new Settings() ); + Properties properties = new Properties(); + properties.put( "foo", "bar" ); + properties.put( "version", "2.0-SNAPSHOT" ); + setVariableValueToObject( invokerMojo, "filterProperties", properties ); + String dirPath = getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + + File.separatorChar + "resources" + File.separatorChar + "unit" + File.separatorChar + "interpolation"; + + interpolatedPomFile = new File( getBasedir(), "target/interpolated-pom.xml" ); + invokerMojo.buildInterpolatedFile( new File( dirPath, "pom.xml" ), interpolatedPomFile ); + reader = ReaderFactory.newXmlReader( interpolatedPomFile ); + String content = IOUtil.toString( reader ); + assertTrue( content.indexOf( "bar" ) > 0 ); + reader.close(); + reader = null; + // recreate it to test delete if exists before creation + invokerMojo.buildInterpolatedFile( new File( dirPath, "pom.xml" ), interpolatedPomFile ); + reader = ReaderFactory.newXmlReader( interpolatedPomFile ); + content = IOUtil.toString( reader ); + assertTrue( content.indexOf( "bar" ) > 0 ); + reader.close(); + reader = null; + } + finally + { + IOUtil.close( reader ); + } + } + + public void testProfilesWithNoFile() + throws Exception + { + + InvokerMojo invokerMojo = new InvokerMojo(); + setVariableValueToObject( invokerMojo, "profiles", Arrays.asList( "zloug" ) ); + setVariableValueToObject( invokerMojo, "settings", new Settings() ); + String dirPath = getBasedir() + File.separatorChar + "src" + File.separatorChar + "test" + File.separatorChar + + "resources" + File.separatorChar + "unit" + File.separatorChar + "profiles-from-file"; + List profiles = invokerMojo.getProfiles( new File( dirPath ) ); + assertTrue( profiles.contains( "zloug" ) ); + assertEquals( 1, profiles.size() ); + + } +} diff --git a/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java new file mode 100644 index 000000000..77656f402 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InvokerMojoTest.java @@ -0,0 +1,120 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.Collections; +import java.util.List; + +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugins.invoker.model.BuildJob; +import org.apache.maven.project.MavenProject; +import org.apache.maven.settings.Settings; + +/** + * @author Olivier Lamy + * @since 18 nov. 07 + */ +public class InvokerMojoTest extends AbstractMojoTestCase +{ + + private MavenProject getMavenProject() + { + MavenProject mavenProject = new MavenProject(); + mavenProject.setFile( new File( "target/foo.txt" ) ); + return mavenProject; + } + + public void testSingleInvokerTest() throws Exception + { + InvokerMojo invokerMojo = new InvokerMojo(); + String dirPath = getBasedir() + "/src/test/resources/unit"; + List goals = invokerMojo.getGoals( new File( dirPath ) ); + assertEquals( 1, goals.size() ); + setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) ); + setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties" ); + setVariableValueToObject( invokerMojo, "project", getMavenProject() ); + setVariableValueToObject( invokerMojo, "invokerTest", "*dummy*" ); + setVariableValueToObject( invokerMojo, "settings", new Settings() ); + List poms = invokerMojo.getBuildJobs(); + assertEquals( 1, poms.size() ); + } + + public void testMultiInvokerTest() throws Exception + { + InvokerMojo invokerMojo = new InvokerMojo(); + String dirPath = getBasedir() + "/src/test/resources/unit"; + List goals = invokerMojo.getGoals( new File( dirPath ) ); + assertEquals( 1, goals.size() ); + setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) ); + setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties" ); + setVariableValueToObject( invokerMojo, "project", getMavenProject() ); + setVariableValueToObject( invokerMojo, "invokerTest", "*dummy*,*terpolatio*" ); + setVariableValueToObject( invokerMojo, "settings", new Settings() ); + List poms = invokerMojo.getBuildJobs(); + assertEquals( 2, poms.size() ); + } + + public void testFullPatternInvokerTest() throws Exception + { + InvokerMojo invokerMojo = new InvokerMojo(); + String dirPath = getBasedir() + "/src/test/resources/unit"; + List goals = invokerMojo.getGoals( new File( dirPath ) ); + assertEquals( 1, goals.size() ); + setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) ); + setVariableValueToObject( invokerMojo, "invokerPropertiesFile", "invoker.properties" ); + setVariableValueToObject( invokerMojo, "project", getMavenProject() ); + setVariableValueToObject( invokerMojo, "invokerTest", "*" ); + setVariableValueToObject( invokerMojo, "settings", new Settings() ); + List poms = invokerMojo.getBuildJobs(); + assertEquals( 4, poms.size() ); + } + + public void testAlreadyCloned() + { + assertFalse( AbstractInvokerMojo.alreadyCloned( "dir", Collections.emptyList() ) ); + assertTrue( AbstractInvokerMojo.alreadyCloned( "dir", Collections.singletonList( "dir" ) ) ); + assertTrue( AbstractInvokerMojo.alreadyCloned( "dir" + File.separator + "sub", + Collections.singletonList( "dir" ) ) ); + assertFalse( AbstractInvokerMojo.alreadyCloned( "dirs", Collections.singletonList( "dir" ) ) ); + } + + public void testParallelThreadsSettings() throws IllegalAccessException + { + Object[][] testValues = { + {"4", 4}, + {"1C", Runtime.getRuntime().availableProcessors()}, + {"2.5C", (int) ( Double.parseDouble( "2.5" ) * Runtime.getRuntime().availableProcessors() )} + }; + + InvokerMojo invokerMojo = new InvokerMojo(); + + for ( Object[] testValue : testValues ) + { + String parallelThreads = (String) testValue[0]; + int expectedParallelThreads = (Integer) testValue[1]; + + setVariableValueToObject( invokerMojo, "parallelThreads", parallelThreads ); + + assertEquals( expectedParallelThreads, invokerMojo.getParallelThreadsCount() ); + } + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java new file mode 100644 index 000000000..3c1e94939 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java @@ -0,0 +1,441 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Properties; + +import org.apache.maven.shared.invoker.InvocationRequest; +import org.apache.maven.shared.invoker.InvocationRequest.ReactorFailureBehavior; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.clearInvocations; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +/** + * Tests the invoker properties facade. + * + * @author Benjamin Bentmann + */ +@RunWith( MockitoJUnitRunner.class ) +public class InvokerPropertiesTest +{ + + @Mock + private InvocationRequest request; + + @Test + public void testConstructorNullSafe() + { + InvokerProperties facade = new InvokerProperties( null ); + assertNotNull( facade.getProperties() ); + } + + @Test + public void testGetInvokerProperty() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + assertNull( facade.get( "undefined-key", 0 ) ); + + props.setProperty( "key", "value" ); + assertEquals( "value", facade.get( "key", 1 ) ); + + props.setProperty( "key.1", "another-value" ); + assertEquals( "another-value", facade.get( "key", 1 ) ); + assertEquals( "value", facade.get( "key", 2 ) ); + } + + @Test + public void testGetJobName() + { + Properties props = new Properties(); + final String jobName = "Build Job name"; + props.put( "invoker.name", jobName ); + InvokerProperties facade = new InvokerProperties( props ); + + assertEquals( jobName, facade.getJobName() ); + } + + @Test + public void testIsExpectedResult() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + assertTrue( facade.isExpectedResult( 0, 0 ) ); + assertFalse( facade.isExpectedResult( 1, 0 ) ); + + props.setProperty( "invoker.buildResult", "success" ); + assertTrue( facade.isExpectedResult( 0, 0 ) ); + assertFalse( facade.isExpectedResult( 1, 0 ) ); + + props.setProperty( "invoker.buildResult", "failure" ); + assertFalse( facade.isExpectedResult( 0, 0 ) ); + assertTrue( facade.isExpectedResult( 1, 0 ) ); + } + + @Test + public void testConfigureRequestEmptyProperties() + { + + InvokerProperties facade = new InvokerProperties( null ); + + facade.configureInvocation( request, 0 ); + verifyZeroInteractions( request ); + } + + @Test + public void testConfigureRequestGoals() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.goals", "verify" ); + facade.configureInvocation( request, 0 ); + verify( request ).setGoals( eq( Collections.singletonList( "verify" ) ) ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.goals", " " ); + facade.configureInvocation( request, 0 ); + verify( request ).setGoals( eq( Collections.emptyList() ) ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.goals", "" ); + facade.configureInvocation( request, 0 ); + verify( request ).setGoals( eq( Collections.emptyList() ) ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.goals", " clean , test verify " ); + facade.configureInvocation( request, 0 ); + verify( request ).setGoals( eq( Arrays.asList( "clean", "test", "verify" ) ) ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testConfigureRequestProfiles() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.profiles", "verify" ); + facade.configureInvocation( request, 0 ); + verify( request ).setProfiles( eq( Collections.singletonList( "verify" ) ) ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.profiles", " " ); + facade.configureInvocation( request, 0 ); + verify( request ).setProfiles( eq( Collections.emptyList() ) ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.profiles", "" ); + facade.configureInvocation( request, 0 ); + verify( request ).setProfiles( eq( Collections.emptyList() ) ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.profiles", " clean , test verify ," ); + facade.configureInvocation( request, 0 ); + verify( request ).setProfiles( eq( Arrays.asList( "clean", "test", "verify" ) ) ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testConfigureRequestProject() throws Exception + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + File tempPom = File.createTempFile( "maven-invoker-plugin-test", ".pom" ); + try + { + File tempDir = tempPom.getParentFile(); + when( request.getBaseDirectory() ).thenReturn( tempDir ); + + props.setProperty( "invoker.project", tempPom.getName() ); + facade.configureInvocation( request, 0 ); + verify( request ).getBaseDirectory(); + verify( request ).setBaseDirectory( eq( tempDir ) ); + verify( request ).setPomFile( eq( tempPom ) ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.project", "" ); + facade.configureInvocation( request, 0 ); + verify( request ).getBaseDirectory(); + verify( request ).setBaseDirectory( eq( tempDir ) ); + verify( request ).setPomFile( null ); + verifyNoMoreInteractions( request ); + } + finally + { + tempPom.delete(); + } + } + + @Test + public void testConfigureRequestMavenOpts() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.mavenOpts", "-Xmx512m" ); + facade.configureInvocation( request, 0 ); + verify( request ).setMavenOpts( "-Xmx512m" ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testConfigureRequestFailureBehavior() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.failureBehavior", ReactorFailureBehavior.FailNever.getLongOption() ); + facade.configureInvocation( request, 0 ); + verify( request ).setReactorFailureBehavior( eq( ReactorFailureBehavior.FailNever ) ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testConfigureRequestFailureBehaviorUnKnownName() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.failureBehavior", "xxxUnKnown" ); + try + { + facade.configureInvocation( request, 0 ); + } + catch ( IllegalArgumentException e ) + { + assertEquals( "The string 'xxxUnKnown' can not be converted to enumeration.", e.getMessage() ); + } + verifyZeroInteractions( request ); + } + + + @Test + public void testConfigureRequestRecursion() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.nonRecursive", "true" ); + facade.configureInvocation( request, 0 ); + verify( request ).setRecursive( false ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.nonRecursive", "false" ); + facade.configureInvocation( request, 0 ); + verify( request ).setRecursive( true ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testConfigureRequestOffline() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.offline", "true" ); + facade.configureInvocation( request, 0 ); + verify( request ).setOffline( true ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.offline", "false" ); + facade.configureInvocation( request, 0 ); + verify( request ).setOffline( false ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testConfigureRequestDebug() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.debug", "true" ); + facade.configureInvocation( request, 0 ); + verify( request ).setDebug( true ); + verifyNoMoreInteractions( request ); + clearInvocations( request ); + + props.setProperty( "invoker.debug", "false" ); + facade.configureInvocation( request, 0 ); + verify( request ).setDebug( false ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testConfigureEnvironmentVariables() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.abcdef", "abcdf" ); + props.setProperty( "invoker.environmentVariables.KEY1.1", "value1.1" ); + props.setProperty( "invoker.environmentVariables.KEY1", "value1" ); + props.setProperty( "invoker.environmentVariables.KEY2", "value2" ); + props.setProperty( "invoker.environmentVariables.KEY2.1", "value2.1" ); + props.setProperty( "invoker.environmentVariables.KEY3", "value3" ); + facade.configureInvocation( request, 0 ); + verify( request ).addShellEnvironment( "KEY1", "value1" ); + verify( request ).addShellEnvironment( "KEY2", "value2" ); + verify( request ).addShellEnvironment( "KEY3", "value3" ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testConfigureEnvironmentVariablesWithIndex() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + props.setProperty( "invoker.abcdef", "abcdf" ); + props.setProperty( "invoker.environmentVariables.KEY1.1", "value1.1" ); + props.setProperty( "invoker.environmentVariables.KEY1", "value1" ); + props.setProperty( "invoker.environmentVariables.KEY2", "value2" ); + props.setProperty( "invoker.environmentVariables.KEY2.1", "value2.1" ); + props.setProperty( "invoker.environmentVariables.KEY3", "value3" ); + facade.configureInvocation( request, 1 ); + verify( request ).addShellEnvironment( "KEY1", "value1.1" ); + verify( request ).addShellEnvironment( "KEY2", "value2.1" ); + verify( request ).addShellEnvironment( "KEY3", "value3" ); + verifyNoMoreInteractions( request ); + } + + @Test + public void testIsInvocationDefined() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + assertFalse( facade.isInvocationDefined( 1 ) ); + + props.setProperty( "invoker.goals", "install" ); + assertFalse( facade.isInvocationDefined( 1 ) ); + + props.setProperty( "invoker.goals.2", "install" ); + assertFalse( facade.isInvocationDefined( 1 ) ); + assertTrue( facade.isInvocationDefined( 2 ) ); + assertFalse( facade.isInvocationDefined( 3 ) ); + + props.setProperty( "invoker.goals.3", "install" ); + assertFalse( facade.isInvocationDefined( 1 ) ); + assertTrue( facade.isInvocationDefined( 2 ) ); + assertTrue( facade.isInvocationDefined( 3 ) ); + assertFalse( facade.isInvocationDefined( 4 ) ); + } + + @Test + public void testIsSelectedDefined() + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + assertFalse( facade.isSelectorDefined( 1 ) ); + + props.setProperty( "invoker.java.version", "1.6+" ); + props.setProperty( "invoker.maven.version", "3.0+" ); + props.setProperty( "invoker.os.family", "windows" ); + assertFalse( facade.isSelectorDefined( 1 ) ); + + props.setProperty( "selector.2.java.version", "1.6+" ); + props.setProperty( "selector.3.maven.version", "3.0+" ); + props.setProperty( "selector.4.os.family", "windows" ); + assertFalse( facade.isSelectorDefined( 1 ) ); + assertTrue( facade.isSelectorDefined( 2 ) ); + assertTrue( facade.isSelectorDefined( 3 ) ); + assertTrue( facade.isSelectorDefined( 4 ) ); + assertFalse( facade.isSelectorDefined( 5 ) ); + } + + @Test + public void testGetToolchainsForEmptyProperties() + { + + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + Collection toolchains = facade.getToolchains(); + assertNotNull( toolchains ); + assertEquals( 0, toolchains.size() ); + + toolchains = facade.getToolchains( 1 ); + assertNotNull( toolchains ); + assertEquals( 0, toolchains.size() ); + } + + @Test + public void testGetToolchains() + { + Properties props = new Properties(); + props.put( "invoker.toolchain.jdk.version", "11" ); + InvokerProperties facade = new InvokerProperties( props ); + + Collection toolchains = facade.getToolchains(); + assertNotNull( toolchains ); + assertEquals( 1, toolchains.size() ); + InvokerToolchain toolchain = toolchains.iterator().next(); + assertEquals( "jdk", toolchain.getType() ); + assertEquals( Collections.singletonMap( "version", "11" ), toolchain.getProvides() ); + } + + @Test + public void testGetToolchainsWithIndex() + { + Properties props = new Properties(); + props.put( "selector.1.invoker.toolchain.jdk.version", "11" ); + InvokerProperties facade = new InvokerProperties( props ); + + Collection toolchains = facade.getToolchains( 1 ); + assertNotNull( toolchains ); + assertEquals( 1, toolchains.size() ); + InvokerToolchain toolchain = toolchains.iterator().next(); + assertEquals( "jdk", toolchain.getType() ); + assertEquals( Collections.singletonMap( "version", "11" ), toolchain.getProvides() ); + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java new file mode 100644 index 000000000..8efa4967d --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java @@ -0,0 +1,81 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.junit.Assert.assertEquals; +import java.util.Properties; + +import org.junit.Test; + +/** + * Test for {@link Selector}. + */ +public class SelectorTest +{ + @Test + public void testGlobalMatch() + { + Selector selector = new Selector( "3.2.5", "1.7", null ); + + Properties props = new Properties(); + props.setProperty( "invoker.maven.version", "3.0+" ); + InvokerProperties invokerProperties = new InvokerProperties( props ); + assertEquals( 0, selector.getSelection( invokerProperties ) ); + } + + @Test + public void testSelectorMatch() + { + Selector selector = new Selector( "3.2.5", "1.7", null ); + + Properties props = new Properties(); + props.setProperty( "selector.1.maven.version", "3.0+" ); + InvokerProperties invokerProperties = new InvokerProperties( props ); + assertEquals( 0, selector.getSelection( invokerProperties ) ); + + props.setProperty( "selector.1.maven.version", "3.3.1+" ); + assertEquals( Selector.SELECTOR_MULTI, selector.getSelection( invokerProperties ) ); + } + + @Test + public void testSelectorWithGlobalMatch() + { + Selector selector = new Selector( "3.2.5", "1.7", null ); + + Properties props = new Properties(); + // invoker.maven.version is used by all selectors + props.setProperty( "invoker.maven.version", "3.0+" ); + props.setProperty( "selector.1.java.version", "1.4+" ); + props.setProperty( "selector.2.os.family", "myos" ); + InvokerProperties invokerProperties = new InvokerProperties( props ); + assertEquals( 0, selector.getSelection( invokerProperties ) ); + + props.setProperty( "invoker.maven.version", "3.3.1+" ); + assertEquals( Selector.SELECTOR_MULTI, selector.getSelection( invokerProperties ) ); + + props.setProperty( "invoker.maven.version", "3.0+" ); + props.setProperty( "selector.1.maven.version", "3.3.1+" ); + assertEquals( Selector.SELECTOR_MULTI, selector.getSelection( invokerProperties ) ); + + props.setProperty( "selector.2.os.family", "!myos" ); + assertEquals( 0, selector.getSelection( invokerProperties ) ); + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java new file mode 100644 index 000000000..bdeff50bc --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/java/org/apache/maven/plugins/invoker/SelectorUtilsTest.java @@ -0,0 +1,145 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.isA; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager; +import org.apache.maven.toolchain.ToolchainPrivate; +import org.junit.Test; + +/** + * Tests {@link SelectorUtils}. + * + * @author Benjamin Bentmann + */ +public class SelectorUtilsTest +{ + + @Test + public void testParseList() + { + List includes = new ArrayList(); + List excludes = new ArrayList(); + + SelectorUtils.parseList( null, includes, excludes ); + + SelectorUtils.parseList( " 1.5, !1.4, 1.6+ ", includes, excludes ); + assertEquals( Arrays.asList( "1.5", "1.6+" ), includes ); + assertEquals( Arrays.asList( "1.4" ), excludes ); + } + + @Test + public void testParseVersion() + { + assertEquals( Arrays.asList( 1, 6, 0, 12 ), SelectorUtils.parseVersion( "1.6.0_12" ) ); + + assertEquals( Arrays.asList( 1, 6, 0, 12 ), SelectorUtils.parseVersion( "1.6.0_12+" ) ); + assertEquals( Arrays.asList( 1, 6, 0, 12 ), SelectorUtils.parseVersion( "1.6.0_12-" ) ); + } + + @Test + public void testCompareVersions() + { + assertTrue( SelectorUtils.compareVersions( Arrays.asList( 1, 6 ), Arrays.asList( 1, 6 ) ) == 0 ); + + assertTrue( SelectorUtils.compareVersions( Arrays.asList( 1, 5 ), Arrays.asList( 1, 6 ) ) < 0 ); + assertTrue( SelectorUtils.compareVersions( Arrays.asList( 1, 6 ), Arrays.asList( 1, 5 ) ) > 0 ); + + assertTrue( SelectorUtils.compareVersions( Arrays.asList( 1 ), Arrays.asList( 1, 6 ) ) < 0 ); + assertTrue( SelectorUtils.compareVersions( Arrays.asList( 1, 6 ), Arrays.asList( 1 ) ) > 0 ); + } + + @Test + public void testIsMatchingJre() + { + + assertFalse( SelectorUtils.isJreVersion( Arrays.asList( 1, 4, 2, 8 ), "1.5" ) ); + assertTrue( SelectorUtils.isJreVersion( Arrays.asList( 1, 5 ), "1.5" ) ); + assertTrue( SelectorUtils.isJreVersion( Arrays.asList( 1, 5, 9 ), "1.5" ) ); + assertFalse( SelectorUtils.isJreVersion( Arrays.asList( 1, 6 ), "1.5" ) ); + + assertFalse( SelectorUtils.isJreVersion( Arrays.asList( 1, 4, 2, 8 ), "1.5+" ) ); + assertTrue( SelectorUtils.isJreVersion( Arrays.asList( 1, 5 ), "1.5+" ) ); + assertTrue( SelectorUtils.isJreVersion( Arrays.asList( 1, 5, 9 ), "1.5+" ) ); + assertTrue( SelectorUtils.isJreVersion( Arrays.asList( 1, 6 ), "1.5+" ) ); + + assertTrue( SelectorUtils.isJreVersion( Arrays.asList( 1, 4, 2, 8 ), "1.5-" ) ); + assertFalse( SelectorUtils.isJreVersion( Arrays.asList( 1, 5 ), "1.5-" ) ); + assertFalse( SelectorUtils.isJreVersion( Arrays.asList( 1, 5, 9 ), "1.5-" ) ); + assertFalse( SelectorUtils.isJreVersion( Arrays.asList( 1, 6 ), "1.5-" ) ); + + assertTrue( SelectorUtils.isJreVersion( (String) null, "1.5" ) ); + assertTrue( SelectorUtils.isJreVersion( "", "1.5" ) ); + } + + @Test + public void testIsMatchingToolchain() throws Exception + { + InvokerToolchain openJdk9 = new InvokerToolchain( "jdk" ); + openJdk9.addProvides( "version", "9" ); + openJdk9.addProvides( "vendor", "openJDK" ); + + InvokerToolchain maven360 = new InvokerToolchain( "maven" ); + openJdk9.addProvides( "version", "3.6.0" ); + + ToolchainPrivateManager toolchainPrivateManager = mock( ToolchainPrivateManager.class ); + ToolchainPrivate jdkMatching = mock( ToolchainPrivate.class ); + when( jdkMatching.matchesRequirements( isA( Map.class ) ) ).thenReturn( true ); + when( jdkMatching.getType() ).thenReturn( "jdk" ); + + ToolchainPrivate jdkMismatch = mock( ToolchainPrivate.class ); + when( jdkMismatch.getType() ).thenReturn( "jdk" ); + + when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ) + .thenReturn( new ToolchainPrivate[] { jdkMatching } ); + assertTrue( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) ); + + when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ) + .thenReturn( new ToolchainPrivate[] { jdkMismatch } ); + assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) ); + + when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ) + .thenReturn( new ToolchainPrivate[] { jdkMatching, jdkMismatch, jdkMatching } ); + assertTrue( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) ); + + when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ) + .thenReturn( new ToolchainPrivate[0] ); + assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Collections.singleton( openJdk9 ) ) ); + + when( toolchainPrivateManager.getToolchainPrivates( "jdk" ) ) + .thenReturn( new ToolchainPrivate[] { jdkMatching } ); + when( toolchainPrivateManager.getToolchainPrivates( "maven" ) ) + .thenReturn( new ToolchainPrivate[0] ); + assertFalse( SelectorUtils.isToolchain( toolchainPrivateManager, Arrays.asList( openJdk9, maven360 ) ) ); + } + +} diff --git a/Java-base/maven-invoker-plugin/src/src/test/resources/unit/dummy/pom.xml b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/dummy/pom.xml new file mode 100644 index 000000000..ab2014a89 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/dummy/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven.test + unit + pom + 0.1-SNAPSHOT + + @foo@ + + \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/test/resources/unit/goals-from-file/pom.xml b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/goals-from-file/pom.xml new file mode 100644 index 000000000..fc80363ef --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/goals-from-file/pom.xml @@ -0,0 +1,26 @@ + + + + 4.0.0 + org.apache.maven.test + unit + pom + 0.1-SNAPSHOT + \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/test/resources/unit/goals-from-file/verify.bsh b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/goals-from-file/verify.bsh new file mode 100644 index 000000000..cdd4e7e55 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/goals-from-file/verify.bsh @@ -0,0 +1,48 @@ + +/* + * 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 org.codehaus.plexus.util.*; + +boolean result = true; + +try +{ + + File build = new File( basedir, "build.log" ); + if ( !build.exists() || build.isDirectory() ) + { + System.err.println( "build.log file is missing or a directory." ); + return false; + } + String buildContent = FileUtils.fileRead( build ); + int indexOf = buildContent.indexOf( "BUILD SUCCESSFUL" ); + if ( indexOf < 0 ) + { + System.err.println( "build.log doesn't contains BUILD SUCCESSFUL" ); + } +} +catch( IOException e ) +{ + e.printStackTrace(); + result = false; +} + +return result; diff --git a/Java-base/maven-invoker-plugin/src/src/test/resources/unit/interpolation/pom.xml b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/interpolation/pom.xml new file mode 100644 index 000000000..ab2014a89 --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/interpolation/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven.test + unit + pom + 0.1-SNAPSHOT + + @foo@ + + \ No newline at end of file diff --git a/Java-base/maven-invoker-plugin/src/src/test/resources/unit/profiles-from-file/emptyProfiles.txt b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/profiles-from-file/emptyProfiles.txt new file mode 100644 index 000000000..e69de29bb diff --git a/Java-base/maven-invoker-plugin/src/src/test/resources/unit/profiles-from-file/profiles.txt b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/profiles-from-file/profiles.txt new file mode 100644 index 000000000..f33f47f7f --- /dev/null +++ b/Java-base/maven-invoker-plugin/src/src/test/resources/unit/profiles-from-file/profiles.txt @@ -0,0 +1 @@ +foo, bar diff --git a/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/Dockerfile b/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/Dockerfile new file mode 100644 index 000000000..b3ce32683 --- /dev/null +++ b/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/Dockerfile @@ -0,0 +1,18 @@ +FROM ghcr.io/kupl/starlab-benchmarks/java-base:maven-invoker-plugin + +ENV TZ=Asia/Seoul + +COPY ./metadata.json . +COPY ./npe.json . +COPY ./buggy.java /tmp/buggy.java +RUN export BUGGY_PATH=$(cat metadata.json | jq -r ".npe.filepath") \ + && export BUGGY_LINE=$(cat metadata.json | jq -r ".npe.line") \ + && export BUGGY_MTHD=$(cat metadata.json | jq -r ".npe.npe_method") \ + && mv /tmp/buggy.java $BUGGY_PATH \ + && echo "[{\"filepath\": \"$BUGGY_PATH\", \"line\": $BUGGY_LINE, \"method_name\": \"$BUGGY_MTHD\"}]" | jq . > traces.json + +RUN git init . && git add -A + +RUN $(cat metadata.json | jq -r ".buildCommand") + +RUN $(cat metadata.json | jq -r ".testCommand"); if [ $? -eq 0 ]; then exit 1; fi diff --git a/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/buggy.java b/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/buggy.java new file mode 100644 index 000000000..7883314f4 --- /dev/null +++ b/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/buggy.java @@ -0,0 +1,2880 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.execution.MavenSession; +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecution; +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.plugins.invoker.model.BuildJob; +import org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Writer; +import org.apache.maven.project.MavenProject; +import org.apache.maven.settings.Settings; +import org.apache.maven.settings.SettingsUtils; +import org.apache.maven.settings.TrackableBase; +import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; +import org.apache.maven.settings.building.SettingsBuilder; +import org.apache.maven.settings.building.SettingsBuildingException; +import org.apache.maven.settings.building.SettingsBuildingRequest; +import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; +import org.apache.maven.shared.invoker.CommandLineConfigurationException; +import org.apache.maven.shared.invoker.DefaultInvocationRequest; +import org.apache.maven.shared.invoker.InvocationRequest; +import org.apache.maven.shared.invoker.InvocationResult; +import org.apache.maven.shared.invoker.Invoker; +import org.apache.maven.shared.invoker.MavenCommandLineBuilder; +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.apache.maven.shared.scriptinterpreter.RunErrorException; +import org.apache.maven.shared.scriptinterpreter.RunFailureException; +import org.apache.maven.shared.scriptinterpreter.ScriptRunner; +import org.apache.maven.shared.utils.logging.MessageBuilder; +import org.apache.maven.toolchain.MisconfiguredToolchainException; +import org.apache.maven.toolchain.ToolchainManagerPrivate; +import org.apache.maven.toolchain.ToolchainPrivate; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.RegexBasedInterpolator; +import org.codehaus.plexus.util.DirectoryScanner; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.InterpolationFilterReader; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.ReflectionUtils; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.WriterFactory; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.codehaus.plexus.util.xml.Xpp3DomWriter; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeSet; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; + +/** + * Provides common code for mojos invoking sub builds. + * + * @author Stephen Connolly + * @since 15-Aug-2009 09:09:29 + */ +public abstract class AbstractInvokerMojo + extends AbstractMojo +{ + /** + * The zero-based column index where to print the invoker result. + */ + private static final int RESULT_COLUMN = 60; + + /** + * Flag used to suppress certain invocations. This is useful in tailoring the build using profiles. + * + * @since 1.1 + */ + @Parameter( property = "invoker.skip", defaultValue = "false" ) + private boolean skipInvocation; + + /** + * Flag used to suppress the summary output notifying of successes and failures. If set to true, the + * only indication of the build's success or failure will be the effect it has on the main build (if it fails, the + * main build should fail as well). If {@link #streamLogs} is enabled, the sub-build summary will also provide an + * indication. + */ + @Parameter( defaultValue = "false" ) + protected boolean suppressSummaries; + + /** + * Flag used to determine whether the build logs should be output to the normal mojo log. + */ + @Parameter( property = "invoker.streamLogs", defaultValue = "false" ) + private boolean streamLogs; + + /** + * The local repository for caching artifacts. It is strongly recommended to specify a path to an isolated + * repository like ${project.build.directory}/it-repo. Otherwise, your ordinary local repository will + * be used, potentially soiling it with broken artifacts. + */ + @Parameter( property = "invoker.localRepositoryPath", defaultValue = "${settings.localRepository}" ) + private File localRepositoryPath; + + /** + * Directory to search for integration tests. + */ + @Parameter( property = "invoker.projectsDirectory", defaultValue = "${basedir}/src/it/" ) + private File projectsDirectory; + + /** + * Base directory where all build reports are written to. Every execution of an integration test will produce an XML + * file which contains the information about success or failure of that particular build job. The format of the + * resulting XML file is documented in the given build-job reference. + * + * @since 1.4 + */ + @Parameter( property = "invoker.reportsDirectory", defaultValue = "${project.build.directory}/invoker-reports" ) + private File reportsDirectory; + + /** + * A flag to disable the generation of build reports. + * + * @since 1.4 + */ + @Parameter( property = "invoker.disableReports", defaultValue = "false" ) + private boolean disableReports; + + /** + * Directory to which projects should be cloned prior to execution. If set to {@code null}, each integration test + * will be run in the directory in which the corresponding IT POM was found. In this case, you most likely want to + * configure your SCM to ignore target and build.log in the test's base directory. + * + * @since 1.1 + */ + @Parameter( property = "invoker.cloneProjectsTo" ) + private File cloneProjectsTo; + + // CHECKSTYLE_OFF: LineLength + /** + * Some files are normally excluded when copying the IT projects from the directory specified by the parameter + * projectsDirectory to the directory given by cloneProjectsTo (e.g. .svn, CVS, + * *~, etc: see + * reference for full list). Setting this parameter to true will cause all files to be copied to + * the cloneProjectsTo directory. + * + * @since 1.2 + */ + @Parameter( defaultValue = "false" ) + private boolean cloneAllFiles; + // CHECKSTYLE_ON: LineLength + + /** + * Ensure the {@link #cloneProjectsTo} directory is not polluted with files from earlier invoker runs. + * + * @since 1.6 + */ + @Parameter( defaultValue = "true" ) + private boolean cloneClean; + + /** + * A single POM to build, skipping any scanning parameters and behavior. + */ + @Parameter( property = "invoker.pom" ) + private File pom; + + /** + * Include patterns for searching the integration test directory for projects. This parameter is meant to be set + * from the POM. If this parameter is not set, the plugin will search for all pom.xml files one + * directory below {@link #projectsDirectory} (i.e. */pom.xml).
+ *
+ * Starting with version 1.3, mere directories can also be matched by these patterns. For example, the include + * pattern * will run Maven builds on all immediate sub directories of {@link #projectsDirectory}, + * regardless if they contain a pom.xml. This allows to perform builds that need/should not depend on + * the existence of a POM. + */ + @Parameter + private List pomIncludes = Collections.singletonList( "*/pom.xml" ); + + /** + * Exclude patterns for searching the integration test directory. This parameter is meant to be set from the POM. By + * default, no POM files are excluded. For the convenience of using an include pattern like *, the + * custom settings file specified by the parameter {@link #settingsFile} will always be excluded automatically. + */ + @Parameter + private List pomExcludes = Collections.emptyList(); + + /** + * Include patterns for searching the projects directory for projects that need to be run before the other projects. + * This parameter allows to declare projects that perform setup tasks like installing utility artifacts into the + * local repository. Projects matched by these patterns are implicitly excluded from the scan for ordinary projects. + * Also, the exclusions defined by the parameter {@link #pomExcludes} apply to the setup projects, too. Default + * value is: setup*/pom.xml. + * + * @since 1.3 + */ + @Parameter + private List setupIncludes = Collections.singletonList( "setup*/pom.xml" ); + + /** + * The list of goals to execute on each project. Default value is: package. + */ + @Parameter + private List goals = Collections.singletonList( "package" ); + + /** + */ + @Component + private Invoker invoker; + + @Component + private SettingsBuilder settingsBuilder; + + @Component + private ToolchainManagerPrivate toolchainManagerPrivate; + + /** + * Relative path of a selector script to run prior in order to decide if the build should be executed. This script + * may be written with either BeanShell or Groovy. If the file extension is omitted (e.g. selector), + * the plugin searches for the file by trying out the well-known extensions .bsh and + * .groovy. If this script exists for a particular project but returns any non-null value different + * from true, the corresponding build is flagged as skipped. In this case, none of the pre-build hook + * script, Maven nor the post-build hook script will be invoked. If this script throws an exception, the + * corresponding build is flagged as in error, and none of the pre-build hook script, Maven not the post-build hook + * script will be invoked. + * + * @since 1.5 + */ + @Parameter( property = "invoker.selectorScript", defaultValue = "selector" ) + private String selectorScript; + + /** + * Relative path of a pre-build hook script to run prior to executing the build. This script may be written with + * either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. prebuild), the plugin + * searches for the file by trying out the well-known extensions .bsh and .groovy. If this + * script exists for a particular project but returns any non-null value different from true or throws + * an exception, the corresponding build is flagged as a failure. In this case, neither Maven nor the post-build + * hook script will be invoked. + */ + @Parameter( property = "invoker.preBuildHookScript", defaultValue = "prebuild" ) + private String preBuildHookScript; + + /** + * Relative path of a cleanup/verification hook script to run after executing the build. This script may be written + * with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. verify), the + * plugin searches for the file by trying out the well-known extensions .bsh and .groovy. + * If this script exists for a particular project but returns any non-null value different from true or + * throws an exception, the corresponding build is flagged as a failure. + */ + @Parameter( property = "invoker.postBuildHookScript", defaultValue = "postbuild" ) + private String postBuildHookScript; + + /** + * Location of a properties file that defines CLI properties for the test. + */ + @Parameter( property = "invoker.testPropertiesFile", defaultValue = "test.properties" ) + private String testPropertiesFile; + + /** + * Common set of properties to pass in on each project's command line, via -D parameters. + * + * @since 1.1 + */ + @Parameter + private Map properties; + + /** + * Whether to show errors in the build output. + */ + @Parameter( property = "invoker.showErrors", defaultValue = "false" ) + private boolean showErrors; + + /** + * Whether to show debug statements in the build output. + */ + @Parameter( property = "invoker.debug", defaultValue = "false" ) + private boolean debug; + + /** + * Suppress logging to the build.log file. + */ + @Parameter( property = "invoker.noLog", defaultValue = "false" ) + private boolean noLog; + + /** + * By default a {@code build.log} is created in the root of the project. By setting this folder + * files are written to a different folder, respecting the structure of the projectsDirectory. + * + * @since 3.2.0 + */ + @Parameter + private File logDirectory; + + /** + * List of profile identifiers to explicitly trigger in the build. + * + * @since 1.1 + */ + @Parameter + private List profiles; + + /** + * A list of additional properties which will be used to filter tokens in POMs and goal files. + * + * @since 1.3 + */ + @Parameter + private Map filterProperties; + + /** + * The Maven Project Object + * + * @since 1.1 + */ + @Parameter( defaultValue = "${project}", readonly = true, required = true ) + private MavenProject project; + + @Parameter( defaultValue = "${session}", readonly = true, required = true ) + private MavenSession session; + + @Parameter( defaultValue = "${mojoExecution}", readonly = true, required = true ) + private MojoExecution mojoExecution; + + /** + * A comma separated list of projectname patterns to run. Specify this parameter to run individual tests by file + * name, overriding the {@link #setupIncludes}, {@link #pomIncludes} and {@link #pomExcludes} parameters. Each + * pattern you specify here will be used to create an include/exclude pattern formatted like + * ${projectsDirectory}/pattern. To exclude a test, prefix the pattern with a '!'. + * So you can just type -Dinvoker.test=SimpleTest,Comp*Test,!Compare* to run builds in + * ${projectsDirectory}/SimpleTest and ${projectsDirectory}/ComplexTest, but not + * ${projectsDirectory}/CompareTest + * + * @since 1.1 (exclusion since 1.8) + */ + @Parameter( property = "invoker.test" ) + private String invokerTest; + + /** + * Path to an alternate settings.xml to use for Maven invocation with all ITs. Note that the + * <localRepository> element of this settings file is always ignored, i.e. the path given by the + * parameter {@link #localRepositoryPath} is dominant. + * + * @since 1.2 + */ + @Parameter( property = "invoker.settingsFile" ) + private File settingsFile; + + /** + * The MAVEN_OPTS environment variable to use when invoking Maven. This value can be overridden for + * individual integration tests by using {@link #invokerPropertiesFile}. + * + * @since 1.2 + */ + @Parameter( property = "invoker.mavenOpts" ) + private String mavenOpts; + + /** + * The home directory of the Maven installation to use for the forked builds. Defaults to the current Maven + * installation. + * + * @since 1.3 + */ + @Parameter( property = "invoker.mavenHome" ) + private File mavenHome; + + /** + * mavenExecutable can either be a file relative to ${maven.home}/bin/ or an absolute file. + * + * @since 1.8 + * @see Invoker#setMavenExecutable(File) + */ + @Parameter( property = "invoker.mavenExecutable" ) + private String mavenExecutable; + + /** + * The JAVA_HOME environment variable to use for forked Maven invocations. Defaults to the current Java + * home directory. + * + * @since 1.3 + */ + @Parameter( property = "invoker.javaHome" ) + private File javaHome; + + /** + * The file encoding for the pre-/post-build scripts and the list files for goals and profiles. + * + * @since 1.2 + */ + @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" ) + private String encoding; + + /** + * The current user system settings for use in Maven. + * + * @since 1.2 + */ + @Parameter( defaultValue = "${settings}", readonly = true, required = true ) + private Settings settings; + + /** + * A flag whether the test class path of the project under test should be included in the class path of the + * pre-/post-build scripts. If set to false, the class path of script interpreter consists only of the + * runtime dependencies of the Maven Invoker Plugin. If set the true, + * the project's test class path will be prepended to the interpreter class path. Among others, this feature allows + * the scripts to access utility classes from the test sources of your project. + * + * @since 1.2 + */ + @Parameter( property = "invoker.addTestClassPath", defaultValue = "false" ) + private boolean addTestClassPath; + + /** + * The test class path of the project under test. + */ + @Parameter( defaultValue = "${project.testClasspathElements}", readonly = true ) + private List testClassPath; + + /** + * The name of an optional project-specific file that contains properties used to specify settings for an individual + * Maven invocation. Any property present in the file will override the corresponding setting from the plugin + * configuration. The values of the properties are filtered and may use expressions like + * ${project.version} to reference project properties or values from the parameter + * {@link #filterProperties}.

+ * + *

+ * As of 3.2.0 it is possible to put this folder in any of the ancestor folders, where properties will be inherited. + * This way you can provide a single properties file for a group of projects + *

+ * + * The snippet below describes the supported properties: + *
+     * # A comma or space separated list of goals/phases to execute, may
+     * # specify an empty list to execute the default goal of the IT project.
+     * # Environment variables used by maven plugins can be added here
+     * invoker.goals = clean install -Dplugin.variable=value
+     *
+     * # Or you can give things like this if you need.
+     * invoker.goals = -T2 clean verify
+     *
+     * # Optionally, a list of goals to run during further invocations of Maven
+     * invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:run
+     *
+     * # A comma or space separated list of profiles to activate
+     * invoker.profiles = its,jdk15
+     *
+     * # The path to an alternative POM or base directory to invoke Maven on, defaults to the
+     * # project that was originally specified in the plugin configuration
+     * # Since plugin version 1.4
+     * invoker.project = sub-module
+     *
+     * # The value for the environment variable MAVEN_OPTS
+     * invoker.mavenOpts = -Dfile.encoding=UTF-16 -Xms32m -Xmx256m
+     *
+     * # Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
+     * invoker.failureBehavior = fail-never
+     *
+     * # The expected result of the build, possible values are "success" (default) and "failure"
+     * invoker.buildResult = failure
+     *
+     * # A boolean value controlling the aggregator mode of Maven, defaults to "false"
+     * invoker.nonRecursive = true
+     *
+     * # A boolean value controlling the network behavior of Maven, defaults to "false"
+     * # Since plugin version 1.4
+     * invoker.offline = true
+     *
+     * # The path to the properties file from which to load system properties, defaults to the
+     * # filename given by the plugin parameter testPropertiesFile
+     * # Since plugin version 1.4
+     * invoker.systemPropertiesFile = test.properties
+     *
+     * # An optional human friendly name for this build job to be included in the build reports.
+     * # Since plugin version 1.4
+     * invoker.name = Test Build 01
+     *
+     * # An optional description for this build job to be included in the build reports.
+     * # Since plugin version 1.4
+     * invoker.description = Checks the support for build reports.
+     *
+     * # A comma separated list of JRE versions on which this build job should be run.
+     * # Since plugin version 1.4
+     * invoker.java.version = 1.4+, !1.4.1, 1.7-
+     * 
+     * # A comma separated list of OS families on which this build job should be run.
+     * # Since plugin version 1.4
+     * invoker.os.family = !windows, unix, mac
+     *
+     * # A comma separated list of Maven versions on which this build should be run.
+     * # Since plugin version 1.5
+     * invoker.maven.version = 2.0.10+, !2.1.0, !2.2.0
+     * 
+     * # A mapping for toolchain to ensure it exists
+     * # Since plugin version 3.2.0
+     * invoker.toolchain.<type>.<provides> = value
+     * invoker.toolchain.jdk.version = 11
+     * 
+     * # For java.version, maven.version, os.family and toolchain it is possible to define multiple selectors.
+     * # If one of the indexed selectors matches, the test is executed.
+     * # With the invoker.x.y equivalents you can specify global matchers.  
+     * selector.1.java.version = 1.8+
+     * selector.1.maven.version = 3.2.5+
+     * selector.1.os.family = !windows
+     * selector.2.maven.version = 3.0+
+     * selector.3.java.version = 9+
+     * 
+     * # A boolean value controlling the debug logging level of Maven, , defaults to "false"
+     * # Since plugin version 1.8
+     * invoker.debug = true
+     * 
+     * # Path to an alternate settings.xml to use for Maven invocation with this IT.
+     * # Since plugin version 3.0.1
+     * invoker.settingsFile = ../
+     *
+     * # An integer value to control run order of projects. sorted in the descending order of the ordinal.
+     * # In other words, the BuildJobs with the highest numbers will be executed first
+     * # Since plugin version 3.2.1
+     * invoker.ordinal = 3
+     * invoker.ordinal = 1
+     *
+     * # The additional value for the environment variable.
+     * # Since plugin version 3.2.2
+     * invoker.environmentVariables.<variableName> = variableValue
+     * invoker.environmentVariables.MY_ENV_NAME = myEnvValue
+     *
+     * 
+ * + * @since 1.2 + */ + @Parameter( property = "invoker.invokerPropertiesFile", defaultValue = "invoker.properties" ) + private String invokerPropertiesFile; + + /** + * flag to enable show mvn version used for running its (cli option : -V,--show-version ) + * + * @since 1.4 + */ + @Parameter( property = "invoker.showVersion", defaultValue = "false" ) + private boolean showVersion; + + /** + *

Number of threads for running tests in parallel. This will be the number of maven forked process in parallel. + * When terminated with "C", the number part is multiplied by the number of processors (cores) available + * to the Java virtual machine. Floating point value are only accepted together with "C".

+ * + *

Example values: "1.5C", "4"

+ * + * @since 1.6 + */ + @Parameter( property = "invoker.parallelThreads", defaultValue = "1" ) + private String parallelThreads; + + /** + * @since 1.6 + */ + @Parameter( property = "plugin.artifacts", required = true, readonly = true ) + private List pluginArtifacts; + + /** + * If enable and if you have a settings file configured for the execution, it will be merged with your user + * settings. + * + * @since 1.6 + */ + @Parameter( property = "invoker.mergeUserSettings", defaultValue = "false" ) + private boolean mergeUserSettings; + + /** + * Additional environment variables to set on the command line. + * + * @since 1.8 + */ + @Parameter + private Map environmentVariables; + + /** + * Additional variables for use in the hook scripts. + * + * @since 1.9 + */ + @Parameter + private Map scriptVariables; + + /** + * + * @since 3.0.2 + */ + @Parameter( defaultValue = "0", property = "invoker.timeoutInSeconds" ) + private int timeoutInSeconds; + + /** + * Write test result in junit format. + * @since 3.1.2 + */ + @Parameter( defaultValue = "false", property = "invoker.writeJunitReport" ) + private boolean writeJunitReport; + + /** + * The package name use in junit report + * @since 3.1.2 + */ + @Parameter( defaultValue = "maven.invoker.it", property = "invoker.junitPackageName" ) + private String junitPackageName = "maven.invoker.it"; + + /** + * The scripter runner that is responsible to execute hook scripts. + */ + private ScriptRunner scriptRunner; + + /** + * A string used to prefix the file name of the filtered POMs in case the POMs couldn't be filtered in-place (i.e. + * the projects were not cloned to a temporary directory), can be null. This will be set to + * null if the POMs have already been filtered during cloning. + */ + private String filteredPomPrefix = "interpolated-"; + + /** + * The format for elapsed build time. + */ + private final DecimalFormat secFormat = new DecimalFormat( "(0.0 s)", new DecimalFormatSymbols( Locale.ENGLISH ) ); + + /** + * The version of Maven which is used to run the builds + */ + private String actualMavenVersion; + + /** + * Invokes Maven on the configured test projects. + * + * @throws org.apache.maven.plugin.MojoExecutionException If the goal encountered severe errors. + * @throws org.apache.maven.plugin.MojoFailureException If any of the Maven builds failed. + */ + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( skipInvocation ) + { + getLog().info( "Skipping invocation per configuration." + + " If this is incorrect, ensure the skipInvocation parameter is not set to true." ); + return; + } + + if ( StringUtils.isEmpty( encoding ) ) + { + getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING + + ", i.e. build is platform dependent!" ); + } + + // done it here to prevent issues with concurrent access in case of parallel run + if ( !disableReports ) + { + setupReportsFolder(); + } + + List buildJobs; + if ( pom == null ) + { + try + { + buildJobs = getBuildJobs(); + } + catch ( final IOException e ) + { + throw new MojoExecutionException( "Error retrieving POM list from includes, " + + "excludes, and projects directory. Reason: " + e.getMessage(), e ); + } + } + else + { + try + { + projectsDirectory = pom.getCanonicalFile().getParentFile(); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to discover projectsDirectory from " + + "pom File parameter. Reason: " + e.getMessage(), e ); + } + + buildJobs = Collections.singletonList( new BuildJob( pom.getName(), BuildJob.Type.NORMAL ) ); + } + + if ( buildJobs.isEmpty() ) + { + doFailIfNoProjects(); + + getLog().info( "No projects were selected for execution." ); + return; + } + + handleScriptRunnerWithScriptClassPath(); + + Collection collectedProjects = new LinkedHashSet<>(); + for ( BuildJob buildJob : buildJobs ) + { + collectProjects( projectsDirectory, buildJob.getProject(), collectedProjects, true ); + } + + File projectsDir = projectsDirectory; + + if ( cloneProjectsTo != null ) + { + cloneProjects( collectedProjects ); + projectsDir = cloneProjectsTo; + } + else if ( cloneProjectsTo == null && "maven-plugin".equals( project.getPackaging() ) ) + { + cloneProjectsTo = new File( project.getBuild().getDirectory(), "its" ); + cloneProjects( collectedProjects ); + projectsDir = cloneProjectsTo; + } + else + { + getLog().warn( "Filtering of parent/child POMs is not supported without cloning the projects" ); + } + + // First run setup jobs. + List setupBuildJobs = null; + try + { + setupBuildJobs = getSetupBuildJobsFromFolders(); + } + catch ( IOException e ) + { + getLog().error( "Failure during scanning of folders.", e ); + // TODO: Check shouldn't we fail in case of problems? + } + + if ( !setupBuildJobs.isEmpty() ) + { + // Run setup jobs in single thread + // mode. + // + // Some Idea about ordering? + getLog().info( "Running " + setupBuildJobs.size() + " setup job" + + ( ( setupBuildJobs.size() < 2 ) ? "" : "s" ) + ":" ); + runBuilds( projectsDir, setupBuildJobs, 1 ); + getLog().info( "Setup done." ); + } + + // Afterwards run all other jobs. + List nonSetupBuildJobs = getNonSetupJobs( buildJobs ); + // We will run the non setup jobs with the configured + // parallelThreads number. + runBuilds( projectsDir, nonSetupBuildJobs, getParallelThreadsCount() ); + + writeSummaryFile( nonSetupBuildJobs ); + + processResults( new InvokerSession( nonSetupBuildJobs ) ); + + } + + /** + * This will create the necessary folders for the reports. + * + * @throws MojoExecutionException in case of failure during creation of the reports folder. + */ + private void setupReportsFolder() + throws MojoExecutionException + { + // If it exists from previous run... + if ( reportsDirectory.exists() ) + { + try + { + FileUtils.deleteDirectory( reportsDirectory ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failure while trying to delete " + + reportsDirectory.getAbsolutePath(), e ); + } + } + if ( !reportsDirectory.mkdirs() ) + { + throw new MojoExecutionException( "Failure while creating the " + reportsDirectory.getAbsolutePath() ); + } + } + + private List getNonSetupJobs( List buildJobs ) + { + List result = new LinkedList<>(); + for ( BuildJob buildJob : buildJobs ) + { + if ( !buildJob.getType().equals( BuildJob.Type.SETUP ) ) + { + result.add( buildJob ); + } + } + return result; + } + + private void handleScriptRunnerWithScriptClassPath() + { + final List scriptClassPath; + if ( addTestClassPath ) + { + scriptClassPath = new ArrayList<>( testClassPath ); + for ( Artifact pluginArtifact : pluginArtifacts ) + { + scriptClassPath.remove( pluginArtifact.getFile().getAbsolutePath() ); + } + } + else + { + scriptClassPath = null; + } + scriptRunner = new ScriptRunner( getLog() ); + scriptRunner.setScriptEncoding( encoding ); + scriptRunner.setGlobalVariable( "localRepositoryPath", localRepositoryPath ); + if ( scriptVariables != null ) + { + for ( Entry entry : scriptVariables.entrySet() ) + { + scriptRunner.setGlobalVariable( entry.getKey(), entry.getValue() ); + } + } + scriptRunner.setClassPath( scriptClassPath ); + } + + private void writeSummaryFile( List buildJobs ) + throws MojoExecutionException + { + + File summaryReportFile = new File( reportsDirectory, "invoker-summary.txt" ); + + try ( Writer writer = new BufferedWriter( new FileWriter( summaryReportFile ) ) ) + { + for ( BuildJob buildJob : buildJobs ) + { + if ( !buildJob.getResult().equals( BuildJob.Result.SUCCESS ) ) + { + writer.append( buildJob.getResult() ); + writer.append( " [" ); + writer.append( buildJob.getProject() ); + writer.append( "] " ); + if ( buildJob.getFailureMessage() != null ) + { + writer.append( " " ); + writer.append( buildJob.getFailureMessage() ); + } + writer.append( "\n" ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write summary report " + summaryReportFile, e ); + } + } + + protected void doFailIfNoProjects() + throws MojoFailureException + { + // should only be used during run and verify + } + + /** + * Processes the results of invoking the build jobs. + * + * @param invokerSession The session with the build jobs, must not be null. + * @throws MojoFailureException If the mojo had failed as a result of invoking the build jobs. + * @since 1.4 + */ + abstract void processResults( InvokerSession invokerSession ) + throws MojoFailureException; + + /** + * Creates a new reader for the specified file, using the plugin's {@link #encoding} parameter. + * + * @param file The file to create a reader for, must not be null. + * @return The reader for the file, never null. + * @throws java.io.IOException If the specified file was not found or the configured encoding is not supported. + */ + private Reader newReader( File file ) + throws IOException + { + if ( StringUtils.isNotEmpty( encoding ) ) + { + return ReaderFactory.newReader( file, encoding ); + } + else + { + return ReaderFactory.newPlatformReader( file ); + } + } + + /** + * Collects all projects locally reachable from the specified project. The method will as such try to read the POM + * and recursively follow its parent/module elements. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param projectPath The relative path of the current project, can denote either the POM or its base directory, + * must not be null. + * @param projectPaths The set of already collected projects to add new projects to, must not be null. + * This set will hold the relative paths to either a POM file or a project base directory. + * @param included A flag indicating whether the specified project has been explicitly included via the parameter + * {@link #pomIncludes}. Such projects will always be added to the result set even if there is no + * corresponding POM. + * @throws org.apache.maven.plugin.MojoExecutionException If the project tree could not be traversed. + */ + private void collectProjects( File projectsDir, String projectPath, Collection projectPaths, + boolean included ) + throws MojoExecutionException + { + projectPath = projectPath.replace( '\\', '/' ); + File pomFile = new File( projectsDir, projectPath ); + if ( pomFile.isDirectory() ) + { + pomFile = new File( pomFile, "pom.xml" ); + if ( !pomFile.exists() ) + { + if ( included ) + { + projectPaths.add( projectPath ); + } + return; + } + if ( !projectPath.endsWith( "/" ) ) + { + projectPath += '/'; + } + projectPath += "pom.xml"; + } + else if ( !pomFile.isFile() ) + { + return; + } + if ( !projectPaths.add( projectPath ) ) + { + return; + } + getLog().debug( "Collecting parent/child projects of " + projectPath ); + + Model model = PomUtils.loadPom( pomFile ); + + try + { + String projectsRoot = projectsDir.getCanonicalPath(); + String projectDir = pomFile.getParent(); + + String parentPath = "../pom.xml"; + if ( model.getParent() != null && StringUtils.isNotEmpty( model.getParent().getRelativePath() ) ) + { + parentPath = model.getParent().getRelativePath(); + } + String parent = relativizePath( new File( projectDir, parentPath ), projectsRoot ); + if ( parent != null ) + { + collectProjects( projectsDir, parent, projectPaths, false ); + } + + Collection modulePaths = new LinkedHashSet<>(); + + modulePaths.addAll( model.getModules() ); + + for ( Profile profile : model.getProfiles() ) + { + modulePaths.addAll( profile.getModules() ); + } + + for ( String modulePath : modulePaths ) + { + String module = relativizePath( new File( projectDir, modulePath ), projectsRoot ); + if ( module != null ) + { + collectProjects( projectsDir, module, projectPaths, false ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to analyze POM: " + pomFile, e ); + } + } + + /** + * Copies the specified projects to the directory given by {@link #cloneProjectsTo}. A project may either be denoted + * by a path to a POM file or merely by a path to a base directory. During cloning, the POM files will be filtered. + * + * @param projectPaths The paths to the projects to clone, relative to the projects directory, must not be + * null nor contain null elements. + * @throws org.apache.maven.plugin.MojoExecutionException If the the projects could not be copied/filtered. + */ + private void cloneProjects( Collection projectPaths ) + throws MojoExecutionException + { + if ( !cloneProjectsTo.mkdirs() && cloneClean ) + { + try + { + FileUtils.cleanDirectory( cloneProjectsTo ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not clean the cloneProjectsTo directory. Reason: " + + e.getMessage(), e ); + } + } + + // determine project directories to clone + Collection dirs = new LinkedHashSet<>(); + for ( String projectPath : projectPaths ) + { + if ( !new File( projectsDirectory, projectPath ).isDirectory() ) + { + projectPath = getParentPath( projectPath ); + } + dirs.add( projectPath ); + } + + boolean filter; + + // clone project directories + try + { + filter = !cloneProjectsTo.getCanonicalFile().equals( projectsDirectory.getCanonicalFile() ); + + List clonedSubpaths = new ArrayList<>(); + + for ( String subpath : dirs ) + { + // skip this project if its parent directory is also scheduled for cloning + if ( !".".equals( subpath ) && dirs.contains( getParentPath( subpath ) ) ) + { + continue; + } + + // avoid copying subdirs that are already cloned. + if ( !alreadyCloned( subpath, clonedSubpaths ) ) + { + // avoid creating new files that point to dir/. + if ( ".".equals( subpath ) ) + { + String cloneSubdir = relativizePath( cloneProjectsTo, projectsDirectory.getCanonicalPath() ); + + // avoid infinite recursion if the cloneTo path is a subdirectory. + if ( cloneSubdir != null ) + { + File temp = File.createTempFile( "pre-invocation-clone.", "" ); + temp.delete(); + temp.mkdirs(); + + copyDirectoryStructure( projectsDirectory, temp ); + + FileUtils.deleteDirectory( new File( temp, cloneSubdir ) ); + + copyDirectoryStructure( temp, cloneProjectsTo ); + } + else + { + copyDirectoryStructure( projectsDirectory, cloneProjectsTo ); + } + } + else + { + File srcDir = new File( projectsDirectory, subpath ); + File dstDir = new File( cloneProjectsTo, subpath ); + copyDirectoryStructure( srcDir, dstDir ); + } + + clonedSubpaths.add( subpath ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to clone projects from: " + projectsDirectory + " to: " + + cloneProjectsTo + ". Reason: " + e.getMessage(), e ); + } + + // filter cloned POMs + if ( filter ) + { + for ( String projectPath : projectPaths ) + { + File pomFile = new File( cloneProjectsTo, projectPath ); + if ( pomFile.isFile() ) + { + buildInterpolatedFile( pomFile, pomFile ); + } + + // MINVOKER-186 + // The following is a temporary solution to support Maven 3.3.1 (.mvn/extensions.xml) filtering + // Will be replaced by MINVOKER-117 with general filtering mechanism + File baseDir = pomFile.getParentFile(); + File mvnDir = new File( baseDir, ".mvn" ); + if ( mvnDir.isDirectory() ) + { + File extensionsFile = new File( mvnDir, "extensions.xml" ); + if ( extensionsFile.isFile() ) + { + buildInterpolatedFile( extensionsFile, extensionsFile ); + } + } + // END MINVOKER-186 + } + filteredPomPrefix = null; + } + } + + /** + * Gets the parent path of the specified relative path. + * + * @param path The relative path whose parent should be retrieved, must not be null. + * @return The parent path or "." if the specified path has no parent, never null. + */ + private String getParentPath( String path ) + { + int lastSep = Math.max( path.lastIndexOf( '/' ), path.lastIndexOf( '\\' ) ); + return ( lastSep < 0 ) ? "." : path.substring( 0, lastSep ); + } + + /** + * Copied a directory structure with default exclusions (.svn, CVS, etc) + * + * @param sourceDir The source directory to copy, must not be null. + * @param destDir The target directory to copy to, must not be null. + * @throws java.io.IOException If the directory structure could not be copied. + */ + private void copyDirectoryStructure( File sourceDir, File destDir ) + throws IOException + { + DirectoryScanner scanner = new DirectoryScanner(); + scanner.setBasedir( sourceDir ); + if ( !cloneAllFiles ) + { + scanner.addDefaultExcludes(); + } + scanner.scan(); + + /* + * NOTE: Make sure the destination directory is always there (even if empty) to support POM-less ITs. + */ + destDir.mkdirs(); + // Create all the directories, including any symlinks present in source + FileUtils.mkDirs( sourceDir, scanner.getIncludedDirectories(), destDir ); + + for ( String includedFile : scanner.getIncludedFiles() ) + { + File sourceFile = new File( sourceDir, includedFile ); + File destFile = new File( destDir, includedFile ); + FileUtils.copyFile( sourceFile, destFile ); + + // ensure clone project must be writable for additional changes + destFile.setWritable( true ); + } + } + + /** + * Determines whether the specified sub path has already been cloned, i.e. whether one of its ancestor directories + * was already cloned. + * + * @param subpath The sub path to check, must not be null. + * @param clonedSubpaths The list of already cloned paths, must not be null nor contain + * null elements. + * @return true if the specified path has already been cloned, false otherwise. + */ + static boolean alreadyCloned( String subpath, List clonedSubpaths ) + { + for ( String path : clonedSubpaths ) + { + if ( ".".equals( path ) || subpath.equals( path ) || subpath.startsWith( path + File.separator ) ) + { + return true; + } + } + + return false; + } + + /** + * Runs the specified build jobs. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param buildJobs The build jobs to run must not be null nor contain null elements. + * @throws org.apache.maven.plugin.MojoExecutionException If any build could not be launched. + */ + private void runBuilds( final File projectsDir, List buildJobs, int runWithParallelThreads ) + throws MojoExecutionException + { + if ( !localRepositoryPath.exists() ) + { + localRepositoryPath.mkdirs(); + } + + // ----------------------------------------------- + // interpolate settings file + // ----------------------------------------------- + + File interpolatedSettingsFile = interpolateSettings( settingsFile ); + + final File mergedSettingsFile = mergeSettings( interpolatedSettingsFile ); + + if ( mavenHome != null ) + { + actualMavenVersion = SelectorUtils.getMavenVersion( mavenHome ); + } + else + { + actualMavenVersion = SelectorUtils.getMavenVersion(); + } + scriptRunner.setGlobalVariable( "mavenVersion", actualMavenVersion ); + + final CharSequence actualJreVersion; + // @todo if ( javaVersions ) ... to be picked up from toolchains + if ( javaHome != null ) + { + actualJreVersion = resolveExternalJreVersion(); + } + else + { + actualJreVersion = SelectorUtils.getJreVersion(); + } + + final Path projectsPath = this.projectsDirectory.toPath(); + + Set folderGroupSet = new HashSet<>(); + folderGroupSet.add( Paths.get( "." ) ); + for ( BuildJob buildJob : buildJobs ) + { + Path p = Paths.get( buildJob.getProject() ); + + if ( Files.isRegularFile( projectsPath.resolve( p ) ) ) + { + p = p.getParent(); + } + + if ( p != null ) + { + p = p.getParent(); + } + + while ( p != null && folderGroupSet.add( p ) ) + { + p = p.getParent(); + } + } + + List folderGroup = new ArrayList<>( folderGroupSet ); + Collections.sort( folderGroup ); + + final Map globalInvokerProperties = new HashMap<>(); + + for ( Path path : folderGroup ) + { + Properties ancestorProperties = globalInvokerProperties.get( projectsPath.resolve( path ).getParent() ); + + Path currentInvokerProperties = projectsPath.resolve( path ).resolve( invokerPropertiesFile ); + + Properties currentProperties; + if ( Files.isRegularFile( currentInvokerProperties ) ) + { + if ( ancestorProperties != null ) + { + currentProperties = new Properties( ancestorProperties ); + + } + else + { + currentProperties = new Properties(); + } + } + else + { + currentProperties = ancestorProperties; + } + + if ( Files.isRegularFile( currentInvokerProperties ) ) + { + try ( InputStream in = new FileInputStream( currentInvokerProperties.toFile() ) ) + { + currentProperties.load( in ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read invoker properties: " + + currentInvokerProperties ); + } + } + + if ( currentProperties != null ) + { + globalInvokerProperties.put( projectsPath.resolve( path ).normalize(), currentProperties ); + } + } + + try + { + if ( runWithParallelThreads > 1 ) + { + getLog().info( "use parallelThreads " + runWithParallelThreads ); + + ExecutorService executorService = Executors.newFixedThreadPool( runWithParallelThreads ); + for ( final BuildJob job : buildJobs ) + { + executorService.execute( new Runnable() + { + public void run() + { + try + { + Path ancestorFolder = getAncestorFolder( projectsPath.resolve( job.getProject() ) ); + + runBuild( projectsDir, job, mergedSettingsFile, javaHome, actualJreVersion, + globalInvokerProperties.get( ancestorFolder ) ); + } + catch ( MojoExecutionException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + } + } ); + } + + try + { + executorService.shutdown(); + // TODO add a configurable time out + executorService.awaitTermination( Long.MAX_VALUE, TimeUnit.MILLISECONDS ); + } + catch ( InterruptedException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } + else + { + for ( BuildJob job : buildJobs ) + { + Path ancestorFolder = getAncestorFolder( projectsPath.resolve( job.getProject() ) ); + + runBuild( projectsDir, job, mergedSettingsFile, javaHome, actualJreVersion, + globalInvokerProperties.get( ancestorFolder ) ); + } + } + } + finally + { + if ( interpolatedSettingsFile != null && cloneProjectsTo == null ) + { + interpolatedSettingsFile.delete(); + } + if ( mergedSettingsFile != null && mergedSettingsFile.exists() ) + { + mergedSettingsFile.delete(); + } + } + } + + private Path getAncestorFolder( Path p ) + { + Path ancestor = p; + if ( Files.isRegularFile( ancestor ) ) + { + ancestor = ancestor.getParent(); + } + if ( ancestor != null ) + { + ancestor = ancestor.getParent(); + } + return ancestor; + } + + /** + * Interpolate settings.xml file. + * @param settingsFile a settings file + * + * @return The interpolated settings.xml file. + * @throws MojoExecutionException in case of a problem. + */ + private File interpolateSettings( File settingsFile ) + throws MojoExecutionException + { + File interpolatedSettingsFile = null; + if ( settingsFile != null ) + { + if ( cloneProjectsTo != null ) + { + interpolatedSettingsFile = new File( cloneProjectsTo, "interpolated-" + settingsFile.getName() ); + } + else + { + interpolatedSettingsFile = + new File( settingsFile.getParentFile(), "interpolated-" + settingsFile.getName() ); + } + buildInterpolatedFile( settingsFile, interpolatedSettingsFile ); + } + return interpolatedSettingsFile; + } + + /** + * Merge the settings file + * + * @param interpolatedSettingsFile The interpolated settings file. + * @return The merged settings file. + * @throws MojoExecutionException Fail the build in case the merged settings file can't be created. + */ + private File mergeSettings( File interpolatedSettingsFile ) + throws MojoExecutionException + { + File mergedSettingsFile; + Settings mergedSettings = this.settings; + if ( mergeUserSettings ) + { + if ( interpolatedSettingsFile != null ) + { + // Have to merge the specified settings file (dominant) and the one of the invoking Maven process + try + { + SettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); + request.setGlobalSettingsFile( interpolatedSettingsFile ); + + Settings dominantSettings = settingsBuilder.build( request ).getEffectiveSettings(); + Settings recessiveSettings = cloneSettings(); + SettingsUtils.merge( dominantSettings, recessiveSettings, TrackableBase.USER_LEVEL ); + + mergedSettings = dominantSettings; + getLog().debug( "Merged specified settings file with settings of invoking process" ); + } + catch ( SettingsBuildingException e ) + { + throw new MojoExecutionException( "Could not read specified settings file", e ); + } + } + } + + if ( this.settingsFile != null && !mergeUserSettings ) + { + mergedSettingsFile = interpolatedSettingsFile; + } + else + { + try + { + mergedSettingsFile = writeMergedSettingsFile( mergedSettings ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not create temporary file for invoker settings.xml", e ); + } + } + return mergedSettingsFile; + } + + private File writeMergedSettingsFile( Settings mergedSettings ) + throws IOException + { + File mergedSettingsFile; + mergedSettingsFile = File.createTempFile( "invoker-settings", ".xml" ); + + SettingsXpp3Writer settingsWriter = new SettingsXpp3Writer(); + + + try ( FileWriter fileWriter = new FileWriter( mergedSettingsFile ) ) + { + settingsWriter.write( fileWriter, mergedSettings ); + } + + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Created temporary file for invoker settings.xml: " + + mergedSettingsFile.getAbsolutePath() ); + } + return mergedSettingsFile; + } + + private Settings cloneSettings() + { + Settings recessiveSettings = SettingsUtils.copySettings( this.settings ); + + // MINVOKER-133: reset sourceLevelSet + resetSourceLevelSet( recessiveSettings ); + for ( org.apache.maven.settings.Mirror mirror : recessiveSettings.getMirrors() ) + { + resetSourceLevelSet( mirror ); + } + for ( org.apache.maven.settings.Server server : recessiveSettings.getServers() ) + { + resetSourceLevelSet( server ); + } + for ( org.apache.maven.settings.Proxy proxy : recessiveSettings.getProxies() ) + { + resetSourceLevelSet( proxy ); + } + for ( org.apache.maven.settings.Profile profile : recessiveSettings.getProfiles() ) + { + resetSourceLevelSet( profile ); + } + + return recessiveSettings; + } + + private void resetSourceLevelSet( org.apache.maven.settings.TrackableBase trackable ) + { + try + { + ReflectionUtils.setVariableValueInObject( trackable, "sourceLevelSet", Boolean.FALSE ); + getLog().debug( "sourceLevelSet: " + + ReflectionUtils.getValueIncludingSuperclasses( "sourceLevelSet", trackable ) ); + } + catch ( IllegalAccessException e ) + { + // noop + } + } + + private CharSequence resolveExternalJreVersion() + { + Artifact pluginArtifact = mojoExecution.getMojoDescriptor().getPluginDescriptor().getPluginArtifact(); + pluginArtifact.getFile(); + + Commandline commandLine = new Commandline(); + commandLine.setExecutable( new File( javaHome, "bin/java" ).getAbsolutePath() ); + commandLine.createArg().setValue( "-cp" ); + commandLine.createArg().setFile( pluginArtifact.getFile() ); + commandLine.createArg().setValue( SystemPropertyPrinter.class.getName() ); + commandLine.createArg().setValue( "java.version" ); + + final StringBuilder actualJreVersion = new StringBuilder(); + StreamConsumer consumer = new StreamConsumer() + { + public void consumeLine( String line ) + { + actualJreVersion.append( line ); + } + }; + try + { + CommandLineUtils.executeCommandLine( commandLine, consumer, null ); + } + catch ( CommandLineException e ) + { + getLog().warn( e.getMessage() ); + } + return actualJreVersion; + } + + /** + * Interpolate the pom file. + * + * @param pomFile The pom file. + * @param basedir The base directory. + * @return interpolated pom file location in case we have interpolated the pom file otherwise the original pom file + * will be returned. + * @throws MojoExecutionException + */ + private File interpolatePomFile( File pomFile, File basedir ) + throws MojoExecutionException + { + File interpolatedPomFile = null; + if ( pomFile != null ) + { + if ( StringUtils.isNotEmpty( filteredPomPrefix ) ) + { + interpolatedPomFile = new File( basedir, filteredPomPrefix + pomFile.getName() ); + buildInterpolatedFile( pomFile, interpolatedPomFile ); + } + else + { + interpolatedPomFile = pomFile; + } + } + return interpolatedPomFile; + } + + /** + * Runs the specified project. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param buildJob The build job to run, must not be null. + * @param settingsFile The (already interpolated) user settings file for the build, may be null to use + * the current user settings. + * @param globalInvokerProperties + * @throws org.apache.maven.plugin.MojoExecutionException If the project could not be launched. + */ + private void runBuild( File projectsDir, BuildJob buildJob, File settingsFile, File actualJavaHome, + CharSequence actualJreVersion, Properties globalInvokerProperties ) + throws MojoExecutionException + { + // FIXME: Think about the following code part -- START + File pomFile = new File( projectsDir, buildJob.getProject() ); + File basedir; + if ( pomFile.isDirectory() ) + { + basedir = pomFile; + pomFile = new File( basedir, "pom.xml" ); + if ( !pomFile.exists() ) + { + pomFile = null; + } + else + { + buildJob.setProject( buildJob.getProject() + File.separator + "pom.xml" ); + } + } + else + { + basedir = pomFile.getParentFile(); + } + + File interpolatedPomFile = interpolatePomFile( pomFile, basedir ); + // FIXME: Think about the following code part -- ^^^^^^^ END + + getLog().info( buffer().a( "Building: " ).strong( buildJob.getProject() ).toString() ); + + InvokerProperties invokerProperties = getInvokerProperties( basedir, globalInvokerProperties ); + + // let's set what details we can + buildJob.setName( invokerProperties.getJobName() ); + buildJob.setDescription( invokerProperties.getJobDescription() ); + + try + { + int selection = getSelection( invokerProperties, actualJreVersion ); + if ( selection == 0 ) + { + long milliseconds = System.currentTimeMillis(); + boolean executed; + + FileLogger buildLogger = setupBuildLogFile( basedir ); + if ( buildLogger != null ) + { + buildJob.setBuildlog( buildLogger.getOutputFile().getAbsolutePath() ); + } + + try + { + executed = runBuild( basedir, interpolatedPomFile, settingsFile, actualJavaHome, + invokerProperties, buildLogger ); + } + finally + { + milliseconds = System.currentTimeMillis() - milliseconds; + buildJob.setTime( milliseconds / 1000.0 ); + + if ( buildLogger != null ) + { + buildLogger.close(); + } + } + + if ( executed ) + { + buildJob.setResult( BuildJob.Result.SUCCESS ); + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).success( "SUCCESS" ).a( ' ' ) + + formatTime( buildJob.getTime() ) ); + } + } + else + { + buildJob.setResult( BuildJob.Result.SKIPPED ); + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).warning( "SKIPPED" ).a( ' ' ) + + formatTime( buildJob.getTime() ) ); + } + } + } + else + { + buildJob.setResult( BuildJob.Result.SKIPPED ); + + StringBuilder message = new StringBuilder(); + if ( selection == Selector.SELECTOR_MULTI ) + { + message.append( "non-matching selectors" ); + } + else + { + if ( ( selection & Selector.SELECTOR_MAVENVERSION ) != 0 ) + { + message.append( "Maven version" ); + } + if ( ( selection & Selector.SELECTOR_JREVERSION ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "JRE version" ); + } + if ( ( selection & Selector.SELECTOR_OSFAMILY ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "OS" ); + } + if ( ( selection & Selector.SELECTOR_TOOLCHAIN ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "Toolchain" ); + } + } + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).warning( "SKIPPED" ) + " due to " + message.toString() ); + } + + // Abuse failureMessage, the field in the report which should contain the reason for skipping + // Consider skipCode + I18N + buildJob.setFailureMessage( "Skipped due to " + message.toString() ); + } + } + catch ( RunErrorException e ) + { + buildJob.setResult( BuildJob.Result.ERROR ); + buildJob.setFailureMessage( e.getMessage() ); + + if ( !suppressSummaries ) + { + getLog().info( " " + e.getMessage() ); + getLog().info( pad( buildJob ).failure( "ERROR" ).a( ' ' ) + formatTime( buildJob.getTime() ) ); + } + } + catch ( RunFailureException e ) + { + buildJob.setResult( e.getType() ); + buildJob.setFailureMessage( e.getMessage() ); + + if ( !suppressSummaries ) + { + getLog().info( " " + e.getMessage() ); + getLog().info( pad( buildJob ).failure( "FAILED" ).a( ' ' ) + formatTime( buildJob.getTime() ) ); + } + } + finally + { + deleteInterpolatedPomFile( interpolatedPomFile ); + writeBuildReport( buildJob ); + } + } + + private MessageBuilder pad( BuildJob buildJob ) + { + MessageBuilder buffer = buffer( 128 ); + + buffer.a( " " ); + buffer.a( buildJob.getProject() ); + + int l = 10 + buildJob.getProject().length(); + + if ( l < RESULT_COLUMN ) + { + buffer.a( ' ' ); + l++; + + if ( l < RESULT_COLUMN ) + { + for ( int i = RESULT_COLUMN - l; i > 0; i-- ) + { + buffer.a( '.' ); + } + } + } + + return buffer.a( ' ' ); + } + + /** + * Delete the interpolated pom file if it has been created before. + * + * @param interpolatedPomFile The interpolated pom file. + */ + private void deleteInterpolatedPomFile( File interpolatedPomFile ) + { + if ( interpolatedPomFile != null && StringUtils.isNotEmpty( filteredPomPrefix ) ) + { + interpolatedPomFile.delete(); + } + } + + /** + * Determines whether selector conditions of the specified invoker properties match the current environment. + * + * @param invokerProperties The invoker properties to check, must not be null. + * @return 0 if the job corresponding to the properties should be run, otherwise a bitwise value + * representing the reason why it should be skipped. + */ + private int getSelection( InvokerProperties invokerProperties, CharSequence actualJreVersion ) + { + return new Selector( actualMavenVersion, actualJreVersion.toString(), + getToolchainPrivateManager() ).getSelection( invokerProperties ); + } + + private ToolchainPrivateManager getToolchainPrivateManager() + { + return new ToolchainPrivateManager( toolchainManagerPrivate, session ); + } + + /** + * Writes the XML report for the specified build job unless report generation has been disabled. + * + * @param buildJob The build job whose report should be written, must not be null. + * @throws org.apache.maven.plugin.MojoExecutionException If the report could not be written. + */ + private void writeBuildReport( BuildJob buildJob ) + throws MojoExecutionException + { + if ( disableReports ) + { + return; + } + + String safeFileName = buildJob.getProject().replace( '/', '_' ).replace( '\\', '_' ).replace( ' ', '_' ); + if ( safeFileName.endsWith( "_pom.xml" ) ) + { + safeFileName = safeFileName.substring( 0, safeFileName.length() - "_pom.xml".length() ); + } + + File reportFile = new File( reportsDirectory, "BUILD-" + safeFileName + ".xml" ); + try ( FileOutputStream fos = new FileOutputStream( reportFile ); + Writer osw = new OutputStreamWriter( fos, buildJob.getModelEncoding() ) ) + { + BuildJobXpp3Writer writer = new BuildJobXpp3Writer(); + + writer.write( osw, buildJob ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write build report " + reportFile, e ); + } + + if ( writeJunitReport ) + { + writeJunitReport( buildJob, safeFileName ); + } + } + + private void writeJunitReport( BuildJob buildJob, String safeFileName ) + throws MojoExecutionException + { + File reportFile = new File( reportsDirectory, "TEST-" + safeFileName + ".xml" ); + Xpp3Dom testsuite = new Xpp3Dom( "testsuite" ); + testsuite.setAttribute( "name", junitPackageName + "." + safeFileName ); + testsuite.setAttribute( "time", Double.toString( buildJob.getTime() ) ); + + // set default value for required attributes + testsuite.setAttribute( "tests", "1" ); + testsuite.setAttribute( "errors", "0" ); + testsuite.setAttribute( "skipped", "0" ); + testsuite.setAttribute( "failures", "0" ); + + Xpp3Dom testcase = new Xpp3Dom( "testcase" ); + testsuite.addChild( testcase ); + switch ( buildJob.getResult() ) + { + case BuildJob.Result.SUCCESS: + break; + case BuildJob.Result.SKIPPED: + testsuite.setAttribute( "skipped", "1" ); + // adding the failure element + Xpp3Dom skipped = new Xpp3Dom( "skipped" ); + testcase.addChild( skipped ); + skipped.setValue( buildJob.getFailureMessage() ); + break; + case BuildJob.Result.ERROR: + testsuite.setAttribute( "errors", "1" ); + break; + default: + testsuite.setAttribute( "failures", "1" ); + // adding the failure element + Xpp3Dom failure = new Xpp3Dom( "failure" ); + testcase.addChild( failure ); + failure.setAttribute( "message", buildJob.getFailureMessage() ); + } + testcase.setAttribute( "classname", junitPackageName + "." + safeFileName ); + testcase.setAttribute( "name", safeFileName ); + testcase.setAttribute( "time", Double.toString( buildJob.getTime() ) ); + Xpp3Dom systemOut = new Xpp3Dom( "system-out" ); + testcase.addChild( systemOut ); + + + File buildLogFile = buildJob.getBuildlog() != null ? new File( buildJob.getBuildlog() ) : null; + + if ( buildLogFile != null && buildLogFile.exists() ) + { + getLog().debug( "fileLogger:" + buildLogFile ); + try + { + systemOut.setValue( FileUtils.fileRead( buildLogFile ) ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read logfile " + buildLogFile, e ); + } + } + else + { + getLog().debug( safeFileName + "not exists buildLogFile = " + buildLogFile ); + } + + try ( FileOutputStream fos = new FileOutputStream( reportFile ); + Writer osw = new OutputStreamWriter( fos, buildJob.getModelEncoding() ) ) + { + Xpp3DomWriter.write( osw, testsuite ); + } catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write JUnit build report " + reportFile, e ); + } + } + + /** + * Formats the specified build duration time. + * + * @param seconds The duration of the build. + * @return The formatted time, never null. + */ + private String formatTime( double seconds ) + { + return secFormat.format( seconds ); + } + + /** + * Runs the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @param pomFile The (already interpolated) POM file, may be null for a POM-less Maven invocation. + * @param settingsFile The (already interpolated) user settings file for the build, may be null. Will + * be merged with the settings file of the invoking Maven process. + * @param invokerProperties The properties to use. + * @param logger file logger to write execution build.log + * @return true if the project was launched or false if the selector script indicated that + * the project should be skipped. + * @throws org.apache.maven.plugin.MojoExecutionException If the project could not be launched. + * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException If either a hook script or the build itself + * failed. + */ + private boolean runBuild( File basedir, File pomFile, File settingsFile, File actualJavaHome, + InvokerProperties invokerProperties, FileLogger logger ) + throws MojoExecutionException, RunFailureException + { + if ( getLog().isDebugEnabled() && !invokerProperties.getProperties().isEmpty() ) + { + Properties props = invokerProperties.getProperties(); + getLog().debug( "Using invoker properties:" ); + for ( String key : new TreeSet( props.stringPropertyNames() ) ) + { + String value = props.getProperty( key ); + getLog().debug( " " + key + " = " + value ); + } + } + + List goals = getGoals( basedir ); + + List profiles = getProfiles( basedir ); + + Map context = new LinkedHashMap<>(); + + boolean selectorResult = true; + + try + { + try + { + scriptRunner.run( "selector script", basedir, selectorScript, context, logger, BuildJob.Result.SKIPPED, + false ); + } + catch ( RunErrorException e ) + { + selectorResult = false; + throw e; + } + catch ( RunFailureException e ) + { + selectorResult = false; + return false; + } + + scriptRunner.run( "pre-build script", basedir, preBuildHookScript, context, logger, + BuildJob.Result.FAILURE_PRE_HOOK, false ); + + final InvocationRequest request = new DefaultInvocationRequest(); + + request.setLocalRepositoryDirectory( localRepositoryPath ); + + request.setBatchMode( true ); + + request.setShowErrors( showErrors ); + + request.setDebug( debug ); + + request.setShowVersion( showVersion ); + + setupLoggerForBuildJob( logger, request ); + + if ( mavenHome != null ) + { + invoker.setMavenHome( mavenHome ); + // FIXME: Should we really take care of M2_HOME? + request.addShellEnvironment( "M2_HOME", mavenHome.getAbsolutePath() ); + } + + if ( mavenExecutable != null ) + { + invoker.setMavenExecutable( new File( mavenExecutable ) ); + } + + if ( actualJavaHome != null ) + { + request.setJavaHome( actualJavaHome ); + } + + if ( environmentVariables != null ) + { + for ( Map.Entry variable : environmentVariables.entrySet() ) + { + request.addShellEnvironment( variable.getKey(), variable.getValue() ); + } + } + + for ( int invocationIndex = 1;; invocationIndex++ ) + { + if ( invocationIndex > 1 && !invokerProperties.isInvocationDefined( invocationIndex ) ) + { + break; + } + + request.setBaseDirectory( basedir ); + + request.setPomFile( pomFile ); + + request.setGoals( goals ); + + request.setProfiles( profiles ); + + request.setMavenOpts( mavenOpts ); + + request.setOffline( false ); + + int timeOut = invokerProperties.getTimeoutInSeconds( invocationIndex ); + // not set so we use the one at the mojo level + request.setTimeoutInSeconds( timeOut < 0 ? timeoutInSeconds : timeOut ); + + String customSettingsFile = invokerProperties.getSettingsFile( invocationIndex ); + if ( customSettingsFile != null ) + { + File interpolateSettingsFile = interpolateSettings( new File( customSettingsFile ) ); + File mergeSettingsFile = mergeSettings( interpolateSettingsFile ); + + request.setUserSettingsFile( mergeSettingsFile ); + } + else + { + request.setUserSettingsFile( settingsFile ); + } + + Properties systemProperties = + getSystemProperties( basedir, invokerProperties.getSystemPropertiesFile( invocationIndex ) ); + request.setProperties( systemProperties ); + + invokerProperties.configureInvocation( request, invocationIndex ); + + if ( getLog().isDebugEnabled() ) + { + try + { + getLog().debug( "Using MAVEN_OPTS: " + request.getMavenOpts() ); + getLog().debug( "Executing: " + new MavenCommandLineBuilder().build( request ) ); + } + catch ( CommandLineConfigurationException e ) + { + getLog().debug( "Failed to display command line: " + e.getMessage() ); + } + } + + try + { + InvocationResult result = invoker.execute( request ); + verify( result, invocationIndex, invokerProperties, logger ); + } + catch ( final MavenInvocationException e ) + { + getLog().debug( "Error invoking Maven: " + e.getMessage(), e ); + throw new RunFailureException( "Maven invocation failed. " + e.getMessage(), + BuildJob.Result.FAILURE_BUILD ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + finally + { + if ( selectorResult ) + { + runPostBuildHook( basedir, context, logger ); + } + } + return true; + } + + int getParallelThreadsCount() + { + if ( parallelThreads.endsWith( "C" ) ) + { + double parallelThreadsMultiple = Double.parseDouble( + parallelThreads.substring( 0, parallelThreads.length() - 1 ) ); + return (int) ( parallelThreadsMultiple * Runtime.getRuntime().availableProcessors() ); + } + else + { + return Integer.parseInt( parallelThreads ); + } + } + + private void runPostBuildHook( File basedir, Map context, FileLogger logger ) + throws MojoExecutionException, RunFailureException + { + try + { + scriptRunner.run( "post-build script", basedir, postBuildHookScript, context, logger, + BuildJob.Result.FAILURE_POST_HOOK, true ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } + private void setupLoggerForBuildJob( FileLogger logger, final InvocationRequest request ) + { + if ( logger != null ) + { + request.setErrorHandler( logger ); + + request.setOutputHandler( logger ); + } + } + + /** + * Initializes the build logger for the specified project. This will write the logging information into + * {@code build.log}. + * + * @param basedir The base directory of the project, must not be null. + * @return The build logger or null if logging has been disabled. + * @throws org.apache.maven.plugin.MojoExecutionException If the log file could not be created. + */ + private FileLogger setupBuildLogFile( File basedir ) + throws MojoExecutionException + { + FileLogger logger = null; + + if ( !noLog ) + { + Path projectLogDirectory; + if ( logDirectory == null ) + { + projectLogDirectory = basedir.toPath(); + } + else if ( cloneProjectsTo != null ) + { + projectLogDirectory = + logDirectory.toPath().resolve( cloneProjectsTo.toPath().relativize( basedir.toPath() ) ); + } + else + { + projectLogDirectory = + logDirectory.toPath().resolve( projectsDirectory.toPath().relativize( basedir.toPath() ) ); + } + + try + { + if ( streamLogs ) + { + logger = new FileLogger( projectLogDirectory.resolve( "build.log" ).toFile(), getLog() ); + } + else + { + logger = new FileLogger( projectLogDirectory.resolve( "build.log" ).toFile() ); + } + + getLog().debug( "Build log initialized in: " + projectLogDirectory ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error initializing build logfile in: " + projectLogDirectory, e ); + } + } + + return logger; + } + + /** + * Gets the system properties to use for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @param filename The filename to the properties file to load, may be null to use the default path + * given by {@link #testPropertiesFile}. + * @return The system properties to use, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the properties file exists but could not be read. + */ + private Properties getSystemProperties( final File basedir, final String filename ) + throws MojoExecutionException + { + Properties collectedTestProperties = new Properties(); + + if ( properties != null ) + { + // MINVOKER-118: property can have empty value, which is not accepted by collectedTestProperties + for ( Map.Entry entry : properties.entrySet() ) + { + if ( entry.getValue() != null ) + { + collectedTestProperties.put( entry.getKey(), entry.getValue() ); + } + } + } + + File propertiesFile = null; + if ( filename != null ) + { + propertiesFile = new File( basedir, filename ); + } + else if ( testPropertiesFile != null ) + { + propertiesFile = new File( basedir, testPropertiesFile ); + } + + if ( propertiesFile != null && propertiesFile.isFile() ) + { + + try ( InputStream fin = new FileInputStream( propertiesFile ) ) + { + Properties loadedProperties = new Properties(); + loadedProperties.load( fin ); + collectedTestProperties.putAll( loadedProperties ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error reading system properties from " + propertiesFile ); + } + } + + return collectedTestProperties; + } + + /** + * Verifies the invocation result. + * + * @param result The invocation result to check, must not be null. + * @param invocationIndex The index of the invocation for which to check the exit code, must not be negative. + * @param invokerProperties The invoker properties used to check the exit code, must not be null. + * @param logger The build logger, may be null if logging is disabled. + * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException If the invocation result indicates a build + * failure. + */ + private void verify( InvocationResult result, int invocationIndex, InvokerProperties invokerProperties, + FileLogger logger ) + throws RunFailureException + { + if ( result.getExecutionException() != null ) + { + throw new RunFailureException( "The Maven invocation failed. " + + result.getExecutionException().getMessage(), BuildJob.Result.ERROR ); + } + else if ( !invokerProperties.isExpectedResult( result.getExitCode(), invocationIndex ) ) + { + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( "The build exited with code " ).append( result.getExitCode() ).append( ". " ); + if ( logger != null ) + { + buffer.append( "See " ); + buffer.append( logger.getOutputFile().getAbsolutePath() ); + buffer.append( " for details." ); + } + else + { + buffer.append( "See console output for details." ); + } + throw new RunFailureException( buffer.toString(), BuildJob.Result.FAILURE_BUILD ); + } + } + + /** + * Gets the goal list for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @return The list of goals to run when building the project, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the profile file could not be read. + */ + List getGoals( final File basedir ) + throws MojoExecutionException + { + try + { + // FIXME: Currently we have null for goalsFile which has been removed. + // This might mean we can remove getGoals() at all ? Check this. + return getTokens( basedir, null, goals ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "error reading goals", e ); + } + } + + /** + * Gets the profile list for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @return The list of profiles to activate when building the project, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the profile file could not be read. + */ + List getProfiles( File basedir ) + throws MojoExecutionException + { + try + { + return getTokens( basedir, null, profiles ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "error reading profiles", e ); + } + } + + private List calculateExcludes() + throws IOException + { + List excludes = + ( pomExcludes != null ) ? new ArrayList<>( pomExcludes ) : new ArrayList(); + if ( this.settingsFile != null ) + { + String exclude = relativizePath( this.settingsFile, projectsDirectory.getCanonicalPath() ); + if ( exclude != null ) + { + excludes.add( exclude.replace( '\\', '/' ) ); + getLog().debug( "Automatically excluded " + exclude + " from project scanning" ); + } + } + return excludes; + + } + + /** + * @return The list of setupUp jobs. + * @throws IOException + * @see {@link #setupIncludes} + */ + private List getSetupBuildJobsFromFolders() + throws IOException, MojoExecutionException + { + List excludes = calculateExcludes(); + + List setupPoms = scanProjectsDirectory( setupIncludes, excludes, BuildJob.Type.SETUP ); + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Setup projects: " + setupPoms ); + } + + return setupPoms; + } + + private static class OrdinalComparator implements Comparator + { + private static final OrdinalComparator INSTANCE = new OrdinalComparator(); + + @Override + public int compare( Object o1, Object o2 ) + { + return Integer.compare( ( ( BuildJob ) o2 ).getOrdinal(), ( ( BuildJob ) o1 ).getOrdinal() ); + } + } + + /** + * Gets the build jobs that should be processed. Note that the order of the returned build jobs is significant. + * + * @return The build jobs to process, may be empty but never null. + * @throws java.io.IOException If the projects directory could not be scanned. + */ + List getBuildJobs() + throws IOException, MojoExecutionException + { + List buildJobs; + + if ( invokerTest == null ) + { + List excludes = calculateExcludes(); + + List setupPoms = scanProjectsDirectory( setupIncludes, excludes, BuildJob.Type.SETUP ); + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Setup projects: " + Arrays.asList( setupPoms ) ); + } + + List normalPoms = scanProjectsDirectory( pomIncludes, excludes, BuildJob.Type.NORMAL ); + + Map uniquePoms = new LinkedHashMap<>(); + for ( BuildJob setupPom : setupPoms ) + { + uniquePoms.put( setupPom.getProject(), setupPom ); + } + for ( BuildJob normalPom : normalPoms ) + { + if ( !uniquePoms.containsKey( normalPom.getProject() ) ) + { + uniquePoms.put( normalPom.getProject(), normalPom ); + } + } + + buildJobs = new ArrayList<>( uniquePoms.values() ); + } + else + { + String[] testRegexes = StringUtils.split( invokerTest, "," ); + List includes = new ArrayList<>( testRegexes.length ); + List excludes = new ArrayList<>(); + + for ( String regex : testRegexes ) + { + // user just use -Dinvoker.test=MWAR191,MNG111 to use a directory thats the end is not pom.xml + if ( regex.startsWith( "!" ) ) + { + excludes.add( regex.substring( 1 ) ); + } + else + { + includes.add( regex ); + } + } + + // it would be nice if we could figure out what types these are... but perhaps + // not necessary for the -Dinvoker.test=xxx t + buildJobs = scanProjectsDirectory( includes, excludes, BuildJob.Type.DIRECT ); + } + + relativizeProjectPaths( buildJobs ); + + return buildJobs; + } + + /** + * Scans the projects directory for projects to build. Both (POM) files and mere directories will be matched by the + * scanner patterns. If the patterns match a directory which contains a file named "pom.xml", the results will + * include the path to this file rather than the directory path in order to avoid duplicate invocations of the same + * project. + * + * @param includes The include patterns for the scanner, may be null. + * @param excludes The exclude patterns for the scanner, may be null to exclude nothing. + * @param type The type to assign to the resulting build jobs, must not be null. + * @return The build jobs matching the patterns, never null. + * @throws java.io.IOException If the project directory could not be scanned. + */ + private List scanProjectsDirectory( List includes, List excludes, String type ) + throws IOException, MojoExecutionException + { + if ( !projectsDirectory.isDirectory() ) + { + return Collections.emptyList(); + } + + DirectoryScanner scanner = new DirectoryScanner(); + scanner.setBasedir( projectsDirectory.getCanonicalFile() ); + scanner.setFollowSymlinks( false ); + if ( includes != null ) + { + scanner.setIncludes( includes.toArray( new String[includes.size()] ) ); + } + if ( excludes != null ) + { + scanner.setExcludes( excludes.toArray( new String[excludes.size()] ) ); + } + scanner.addDefaultExcludes(); + scanner.scan(); + + Map matches = new LinkedHashMap<>(); + + for ( String includedFile : scanner.getIncludedFiles() ) + { + matches.put( includedFile, new BuildJob( includedFile, type ) ); + } + + for ( String includedDir : scanner.getIncludedDirectories() ) + { + String includedFile = includedDir + File.separatorChar + "pom.xml"; + if ( new File( scanner.getBasedir(), includedFile ).isFile() ) + { + matches.put( includedFile, new BuildJob( includedFile, type ) ); + } + else + { + matches.put( includedDir, new BuildJob( includedDir, type ) ); + } + } + + List projects = new ArrayList<>( matches.size() ); + + // setup ordinal values to have an order here + for ( BuildJob buildJob : matches.values() ) + { + InvokerProperties invokerProperties = + getInvokerProperties( new File( projectsDirectory, buildJob.getProject() ).getParentFile(), + null ); + buildJob.setOrdinal( invokerProperties.getOrdinal() ); + projects.add( buildJob ); + } + Collections.sort( projects, OrdinalComparator.INSTANCE ); + return projects; + } + + /** + * Relativizes the project paths of the specified build jobs against the directory specified by + * {@link #projectsDirectory} (if possible). If a project path does not denote a sub path of the projects directory, + * it is returned as is. + * + * @param buildJobs The build jobs whose project paths should be relativized, must not be null nor + * contain null elements. + * @throws java.io.IOException If any path could not be relativized. + */ + private void relativizeProjectPaths( List buildJobs ) + throws IOException + { + String projectsDirPath = projectsDirectory.getCanonicalPath(); + + for ( BuildJob buildJob : buildJobs ) + { + String projectPath = buildJob.getProject(); + + File file = new File( projectPath ); + + if ( !file.isAbsolute() ) + { + file = new File( projectsDirectory, projectPath ); + } + + String relativizedPath = relativizePath( file, projectsDirPath ); + + if ( relativizedPath == null ) + { + relativizedPath = projectPath; + } + + buildJob.setProject( relativizedPath ); + } + } + + /** + * Relativizes the specified path against the given base directory. Besides relativization, the returned path will + * also be normalized, e.g. directory references like ".." will be removed. + * + * @param path The path to relativize, must not be null. + * @param basedir The (canonical path of the) base directory to relativize against, must not be null. + * @return The relative path in normal form or null if the input path does not denote a sub path of the + * base directory. + * @throws java.io.IOException If the path could not be relativized. + */ + private String relativizePath( File path, String basedir ) + throws IOException + { + String relativizedPath = path.getCanonicalPath(); + + if ( relativizedPath.startsWith( basedir ) ) + { + relativizedPath = relativizedPath.substring( basedir.length() ); + if ( relativizedPath.startsWith( File.separator ) ) + { + relativizedPath = relativizedPath.substring( File.separator.length() ); + } + + return relativizedPath; + } + else + { + return null; + } + } + + /** + * Returns the map-based value source used to interpolate POMs and other stuff. + * + * @param escapeXml {@code true}, to escape any XML special characters in the property values; {@code false}, to not + * escape any property values. + * + * @return The map-based value source for interpolation, never null. + */ +/** + * Returns the map-based value source used to interpolate POMs and other stuff. + * + * @param escapeXml + * {@code true}, to escape any XML special characters in the property values; {@code false}, to not + * escape any property values. + * @return The map-based value source for interpolation, never null. + */ +private java.util.Map getInterpolationValueSource(final boolean escapeXml) { + java.util.Map props = new java.util.HashMap<>(); + { + props.putAll(/* NPEX_NULL_EXP */ + filterProperties); + } + props.put("basedir", this.project.getBasedir().getAbsolutePath()); + props.put("baseurl", org.apache.maven.plugins.invoker.AbstractInvokerMojo.toUrl(this.project.getBasedir().getAbsolutePath())); + if (settings.getLocalRepository() != null) { + props.put("localRepository", settings.getLocalRepository()); + props.put("localRepositoryUrl", org.apache.maven.plugins.invoker.AbstractInvokerMojo.toUrl(settings.getLocalRepository())); + } + return new org.apache.maven.plugins.invoker.CompositeMap(this.project, props, escapeXml); +} + + /** + * Converts the specified filesystem path to a URL. The resulting URL has no trailing slash regardless whether the + * path denotes a file or a directory. + * + * @param filename The filesystem path to convert, must not be null. + * @return The file: URL for the specified path, never null. + */ + private static String toUrl( String filename ) + { + /* + * NOTE: Maven fails to properly handle percent-encoded "file:" URLs (WAGON-111) so don't use File.toURI() here + * as-is but use the decoded path component in the URL. + */ + String url = "file://" + new File( filename ).toURI().getPath(); + if ( url.endsWith( "/" ) ) + { + url = url.substring( 0, url.length() - 1 ); + } + return url; + } + + /** + * Gets goal/profile names for the specified project, either directly from the plugin configuration or from an + * external token file. + * + * @param basedir The base directory of the test project, must not be null. + * @param filename The (simple) name of an optional file in the project base directory from which to read + * goals/profiles, may be null. + * @param defaultTokens The list of tokens to return in case the specified token file does not exist, may be + * null. + * @return The list of goal/profile names, may be empty but never null. + * @throws java.io.IOException If the token file exists but could not be parsed. + */ + private List getTokens( File basedir, String filename, List defaultTokens ) + throws IOException + { + List tokens = ( defaultTokens != null ) ? defaultTokens : new ArrayList(); + + if ( StringUtils.isNotEmpty( filename ) ) + { + File tokenFile = new File( basedir, filename ); + + if ( tokenFile.exists() ) + { + tokens = readTokens( tokenFile ); + } + } + + return tokens; + } + + /** + * Reads the tokens from the specified file. Tokens are separated either by line terminators or commas. During + * parsing, the file contents will be interpolated. + * + * @param tokenFile The file to read the tokens from, must not be null. + * @return The list of tokens, may be empty but never null. + * @throws java.io.IOException If the token file could not be read. + */ + private List readTokens( final File tokenFile ) + throws IOException + { + List result = new ArrayList<>(); + + Map composite = getInterpolationValueSource( false ); + + try ( BufferedReader reader = + new BufferedReader( new InterpolationFilterReader( newReader( tokenFile ), composite ) ) ) + { + for ( String line = reader.readLine(); line != null; line = reader.readLine() ) + { + result.addAll( collectListFromCSV( line ) ); + } + } + + return result; + } + + /** + * Gets a list of comma separated tokens from the specified line. + * + * @param csv The line with comma separated tokens, may be null. + * @return The list of tokens from the line, may be empty but never null. + */ + private List collectListFromCSV( final String csv ) + { + final List result = new ArrayList<>(); + + if ( ( csv != null ) && ( csv.trim().length() > 0 ) ) + { + final StringTokenizer st = new StringTokenizer( csv, "," ); + + while ( st.hasMoreTokens() ) + { + result.add( st.nextToken().trim() ); + } + } + + return result; + } + + /** + * Interpolates the specified POM/settings file to a temporary file. The destination file may be same as the input + * file, i.e. interpolation can be performed in-place. + *

+ * Note:This methods expects the file to be a XML file and applies special XML escaping during interpolation. + *

+ * + * @param originalFile The XML file to interpolate, must not be null. + * @param interpolatedFile The target file to write the interpolated contents of the original file to, must not be + * null. + * + * @throws org.apache.maven.plugin.MojoExecutionException If the target file could not be created. + */ + void buildInterpolatedFile( File originalFile, File interpolatedFile ) + throws MojoExecutionException + { + getLog().debug( "Interpolate " + originalFile.getPath() + " to " + interpolatedFile.getPath() ); + + try + { + String xml; + + Map composite = getInterpolationValueSource( true ); + + // interpolation with token @...@ + try ( Reader reader = + new InterpolationFilterReader( ReaderFactory.newXmlReader( originalFile ), composite, "@", "@" ) ) + { + xml = IOUtil.toString( reader ); + } + + try ( Writer writer = WriterFactory.newXmlWriter( interpolatedFile ) ) + { + interpolatedFile.getParentFile().mkdirs(); + + writer.write( xml ); + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to interpolate file " + originalFile.getPath(), e ); + } + } + + /** + * Gets the (interpolated) invoker properties for an integration test. + * + * @param projectDirectory The base directory of the IT project, must not be null. + * @return The invoker properties, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If an I/O error occurred during reading the properties. + */ + private InvokerProperties getInvokerProperties( final File projectDirectory, Properties globalInvokerProperties ) + throws MojoExecutionException + { + Properties props; + if ( globalInvokerProperties != null ) + { + props = new Properties( globalInvokerProperties ); + } + else + { + props = new Properties(); + } + + File propertiesFile = new File( projectDirectory, invokerPropertiesFile ); + if ( propertiesFile.isFile() ) + { + try ( InputStream in = new FileInputStream( propertiesFile ) ) + { + props.load( in ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read invoker properties: " + propertiesFile, e ); + } + } + + Interpolator interpolator = new RegexBasedInterpolator(); + interpolator.addValueSource( new MapBasedValueSource( getInterpolationValueSource( false ) ) ); + // CHECKSTYLE_OFF: LineLength + for ( String key : props.stringPropertyNames() ) + { + String value = props.getProperty( key ); + try + { + value = interpolator.interpolate( value, "" ); + } + catch ( InterpolationException e ) + { + throw new MojoExecutionException( "Failed to interpolate invoker properties: " + propertiesFile, + e ); + } + props.setProperty( key, value ); + } + return new InvokerProperties( props ); + } + + static class ToolchainPrivateManager + { + private ToolchainManagerPrivate manager; + + private MavenSession session; + + ToolchainPrivateManager( ToolchainManagerPrivate manager, MavenSession session ) + { + this.manager = manager; + this.session = session; + } + + ToolchainPrivate[] getToolchainPrivates( String type ) throws MisconfiguredToolchainException + { + return manager.getToolchainsForType( type, session ); + } + } +} diff --git a/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/metadata.json b/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/metadata.json new file mode 100644 index 000000000..96ce533b5 --- /dev/null +++ b/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/metadata.json @@ -0,0 +1,21 @@ +{ + "language": "java", + "id": "maven-invoker-plugin-AbstractInvokerMojo_2646", + "buggyPath": ".", + "referencePath": null, + "buildCommand": "mvn package -V -B -Denforcer.skip=true -Dcheckstyle.skip=true -Dcobertura.skip=true -Drat.skip=true -Dlicense.skip=true -Dfindbugs.skip=true -Dgpg.skip=true -Dskip.npm=true -Dskip.gulp=true -Dskip.bower=true -Drat.numUnapprovedLicenses=100 -DskipTests=true -DskipITs=true -Dtest=None -DfailIfNoTests=false", + "testCommand": "mvn test -V -B -Denforcer.skip=true -Dcheckstyle.skip=true -Dcobertura.skip=true -Drat.skip=true -Dlicense.skip=true -Dfindbugs.skip=true -Dgpg.skip=true -Dskip.npm=true -Dskip.gulp=true -Dskip.bower=true -Drat.numUnapprovedLicenses=100", + "categories": [ + "safety", + "npe" + ], + "npe": { + "filepath": "src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java", + "line": 2654, + "npe_method": "getInterpolationValueSource", + "deref_field": "filterProperties", + "npe_class": "AbstractInvokerMojo", + "repo": "maven-invoker-plugin", + "bug_id": "AbstractInvokerMojo_2646" + } +} diff --git a/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/npe.json b/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/npe.json new file mode 100644 index 000000000..600981c3a --- /dev/null +++ b/Java/maven-invoker-plugin-AbstractInvokerMojo_2646/npe.json @@ -0,0 +1,7 @@ +{ + "filepath": "src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java", + "line": 2654, + "npe_method": "getInterpolationValueSource", + "deref_field": "filterProperties", + "npe_class": "AbstractInvokerMojo" +} \ No newline at end of file diff --git a/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/Dockerfile b/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/Dockerfile new file mode 100644 index 000000000..b3ce32683 --- /dev/null +++ b/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/Dockerfile @@ -0,0 +1,18 @@ +FROM ghcr.io/kupl/starlab-benchmarks/java-base:maven-invoker-plugin + +ENV TZ=Asia/Seoul + +COPY ./metadata.json . +COPY ./npe.json . +COPY ./buggy.java /tmp/buggy.java +RUN export BUGGY_PATH=$(cat metadata.json | jq -r ".npe.filepath") \ + && export BUGGY_LINE=$(cat metadata.json | jq -r ".npe.line") \ + && export BUGGY_MTHD=$(cat metadata.json | jq -r ".npe.npe_method") \ + && mv /tmp/buggy.java $BUGGY_PATH \ + && echo "[{\"filepath\": \"$BUGGY_PATH\", \"line\": $BUGGY_LINE, \"method_name\": \"$BUGGY_MTHD\"}]" | jq . > traces.json + +RUN git init . && git add -A + +RUN $(cat metadata.json | jq -r ".buildCommand") + +RUN $(cat metadata.json | jq -r ".testCommand"); if [ $? -eq 0 ]; then exit 1; fi diff --git a/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/buggy.java b/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/buggy.java new file mode 100644 index 000000000..33cccbdf8 --- /dev/null +++ b/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/buggy.java @@ -0,0 +1,2880 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.execution.MavenSession; +import org.apache.maven.model.Model; +import org.apache.maven.model.Profile; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecution; +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.plugins.invoker.model.BuildJob; +import org.apache.maven.plugins.invoker.model.io.xpp3.BuildJobXpp3Writer; +import org.apache.maven.project.MavenProject; +import org.apache.maven.settings.Settings; +import org.apache.maven.settings.SettingsUtils; +import org.apache.maven.settings.TrackableBase; +import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; +import org.apache.maven.settings.building.SettingsBuilder; +import org.apache.maven.settings.building.SettingsBuildingException; +import org.apache.maven.settings.building.SettingsBuildingRequest; +import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; +import org.apache.maven.shared.invoker.CommandLineConfigurationException; +import org.apache.maven.shared.invoker.DefaultInvocationRequest; +import org.apache.maven.shared.invoker.InvocationRequest; +import org.apache.maven.shared.invoker.InvocationResult; +import org.apache.maven.shared.invoker.Invoker; +import org.apache.maven.shared.invoker.MavenCommandLineBuilder; +import org.apache.maven.shared.invoker.MavenInvocationException; +import org.apache.maven.shared.scriptinterpreter.RunErrorException; +import org.apache.maven.shared.scriptinterpreter.RunFailureException; +import org.apache.maven.shared.scriptinterpreter.ScriptRunner; +import org.apache.maven.shared.utils.logging.MessageBuilder; +import org.apache.maven.toolchain.MisconfiguredToolchainException; +import org.apache.maven.toolchain.ToolchainManagerPrivate; +import org.apache.maven.toolchain.ToolchainPrivate; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.MapBasedValueSource; +import org.codehaus.plexus.interpolation.RegexBasedInterpolator; +import org.codehaus.plexus.util.DirectoryScanner; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.InterpolationFilterReader; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.ReflectionUtils; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.WriterFactory; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.codehaus.plexus.util.xml.Xpp3DomWriter; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeSet; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; + +/** + * Provides common code for mojos invoking sub builds. + * + * @author Stephen Connolly + * @since 15-Aug-2009 09:09:29 + */ +public abstract class AbstractInvokerMojo + extends AbstractMojo +{ + /** + * The zero-based column index where to print the invoker result. + */ + private static final int RESULT_COLUMN = 60; + + /** + * Flag used to suppress certain invocations. This is useful in tailoring the build using profiles. + * + * @since 1.1 + */ + @Parameter( property = "invoker.skip", defaultValue = "false" ) + private boolean skipInvocation; + + /** + * Flag used to suppress the summary output notifying of successes and failures. If set to true, the + * only indication of the build's success or failure will be the effect it has on the main build (if it fails, the + * main build should fail as well). If {@link #streamLogs} is enabled, the sub-build summary will also provide an + * indication. + */ + @Parameter( defaultValue = "false" ) + protected boolean suppressSummaries; + + /** + * Flag used to determine whether the build logs should be output to the normal mojo log. + */ + @Parameter( property = "invoker.streamLogs", defaultValue = "false" ) + private boolean streamLogs; + + /** + * The local repository for caching artifacts. It is strongly recommended to specify a path to an isolated + * repository like ${project.build.directory}/it-repo. Otherwise, your ordinary local repository will + * be used, potentially soiling it with broken artifacts. + */ + @Parameter( property = "invoker.localRepositoryPath", defaultValue = "${settings.localRepository}" ) + private File localRepositoryPath; + + /** + * Directory to search for integration tests. + */ + @Parameter( property = "invoker.projectsDirectory", defaultValue = "${basedir}/src/it/" ) + private File projectsDirectory; + + /** + * Base directory where all build reports are written to. Every execution of an integration test will produce an XML + * file which contains the information about success or failure of that particular build job. The format of the + * resulting XML file is documented in the given build-job reference. + * + * @since 1.4 + */ + @Parameter( property = "invoker.reportsDirectory", defaultValue = "${project.build.directory}/invoker-reports" ) + private File reportsDirectory; + + /** + * A flag to disable the generation of build reports. + * + * @since 1.4 + */ + @Parameter( property = "invoker.disableReports", defaultValue = "false" ) + private boolean disableReports; + + /** + * Directory to which projects should be cloned prior to execution. If set to {@code null}, each integration test + * will be run in the directory in which the corresponding IT POM was found. In this case, you most likely want to + * configure your SCM to ignore target and build.log in the test's base directory. + * + * @since 1.1 + */ + @Parameter( property = "invoker.cloneProjectsTo" ) + private File cloneProjectsTo; + + // CHECKSTYLE_OFF: LineLength + /** + * Some files are normally excluded when copying the IT projects from the directory specified by the parameter + * projectsDirectory to the directory given by cloneProjectsTo (e.g. .svn, CVS, + * *~, etc: see + * reference for full list). Setting this parameter to true will cause all files to be copied to + * the cloneProjectsTo directory. + * + * @since 1.2 + */ + @Parameter( defaultValue = "false" ) + private boolean cloneAllFiles; + // CHECKSTYLE_ON: LineLength + + /** + * Ensure the {@link #cloneProjectsTo} directory is not polluted with files from earlier invoker runs. + * + * @since 1.6 + */ + @Parameter( defaultValue = "true" ) + private boolean cloneClean; + + /** + * A single POM to build, skipping any scanning parameters and behavior. + */ + @Parameter( property = "invoker.pom" ) + private File pom; + + /** + * Include patterns for searching the integration test directory for projects. This parameter is meant to be set + * from the POM. If this parameter is not set, the plugin will search for all pom.xml files one + * directory below {@link #projectsDirectory} (i.e. */pom.xml).
+ *
+ * Starting with version 1.3, mere directories can also be matched by these patterns. For example, the include + * pattern * will run Maven builds on all immediate sub directories of {@link #projectsDirectory}, + * regardless if they contain a pom.xml. This allows to perform builds that need/should not depend on + * the existence of a POM. + */ + @Parameter + private List pomIncludes = Collections.singletonList( "*/pom.xml" ); + + /** + * Exclude patterns for searching the integration test directory. This parameter is meant to be set from the POM. By + * default, no POM files are excluded. For the convenience of using an include pattern like *, the + * custom settings file specified by the parameter {@link #settingsFile} will always be excluded automatically. + */ + @Parameter + private List pomExcludes = Collections.emptyList(); + + /** + * Include patterns for searching the projects directory for projects that need to be run before the other projects. + * This parameter allows to declare projects that perform setup tasks like installing utility artifacts into the + * local repository. Projects matched by these patterns are implicitly excluded from the scan for ordinary projects. + * Also, the exclusions defined by the parameter {@link #pomExcludes} apply to the setup projects, too. Default + * value is: setup*/pom.xml. + * + * @since 1.3 + */ + @Parameter + private List setupIncludes = Collections.singletonList( "setup*/pom.xml" ); + + /** + * The list of goals to execute on each project. Default value is: package. + */ + @Parameter + private List goals = Collections.singletonList( "package" ); + + /** + */ + @Component + private Invoker invoker; + + @Component + private SettingsBuilder settingsBuilder; + + @Component + private ToolchainManagerPrivate toolchainManagerPrivate; + + /** + * Relative path of a selector script to run prior in order to decide if the build should be executed. This script + * may be written with either BeanShell or Groovy. If the file extension is omitted (e.g. selector), + * the plugin searches for the file by trying out the well-known extensions .bsh and + * .groovy. If this script exists for a particular project but returns any non-null value different + * from true, the corresponding build is flagged as skipped. In this case, none of the pre-build hook + * script, Maven nor the post-build hook script will be invoked. If this script throws an exception, the + * corresponding build is flagged as in error, and none of the pre-build hook script, Maven not the post-build hook + * script will be invoked. + * + * @since 1.5 + */ + @Parameter( property = "invoker.selectorScript", defaultValue = "selector" ) + private String selectorScript; + + /** + * Relative path of a pre-build hook script to run prior to executing the build. This script may be written with + * either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. prebuild), the plugin + * searches for the file by trying out the well-known extensions .bsh and .groovy. If this + * script exists for a particular project but returns any non-null value different from true or throws + * an exception, the corresponding build is flagged as a failure. In this case, neither Maven nor the post-build + * hook script will be invoked. + */ + @Parameter( property = "invoker.preBuildHookScript", defaultValue = "prebuild" ) + private String preBuildHookScript; + + /** + * Relative path of a cleanup/verification hook script to run after executing the build. This script may be written + * with either BeanShell or Groovy (since 1.3). If the file extension is omitted (e.g. verify), the + * plugin searches for the file by trying out the well-known extensions .bsh and .groovy. + * If this script exists for a particular project but returns any non-null value different from true or + * throws an exception, the corresponding build is flagged as a failure. + */ + @Parameter( property = "invoker.postBuildHookScript", defaultValue = "postbuild" ) + private String postBuildHookScript; + + /** + * Location of a properties file that defines CLI properties for the test. + */ + @Parameter( property = "invoker.testPropertiesFile", defaultValue = "test.properties" ) + private String testPropertiesFile; + + /** + * Common set of properties to pass in on each project's command line, via -D parameters. + * + * @since 1.1 + */ + @Parameter + private Map properties; + + /** + * Whether to show errors in the build output. + */ + @Parameter( property = "invoker.showErrors", defaultValue = "false" ) + private boolean showErrors; + + /** + * Whether to show debug statements in the build output. + */ + @Parameter( property = "invoker.debug", defaultValue = "false" ) + private boolean debug; + + /** + * Suppress logging to the build.log file. + */ + @Parameter( property = "invoker.noLog", defaultValue = "false" ) + private boolean noLog; + + /** + * By default a {@code build.log} is created in the root of the project. By setting this folder + * files are written to a different folder, respecting the structure of the projectsDirectory. + * + * @since 3.2.0 + */ + @Parameter + private File logDirectory; + + /** + * List of profile identifiers to explicitly trigger in the build. + * + * @since 1.1 + */ + @Parameter + private List profiles; + + /** + * A list of additional properties which will be used to filter tokens in POMs and goal files. + * + * @since 1.3 + */ + @Parameter + private Map filterProperties; + + /** + * The Maven Project Object + * + * @since 1.1 + */ + @Parameter( defaultValue = "${project}", readonly = true, required = true ) + private MavenProject project; + + @Parameter( defaultValue = "${session}", readonly = true, required = true ) + private MavenSession session; + + @Parameter( defaultValue = "${mojoExecution}", readonly = true, required = true ) + private MojoExecution mojoExecution; + + /** + * A comma separated list of projectname patterns to run. Specify this parameter to run individual tests by file + * name, overriding the {@link #setupIncludes}, {@link #pomIncludes} and {@link #pomExcludes} parameters. Each + * pattern you specify here will be used to create an include/exclude pattern formatted like + * ${projectsDirectory}/pattern. To exclude a test, prefix the pattern with a '!'. + * So you can just type -Dinvoker.test=SimpleTest,Comp*Test,!Compare* to run builds in + * ${projectsDirectory}/SimpleTest and ${projectsDirectory}/ComplexTest, but not + * ${projectsDirectory}/CompareTest + * + * @since 1.1 (exclusion since 1.8) + */ + @Parameter( property = "invoker.test" ) + private String invokerTest; + + /** + * Path to an alternate settings.xml to use for Maven invocation with all ITs. Note that the + * <localRepository> element of this settings file is always ignored, i.e. the path given by the + * parameter {@link #localRepositoryPath} is dominant. + * + * @since 1.2 + */ + @Parameter( property = "invoker.settingsFile" ) + private File settingsFile; + + /** + * The MAVEN_OPTS environment variable to use when invoking Maven. This value can be overridden for + * individual integration tests by using {@link #invokerPropertiesFile}. + * + * @since 1.2 + */ + @Parameter( property = "invoker.mavenOpts" ) + private String mavenOpts; + + /** + * The home directory of the Maven installation to use for the forked builds. Defaults to the current Maven + * installation. + * + * @since 1.3 + */ + @Parameter( property = "invoker.mavenHome" ) + private File mavenHome; + + /** + * mavenExecutable can either be a file relative to ${maven.home}/bin/ or an absolute file. + * + * @since 1.8 + * @see Invoker#setMavenExecutable(File) + */ + @Parameter( property = "invoker.mavenExecutable" ) + private String mavenExecutable; + + /** + * The JAVA_HOME environment variable to use for forked Maven invocations. Defaults to the current Java + * home directory. + * + * @since 1.3 + */ + @Parameter( property = "invoker.javaHome" ) + private File javaHome; + + /** + * The file encoding for the pre-/post-build scripts and the list files for goals and profiles. + * + * @since 1.2 + */ + @Parameter( property = "encoding", defaultValue = "${project.build.sourceEncoding}" ) + private String encoding; + + /** + * The current user system settings for use in Maven. + * + * @since 1.2 + */ + @Parameter( defaultValue = "${settings}", readonly = true, required = true ) + private Settings settings; + + /** + * A flag whether the test class path of the project under test should be included in the class path of the + * pre-/post-build scripts. If set to false, the class path of script interpreter consists only of the + * runtime dependencies of the Maven Invoker Plugin. If set the true, + * the project's test class path will be prepended to the interpreter class path. Among others, this feature allows + * the scripts to access utility classes from the test sources of your project. + * + * @since 1.2 + */ + @Parameter( property = "invoker.addTestClassPath", defaultValue = "false" ) + private boolean addTestClassPath; + + /** + * The test class path of the project under test. + */ + @Parameter( defaultValue = "${project.testClasspathElements}", readonly = true ) + private List testClassPath; + + /** + * The name of an optional project-specific file that contains properties used to specify settings for an individual + * Maven invocation. Any property present in the file will override the corresponding setting from the plugin + * configuration. The values of the properties are filtered and may use expressions like + * ${project.version} to reference project properties or values from the parameter + * {@link #filterProperties}.

+ * + *

+ * As of 3.2.0 it is possible to put this folder in any of the ancestor folders, where properties will be inherited. + * This way you can provide a single properties file for a group of projects + *

+ * + * The snippet below describes the supported properties: + *
+     * # A comma or space separated list of goals/phases to execute, may
+     * # specify an empty list to execute the default goal of the IT project.
+     * # Environment variables used by maven plugins can be added here
+     * invoker.goals = clean install -Dplugin.variable=value
+     *
+     * # Or you can give things like this if you need.
+     * invoker.goals = -T2 clean verify
+     *
+     * # Optionally, a list of goals to run during further invocations of Maven
+     * invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:run
+     *
+     * # A comma or space separated list of profiles to activate
+     * invoker.profiles = its,jdk15
+     *
+     * # The path to an alternative POM or base directory to invoke Maven on, defaults to the
+     * # project that was originally specified in the plugin configuration
+     * # Since plugin version 1.4
+     * invoker.project = sub-module
+     *
+     * # The value for the environment variable MAVEN_OPTS
+     * invoker.mavenOpts = -Dfile.encoding=UTF-16 -Xms32m -Xmx256m
+     *
+     * # Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
+     * invoker.failureBehavior = fail-never
+     *
+     * # The expected result of the build, possible values are "success" (default) and "failure"
+     * invoker.buildResult = failure
+     *
+     * # A boolean value controlling the aggregator mode of Maven, defaults to "false"
+     * invoker.nonRecursive = true
+     *
+     * # A boolean value controlling the network behavior of Maven, defaults to "false"
+     * # Since plugin version 1.4
+     * invoker.offline = true
+     *
+     * # The path to the properties file from which to load system properties, defaults to the
+     * # filename given by the plugin parameter testPropertiesFile
+     * # Since plugin version 1.4
+     * invoker.systemPropertiesFile = test.properties
+     *
+     * # An optional human friendly name for this build job to be included in the build reports.
+     * # Since plugin version 1.4
+     * invoker.name = Test Build 01
+     *
+     * # An optional description for this build job to be included in the build reports.
+     * # Since plugin version 1.4
+     * invoker.description = Checks the support for build reports.
+     *
+     * # A comma separated list of JRE versions on which this build job should be run.
+     * # Since plugin version 1.4
+     * invoker.java.version = 1.4+, !1.4.1, 1.7-
+     * 
+     * # A comma separated list of OS families on which this build job should be run.
+     * # Since plugin version 1.4
+     * invoker.os.family = !windows, unix, mac
+     *
+     * # A comma separated list of Maven versions on which this build should be run.
+     * # Since plugin version 1.5
+     * invoker.maven.version = 2.0.10+, !2.1.0, !2.2.0
+     * 
+     * # A mapping for toolchain to ensure it exists
+     * # Since plugin version 3.2.0
+     * invoker.toolchain.<type>.<provides> = value
+     * invoker.toolchain.jdk.version = 11
+     * 
+     * # For java.version, maven.version, os.family and toolchain it is possible to define multiple selectors.
+     * # If one of the indexed selectors matches, the test is executed.
+     * # With the invoker.x.y equivalents you can specify global matchers.  
+     * selector.1.java.version = 1.8+
+     * selector.1.maven.version = 3.2.5+
+     * selector.1.os.family = !windows
+     * selector.2.maven.version = 3.0+
+     * selector.3.java.version = 9+
+     * 
+     * # A boolean value controlling the debug logging level of Maven, , defaults to "false"
+     * # Since plugin version 1.8
+     * invoker.debug = true
+     * 
+     * # Path to an alternate settings.xml to use for Maven invocation with this IT.
+     * # Since plugin version 3.0.1
+     * invoker.settingsFile = ../
+     *
+     * # An integer value to control run order of projects. sorted in the descending order of the ordinal.
+     * # In other words, the BuildJobs with the highest numbers will be executed first
+     * # Since plugin version 3.2.1
+     * invoker.ordinal = 3
+     * invoker.ordinal = 1
+     *
+     * # The additional value for the environment variable.
+     * # Since plugin version 3.2.2
+     * invoker.environmentVariables.<variableName> = variableValue
+     * invoker.environmentVariables.MY_ENV_NAME = myEnvValue
+     *
+     * 
+ * + * @since 1.2 + */ + @Parameter( property = "invoker.invokerPropertiesFile", defaultValue = "invoker.properties" ) + private String invokerPropertiesFile; + + /** + * flag to enable show mvn version used for running its (cli option : -V,--show-version ) + * + * @since 1.4 + */ + @Parameter( property = "invoker.showVersion", defaultValue = "false" ) + private boolean showVersion; + + /** + *

Number of threads for running tests in parallel. This will be the number of maven forked process in parallel. + * When terminated with "C", the number part is multiplied by the number of processors (cores) available + * to the Java virtual machine. Floating point value are only accepted together with "C".

+ * + *

Example values: "1.5C", "4"

+ * + * @since 1.6 + */ + @Parameter( property = "invoker.parallelThreads", defaultValue = "1" ) + private String parallelThreads; + + /** + * @since 1.6 + */ + @Parameter( property = "plugin.artifacts", required = true, readonly = true ) + private List pluginArtifacts; + + /** + * If enable and if you have a settings file configured for the execution, it will be merged with your user + * settings. + * + * @since 1.6 + */ + @Parameter( property = "invoker.mergeUserSettings", defaultValue = "false" ) + private boolean mergeUserSettings; + + /** + * Additional environment variables to set on the command line. + * + * @since 1.8 + */ + @Parameter + private Map environmentVariables; + + /** + * Additional variables for use in the hook scripts. + * + * @since 1.9 + */ + @Parameter + private Map scriptVariables; + + /** + * + * @since 3.0.2 + */ + @Parameter( defaultValue = "0", property = "invoker.timeoutInSeconds" ) + private int timeoutInSeconds; + + /** + * Write test result in junit format. + * @since 3.1.2 + */ + @Parameter( defaultValue = "false", property = "invoker.writeJunitReport" ) + private boolean writeJunitReport; + + /** + * The package name use in junit report + * @since 3.1.2 + */ + @Parameter( defaultValue = "maven.invoker.it", property = "invoker.junitPackageName" ) + private String junitPackageName = "maven.invoker.it"; + + /** + * The scripter runner that is responsible to execute hook scripts. + */ + private ScriptRunner scriptRunner; + + /** + * A string used to prefix the file name of the filtered POMs in case the POMs couldn't be filtered in-place (i.e. + * the projects were not cloned to a temporary directory), can be null. This will be set to + * null if the POMs have already been filtered during cloning. + */ + private String filteredPomPrefix = "interpolated-"; + + /** + * The format for elapsed build time. + */ + private final DecimalFormat secFormat = new DecimalFormat( "(0.0 s)", new DecimalFormatSymbols( Locale.ENGLISH ) ); + + /** + * The version of Maven which is used to run the builds + */ + private String actualMavenVersion; + + /** + * Invokes Maven on the configured test projects. + * + * @throws org.apache.maven.plugin.MojoExecutionException If the goal encountered severe errors. + * @throws org.apache.maven.plugin.MojoFailureException If any of the Maven builds failed. + */ + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( skipInvocation ) + { + getLog().info( "Skipping invocation per configuration." + + " If this is incorrect, ensure the skipInvocation parameter is not set to true." ); + return; + } + + if ( StringUtils.isEmpty( encoding ) ) + { + getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING + + ", i.e. build is platform dependent!" ); + } + + // done it here to prevent issues with concurrent access in case of parallel run + if ( !disableReports ) + { + setupReportsFolder(); + } + + List buildJobs; + if ( pom == null ) + { + try + { + buildJobs = getBuildJobs(); + } + catch ( final IOException e ) + { + throw new MojoExecutionException( "Error retrieving POM list from includes, " + + "excludes, and projects directory. Reason: " + e.getMessage(), e ); + } + } + else + { + try + { + projectsDirectory = pom.getCanonicalFile().getParentFile(); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to discover projectsDirectory from " + + "pom File parameter. Reason: " + e.getMessage(), e ); + } + + buildJobs = Collections.singletonList( new BuildJob( pom.getName(), BuildJob.Type.NORMAL ) ); + } + + if ( buildJobs.isEmpty() ) + { + doFailIfNoProjects(); + + getLog().info( "No projects were selected for execution." ); + return; + } + + handleScriptRunnerWithScriptClassPath(); + + Collection collectedProjects = new LinkedHashSet<>(); + for ( BuildJob buildJob : buildJobs ) + { + collectProjects( projectsDirectory, buildJob.getProject(), collectedProjects, true ); + } + + File projectsDir = projectsDirectory; + + if ( cloneProjectsTo != null ) + { + cloneProjects( collectedProjects ); + projectsDir = cloneProjectsTo; + } + else if ( cloneProjectsTo == null && "maven-plugin".equals( project.getPackaging() ) ) + { + cloneProjectsTo = new File( project.getBuild().getDirectory(), "its" ); + cloneProjects( collectedProjects ); + projectsDir = cloneProjectsTo; + } + else + { + getLog().warn( "Filtering of parent/child POMs is not supported without cloning the projects" ); + } + + // First run setup jobs. + List setupBuildJobs = null; + try + { + setupBuildJobs = getSetupBuildJobsFromFolders(); + } + catch ( IOException e ) + { + getLog().error( "Failure during scanning of folders.", e ); + // TODO: Check shouldn't we fail in case of problems? + } + + if ( !setupBuildJobs.isEmpty() ) + { + // Run setup jobs in single thread + // mode. + // + // Some Idea about ordering? + getLog().info( "Running " + setupBuildJobs.size() + " setup job" + + ( ( setupBuildJobs.size() < 2 ) ? "" : "s" ) + ":" ); + runBuilds( projectsDir, setupBuildJobs, 1 ); + getLog().info( "Setup done." ); + } + + // Afterwards run all other jobs. + List nonSetupBuildJobs = getNonSetupJobs( buildJobs ); + // We will run the non setup jobs with the configured + // parallelThreads number. + runBuilds( projectsDir, nonSetupBuildJobs, getParallelThreadsCount() ); + + writeSummaryFile( nonSetupBuildJobs ); + + processResults( new InvokerSession( nonSetupBuildJobs ) ); + + } + + /** + * This will create the necessary folders for the reports. + * + * @throws MojoExecutionException in case of failure during creation of the reports folder. + */ + private void setupReportsFolder() + throws MojoExecutionException + { + // If it exists from previous run... + if ( reportsDirectory.exists() ) + { + try + { + FileUtils.deleteDirectory( reportsDirectory ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failure while trying to delete " + + reportsDirectory.getAbsolutePath(), e ); + } + } + if ( !reportsDirectory.mkdirs() ) + { + throw new MojoExecutionException( "Failure while creating the " + reportsDirectory.getAbsolutePath() ); + } + } + + private List getNonSetupJobs( List buildJobs ) + { + List result = new LinkedList<>(); + for ( BuildJob buildJob : buildJobs ) + { + if ( !buildJob.getType().equals( BuildJob.Type.SETUP ) ) + { + result.add( buildJob ); + } + } + return result; + } + + private void handleScriptRunnerWithScriptClassPath() + { + final List scriptClassPath; + if ( addTestClassPath ) + { + scriptClassPath = new ArrayList<>( testClassPath ); + for ( Artifact pluginArtifact : pluginArtifacts ) + { + scriptClassPath.remove( pluginArtifact.getFile().getAbsolutePath() ); + } + } + else + { + scriptClassPath = null; + } + scriptRunner = new ScriptRunner( getLog() ); + scriptRunner.setScriptEncoding( encoding ); + scriptRunner.setGlobalVariable( "localRepositoryPath", localRepositoryPath ); + if ( scriptVariables != null ) + { + for ( Entry entry : scriptVariables.entrySet() ) + { + scriptRunner.setGlobalVariable( entry.getKey(), entry.getValue() ); + } + } + scriptRunner.setClassPath( scriptClassPath ); + } + + private void writeSummaryFile( List buildJobs ) + throws MojoExecutionException + { + + File summaryReportFile = new File( reportsDirectory, "invoker-summary.txt" ); + + try ( Writer writer = new BufferedWriter( new FileWriter( summaryReportFile ) ) ) + { + for ( BuildJob buildJob : buildJobs ) + { + if ( !buildJob.getResult().equals( BuildJob.Result.SUCCESS ) ) + { + writer.append( buildJob.getResult() ); + writer.append( " [" ); + writer.append( buildJob.getProject() ); + writer.append( "] " ); + if ( buildJob.getFailureMessage() != null ) + { + writer.append( " " ); + writer.append( buildJob.getFailureMessage() ); + } + writer.append( "\n" ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write summary report " + summaryReportFile, e ); + } + } + + protected void doFailIfNoProjects() + throws MojoFailureException + { + // should only be used during run and verify + } + + /** + * Processes the results of invoking the build jobs. + * + * @param invokerSession The session with the build jobs, must not be null. + * @throws MojoFailureException If the mojo had failed as a result of invoking the build jobs. + * @since 1.4 + */ + abstract void processResults( InvokerSession invokerSession ) + throws MojoFailureException; + + /** + * Creates a new reader for the specified file, using the plugin's {@link #encoding} parameter. + * + * @param file The file to create a reader for, must not be null. + * @return The reader for the file, never null. + * @throws java.io.IOException If the specified file was not found or the configured encoding is not supported. + */ + private Reader newReader( File file ) + throws IOException + { + if ( StringUtils.isNotEmpty( encoding ) ) + { + return ReaderFactory.newReader( file, encoding ); + } + else + { + return ReaderFactory.newPlatformReader( file ); + } + } + + /** + * Collects all projects locally reachable from the specified project. The method will as such try to read the POM + * and recursively follow its parent/module elements. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param projectPath The relative path of the current project, can denote either the POM or its base directory, + * must not be null. + * @param projectPaths The set of already collected projects to add new projects to, must not be null. + * This set will hold the relative paths to either a POM file or a project base directory. + * @param included A flag indicating whether the specified project has been explicitly included via the parameter + * {@link #pomIncludes}. Such projects will always be added to the result set even if there is no + * corresponding POM. + * @throws org.apache.maven.plugin.MojoExecutionException If the project tree could not be traversed. + */ + private void collectProjects( File projectsDir, String projectPath, Collection projectPaths, + boolean included ) + throws MojoExecutionException + { + projectPath = projectPath.replace( '\\', '/' ); + File pomFile = new File( projectsDir, projectPath ); + if ( pomFile.isDirectory() ) + { + pomFile = new File( pomFile, "pom.xml" ); + if ( !pomFile.exists() ) + { + if ( included ) + { + projectPaths.add( projectPath ); + } + return; + } + if ( !projectPath.endsWith( "/" ) ) + { + projectPath += '/'; + } + projectPath += "pom.xml"; + } + else if ( !pomFile.isFile() ) + { + return; + } + if ( !projectPaths.add( projectPath ) ) + { + return; + } + getLog().debug( "Collecting parent/child projects of " + projectPath ); + + Model model = PomUtils.loadPom( pomFile ); + + try + { + String projectsRoot = projectsDir.getCanonicalPath(); + String projectDir = pomFile.getParent(); + + String parentPath = "../pom.xml"; + if ( model.getParent() != null && StringUtils.isNotEmpty( model.getParent().getRelativePath() ) ) + { + parentPath = model.getParent().getRelativePath(); + } + String parent = relativizePath( new File( projectDir, parentPath ), projectsRoot ); + if ( parent != null ) + { + collectProjects( projectsDir, parent, projectPaths, false ); + } + + Collection modulePaths = new LinkedHashSet<>(); + + modulePaths.addAll( model.getModules() ); + + for ( Profile profile : model.getProfiles() ) + { + modulePaths.addAll( profile.getModules() ); + } + + for ( String modulePath : modulePaths ) + { + String module = relativizePath( new File( projectDir, modulePath ), projectsRoot ); + if ( module != null ) + { + collectProjects( projectsDir, module, projectPaths, false ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to analyze POM: " + pomFile, e ); + } + } + + /** + * Copies the specified projects to the directory given by {@link #cloneProjectsTo}. A project may either be denoted + * by a path to a POM file or merely by a path to a base directory. During cloning, the POM files will be filtered. + * + * @param projectPaths The paths to the projects to clone, relative to the projects directory, must not be + * null nor contain null elements. + * @throws org.apache.maven.plugin.MojoExecutionException If the the projects could not be copied/filtered. + */ + private void cloneProjects( Collection projectPaths ) + throws MojoExecutionException + { + if ( !cloneProjectsTo.mkdirs() && cloneClean ) + { + try + { + FileUtils.cleanDirectory( cloneProjectsTo ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not clean the cloneProjectsTo directory. Reason: " + + e.getMessage(), e ); + } + } + + // determine project directories to clone + Collection dirs = new LinkedHashSet<>(); + for ( String projectPath : projectPaths ) + { + if ( !new File( projectsDirectory, projectPath ).isDirectory() ) + { + projectPath = getParentPath( projectPath ); + } + dirs.add( projectPath ); + } + + boolean filter; + + // clone project directories + try + { + filter = !cloneProjectsTo.getCanonicalFile().equals( projectsDirectory.getCanonicalFile() ); + + List clonedSubpaths = new ArrayList<>(); + + for ( String subpath : dirs ) + { + // skip this project if its parent directory is also scheduled for cloning + if ( !".".equals( subpath ) && dirs.contains( getParentPath( subpath ) ) ) + { + continue; + } + + // avoid copying subdirs that are already cloned. + if ( !alreadyCloned( subpath, clonedSubpaths ) ) + { + // avoid creating new files that point to dir/. + if ( ".".equals( subpath ) ) + { + String cloneSubdir = relativizePath( cloneProjectsTo, projectsDirectory.getCanonicalPath() ); + + // avoid infinite recursion if the cloneTo path is a subdirectory. + if ( cloneSubdir != null ) + { + File temp = File.createTempFile( "pre-invocation-clone.", "" ); + temp.delete(); + temp.mkdirs(); + + copyDirectoryStructure( projectsDirectory, temp ); + + FileUtils.deleteDirectory( new File( temp, cloneSubdir ) ); + + copyDirectoryStructure( temp, cloneProjectsTo ); + } + else + { + copyDirectoryStructure( projectsDirectory, cloneProjectsTo ); + } + } + else + { + File srcDir = new File( projectsDirectory, subpath ); + File dstDir = new File( cloneProjectsTo, subpath ); + copyDirectoryStructure( srcDir, dstDir ); + } + + clonedSubpaths.add( subpath ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to clone projects from: " + projectsDirectory + " to: " + + cloneProjectsTo + ". Reason: " + e.getMessage(), e ); + } + + // filter cloned POMs + if ( filter ) + { + for ( String projectPath : projectPaths ) + { + File pomFile = new File( cloneProjectsTo, projectPath ); + if ( pomFile.isFile() ) + { + buildInterpolatedFile( pomFile, pomFile ); + } + + // MINVOKER-186 + // The following is a temporary solution to support Maven 3.3.1 (.mvn/extensions.xml) filtering + // Will be replaced by MINVOKER-117 with general filtering mechanism + File baseDir = pomFile.getParentFile(); + File mvnDir = new File( baseDir, ".mvn" ); + if ( mvnDir.isDirectory() ) + { + File extensionsFile = new File( mvnDir, "extensions.xml" ); + if ( extensionsFile.isFile() ) + { + buildInterpolatedFile( extensionsFile, extensionsFile ); + } + } + // END MINVOKER-186 + } + filteredPomPrefix = null; + } + } + + /** + * Gets the parent path of the specified relative path. + * + * @param path The relative path whose parent should be retrieved, must not be null. + * @return The parent path or "." if the specified path has no parent, never null. + */ + private String getParentPath( String path ) + { + int lastSep = Math.max( path.lastIndexOf( '/' ), path.lastIndexOf( '\\' ) ); + return ( lastSep < 0 ) ? "." : path.substring( 0, lastSep ); + } + + /** + * Copied a directory structure with default exclusions (.svn, CVS, etc) + * + * @param sourceDir The source directory to copy, must not be null. + * @param destDir The target directory to copy to, must not be null. + * @throws java.io.IOException If the directory structure could not be copied. + */ + private void copyDirectoryStructure( File sourceDir, File destDir ) + throws IOException + { + DirectoryScanner scanner = new DirectoryScanner(); + scanner.setBasedir( sourceDir ); + if ( !cloneAllFiles ) + { + scanner.addDefaultExcludes(); + } + scanner.scan(); + + /* + * NOTE: Make sure the destination directory is always there (even if empty) to support POM-less ITs. + */ + destDir.mkdirs(); + // Create all the directories, including any symlinks present in source + FileUtils.mkDirs( sourceDir, scanner.getIncludedDirectories(), destDir ); + + for ( String includedFile : scanner.getIncludedFiles() ) + { + File sourceFile = new File( sourceDir, includedFile ); + File destFile = new File( destDir, includedFile ); + FileUtils.copyFile( sourceFile, destFile ); + + // ensure clone project must be writable for additional changes + destFile.setWritable( true ); + } + } + + /** + * Determines whether the specified sub path has already been cloned, i.e. whether one of its ancestor directories + * was already cloned. + * + * @param subpath The sub path to check, must not be null. + * @param clonedSubpaths The list of already cloned paths, must not be null nor contain + * null elements. + * @return true if the specified path has already been cloned, false otherwise. + */ + static boolean alreadyCloned( String subpath, List clonedSubpaths ) + { + for ( String path : clonedSubpaths ) + { + if ( ".".equals( path ) || subpath.equals( path ) || subpath.startsWith( path + File.separator ) ) + { + return true; + } + } + + return false; + } + + /** + * Runs the specified build jobs. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param buildJobs The build jobs to run must not be null nor contain null elements. + * @throws org.apache.maven.plugin.MojoExecutionException If any build could not be launched. + */ + private void runBuilds( final File projectsDir, List buildJobs, int runWithParallelThreads ) + throws MojoExecutionException + { + if ( !localRepositoryPath.exists() ) + { + localRepositoryPath.mkdirs(); + } + + // ----------------------------------------------- + // interpolate settings file + // ----------------------------------------------- + + File interpolatedSettingsFile = interpolateSettings( settingsFile ); + + final File mergedSettingsFile = mergeSettings( interpolatedSettingsFile ); + + if ( mavenHome != null ) + { + actualMavenVersion = SelectorUtils.getMavenVersion( mavenHome ); + } + else + { + actualMavenVersion = SelectorUtils.getMavenVersion(); + } + scriptRunner.setGlobalVariable( "mavenVersion", actualMavenVersion ); + + final CharSequence actualJreVersion; + // @todo if ( javaVersions ) ... to be picked up from toolchains + if ( javaHome != null ) + { + actualJreVersion = resolveExternalJreVersion(); + } + else + { + actualJreVersion = SelectorUtils.getJreVersion(); + } + + final Path projectsPath = this.projectsDirectory.toPath(); + + Set folderGroupSet = new HashSet<>(); + folderGroupSet.add( Paths.get( "." ) ); + for ( BuildJob buildJob : buildJobs ) + { + Path p = Paths.get( buildJob.getProject() ); + + if ( Files.isRegularFile( projectsPath.resolve( p ) ) ) + { + p = p.getParent(); + } + + if ( p != null ) + { + p = p.getParent(); + } + + while ( p != null && folderGroupSet.add( p ) ) + { + p = p.getParent(); + } + } + + List folderGroup = new ArrayList<>( folderGroupSet ); + Collections.sort( folderGroup ); + + final Map globalInvokerProperties = new HashMap<>(); + + for ( Path path : folderGroup ) + { + Properties ancestorProperties = globalInvokerProperties.get( projectsPath.resolve( path ).getParent() ); + + Path currentInvokerProperties = projectsPath.resolve( path ).resolve( invokerPropertiesFile ); + + Properties currentProperties; + if ( Files.isRegularFile( currentInvokerProperties ) ) + { + if ( ancestorProperties != null ) + { + currentProperties = new Properties( ancestorProperties ); + + } + else + { + currentProperties = new Properties(); + } + } + else + { + currentProperties = ancestorProperties; + } + + if ( Files.isRegularFile( currentInvokerProperties ) ) + { + try ( InputStream in = new FileInputStream( currentInvokerProperties.toFile() ) ) + { + currentProperties.load( in ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read invoker properties: " + + currentInvokerProperties ); + } + } + + if ( currentProperties != null ) + { + globalInvokerProperties.put( projectsPath.resolve( path ).normalize(), currentProperties ); + } + } + + try + { + if ( runWithParallelThreads > 1 ) + { + getLog().info( "use parallelThreads " + runWithParallelThreads ); + + ExecutorService executorService = Executors.newFixedThreadPool( runWithParallelThreads ); + for ( final BuildJob job : buildJobs ) + { + executorService.execute( new Runnable() + { + public void run() + { + try + { + Path ancestorFolder = getAncestorFolder( projectsPath.resolve( job.getProject() ) ); + + runBuild( projectsDir, job, mergedSettingsFile, javaHome, actualJreVersion, + globalInvokerProperties.get( ancestorFolder ) ); + } + catch ( MojoExecutionException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + } + } ); + } + + try + { + executorService.shutdown(); + // TODO add a configurable time out + executorService.awaitTermination( Long.MAX_VALUE, TimeUnit.MILLISECONDS ); + } + catch ( InterruptedException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } + else + { + for ( BuildJob job : buildJobs ) + { + Path ancestorFolder = getAncestorFolder( projectsPath.resolve( job.getProject() ) ); + + runBuild( projectsDir, job, mergedSettingsFile, javaHome, actualJreVersion, + globalInvokerProperties.get( ancestorFolder ) ); + } + } + } + finally + { + if ( interpolatedSettingsFile != null && cloneProjectsTo == null ) + { + interpolatedSettingsFile.delete(); + } + if ( mergedSettingsFile != null && mergedSettingsFile.exists() ) + { + mergedSettingsFile.delete(); + } + } + } + + private Path getAncestorFolder( Path p ) + { + Path ancestor = p; + if ( Files.isRegularFile( ancestor ) ) + { + ancestor = ancestor.getParent(); + } + if ( ancestor != null ) + { + ancestor = ancestor.getParent(); + } + return ancestor; + } + + /** + * Interpolate settings.xml file. + * @param settingsFile a settings file + * + * @return The interpolated settings.xml file. + * @throws MojoExecutionException in case of a problem. + */ + private File interpolateSettings( File settingsFile ) + throws MojoExecutionException + { + File interpolatedSettingsFile = null; + if ( settingsFile != null ) + { + if ( cloneProjectsTo != null ) + { + interpolatedSettingsFile = new File( cloneProjectsTo, "interpolated-" + settingsFile.getName() ); + } + else + { + interpolatedSettingsFile = + new File( settingsFile.getParentFile(), "interpolated-" + settingsFile.getName() ); + } + buildInterpolatedFile( settingsFile, interpolatedSettingsFile ); + } + return interpolatedSettingsFile; + } + + /** + * Merge the settings file + * + * @param interpolatedSettingsFile The interpolated settings file. + * @return The merged settings file. + * @throws MojoExecutionException Fail the build in case the merged settings file can't be created. + */ + private File mergeSettings( File interpolatedSettingsFile ) + throws MojoExecutionException + { + File mergedSettingsFile; + Settings mergedSettings = this.settings; + if ( mergeUserSettings ) + { + if ( interpolatedSettingsFile != null ) + { + // Have to merge the specified settings file (dominant) and the one of the invoking Maven process + try + { + SettingsBuildingRequest request = new DefaultSettingsBuildingRequest(); + request.setGlobalSettingsFile( interpolatedSettingsFile ); + + Settings dominantSettings = settingsBuilder.build( request ).getEffectiveSettings(); + Settings recessiveSettings = cloneSettings(); + SettingsUtils.merge( dominantSettings, recessiveSettings, TrackableBase.USER_LEVEL ); + + mergedSettings = dominantSettings; + getLog().debug( "Merged specified settings file with settings of invoking process" ); + } + catch ( SettingsBuildingException e ) + { + throw new MojoExecutionException( "Could not read specified settings file", e ); + } + } + } + + if ( this.settingsFile != null && !mergeUserSettings ) + { + mergedSettingsFile = interpolatedSettingsFile; + } + else + { + try + { + mergedSettingsFile = writeMergedSettingsFile( mergedSettings ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not create temporary file for invoker settings.xml", e ); + } + } + return mergedSettingsFile; + } + + private File writeMergedSettingsFile( Settings mergedSettings ) + throws IOException + { + File mergedSettingsFile; + mergedSettingsFile = File.createTempFile( "invoker-settings", ".xml" ); + + SettingsXpp3Writer settingsWriter = new SettingsXpp3Writer(); + + + try ( FileWriter fileWriter = new FileWriter( mergedSettingsFile ) ) + { + settingsWriter.write( fileWriter, mergedSettings ); + } + + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Created temporary file for invoker settings.xml: " + + mergedSettingsFile.getAbsolutePath() ); + } + return mergedSettingsFile; + } + + private Settings cloneSettings() + { + Settings recessiveSettings = SettingsUtils.copySettings( this.settings ); + + // MINVOKER-133: reset sourceLevelSet + resetSourceLevelSet( recessiveSettings ); + for ( org.apache.maven.settings.Mirror mirror : recessiveSettings.getMirrors() ) + { + resetSourceLevelSet( mirror ); + } + for ( org.apache.maven.settings.Server server : recessiveSettings.getServers() ) + { + resetSourceLevelSet( server ); + } + for ( org.apache.maven.settings.Proxy proxy : recessiveSettings.getProxies() ) + { + resetSourceLevelSet( proxy ); + } + for ( org.apache.maven.settings.Profile profile : recessiveSettings.getProfiles() ) + { + resetSourceLevelSet( profile ); + } + + return recessiveSettings; + } + + private void resetSourceLevelSet( org.apache.maven.settings.TrackableBase trackable ) + { + try + { + ReflectionUtils.setVariableValueInObject( trackable, "sourceLevelSet", Boolean.FALSE ); + getLog().debug( "sourceLevelSet: " + + ReflectionUtils.getValueIncludingSuperclasses( "sourceLevelSet", trackable ) ); + } + catch ( IllegalAccessException e ) + { + // noop + } + } + + private CharSequence resolveExternalJreVersion() + { + Artifact pluginArtifact = mojoExecution.getMojoDescriptor().getPluginDescriptor().getPluginArtifact(); + pluginArtifact.getFile(); + + Commandline commandLine = new Commandline(); + commandLine.setExecutable( new File( javaHome, "bin/java" ).getAbsolutePath() ); + commandLine.createArg().setValue( "-cp" ); + commandLine.createArg().setFile( pluginArtifact.getFile() ); + commandLine.createArg().setValue( SystemPropertyPrinter.class.getName() ); + commandLine.createArg().setValue( "java.version" ); + + final StringBuilder actualJreVersion = new StringBuilder(); + StreamConsumer consumer = new StreamConsumer() + { + public void consumeLine( String line ) + { + actualJreVersion.append( line ); + } + }; + try + { + CommandLineUtils.executeCommandLine( commandLine, consumer, null ); + } + catch ( CommandLineException e ) + { + getLog().warn( e.getMessage() ); + } + return actualJreVersion; + } + + /** + * Interpolate the pom file. + * + * @param pomFile The pom file. + * @param basedir The base directory. + * @return interpolated pom file location in case we have interpolated the pom file otherwise the original pom file + * will be returned. + * @throws MojoExecutionException + */ + private File interpolatePomFile( File pomFile, File basedir ) + throws MojoExecutionException + { + File interpolatedPomFile = null; + if ( pomFile != null ) + { + if ( StringUtils.isNotEmpty( filteredPomPrefix ) ) + { + interpolatedPomFile = new File( basedir, filteredPomPrefix + pomFile.getName() ); + buildInterpolatedFile( pomFile, interpolatedPomFile ); + } + else + { + interpolatedPomFile = pomFile; + } + } + return interpolatedPomFile; + } + + /** + * Runs the specified project. + * + * @param projectsDir The base directory of all projects, must not be null. + * @param buildJob The build job to run, must not be null. + * @param settingsFile The (already interpolated) user settings file for the build, may be null to use + * the current user settings. + * @param globalInvokerProperties + * @throws org.apache.maven.plugin.MojoExecutionException If the project could not be launched. + */ + private void runBuild( File projectsDir, BuildJob buildJob, File settingsFile, File actualJavaHome, + CharSequence actualJreVersion, Properties globalInvokerProperties ) + throws MojoExecutionException + { + // FIXME: Think about the following code part -- START + File pomFile = new File( projectsDir, buildJob.getProject() ); + File basedir; + if ( pomFile.isDirectory() ) + { + basedir = pomFile; + pomFile = new File( basedir, "pom.xml" ); + if ( !pomFile.exists() ) + { + pomFile = null; + } + else + { + buildJob.setProject( buildJob.getProject() + File.separator + "pom.xml" ); + } + } + else + { + basedir = pomFile.getParentFile(); + } + + File interpolatedPomFile = interpolatePomFile( pomFile, basedir ); + // FIXME: Think about the following code part -- ^^^^^^^ END + + getLog().info( buffer().a( "Building: " ).strong( buildJob.getProject() ).toString() ); + + InvokerProperties invokerProperties = getInvokerProperties( basedir, globalInvokerProperties ); + + // let's set what details we can + buildJob.setName( invokerProperties.getJobName() ); + buildJob.setDescription( invokerProperties.getJobDescription() ); + + try + { + int selection = getSelection( invokerProperties, actualJreVersion ); + if ( selection == 0 ) + { + long milliseconds = System.currentTimeMillis(); + boolean executed; + + FileLogger buildLogger = setupBuildLogFile( basedir ); + if ( buildLogger != null ) + { + buildJob.setBuildlog( buildLogger.getOutputFile().getAbsolutePath() ); + } + + try + { + executed = runBuild( basedir, interpolatedPomFile, settingsFile, actualJavaHome, + invokerProperties, buildLogger ); + } + finally + { + milliseconds = System.currentTimeMillis() - milliseconds; + buildJob.setTime( milliseconds / 1000.0 ); + + if ( buildLogger != null ) + { + buildLogger.close(); + } + } + + if ( executed ) + { + buildJob.setResult( BuildJob.Result.SUCCESS ); + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).success( "SUCCESS" ).a( ' ' ) + + formatTime( buildJob.getTime() ) ); + } + } + else + { + buildJob.setResult( BuildJob.Result.SKIPPED ); + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).warning( "SKIPPED" ).a( ' ' ) + + formatTime( buildJob.getTime() ) ); + } + } + } + else + { + buildJob.setResult( BuildJob.Result.SKIPPED ); + + StringBuilder message = new StringBuilder(); + if ( selection == Selector.SELECTOR_MULTI ) + { + message.append( "non-matching selectors" ); + } + else + { + if ( ( selection & Selector.SELECTOR_MAVENVERSION ) != 0 ) + { + message.append( "Maven version" ); + } + if ( ( selection & Selector.SELECTOR_JREVERSION ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "JRE version" ); + } + if ( ( selection & Selector.SELECTOR_OSFAMILY ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "OS" ); + } + if ( ( selection & Selector.SELECTOR_TOOLCHAIN ) != 0 ) + { + if ( message.length() > 0 ) + { + message.append( ", " ); + } + message.append( "Toolchain" ); + } + } + + if ( !suppressSummaries ) + { + getLog().info( pad( buildJob ).warning( "SKIPPED" ) + " due to " + message.toString() ); + } + + // Abuse failureMessage, the field in the report which should contain the reason for skipping + // Consider skipCode + I18N + buildJob.setFailureMessage( "Skipped due to " + message.toString() ); + } + } + catch ( RunErrorException e ) + { + buildJob.setResult( BuildJob.Result.ERROR ); + buildJob.setFailureMessage( e.getMessage() ); + + if ( !suppressSummaries ) + { + getLog().info( " " + e.getMessage() ); + getLog().info( pad( buildJob ).failure( "ERROR" ).a( ' ' ) + formatTime( buildJob.getTime() ) ); + } + } + catch ( RunFailureException e ) + { + buildJob.setResult( e.getType() ); + buildJob.setFailureMessage( e.getMessage() ); + + if ( !suppressSummaries ) + { + getLog().info( " " + e.getMessage() ); + getLog().info( pad( buildJob ).failure( "FAILED" ).a( ' ' ) + formatTime( buildJob.getTime() ) ); + } + } + finally + { + deleteInterpolatedPomFile( interpolatedPomFile ); + writeBuildReport( buildJob ); + } + } + + private MessageBuilder pad( BuildJob buildJob ) + { + MessageBuilder buffer = buffer( 128 ); + + buffer.a( " " ); + buffer.a( buildJob.getProject() ); + + int l = 10 + buildJob.getProject().length(); + + if ( l < RESULT_COLUMN ) + { + buffer.a( ' ' ); + l++; + + if ( l < RESULT_COLUMN ) + { + for ( int i = RESULT_COLUMN - l; i > 0; i-- ) + { + buffer.a( '.' ); + } + } + } + + return buffer.a( ' ' ); + } + + /** + * Delete the interpolated pom file if it has been created before. + * + * @param interpolatedPomFile The interpolated pom file. + */ + private void deleteInterpolatedPomFile( File interpolatedPomFile ) + { + if ( interpolatedPomFile != null && StringUtils.isNotEmpty( filteredPomPrefix ) ) + { + interpolatedPomFile.delete(); + } + } + + /** + * Determines whether selector conditions of the specified invoker properties match the current environment. + * + * @param invokerProperties The invoker properties to check, must not be null. + * @return 0 if the job corresponding to the properties should be run, otherwise a bitwise value + * representing the reason why it should be skipped. + */ + private int getSelection( InvokerProperties invokerProperties, CharSequence actualJreVersion ) + { + return new Selector( actualMavenVersion, actualJreVersion.toString(), + getToolchainPrivateManager() ).getSelection( invokerProperties ); + } + + private ToolchainPrivateManager getToolchainPrivateManager() + { + return new ToolchainPrivateManager( toolchainManagerPrivate, session ); + } + + /** + * Writes the XML report for the specified build job unless report generation has been disabled. + * + * @param buildJob The build job whose report should be written, must not be null. + * @throws org.apache.maven.plugin.MojoExecutionException If the report could not be written. + */ + private void writeBuildReport( BuildJob buildJob ) + throws MojoExecutionException + { + if ( disableReports ) + { + return; + } + + String safeFileName = buildJob.getProject().replace( '/', '_' ).replace( '\\', '_' ).replace( ' ', '_' ); + if ( safeFileName.endsWith( "_pom.xml" ) ) + { + safeFileName = safeFileName.substring( 0, safeFileName.length() - "_pom.xml".length() ); + } + + File reportFile = new File( reportsDirectory, "BUILD-" + safeFileName + ".xml" ); + try ( FileOutputStream fos = new FileOutputStream( reportFile ); + Writer osw = new OutputStreamWriter( fos, buildJob.getModelEncoding() ) ) + { + BuildJobXpp3Writer writer = new BuildJobXpp3Writer(); + + writer.write( osw, buildJob ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write build report " + reportFile, e ); + } + + if ( writeJunitReport ) + { + writeJunitReport( buildJob, safeFileName ); + } + } + + private void writeJunitReport( BuildJob buildJob, String safeFileName ) + throws MojoExecutionException + { + File reportFile = new File( reportsDirectory, "TEST-" + safeFileName + ".xml" ); + Xpp3Dom testsuite = new Xpp3Dom( "testsuite" ); + testsuite.setAttribute( "name", junitPackageName + "." + safeFileName ); + testsuite.setAttribute( "time", Double.toString( buildJob.getTime() ) ); + + // set default value for required attributes + testsuite.setAttribute( "tests", "1" ); + testsuite.setAttribute( "errors", "0" ); + testsuite.setAttribute( "skipped", "0" ); + testsuite.setAttribute( "failures", "0" ); + + Xpp3Dom testcase = new Xpp3Dom( "testcase" ); + testsuite.addChild( testcase ); + switch ( buildJob.getResult() ) + { + case BuildJob.Result.SUCCESS: + break; + case BuildJob.Result.SKIPPED: + testsuite.setAttribute( "skipped", "1" ); + // adding the failure element + Xpp3Dom skipped = new Xpp3Dom( "skipped" ); + testcase.addChild( skipped ); + skipped.setValue( buildJob.getFailureMessage() ); + break; + case BuildJob.Result.ERROR: + testsuite.setAttribute( "errors", "1" ); + break; + default: + testsuite.setAttribute( "failures", "1" ); + // adding the failure element + Xpp3Dom failure = new Xpp3Dom( "failure" ); + testcase.addChild( failure ); + failure.setAttribute( "message", buildJob.getFailureMessage() ); + } + testcase.setAttribute( "classname", junitPackageName + "." + safeFileName ); + testcase.setAttribute( "name", safeFileName ); + testcase.setAttribute( "time", Double.toString( buildJob.getTime() ) ); + Xpp3Dom systemOut = new Xpp3Dom( "system-out" ); + testcase.addChild( systemOut ); + + + File buildLogFile = buildJob.getBuildlog() != null ? new File( buildJob.getBuildlog() ) : null; + + if ( buildLogFile != null && buildLogFile.exists() ) + { + getLog().debug( "fileLogger:" + buildLogFile ); + try + { + systemOut.setValue( FileUtils.fileRead( buildLogFile ) ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read logfile " + buildLogFile, e ); + } + } + else + { + getLog().debug( safeFileName + "not exists buildLogFile = " + buildLogFile ); + } + + try ( FileOutputStream fos = new FileOutputStream( reportFile ); + Writer osw = new OutputStreamWriter( fos, buildJob.getModelEncoding() ) ) + { + Xpp3DomWriter.write( osw, testsuite ); + } catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to write JUnit build report " + reportFile, e ); + } + } + + /** + * Formats the specified build duration time. + * + * @param seconds The duration of the build. + * @return The formatted time, never null. + */ + private String formatTime( double seconds ) + { + return secFormat.format( seconds ); + } + + /** + * Runs the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @param pomFile The (already interpolated) POM file, may be null for a POM-less Maven invocation. + * @param settingsFile The (already interpolated) user settings file for the build, may be null. Will + * be merged with the settings file of the invoking Maven process. + * @param invokerProperties The properties to use. + * @param logger file logger to write execution build.log + * @return true if the project was launched or false if the selector script indicated that + * the project should be skipped. + * @throws org.apache.maven.plugin.MojoExecutionException If the project could not be launched. + * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException If either a hook script or the build itself + * failed. + */ + private boolean runBuild( File basedir, File pomFile, File settingsFile, File actualJavaHome, + InvokerProperties invokerProperties, FileLogger logger ) + throws MojoExecutionException, RunFailureException + { + if ( getLog().isDebugEnabled() && !invokerProperties.getProperties().isEmpty() ) + { + Properties props = invokerProperties.getProperties(); + getLog().debug( "Using invoker properties:" ); + for ( String key : new TreeSet( props.stringPropertyNames() ) ) + { + String value = props.getProperty( key ); + getLog().debug( " " + key + " = " + value ); + } + } + + List goals = getGoals( basedir ); + + List profiles = getProfiles( basedir ); + + Map context = new LinkedHashMap<>(); + + boolean selectorResult = true; + + try + { + try + { + scriptRunner.run( "selector script", basedir, selectorScript, context, logger, BuildJob.Result.SKIPPED, + false ); + } + catch ( RunErrorException e ) + { + selectorResult = false; + throw e; + } + catch ( RunFailureException e ) + { + selectorResult = false; + return false; + } + + scriptRunner.run( "pre-build script", basedir, preBuildHookScript, context, logger, + BuildJob.Result.FAILURE_PRE_HOOK, false ); + + final InvocationRequest request = new DefaultInvocationRequest(); + + request.setLocalRepositoryDirectory( localRepositoryPath ); + + request.setBatchMode( true ); + + request.setShowErrors( showErrors ); + + request.setDebug( debug ); + + request.setShowVersion( showVersion ); + + setupLoggerForBuildJob( logger, request ); + + if ( mavenHome != null ) + { + invoker.setMavenHome( mavenHome ); + // FIXME: Should we really take care of M2_HOME? + request.addShellEnvironment( "M2_HOME", mavenHome.getAbsolutePath() ); + } + + if ( mavenExecutable != null ) + { + invoker.setMavenExecutable( new File( mavenExecutable ) ); + } + + if ( actualJavaHome != null ) + { + request.setJavaHome( actualJavaHome ); + } + + if ( environmentVariables != null ) + { + for ( Map.Entry variable : environmentVariables.entrySet() ) + { + request.addShellEnvironment( variable.getKey(), variable.getValue() ); + } + } + + for ( int invocationIndex = 1;; invocationIndex++ ) + { + if ( invocationIndex > 1 && !invokerProperties.isInvocationDefined( invocationIndex ) ) + { + break; + } + + request.setBaseDirectory( basedir ); + + request.setPomFile( pomFile ); + + request.setGoals( goals ); + + request.setProfiles( profiles ); + + request.setMavenOpts( mavenOpts ); + + request.setOffline( false ); + + int timeOut = invokerProperties.getTimeoutInSeconds( invocationIndex ); + // not set so we use the one at the mojo level + request.setTimeoutInSeconds( timeOut < 0 ? timeoutInSeconds : timeOut ); + + String customSettingsFile = invokerProperties.getSettingsFile( invocationIndex ); + if ( customSettingsFile != null ) + { + File interpolateSettingsFile = interpolateSettings( new File( customSettingsFile ) ); + File mergeSettingsFile = mergeSettings( interpolateSettingsFile ); + + request.setUserSettingsFile( mergeSettingsFile ); + } + else + { + request.setUserSettingsFile( settingsFile ); + } + + Properties systemProperties = + getSystemProperties( basedir, invokerProperties.getSystemPropertiesFile( invocationIndex ) ); + request.setProperties( systemProperties ); + + invokerProperties.configureInvocation( request, invocationIndex ); + + if ( getLog().isDebugEnabled() ) + { + try + { + getLog().debug( "Using MAVEN_OPTS: " + request.getMavenOpts() ); + getLog().debug( "Executing: " + new MavenCommandLineBuilder().build( request ) ); + } + catch ( CommandLineConfigurationException e ) + { + getLog().debug( "Failed to display command line: " + e.getMessage() ); + } + } + + try + { + InvocationResult result = invoker.execute( request ); + verify( result, invocationIndex, invokerProperties, logger ); + } + catch ( final MavenInvocationException e ) + { + getLog().debug( "Error invoking Maven: " + e.getMessage(), e ); + throw new RunFailureException( "Maven invocation failed. " + e.getMessage(), + BuildJob.Result.FAILURE_BUILD ); + } + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + finally + { + if ( selectorResult ) + { + runPostBuildHook( basedir, context, logger ); + } + } + return true; + } + + int getParallelThreadsCount() + { + if ( parallelThreads.endsWith( "C" ) ) + { + double parallelThreadsMultiple = Double.parseDouble( + parallelThreads.substring( 0, parallelThreads.length() - 1 ) ); + return (int) ( parallelThreadsMultiple * Runtime.getRuntime().availableProcessors() ); + } + else + { + return Integer.parseInt( parallelThreads ); + } + } + + private void runPostBuildHook( File basedir, Map context, FileLogger logger ) + throws MojoExecutionException, RunFailureException + { + try + { + scriptRunner.run( "post-build script", basedir, postBuildHookScript, context, logger, + BuildJob.Result.FAILURE_POST_HOOK, true ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } + private void setupLoggerForBuildJob( FileLogger logger, final InvocationRequest request ) + { + if ( logger != null ) + { + request.setErrorHandler( logger ); + + request.setOutputHandler( logger ); + } + } + + /** + * Initializes the build logger for the specified project. This will write the logging information into + * {@code build.log}. + * + * @param basedir The base directory of the project, must not be null. + * @return The build logger or null if logging has been disabled. + * @throws org.apache.maven.plugin.MojoExecutionException If the log file could not be created. + */ + private FileLogger setupBuildLogFile( File basedir ) + throws MojoExecutionException + { + FileLogger logger = null; + + if ( !noLog ) + { + Path projectLogDirectory; + if ( logDirectory == null ) + { + projectLogDirectory = basedir.toPath(); + } + else if ( cloneProjectsTo != null ) + { + projectLogDirectory = + logDirectory.toPath().resolve( cloneProjectsTo.toPath().relativize( basedir.toPath() ) ); + } + else + { + projectLogDirectory = + logDirectory.toPath().resolve( projectsDirectory.toPath().relativize( basedir.toPath() ) ); + } + + try + { + if ( streamLogs ) + { + logger = new FileLogger( projectLogDirectory.resolve( "build.log" ).toFile(), getLog() ); + } + else + { + logger = new FileLogger( projectLogDirectory.resolve( "build.log" ).toFile() ); + } + + getLog().debug( "Build log initialized in: " + projectLogDirectory ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error initializing build logfile in: " + projectLogDirectory, e ); + } + } + + return logger; + } + + /** + * Gets the system properties to use for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @param filename The filename to the properties file to load, may be null to use the default path + * given by {@link #testPropertiesFile}. + * @return The system properties to use, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the properties file exists but could not be read. + */ + private Properties getSystemProperties( final File basedir, final String filename ) + throws MojoExecutionException + { + Properties collectedTestProperties = new Properties(); + + if ( properties != null ) + { + // MINVOKER-118: property can have empty value, which is not accepted by collectedTestProperties + for ( Map.Entry entry : properties.entrySet() ) + { + if ( entry.getValue() != null ) + { + collectedTestProperties.put( entry.getKey(), entry.getValue() ); + } + } + } + + File propertiesFile = null; + if ( filename != null ) + { + propertiesFile = new File( basedir, filename ); + } + else if ( testPropertiesFile != null ) + { + propertiesFile = new File( basedir, testPropertiesFile ); + } + + if ( propertiesFile != null && propertiesFile.isFile() ) + { + + try ( InputStream fin = new FileInputStream( propertiesFile ) ) + { + Properties loadedProperties = new Properties(); + loadedProperties.load( fin ); + collectedTestProperties.putAll( loadedProperties ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error reading system properties from " + propertiesFile ); + } + } + + return collectedTestProperties; + } + + /** + * Verifies the invocation result. + * + * @param result The invocation result to check, must not be null. + * @param invocationIndex The index of the invocation for which to check the exit code, must not be negative. + * @param invokerProperties The invoker properties used to check the exit code, must not be null. + * @param logger The build logger, may be null if logging is disabled. + * @throws org.apache.maven.shared.scriptinterpreter.RunFailureException If the invocation result indicates a build + * failure. + */ + private void verify( InvocationResult result, int invocationIndex, InvokerProperties invokerProperties, + FileLogger logger ) + throws RunFailureException + { + if ( result.getExecutionException() != null ) + { + throw new RunFailureException( "The Maven invocation failed. " + + result.getExecutionException().getMessage(), BuildJob.Result.ERROR ); + } + else if ( !invokerProperties.isExpectedResult( result.getExitCode(), invocationIndex ) ) + { + StringBuilder buffer = new StringBuilder( 256 ); + buffer.append( "The build exited with code " ).append( result.getExitCode() ).append( ". " ); + if ( logger != null ) + { + buffer.append( "See " ); + buffer.append( logger.getOutputFile().getAbsolutePath() ); + buffer.append( " for details." ); + } + else + { + buffer.append( "See console output for details." ); + } + throw new RunFailureException( buffer.toString(), BuildJob.Result.FAILURE_BUILD ); + } + } + + /** + * Gets the goal list for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @return The list of goals to run when building the project, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the profile file could not be read. + */ + List getGoals( final File basedir ) + throws MojoExecutionException + { + try + { + // FIXME: Currently we have null for goalsFile which has been removed. + // This might mean we can remove getGoals() at all ? Check this. + return getTokens( basedir, null, goals ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "error reading goals", e ); + } + } + + /** + * Gets the profile list for the specified project. + * + * @param basedir The base directory of the project, must not be null. + * @return The list of profiles to activate when building the project, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If the profile file could not be read. + */ + List getProfiles( File basedir ) + throws MojoExecutionException + { + try + { + return getTokens( basedir, null, profiles ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "error reading profiles", e ); + } + } + + private List calculateExcludes() + throws IOException + { + List excludes = + ( pomExcludes != null ) ? new ArrayList<>( pomExcludes ) : new ArrayList(); + if ( this.settingsFile != null ) + { + String exclude = relativizePath( this.settingsFile, projectsDirectory.getCanonicalPath() ); + if ( exclude != null ) + { + excludes.add( exclude.replace( '\\', '/' ) ); + getLog().debug( "Automatically excluded " + exclude + " from project scanning" ); + } + } + return excludes; + + } + + /** + * @return The list of setupUp jobs. + * @throws IOException + * @see {@link #setupIncludes} + */ + private List getSetupBuildJobsFromFolders() + throws IOException, MojoExecutionException + { + List excludes = calculateExcludes(); + + List setupPoms = scanProjectsDirectory( setupIncludes, excludes, BuildJob.Type.SETUP ); + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Setup projects: " + setupPoms ); + } + + return setupPoms; + } + + private static class OrdinalComparator implements Comparator + { + private static final OrdinalComparator INSTANCE = new OrdinalComparator(); + + @Override + public int compare( Object o1, Object o2 ) + { + return Integer.compare( ( ( BuildJob ) o2 ).getOrdinal(), ( ( BuildJob ) o1 ).getOrdinal() ); + } + } + + /** + * Gets the build jobs that should be processed. Note that the order of the returned build jobs is significant. + * + * @return The build jobs to process, may be empty but never null. + * @throws java.io.IOException If the projects directory could not be scanned. + */ + List getBuildJobs() + throws IOException, MojoExecutionException + { + List buildJobs; + + if ( invokerTest == null ) + { + List excludes = calculateExcludes(); + + List setupPoms = scanProjectsDirectory( setupIncludes, excludes, BuildJob.Type.SETUP ); + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Setup projects: " + Arrays.asList( setupPoms ) ); + } + + List normalPoms = scanProjectsDirectory( pomIncludes, excludes, BuildJob.Type.NORMAL ); + + Map uniquePoms = new LinkedHashMap<>(); + for ( BuildJob setupPom : setupPoms ) + { + uniquePoms.put( setupPom.getProject(), setupPom ); + } + for ( BuildJob normalPom : normalPoms ) + { + if ( !uniquePoms.containsKey( normalPom.getProject() ) ) + { + uniquePoms.put( normalPom.getProject(), normalPom ); + } + } + + buildJobs = new ArrayList<>( uniquePoms.values() ); + } + else + { + String[] testRegexes = StringUtils.split( invokerTest, "," ); + List includes = new ArrayList<>( testRegexes.length ); + List excludes = new ArrayList<>(); + + for ( String regex : testRegexes ) + { + // user just use -Dinvoker.test=MWAR191,MNG111 to use a directory thats the end is not pom.xml + if ( regex.startsWith( "!" ) ) + { + excludes.add( regex.substring( 1 ) ); + } + else + { + includes.add( regex ); + } + } + + // it would be nice if we could figure out what types these are... but perhaps + // not necessary for the -Dinvoker.test=xxx t + buildJobs = scanProjectsDirectory( includes, excludes, BuildJob.Type.DIRECT ); + } + + relativizeProjectPaths( buildJobs ); + + return buildJobs; + } + + /** + * Scans the projects directory for projects to build. Both (POM) files and mere directories will be matched by the + * scanner patterns. If the patterns match a directory which contains a file named "pom.xml", the results will + * include the path to this file rather than the directory path in order to avoid duplicate invocations of the same + * project. + * + * @param includes The include patterns for the scanner, may be null. + * @param excludes The exclude patterns for the scanner, may be null to exclude nothing. + * @param type The type to assign to the resulting build jobs, must not be null. + * @return The build jobs matching the patterns, never null. + * @throws java.io.IOException If the project directory could not be scanned. + */ + private List scanProjectsDirectory( List includes, List excludes, String type ) + throws IOException, MojoExecutionException + { + if ( !projectsDirectory.isDirectory() ) + { + return Collections.emptyList(); + } + + DirectoryScanner scanner = new DirectoryScanner(); + scanner.setBasedir( projectsDirectory.getCanonicalFile() ); + scanner.setFollowSymlinks( false ); + if ( includes != null ) + { + scanner.setIncludes( includes.toArray( new String[includes.size()] ) ); + } + if ( excludes != null ) + { + scanner.setExcludes( excludes.toArray( new String[excludes.size()] ) ); + } + scanner.addDefaultExcludes(); + scanner.scan(); + + Map matches = new LinkedHashMap<>(); + + for ( String includedFile : scanner.getIncludedFiles() ) + { + matches.put( includedFile, new BuildJob( includedFile, type ) ); + } + + for ( String includedDir : scanner.getIncludedDirectories() ) + { + String includedFile = includedDir + File.separatorChar + "pom.xml"; + if ( new File( scanner.getBasedir(), includedFile ).isFile() ) + { + matches.put( includedFile, new BuildJob( includedFile, type ) ); + } + else + { + matches.put( includedDir, new BuildJob( includedDir, type ) ); + } + } + + List projects = new ArrayList<>( matches.size() ); + + // setup ordinal values to have an order here + for ( BuildJob buildJob : matches.values() ) + { + InvokerProperties invokerProperties = + getInvokerProperties( new File( projectsDirectory, buildJob.getProject() ).getParentFile(), + null ); + buildJob.setOrdinal( invokerProperties.getOrdinal() ); + projects.add( buildJob ); + } + Collections.sort( projects, OrdinalComparator.INSTANCE ); + return projects; + } + + /** + * Relativizes the project paths of the specified build jobs against the directory specified by + * {@link #projectsDirectory} (if possible). If a project path does not denote a sub path of the projects directory, + * it is returned as is. + * + * @param buildJobs The build jobs whose project paths should be relativized, must not be null nor + * contain null elements. + * @throws java.io.IOException If any path could not be relativized. + */ + private void relativizeProjectPaths( List buildJobs ) + throws IOException + { + String projectsDirPath = projectsDirectory.getCanonicalPath(); + + for ( BuildJob buildJob : buildJobs ) + { + String projectPath = buildJob.getProject(); + + File file = new File( projectPath ); + + if ( !file.isAbsolute() ) + { + file = new File( projectsDirectory, projectPath ); + } + + String relativizedPath = relativizePath( file, projectsDirPath ); + + if ( relativizedPath == null ) + { + relativizedPath = projectPath; + } + + buildJob.setProject( relativizedPath ); + } + } + + /** + * Relativizes the specified path against the given base directory. Besides relativization, the returned path will + * also be normalized, e.g. directory references like ".." will be removed. + * + * @param path The path to relativize, must not be null. + * @param basedir The (canonical path of the) base directory to relativize against, must not be null. + * @return The relative path in normal form or null if the input path does not denote a sub path of the + * base directory. + * @throws java.io.IOException If the path could not be relativized. + */ + private String relativizePath( File path, String basedir ) + throws IOException + { + String relativizedPath = path.getCanonicalPath(); + + if ( relativizedPath.startsWith( basedir ) ) + { + relativizedPath = relativizedPath.substring( basedir.length() ); + if ( relativizedPath.startsWith( File.separator ) ) + { + relativizedPath = relativizedPath.substring( File.separator.length() ); + } + + return relativizedPath; + } + else + { + return null; + } + } + + /** + * Returns the map-based value source used to interpolate POMs and other stuff. + * + * @param escapeXml {@code true}, to escape any XML special characters in the property values; {@code false}, to not + * escape any property values. + * + * @return The map-based value source for interpolation, never null. + */ +/** + * Returns the map-based value source used to interpolate POMs and other stuff. + * + * @param escapeXml + * {@code true}, to escape any XML special characters in the property values; {@code false}, to not + * escape any property values. + * @return The map-based value source for interpolation, never null. + */ +private java.util.Map getInterpolationValueSource(final boolean escapeXml) { + java.util.Map props = new java.util.HashMap<>(); + if (filterProperties != null) { + props.putAll(filterProperties); + } + props.put("basedir", this.project.getBasedir().getAbsolutePath()); + props.put("baseurl", org.apache.maven.plugins.invoker.AbstractInvokerMojo.toUrl(this.project.getBasedir().getAbsolutePath())); + { + props.put("localRepository", /* NPEX_NULL_EXP */ + settings.getLocalRepository()); + props.put("localRepositoryUrl", org.apache.maven.plugins.invoker.AbstractInvokerMojo.toUrl(settings.getLocalRepository())); + } + return new org.apache.maven.plugins.invoker.CompositeMap(this.project, props, escapeXml); +} + + /** + * Converts the specified filesystem path to a URL. The resulting URL has no trailing slash regardless whether the + * path denotes a file or a directory. + * + * @param filename The filesystem path to convert, must not be null. + * @return The file: URL for the specified path, never null. + */ + private static String toUrl( String filename ) + { + /* + * NOTE: Maven fails to properly handle percent-encoded "file:" URLs (WAGON-111) so don't use File.toURI() here + * as-is but use the decoded path component in the URL. + */ + String url = "file://" + new File( filename ).toURI().getPath(); + if ( url.endsWith( "/" ) ) + { + url = url.substring( 0, url.length() - 1 ); + } + return url; + } + + /** + * Gets goal/profile names for the specified project, either directly from the plugin configuration or from an + * external token file. + * + * @param basedir The base directory of the test project, must not be null. + * @param filename The (simple) name of an optional file in the project base directory from which to read + * goals/profiles, may be null. + * @param defaultTokens The list of tokens to return in case the specified token file does not exist, may be + * null. + * @return The list of goal/profile names, may be empty but never null. + * @throws java.io.IOException If the token file exists but could not be parsed. + */ + private List getTokens( File basedir, String filename, List defaultTokens ) + throws IOException + { + List tokens = ( defaultTokens != null ) ? defaultTokens : new ArrayList(); + + if ( StringUtils.isNotEmpty( filename ) ) + { + File tokenFile = new File( basedir, filename ); + + if ( tokenFile.exists() ) + { + tokens = readTokens( tokenFile ); + } + } + + return tokens; + } + + /** + * Reads the tokens from the specified file. Tokens are separated either by line terminators or commas. During + * parsing, the file contents will be interpolated. + * + * @param tokenFile The file to read the tokens from, must not be null. + * @return The list of tokens, may be empty but never null. + * @throws java.io.IOException If the token file could not be read. + */ + private List readTokens( final File tokenFile ) + throws IOException + { + List result = new ArrayList<>(); + + Map composite = getInterpolationValueSource( false ); + + try ( BufferedReader reader = + new BufferedReader( new InterpolationFilterReader( newReader( tokenFile ), composite ) ) ) + { + for ( String line = reader.readLine(); line != null; line = reader.readLine() ) + { + result.addAll( collectListFromCSV( line ) ); + } + } + + return result; + } + + /** + * Gets a list of comma separated tokens from the specified line. + * + * @param csv The line with comma separated tokens, may be null. + * @return The list of tokens from the line, may be empty but never null. + */ + private List collectListFromCSV( final String csv ) + { + final List result = new ArrayList<>(); + + if ( ( csv != null ) && ( csv.trim().length() > 0 ) ) + { + final StringTokenizer st = new StringTokenizer( csv, "," ); + + while ( st.hasMoreTokens() ) + { + result.add( st.nextToken().trim() ); + } + } + + return result; + } + + /** + * Interpolates the specified POM/settings file to a temporary file. The destination file may be same as the input + * file, i.e. interpolation can be performed in-place. + *

+ * Note:This methods expects the file to be a XML file and applies special XML escaping during interpolation. + *

+ * + * @param originalFile The XML file to interpolate, must not be null. + * @param interpolatedFile The target file to write the interpolated contents of the original file to, must not be + * null. + * + * @throws org.apache.maven.plugin.MojoExecutionException If the target file could not be created. + */ + void buildInterpolatedFile( File originalFile, File interpolatedFile ) + throws MojoExecutionException + { + getLog().debug( "Interpolate " + originalFile.getPath() + " to " + interpolatedFile.getPath() ); + + try + { + String xml; + + Map composite = getInterpolationValueSource( true ); + + // interpolation with token @...@ + try ( Reader reader = + new InterpolationFilterReader( ReaderFactory.newXmlReader( originalFile ), composite, "@", "@" ) ) + { + xml = IOUtil.toString( reader ); + } + + try ( Writer writer = WriterFactory.newXmlWriter( interpolatedFile ) ) + { + interpolatedFile.getParentFile().mkdirs(); + + writer.write( xml ); + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to interpolate file " + originalFile.getPath(), e ); + } + } + + /** + * Gets the (interpolated) invoker properties for an integration test. + * + * @param projectDirectory The base directory of the IT project, must not be null. + * @return The invoker properties, may be empty but never null. + * @throws org.apache.maven.plugin.MojoExecutionException If an I/O error occurred during reading the properties. + */ + private InvokerProperties getInvokerProperties( final File projectDirectory, Properties globalInvokerProperties ) + throws MojoExecutionException + { + Properties props; + if ( globalInvokerProperties != null ) + { + props = new Properties( globalInvokerProperties ); + } + else + { + props = new Properties(); + } + + File propertiesFile = new File( projectDirectory, invokerPropertiesFile ); + if ( propertiesFile.isFile() ) + { + try ( InputStream in = new FileInputStream( propertiesFile ) ) + { + props.load( in ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Failed to read invoker properties: " + propertiesFile, e ); + } + } + + Interpolator interpolator = new RegexBasedInterpolator(); + interpolator.addValueSource( new MapBasedValueSource( getInterpolationValueSource( false ) ) ); + // CHECKSTYLE_OFF: LineLength + for ( String key : props.stringPropertyNames() ) + { + String value = props.getProperty( key ); + try + { + value = interpolator.interpolate( value, "" ); + } + catch ( InterpolationException e ) + { + throw new MojoExecutionException( "Failed to interpolate invoker properties: " + propertiesFile, + e ); + } + props.setProperty( key, value ); + } + return new InvokerProperties( props ); + } + + static class ToolchainPrivateManager + { + private ToolchainManagerPrivate manager; + + private MavenSession session; + + ToolchainPrivateManager( ToolchainManagerPrivate manager, MavenSession session ) + { + this.manager = manager; + this.session = session; + } + + ToolchainPrivate[] getToolchainPrivates( String type ) throws MisconfiguredToolchainException + { + return manager.getToolchainsForType( type, session ); + } + } +} diff --git a/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/metadata.json b/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/metadata.json new file mode 100644 index 000000000..92ffe34f7 --- /dev/null +++ b/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/metadata.json @@ -0,0 +1,21 @@ +{ + "language": "java", + "id": "maven-invoker-plugin-AbstractInvokerMojo_2652", + "buggyPath": ".", + "referencePath": null, + "buildCommand": "mvn package -V -B -Denforcer.skip=true -Dcheckstyle.skip=true -Dcobertura.skip=true -Drat.skip=true -Dlicense.skip=true -Dfindbugs.skip=true -Dgpg.skip=true -Dskip.npm=true -Dskip.gulp=true -Dskip.bower=true -Drat.numUnapprovedLicenses=100 -DskipTests=true -DskipITs=true -Dtest=None -DfailIfNoTests=false", + "testCommand": "mvn test -V -B -Denforcer.skip=true -Dcheckstyle.skip=true -Dcobertura.skip=true -Drat.skip=true -Dlicense.skip=true -Dfindbugs.skip=true -Dgpg.skip=true -Dskip.npm=true -Dskip.gulp=true -Dskip.bower=true -Drat.numUnapprovedLicenses=100", + "categories": [ + "safety", + "npe" + ], + "npe": { + "filepath": "src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java", + "line": 2659, + "npe_method": "getInterpolationValueSource", + "deref_field": "getLocalRepository", + "npe_class": "AbstractInvokerMojo", + "repo": "maven-invoker-plugin", + "bug_id": "AbstractInvokerMojo_2652" + } +} diff --git a/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/npe.json b/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/npe.json new file mode 100644 index 000000000..e60b5f659 --- /dev/null +++ b/Java/maven-invoker-plugin-AbstractInvokerMojo_2652/npe.json @@ -0,0 +1,7 @@ +{ + "filepath": "src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java", + "line": 2659, + "npe_method": "getInterpolationValueSource", + "deref_field": "getLocalRepository", + "npe_class": "AbstractInvokerMojo" +} \ No newline at end of file diff --git a/Java/maven-invoker-plugin-SelectorUtils_50/Dockerfile b/Java/maven-invoker-plugin-SelectorUtils_50/Dockerfile new file mode 100644 index 000000000..b3ce32683 --- /dev/null +++ b/Java/maven-invoker-plugin-SelectorUtils_50/Dockerfile @@ -0,0 +1,18 @@ +FROM ghcr.io/kupl/starlab-benchmarks/java-base:maven-invoker-plugin + +ENV TZ=Asia/Seoul + +COPY ./metadata.json . +COPY ./npe.json . +COPY ./buggy.java /tmp/buggy.java +RUN export BUGGY_PATH=$(cat metadata.json | jq -r ".npe.filepath") \ + && export BUGGY_LINE=$(cat metadata.json | jq -r ".npe.line") \ + && export BUGGY_MTHD=$(cat metadata.json | jq -r ".npe.npe_method") \ + && mv /tmp/buggy.java $BUGGY_PATH \ + && echo "[{\"filepath\": \"$BUGGY_PATH\", \"line\": $BUGGY_LINE, \"method_name\": \"$BUGGY_MTHD\"}]" | jq . > traces.json + +RUN git init . && git add -A + +RUN $(cat metadata.json | jq -r ".buildCommand") + +RUN $(cat metadata.json | jq -r ".testCommand"); if [ $? -eq 0 ]; then exit 1; fi diff --git a/Java/maven-invoker-plugin-SelectorUtils_50/buggy.java b/Java/maven-invoker-plugin-SelectorUtils_50/buggy.java new file mode 100644 index 000000000..8d6f39fbe --- /dev/null +++ b/Java/maven-invoker-plugin-SelectorUtils_50/buggy.java @@ -0,0 +1,321 @@ +package org.apache.maven.plugins.invoker; + +/* + * 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.FilenameFilter; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager; +import org.apache.maven.project.MavenProject; +import org.apache.maven.toolchain.MisconfiguredToolchainException; +import org.apache.maven.toolchain.ToolchainPrivate; +import org.codehaus.plexus.util.Os; +import org.codehaus.plexus.util.StringUtils; + +/** + * Provides utility methods for selecting build jobs based on environmental conditions. + * + * @author Benjamin Bentmann + */ +class SelectorUtils +{ + +static void parseList(java.lang.String list, java.util.Collection includes, java.util.Collection excludes) { + java.lang.String[] tokens = org.codehaus.plexus.util.StringUtils.split(/* NPEX_NULL_EXP */ + list, ","); + for (java.lang.String token1 : tokens) { + java.lang.String token = token1.trim(); + if (token.startsWith("!")) { + excludes.add(token.substring(1)); + } else { + includes.add(token); + } + } +} + + static boolean isOsFamily( String osSpec ) + { + List includes = new ArrayList<>(); + List excludes = new ArrayList<>(); + parseList( osSpec, includes, excludes ); + + return isOsFamily( includes, true ) && !isOsFamily( excludes, false ); + } + + static boolean isOsFamily( List families, boolean defaultMatch ) + { + if ( families != null && !families.isEmpty() ) + { + for ( String family : families ) + { + if ( Os.isFamily( family ) ) + { + return true; + } + } + + return false; + } + else + { + return defaultMatch; + } + } + + /** + * Retrieves the current Maven version. + * + * @return The current Maven version. + */ + static String getMavenVersion() + { + try + { + // This relies on the fact that MavenProject is the in core classloader + // and that the core classloader is for the maven-core artifact + // and that should have a pom.properties file + // if this ever changes, we will have to revisit this code. + Properties properties = new Properties(); + // CHECKSTYLE_OFF: LineLength + properties.load( MavenProject.class.getClassLoader().getResourceAsStream( "META-INF/maven/org.apache.maven/maven-core/pom.properties" ) ); + // CHECKSTYLE_ON: LineLength + return StringUtils.trim( properties.getProperty( "version" ) ); + } + catch ( Exception e ) + { + return null; + } + } + + static String getMavenVersion( File mavenHome ) + { + File mavenLib = new File( mavenHome, "lib" ); + File[] jarFiles = mavenLib.listFiles( new FilenameFilter() + { + public boolean accept( File dir, String name ) + { + return name.endsWith( ".jar" ); + } + } ); + + for ( File file : jarFiles ) + { + try + { + @SuppressWarnings( "deprecation" ) + URL url = + new URL( "jar:" + file.toURL().toExternalForm() + + "!/META-INF/maven/org.apache.maven/maven-core/pom.properties" ); + + Properties properties = new Properties(); + properties.load( url.openStream() ); + String version = StringUtils.trim( properties.getProperty( "version" ) ); + if ( version != null ) + { + return version; + } + } + catch ( MalformedURLException e ) + { + // ignore + } + catch ( IOException e ) + { + // ignore + } + } + return null; + } + + static boolean isMavenVersion( String mavenSpec ) + { + return isMavenVersion( mavenSpec, getMavenVersion() ); + } + + static boolean isMavenVersion( String mavenSpec, String actualVersion ) + { + List includes = new ArrayList<>(); + List excludes = new ArrayList<>(); + parseList( mavenSpec, includes, excludes ); + + List mavenVersionList = parseVersion( actualVersion ); + + return isJreVersion( mavenVersionList, includes, true ) && !isJreVersion( mavenVersionList, excludes, false ); + } + + static String getJreVersion() + { + return System.getProperty( "java.version", "" ); + } + + static String getJreVersion( File javaHome ) + { + // @todo detect actual version + return null; + } + + static boolean isJreVersion( String jreSpec ) + { + return isJreVersion( jreSpec, getJreVersion() ); + } + + static boolean isJreVersion( String jreSpec, String actualJreVersion ) + { + List includes = new ArrayList(); + List excludes = new ArrayList(); + parseList( jreSpec, includes, excludes ); + + List jreVersion = parseVersion( actualJreVersion ); + + return isJreVersion( jreVersion, includes, true ) && !isJreVersion( jreVersion, excludes, false ); + } + + static boolean isJreVersion( List jreVersion, List versionPatterns, boolean defaultMatch ) + { + if ( versionPatterns != null && !versionPatterns.isEmpty() ) + { + for ( String versionPattern : versionPatterns ) + { + if ( isJreVersion( jreVersion, versionPattern ) ) + { + return true; + } + } + + return false; + } + else + { + return defaultMatch; + } + } + + static boolean isJreVersion( List jreVersion, String versionPattern ) + { + List checkVersion = parseVersion( versionPattern ); + + if ( versionPattern.endsWith( "+" ) ) + { + // 1.5+ <=> [1.5,) + return compareVersions( jreVersion, checkVersion ) >= 0; + } + else if ( versionPattern.endsWith( "-" ) ) + { + // 1.5- <=> (,1.5) + return compareVersions( jreVersion, checkVersion ) < 0; + } + else + { + // 1.5 <=> [1.5,1.6) + return checkVersion.size() <= jreVersion.size() + && checkVersion.equals( jreVersion.subList( 0, checkVersion.size() ) ); + } + } + + static List parseVersion( String version ) + { + version = version.replaceAll( "[^0-9]", "." ); + + String[] tokens = StringUtils.split( version, "." ); + + List numbers = new ArrayList(); + + for ( String token : tokens ) + { + numbers.add( Integer.valueOf( token ) ); + } + + return numbers; + } + + static int compareVersions( List version1, List version2 ) + { + for ( Iterator it1 = version1.iterator(), it2 = version2.iterator();; ) + { + if ( !it1.hasNext() ) + { + return it2.hasNext() ? -1 : 0; + } + if ( !it2.hasNext() ) + { + return it1.hasNext() ? 1 : 0; + } + + Integer num1 = it1.next(); + Integer num2 = it2.next(); + + int rel = num1.compareTo( num2 ); + if ( rel != 0 ) + { + return rel; + } + } + } + + /** + * @param toolchainPrivateManager + * @param invokerToolchains + * @return {@code true} if all invokerToolchains are available, otherwise {@code false} + */ + static boolean isToolchain( ToolchainPrivateManager toolchainPrivateManager, + Collection invokerToolchains ) + { + for ( InvokerToolchain invokerToolchain : invokerToolchains ) + { + boolean found = false; + try + { + for ( ToolchainPrivate tc : toolchainPrivateManager.getToolchainPrivates( invokerToolchain.getType() ) ) + { + if ( !invokerToolchain.getType().equals( tc.getType() ) ) + { + // useful because of MNG-5716 + continue; + } + + if ( tc.matchesRequirements( invokerToolchain.getProvides() ) ) + { + found = true; + continue; + } + } + } + catch ( MisconfiguredToolchainException e ) + { + return false; + } + + if ( !found ) + { + return false; + } + } + + return true; + } +} diff --git a/Java/maven-invoker-plugin-SelectorUtils_50/metadata.json b/Java/maven-invoker-plugin-SelectorUtils_50/metadata.json new file mode 100644 index 000000000..a7f93bca3 --- /dev/null +++ b/Java/maven-invoker-plugin-SelectorUtils_50/metadata.json @@ -0,0 +1,21 @@ +{ + "language": "java", + "id": "maven-invoker-plugin-SelectorUtils_50", + "buggyPath": ".", + "referencePath": null, + "buildCommand": "mvn package -V -B -Denforcer.skip=true -Dcheckstyle.skip=true -Dcobertura.skip=true -Drat.skip=true -Dlicense.skip=true -Dfindbugs.skip=true -Dgpg.skip=true -Dskip.npm=true -Dskip.gulp=true -Dskip.bower=true -Drat.numUnapprovedLicenses=100 -DskipTests=true -DskipITs=true -Dtest=None -DfailIfNoTests=false", + "testCommand": "mvn test -V -B -Denforcer.skip=true -Dcheckstyle.skip=true -Dcobertura.skip=true -Drat.skip=true -Dlicense.skip=true -Dfindbugs.skip=true -Dgpg.skip=true -Dskip.npm=true -Dskip.gulp=true -Dskip.bower=true -Drat.numUnapprovedLicenses=100", + "categories": [ + "safety", + "npe" + ], + "npe": { + "filepath": "src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java", + "line": 50, + "npe_method": "parseList", + "deref_field": "list", + "npe_class": "SelectorUtils", + "repo": "maven-invoker-plugin", + "bug_id": "SelectorUtils_50" + } +} diff --git a/Java/maven-invoker-plugin-SelectorUtils_50/npe.json b/Java/maven-invoker-plugin-SelectorUtils_50/npe.json new file mode 100644 index 000000000..40bcb94e1 --- /dev/null +++ b/Java/maven-invoker-plugin-SelectorUtils_50/npe.json @@ -0,0 +1,7 @@ +{ + "filepath": "src/main/java/org/apache/maven/plugins/invoker/SelectorUtils.java", + "line": 50, + "npe_method": "parseList", + "deref_field": "list", + "npe_class": "SelectorUtils" +} \ No newline at end of file