Skip to content
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

[MSHARED-1019] Allow pass raw cli option to Maven process #43

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

slawekjaranowski
Copy link
Member

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MSHARED-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MSHARED-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement 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
you have to acknowledge this by using the following check-box.

@michael-o
Copy link
Member

I do not fully understand how this works. Can I set args one by one as with a list/array?

@slawekjaranowski
Copy link
Member Author

You provide whole additional args as String.

argLine is passed to shared-utils - Commandline#createArg() and finally is parsed by CommandLineUtils.translateCommandline()

@michael-o
Copy link
Member

What a brittle pain! This will fail sooner or later. I rather prefer an arrray.

@slawekjaranowski
Copy link
Member Author

😄
No problem we can use array/list of String for argLine in InvocationRequest
next each element will be passed as-is to Argument#setValue

https://github.com/apache/maven-shared-utils/blob/master/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java#L476-L492

Will be better?

@michael-o
Copy link
Member

😄 No problem we can use array/list of String for argLine in InvocationRequest next each element will be passed as-is to Argument#setValue

https://github.com/apache/maven-shared-utils/blob/master/src/main/java/org/apache/maven/shared/utils/cli/Commandline.java#L476-L492

Will be better?

Sorry, I seem to be blind again. Which do you compare? A per-line approach or a parser?!

Basically, what I don't understand why we need to parse here although the MavenCli class will do that. Talked about this several times with @cstamas .

@slawekjaranowski
Copy link
Member Author

Now I'm also confused ....
Do you think about InvocationRequest which contains method like .... setDebug, setOffline ... and so on for other Maven options?, So it is historical ... and for compatibility must be preserved

With my PR you needn't us it, and simply:

invocationRequest.setArgLineAtEnd("-e -B clean verify");
invoker.execute( invocationRequest );

@olamy
Copy link
Member

olamy commented Feb 28, 2022

uhm I tend to agree parsing could be a pain for something such

invocationRequest.setArgLineAtEnd("-e -B clean verify -Dfile=c:\\My Files\grhhh windows");

@slawekjaranowski
Copy link
Member Author

I don't parse argLinie, it is pass as-is to shared-utils - Commandline#createArg().setLine(...),
what happens in shared-utils is hidden for invoker

@michael-o
Copy link
Member

@slawekjaranowski Yes, retain previous ones is correct, but new ones should be:

invocationRequest.addArg("-B")
invocationRequest.addArg("-Dfoo=bar")

I have a very special opinion CLI tools on shared utils. I consider 80% of the code as useless.

@slawekjaranowski slawekjaranowski force-pushed the MSHARED-1019 branch 2 times, most recently from 6f309d9 to b360831 Compare February 28, 2022 18:59
@slawekjaranowski slawekjaranowski merged commit 89ee4ed into master Mar 1, 2022
@slawekjaranowski slawekjaranowski deleted the MSHARED-1019 branch March 1, 2022 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants