You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "slawekjaranowski (via GitHub)" <gi...@apache.org> on 2026/07/12 18:58:41 UTC
[PR] Replace Plexus XML configuration with JSR-330 annotated beans [maven-toolchains-plugin]
slawekjaranowski opened a new pull request, #160:
URL: https://github.com/apache/maven-toolchains-plugin/pull/160
## 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
Following this checklist to help us incorporate your
contribution quickly and easily:
- [ ] Your pull request should address just one issue, without pulling in other changes.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
Note that commits might be squashed by a maintainer on merge.
- [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
This may not always be possible but is a best-practice.
- [ ] Run `mvn verify` to make sure basic checks pass.
A more thorough check will be performed on your pull request automatically.
- [ ] You have run the integration tests successfully (`mvn -Prun-its verify`).
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace Plexus XML configuration with JSR-330 annotated beans [maven-toolchains-plugin]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #160:
URL: https://github.com/apache/maven-toolchains-plugin/pull/160#discussion_r3574075216
##########
src/it/select-jdk-toolchain-range/verify.groovy:
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+content = new File(basedir, 'build.log').text
+
+// property is resolved
+assert content.contains('[DEBUG] (f) toolchains = ToolchainsRequirement{toolchains={jdk={version=[8,17]}}}')
Review Comment:
The IT assertion relies on Maven emitting a specific `[DEBUG] (f) toolchains = ...` parameter-dump line. This output is only present when Maven is run with debug enabled (e.g., `-X`), but this IT’s `invoker.properties` does not enable debug, making the test likely to fail or be environment-dependent. Prefer asserting against the plugin’s own INFO log (`Required toolchain: ...`), which is always logged and still proves the property was interpolated (i.e., it should show `[8,17]` rather than `${toolchain.jdk.version}`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace Plexus XML configuration with JSR-330 annotated beans [maven-toolchains-plugin]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #160:
URL: https://github.com/apache/maven-toolchains-plugin/pull/160#discussion_r3573805261
##########
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);
+ }
+}
Review Comment:
`converterLookup` is used in the constructor, but this configurator previously depended on a role-hinted `ConverterLookup` (see removed `components.xml`). With the current constructor, the inherited `converterLookup` may not yet be set by the container and/or may resolve to the default/global lookup, which can cause NPEs or change converter scoping. Prefer injecting a dedicated, named `ConverterLookup` and assigning it to the superclass field.
##########
src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java:
##########
@@ -55,20 +59,13 @@ public Object fromConfiguration(
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) {
Review Comment:
`ExpressionEvaluator` is provided to allow Maven/Plexus expression interpolation (e.g., `${...}`) while converting configuration. The current implementation ignores it and reads `param.getValue()` verbatim, which can change runtime behavior for users relying on expressions in `<toolchains>` requirements.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace Plexus XML configuration with JSR-330 annotated beans [maven-toolchains-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski merged PR #160:
URL: https://github.com/apache/maven-toolchains-plugin/pull/160
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace Plexus XML configuration with JSR-330 annotated beans [maven-toolchains-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #160:
URL: https://github.com/apache/maven-toolchains-plugin/pull/160#discussion_r3574092764
##########
src/it/select-jdk-toolchain-range/verify.groovy:
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+content = new File(basedir, 'build.log').text
+
+// property is resolved
+assert content.contains('[DEBUG] (f) toolchains = ToolchainsRequirement{toolchains={jdk={version=[8,17]}}}')
Review Comment:
for IT debug level is enabled by configuration of invoker
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace Plexus XML configuration with JSR-330 annotated beans [maven-toolchains-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #160:
URL: https://github.com/apache/maven-toolchains-plugin/pull/160#discussion_r3574050472
##########
src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java:
##########
@@ -55,20 +59,13 @@ public Object fromConfiguration(
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) {
Review Comment:
not needed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Replace Plexus XML configuration with JSR-330 annotated beans [maven-toolchains-plugin]
Posted by "slawekjaranowski (via GitHub)" <gi...@apache.org>.
slawekjaranowski commented on code in PR #160:
URL: https://github.com/apache/maven-toolchains-plugin/pull/160#discussion_r3574062430
##########
src/main/java/org/apache/maven/plugins/toolchain/ToolchainConverter.java:
##########
@@ -55,20 +59,13 @@ public Object fromConfiguration(
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) {
Review Comment:
extends IT to confirm
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org