-
Notifications
You must be signed in to change notification settings - Fork 40.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support commas embedded in command line arguments from Maven plugin #18711
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @nosan. I am not sure we want to tokenize on ,--
. I'd like to make sure we are consistent with other core maven plugins before making this change and I haven't researched yet if there is one.
} | ||
List<String> result = new ArrayList<>(); | ||
for (String line : new RunArguments(String.join(",", args)).getArgs()) { | ||
String[] tokens = line.split(",--"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a bit fragile. I think the plan is more to stop binding the property as a String[] but rather introduce another one that we would map to the command-line property. Existing plugins use a space-delimited feature and I haven't checked how they skip spaces within valuesL
@@ -0,0 +1 @@ | |||
invoker.mavenOpts=-Dspring-boot.run.arguments='--management.endpoints.web.exposure.include=prometheus,info,health,metrics,--spring.profiles.active=foo,bar' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more natural if the arguments were separated by a space rather than a comma.
Thanks, @snicoll We can't change the type
Steps to reproduce: <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<arguments>
<argument>--management.endpoints.web.exposure.include=prometheus,info</argument>
<argument>--spring.profiles.active=foo,bar</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin> UPD:
Works fine if we change the type for /**
* Arguments from command line that should be passed to the application.
* @since 2.2.1
*/
@Parameter(property = "spring-boot.run.arguments", readonly = true)
private String args; |
Thanks for the feedback but that's not what I was suggesting
In other words, keep the property that we have but remove the binding to command line and introduce a new property of type |
I've pushed an additional commit with @snicoll suggestions. |
} | ||
String endpoints = args[0].split("=")[1]; | ||
String profile = args[1].split("=")[1]; | ||
System.out.println("I haz been run with profile(s) '" + profile + "' and endpoint(s) '" + endpoints + "'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one typo, haz -> has
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it was done on purpose.
@@ -0,0 +1,2 @@ | |||
def file = new File(basedir, "build.log") | |||
return file.text.contains("I haz been run with profile(s) 'foo,bar' and endpoint(s) 'prometheus,info'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, haz -> has
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it was done on purpose.
Well done once again @nosan! |
Thank you @snicoll |
see gh-18688