This is an automated email from the ASF dual-hosted git repository. slawekjaranowski pushed a commit to branch jsr-330 in repository https://gitbox.apache.org/repos/asf/maven-toolchains-plugin.git
commit 329ebc9a4b522be0f3c4d2b128dd618ba088f0c7 Author: Slawomir Jaranowski <[email protected]> AuthorDate: Sun Jul 12 19:11:23 2026 +0200 Replace Plexus XML configuration with JSR-330 annotated beans ## What changed - Added `@Named("ToolchainsRequirement")` and `@Singleton` annotations to `ToolchainConverter` - Created `ToolchainsComponentConfigurator` extending `BasicComponentConfigurator` — injects `ToolchainConverter` and registers it on initialization - Removed `src/main/resources/META-INF/plexus/components.xml` ## Why - JSR-330 annotations with Sisu replace legacy Plexus XML component descriptors - `sisu-maven-plugin` auto-generates component indexes from annotations, eliminating manual XML maintenance - Cleaner, more maintainable approach with annotations co-located with code ## Testing - All unit tests pass - Sisu index correctly includes both annotated beans - Plugin configuration remains unchanged — `@Mojo(configurator = "toolchains-requirement-configurator")` works as before --- .../plugins/toolchain/ToolchainConverter.java | 19 ++++---- .../toolchain/ToolchainsComponentConfigurator.java | 43 ++++++++++++++++++ .../plugins/toolchain/ToolchainsRequirement.java | 5 ++ src/main/resources/META-INF/plexus/components.xml | 53 ---------------------- 4 files changed, 56 insertions(+), 64 deletions(-) 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 2ce0c9f..7277ef8 100644 --- a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java +++ b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java @@ -18,10 +18,12 @@ */ package org.apache.maven.plugins.toolchain; +import javax.inject.Named; +import javax.inject.Singleton; + import java.util.HashMap; import java.util.Map; -import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; @@ -34,6 +36,8 @@ import org.codehaus.plexus.configuration.PlexusConfiguration; * @author mkleint * @see ToolchainsRequirement */ +@Named("ToolchainsRequirement") +@Singleton public class ToolchainConverter extends AbstractConfigurationConverter { /** @@ -55,20 +59,13 @@ public class ToolchainConverter extends AbstractConfigurationConverter { Class baseType, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator, - ConfigurationListener listener) - throws ComponentConfigurationException { + ConfigurationListener listener) { ToolchainsRequirement retValue = new ToolchainsRequirement(); - - processConfiguration(retValue, configuration, expressionEvaluator); - + processConfiguration(retValue, configuration); return retValue; } - private void processConfiguration( - ToolchainsRequirement requirement, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator) - throws ComponentConfigurationException { + private void processConfiguration(ToolchainsRequirement requirement, PlexusConfiguration configuration) { Map<String, Map<String, String>> map = new HashMap<>(); PlexusConfiguration[] tools = configuration.getChildren(); diff --git a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsComponentConfigurator.java b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsComponentConfigurator.java new file mode 100644 index 0000000..f75e3f8 --- /dev/null +++ b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsComponentConfigurator.java @@ -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. + */ +package org.apache.maven.plugins.toolchain; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.codehaus.plexus.component.configurator.BasicComponentConfigurator; +import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; + +/** + * A configurator for components that handles toolchain requirements specified in Maven configuration. + * <p> + * An instance of {@code ConfigurationConverter} for toolchain requirements + * is injected into this configurator, and the required converter is registered + * during the instantiation process. + */ +@Named("toolchains-requirement-configurator") +@Singleton +public class ToolchainsComponentConfigurator extends BasicComponentConfigurator { + + @Inject + public ToolchainsComponentConfigurator(@Named("ToolchainsRequirement") ConfigurationConverter toolchainConverter) { + this.converterLookup.registerConverter(toolchainConverter); + } +} 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 2016ce1..bb93242 100644 --- a/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsRequirement.java +++ b/src/main/java/org/apache/maven/plugins/toolchain/ToolchainsRequirement.java @@ -42,4 +42,9 @@ public final class ToolchainsRequirement { public Map<String, String> getParams(String type) { return Collections.unmodifiableMap(toolchains.get(type)); } + + @Override + public String toString() { + return "ToolchainsRequirement{toolchains=" + toolchains + '}'; + } } diff --git a/src/main/resources/META-INF/plexus/components.xml b/src/main/resources/META-INF/plexus/components.xml deleted file mode 100644 index 8d96957..0000000 --- a/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,53 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<plexus> - <components> - <component> - <role>org.codehaus.plexus.component.configurator.ComponentConfigurator</role> - <role-hint>toolchains-requirement-configurator</role-hint> - <implementation>org.codehaus.plexus.component.configurator.BasicComponentConfigurator</implementation> - <requirements> - <requirement> - <role>org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup</role> - <role-hint>toolchains-requirement-configurator</role-hint> - </requirement> - </requirements> - </component> - - <component> - <role>org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup</role> - <role-hint>toolchains-requirement-configurator</role-hint> - <implementation>org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup</implementation> - <requirements> - <requirement> - <role>org.codehaus.plexus.component.configurator.converters.ConfigurationConverter</role> - <role-hint>ToolchainsRequirement</role-hint> - <field-name>customConverters</field-name> - </requirement> - </requirements> - </component> - - <component> - <role>org.codehaus.plexus.component.configurator.converters.ConfigurationConverter</role> - <role-hint>ToolchainsRequirement</role-hint> - <implementation>org.apache.maven.plugins.toolchain.ToolchainConverter</implementation> - </component> - </components> -</plexus>
