From 1c2e7006eec21d5999660925ba761025b961c6dd Mon Sep 17 00:00:00 2001 From: hsynkrtl Date: Thu, 25 Jul 2019 13:23:52 +0200 Subject: [PATCH 1/4] [MTOOLCHAINS-29] added optional parameter possibility not to fail if toolchain.xml is not available --- src/it/skip-fail/invoker.properties | 20 ++++++ src/it/skip-fail/pom.xml | 67 +++++++++++++++++++ src/it/skip-fail/verify.groovy | 22 ++++++ .../plugins/toolchain/ToolchainMojo.java | 20 +++++- 4 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 src/it/skip-fail/invoker.properties create mode 100644 src/it/skip-fail/pom.xml create mode 100644 src/it/skip-fail/verify.groovy diff --git a/src/it/skip-fail/invoker.properties b/src/it/skip-fail/invoker.properties new file mode 100644 index 0000000..cbb67b6 --- /dev/null +++ b/src/it/skip-fail/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 = compile +# cannot run this IT with Maven 2 since required --toolchains option was added in 3.0-alpha-3: see MNG-3714 +invoker.maven.version = 3.0+ diff --git a/src/it/skip-fail/pom.xml b/src/it/skip-fail/pom.xml new file mode 100644 index 0000000..ff701e3 --- /dev/null +++ b/src/it/skip-fail/pom.xml @@ -0,0 +1,67 @@ + + + + + + 4.0.0 + + org.apache.maven.plugins.toolchains.its + skip-fail + 1.0-SNAPSHOT + jar + + maven-toolchains-plugin IT: missing toolchain test + + Check that toolchain requirements are checked and not covered as expected + + + + UTF-8 + + + + + + org.apache.maven.plugins + maven-toolchains-plugin + @project.version@ + + + + toolchain + + + + + + + + value + other-value + + + + false + + + + + diff --git a/src/it/skip-fail/verify.groovy b/src/it/skip-fail/verify.groovy new file mode 100644 index 0000000..e1b7fe5 --- /dev/null +++ b/src/it/skip-fail/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. + */ + +content = new File( basedir, 'build.log' ).text + +assert content.indexOf( "MojoFailureException: Cannot find matching toolchain definitions for the following toolchain types:" ) > 0 diff --git a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java index 7cef3d7..3ae6b5d 100644 --- a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java +++ b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java @@ -69,6 +69,13 @@ public class ToolchainMojo @Parameter( required = true ) private ToolchainsRequirement toolchains; + /** + * Flag to fail the build if toolchain requirements not met. + * @since 3.0.1 + */ + @Parameter( defaultValue = "true" ) + private boolean fail; + @Override public void execute() throws MojoExecutionException, MojoFailureException @@ -104,10 +111,17 @@ public void execute() buff.append( getToolchainRequirementAsString( type, toolchains.getParams( type ) ) ); } - getLog().error( buff.toString() ); + if ( fail ) + { + getLog().error( buff.toString() ); - throw new MojoFailureException( buff.toString() + System.lineSeparator() - + "Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file." ); + throw new MojoFailureException( buff.toString() + System.lineSeparator() + + "Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file." ); + } + else + { + getLog().warn( buff.toString() ); + } } } From 752268c3da98913a182a33df0e20a4541070cee4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 17:42:43 +0000 Subject: [PATCH 2/4] Bump org.apache.maven:maven-core in /src/it/setup-custom-toolchain Bumps [org.apache.maven:maven-core](https://github.com/apache/maven) from 3.0.5 to 3.8.1. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.0.5...maven-3.8.1) --- updated-dependencies: - dependency-name: org.apache.maven:maven-core dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/it/setup-custom-toolchain/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/setup-custom-toolchain/pom.xml b/src/it/setup-custom-toolchain/pom.xml index 20a843b..70e8cfe 100644 --- a/src/it/setup-custom-toolchain/pom.xml +++ b/src/it/setup-custom-toolchain/pom.xml @@ -43,7 +43,7 @@ under the License. org.apache.maven maven-core - 3.0.5 + 3.8.1 org.codehaus.plexus From 058f3282b9856d3a325c5078c9fae9e7d8408bdb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 19:42:18 +0000 Subject: [PATCH 3/4] Bump org.codehaus.plexus:plexus-utils in /src/it/setup-custom-toolchain Bumps [org.codehaus.plexus:plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 3.0.15 to 3.0.24. - [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases) - [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-3.0.15...plexus-utils-3.0.24) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/it/setup-custom-toolchain/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/setup-custom-toolchain/pom.xml b/src/it/setup-custom-toolchain/pom.xml index 20a843b..4e99970 100644 --- a/src/it/setup-custom-toolchain/pom.xml +++ b/src/it/setup-custom-toolchain/pom.xml @@ -68,7 +68,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.0.15 + 3.0.24 From 5048be3f378c50046dbfa6ffb2ba67d7b79f94d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:10:40 +0000 Subject: [PATCH 4/4] Bump org.apache.maven:maven-core from 3.0 to 3.8.1 Bumps [org.apache.maven:maven-core](https://github.com/apache/maven) from 3.0 to 3.8.1. - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.0...maven-3.8.1) --- updated-dependencies: - dependency-name: org.apache.maven:maven-core dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c2b46e9..85bf46d 100644 --- a/pom.xml +++ b/pom.xml @@ -71,7 +71,7 @@ under the License. - 3.0 + 3.8.1 7