You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2023/02/08 23:25:01 UTC
[maven-toolchains-plugin] 01/01: [MTOOLCHAINS-45] - Upgrade maven-plugin parent to 39
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch MTOOLCHAINS-45
in repository https://gitbox.apache.org/repos/asf/maven-toolchains-plugin.git
commit e225090c3b7eb6b5730821c04faad00825a9ac18
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Thu Feb 9 00:24:50 2023 +0100
[MTOOLCHAINS-45] - Upgrade maven-plugin parent to 39
---
pom.xml | 26 ++--
.../plugins/toolchain/ToolchainConverter.java | 68 ++++++----
.../maven/plugins/toolchain/ToolchainMojo.java | 146 ++++++++++-----------
.../plugins/toolchain/ToolchainsRequirement.java | 38 ++++--
4 files changed, 149 insertions(+), 129 deletions(-)
diff --git a/pom.xml b/pom.xml
index a8a5c21..b4d0d2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -18,14 +17,13 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
- <version>37</version>
+ <version>39</version>
<relativePath />
</parent>
@@ -34,10 +32,14 @@ under the License.
<packaging>maven-plugin</packaging>
<name>Apache Maven Toolchains Plugin</name>
- <description>
- The Toolchains Plugins allows to share configuration across plugins. For example to make sure the plugins like
- compiler, surefire, javadoc, webstart etc. all use the same JDK for execution.
- </description>
+ <description>The Toolchains Plugins allows to share configuration across plugins. For example to make sure the plugins like
+ compiler, surefire, javadoc, webstart etc. all use the same JDK for execution.</description>
+
+ <contributors>
+ <contributor>
+ <name>Jim Gough</name>
+ </contributor>
+ </contributors>
<prerequisites>
<maven>${mavenVersion}</maven>
@@ -46,8 +48,8 @@ under the License.
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-toolchains-plugin.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-toolchains-plugin.git</developerConnection>
- <url>https://github.com/apache/maven-toolchains-plugin/tree/${project.scm.tag}</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/maven-toolchains-plugin/tree/${project.scm.tag}</url>
</scm>
<issueManagement>
<system>jira</system>
@@ -64,12 +66,6 @@ under the License.
</site>
</distributionManagement>
- <contributors>
- <contributor>
- <name>Jim Gough</name>
- </contributor>
- </contributors>
-
<properties>
<javaVersion>8</javaVersion>
<mavenVersion>3.2.5</mavenVersion>
diff --git a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java
index 43e2b36..6232dc7 100644
--- a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java
+++ b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java
@@ -1,3 +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.
+ */
package org.apache.maven.plugins.toolchain;
/*
@@ -35,59 +53,55 @@ import org.codehaus.plexus.configuration.PlexusConfiguration;
* @author mkleint
* @see ToolchainsRequirement
*/
-public class ToolchainConverter
- extends AbstractConfigurationConverter
-{
+public class ToolchainConverter extends AbstractConfigurationConverter {
/**
* @see org.codehaus.plexus.component.configurator.converters.ConfigurationConverter#canConvert(java.lang.Class)
*/
@Override
- public boolean canConvert( Class type )
- {
- return ToolchainsRequirement.class.isAssignableFrom( type );
+ public boolean canConvert(Class type) {
+ return ToolchainsRequirement.class.isAssignableFrom(type);
}
/**
* @see org.codehaus.plexus.component.configurator.converters.ConfigurationConverter#fromConfiguration(org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup, org.codehaus.plexus.configuration.PlexusConfiguration, java.lang.Class, java.lang.Class, java.lang.ClassLoader, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator, org.codehaus.plexus.component.configurator.ConfigurationListener)
*/
@Override
- public Object fromConfiguration( ConverterLookup converterLookup,
- PlexusConfiguration configuration,
- Class type, Class baseType,
- ClassLoader classLoader,
- ExpressionEvaluator expressionEvaluator,
- ConfigurationListener listener )
- throws ComponentConfigurationException
- {
+ public Object fromConfiguration(
+ ConverterLookup converterLookup,
+ PlexusConfiguration configuration,
+ Class type,
+ Class baseType,
+ ClassLoader classLoader,
+ ExpressionEvaluator expressionEvaluator,
+ ConfigurationListener listener)
+ throws ComponentConfigurationException {
ToolchainsRequirement retValue = new ToolchainsRequirement();
- processConfiguration( retValue, configuration, expressionEvaluator );
+ processConfiguration(retValue, configuration, expressionEvaluator);
return retValue;
}
- private void processConfiguration( ToolchainsRequirement requirement,
- PlexusConfiguration configuration,
- ExpressionEvaluator expressionEvaluator )
- throws ComponentConfigurationException
- {
+ private void processConfiguration(
+ ToolchainsRequirement requirement,
+ PlexusConfiguration configuration,
+ ExpressionEvaluator expressionEvaluator)
+ throws ComponentConfigurationException {
Map<String, Map<String, String>> map = new HashMap<>();
PlexusConfiguration[] tools = configuration.getChildren();
- for ( PlexusConfiguration tool : tools )
- {
+ for (PlexusConfiguration tool : tools) {
String type = tool.getName();
PlexusConfiguration[] params = tool.getChildren();
Map<String, String> parameters = new HashMap<>();
- for ( PlexusConfiguration param : params )
- {
- parameters.put( param.getName(), param.getValue() );
+ for (PlexusConfiguration param : params) {
+ parameters.put(param.getName(), param.getValue());
}
- map.put( type, parameters );
+ map.put(type, parameters);
}
requirement.toolchains = map;
}
-}
\ No newline at end of file
+}
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 37ab11a..d1c8a7f 100644
--- a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java
+++ b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainMojo.java
@@ -1,3 +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.
+ */
package org.apache.maven.plugins.toolchain;
/*
@@ -19,6 +37,10 @@ package org.apache.maven.plugins.toolchain;
* under the License.
*/
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -31,22 +53,18 @@ import org.apache.maven.toolchain.MisconfiguredToolchainException;
import org.apache.maven.toolchain.ToolchainManagerPrivate;
import org.apache.maven.toolchain.ToolchainPrivate;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
/**
* Check that toolchains requirements are met by currently configured toolchains and
* store the selected toolchains in build context for later retrieval by other plugins.
*
* @author mkleint
*/
-@Mojo( name = "toolchain", defaultPhase = LifecyclePhase.VALIDATE,
- configurator = "toolchains-requirement-configurator",
- threadSafe = true )
-public class ToolchainMojo
- extends AbstractMojo
-{
+@Mojo(
+ name = "toolchain",
+ defaultPhase = LifecyclePhase.VALIDATE,
+ configurator = "toolchains-requirement-configurator",
+ threadSafe = true)
+public class ToolchainMojo extends AbstractMojo {
private static final Object LOCK = new Object();
/**
@@ -57,7 +75,7 @@ public class ToolchainMojo
/**
* The current build session instance. This is used for toolchain manager API calls.
*/
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
private MavenSession session;
/**
@@ -68,124 +86,102 @@ public class ToolchainMojo
* </toolchain-type></pre>
* element for each required toolchain.
*/
- @Parameter( required = true )
+ @Parameter(required = true)
private ToolchainsRequirement toolchains;
@Override
- public void execute()
- throws MojoExecutionException, MojoFailureException
- {
- if ( toolchains == null )
- {
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (toolchains == null) {
// should not happen since parameter is required...
- getLog().warn( "No toolchains requirements configured." );
+ getLog().warn("No toolchains requirements configured.");
return;
}
List<String> nonMatchedTypes = new ArrayList<>();
- for ( Map.Entry<String, Map<String, String>> entry : toolchains.getToolchains().entrySet() )
- {
+ for (Map.Entry<String, Map<String, String>> entry :
+ toolchains.getToolchains().entrySet()) {
String type = entry.getKey();
- if ( !selectToolchain( type, entry.getValue() ) )
- {
- nonMatchedTypes.add( type );
+ if (!selectToolchain(type, entry.getValue())) {
+ nonMatchedTypes.add(type);
}
}
- if ( !nonMatchedTypes.isEmpty() )
- {
+ if (!nonMatchedTypes.isEmpty()) {
// TODO add the default toolchain instance if defined??
StringBuilder buff = new StringBuilder();
- buff.append( "Cannot find matching toolchain definitions for the following toolchain types:" );
+ buff.append("Cannot find matching toolchain definitions for the following toolchain types:");
- for ( String type : nonMatchedTypes )
- {
- buff.append( System.lineSeparator() );
- buff.append( getToolchainRequirementAsString( type, toolchains.getParams( type ) ) );
+ for (String type : nonMatchedTypes) {
+ buff.append(System.lineSeparator());
+ buff.append(getToolchainRequirementAsString(type, toolchains.getParams(type)));
}
- getLog().error( buff.toString() );
+ 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.");
}
}
- protected String getToolchainRequirementAsString( String type, Map<String, String> params )
- {
+ protected String getToolchainRequirementAsString(String type, Map<String, String> params) {
StringBuilder buff = new StringBuilder();
- buff.append( type ).append( " [" );
+ buff.append(type).append(" [");
- if ( params.size() == 0 )
- {
- buff.append( " any" );
- }
- else
- {
- for ( Map.Entry<String, String> param : params.entrySet() )
- {
- buff.append( " " ).append( param.getKey() ).append( "='" ).append( param.getValue() );
- buff.append( "'" );
+ if (params.size() == 0) {
+ buff.append(" any");
+ } else {
+ for (Map.Entry<String, String> param : params.entrySet()) {
+ buff.append(" ").append(param.getKey()).append("='").append(param.getValue());
+ buff.append("'");
}
}
- buff.append( " ]" );
+ buff.append(" ]");
return buff.toString();
}
- protected boolean selectToolchain( String type, Map<String, String> params )
- throws MojoExecutionException
- {
- getLog().info( "Required toolchain: " + getToolchainRequirementAsString( type, params ) );
+ protected boolean selectToolchain(String type, Map<String, String> params) throws MojoExecutionException {
+ getLog().info("Required toolchain: " + getToolchainRequirementAsString(type, params));
int typeFound = 0;
- try
- {
- ToolchainPrivate[] tcs = getToolchains( type );
+ try {
+ ToolchainPrivate[] tcs = getToolchains(type);
- for ( ToolchainPrivate tc : tcs )
- {
- if ( !type.equals( tc.getType() ) )
- {
+ for (ToolchainPrivate tc : tcs) {
+ if (!type.equals(tc.getType())) {
// useful because of MNG-5716
continue;
}
typeFound++;
- if ( tc.matchesRequirements( params ) )
- {
- getLog().info( "Found matching toolchain for type " + type + ": " + tc );
+ if (tc.matchesRequirements(params)) {
+ getLog().info("Found matching toolchain for type " + type + ": " + tc);
// store matching toolchain to build context
- synchronized ( LOCK )
- {
- toolchainManagerPrivate.storeToolchainToBuildContext( tc, session );
+ synchronized (LOCK) {
+ toolchainManagerPrivate.storeToolchainToBuildContext(tc, session);
}
return true;
}
}
- }
- catch ( MisconfiguredToolchainException ex )
- {
- throw new MojoExecutionException( "Misconfigured toolchains.", ex );
+ } catch (MisconfiguredToolchainException ex) {
+ throw new MojoExecutionException("Misconfigured toolchains.", ex);
}
- getLog().error( "No toolchain " + ( ( typeFound == 0 ) ? "found" : ( "matched from " + typeFound + " found" ) )
- + " for type " + type );
+ getLog().error("No toolchain " + ((typeFound == 0) ? "found" : ("matched from " + typeFound + " found"))
+ + " for type " + type);
return false;
}
- private ToolchainPrivate[] getToolchains( String type )
- throws MojoExecutionException, MisconfiguredToolchainException
- {
- return toolchainManagerPrivate.getToolchainsForType( type, session );
+ private ToolchainPrivate[] getToolchains(String type)
+ throws MojoExecutionException, MisconfiguredToolchainException {
+ return toolchainManagerPrivate.getToolchainsForType(type, session);
}
-
}
diff --git a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsRequirement.java b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsRequirement.java
index 86de36f..acb1151 100644
--- a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsRequirement.java
+++ b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsRequirement.java
@@ -1,3 +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.
+ */
package org.apache.maven.plugins.toolchain;
/*
@@ -29,22 +47,18 @@ import java.util.Set;
* @author mkleint
* @see ToolchainConverter the custom Plexus converter to instantiate this class
*/
-public final class ToolchainsRequirement
-{
+public final class ToolchainsRequirement {
Map<String, Map<String, String>> toolchains;
- public Map<String, Map<String, String>> getToolchains()
- {
- return Collections.unmodifiableMap( toolchains );
+ public Map<String, Map<String, String>> getToolchains() {
+ return Collections.unmodifiableMap(toolchains);
}
- public Set<String> getToolchainsTypes()
- {
- return Collections.unmodifiableSet( toolchains.keySet() );
+ public Set<String> getToolchainsTypes() {
+ return Collections.unmodifiableSet(toolchains.keySet());
}
- public Map<String, String> getParams( String type )
- {
- return Collections.unmodifiableMap( toolchains.get( type ) );
+ public Map<String, String> getParams(String type) {
+ return Collections.unmodifiableMap(toolchains.get(type));
}
-}
\ No newline at end of file
+}