Skip to content

Support String array for @Parameter's element "defaultValues" - #1273

Open
kwin wants to merge 1 commit into
masterfrom
feature/support-string-array-default-values-on-parameter-annotation
Open

kwin wants to merge 1 commit into
masterfrom
feature/support-string-array-default-values-on-parameter-annotation

Conversation

@kwin

@kwin kwin commented Nov 9, 2026

Copy link
Copy Markdown
Member

Convert multi-value Strings into a comma-separated String of org.apache.maven.plugin.descriptor.Parameter#defaultValue

The underlying Sisu implementaton supports comma separated Strings for collections
(https://eclipse.dev/sisu/org.eclipse.sisu.plexus/configuration.html#Collection_Objects). as well as the Maven 4 equivalent at V4MojoConfigurator.class.

This closes #1272


To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
check one of the following:

@kwin
kwin force-pushed the feature/support-string-array-default-values-on-parameter-annotation branch from 9e83359 to 7e19fd5 Compare November 13, 2026 18:26
@kwin kwin changed the title Support String array for @Parameter's element "defaultValue" Support String array for @Parameter's element "defaultValues" Nov 13, 2026
Convert multi-value Strings into a comma-separated String of
org.apache.maven.plugin.descriptor.Parameter#defaultValue

The underlying Sisu implementaton supports comma separated Strings for
collections
(https://eclipse.dev/sisu/org.eclipse.sisu.plexus/configuration.html#Collection_Objects).
as well as the Maven 4 equivalent at V4MojoConfigurator.class.
The old single-value defaultValue is still supported, but for multi-value defaults, use defaultValues instead.

This closes #1272
@kwin
kwin force-pushed the feature/support-string-array-default-values-on-parameter-annotation branch from 7e19fd5 to bccf6f7 Compare November 13, 2026 18:32
@kwin
kwin marked this pull request as ready for review November 13, 2026 18:33

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: COMMENT — Functionally sound enhancement. The null-based mutual-exclusion logic is correct (ASM only visits explicitly-set annotation attributes, so ParameterAnnotationContent fields default to null for unspecified attributes — the conflict check works correctly even with the annotation interface defaults of "" and {}). Two observations worth addressing:

This review was generated by an AI agent, Hermès on behalf of @gnodet.

/**
* Default values concatenated with commas in the generated plugin descriptor.
* Each String value has the format outlined in {@link #defaultValue()}.
* Multiple values are only supported for collection or array parameters. An empty array specifies no default.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing restriction in Javadoc: The Javadoc says values are "concatenated with commas in the generated plugin descriptor", but doesn't warn that individual values must therefore not contain commas. Since String.join(",", defaultValues) is used without escaping, a value like "a,b" would produce an ambiguous descriptor entry that gets split into two values when parsed. Consider adding:

Suggested change
* Multiple values are only supported for collection or array parameters. An empty array specifies no default.
* Default values concatenated with commas in the generated plugin descriptor.
* Each String value has the format outlined in {@link #defaultValue()}.
* Individual values must not contain commas (the separator character).
* Multiple values are only supported for collection or array parameters. An empty array specifies no default.

Comment on lines +813 to +817
static boolean isCollection(String className) {
return className.endsWith("Collection")
|| className.endsWith("List")
|| className.endsWith("Set")
|| className.endsWith("[]");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 isCollection() is missing Queue and Deque subtypes. The heuristic currently checks Collection, List, Set, and [], but Queue and Deque (and their common implementations like ArrayDeque, LinkedList when used as Deque) are also valid collection types in Mojo parameters. Consider:

Suggested change
static boolean isCollection(String className) {
return className.endsWith("Collection")
|| className.endsWith("List")
|| className.endsWith("Set")
|| className.endsWith("[]");
static boolean isCollection(String className) {
return className.endsWith("Collection")
|| className.endsWith("List")
|| className.endsWith("Set")
|| className.endsWith("Queue")
|| className.endsWith("Deque")
|| className.endsWith("[]");
}

The Javadoc already notes "this is just a heuristic" — worth extending while the method is being added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support String[] for default values on @Parameter annotation

4 participants