maven-mvnd icon indicating copy to clipboard operation
maven-mvnd copied to clipboard

Missing argument for option -D

Open walnut-tom opened this issue 2 years ago • 5 comments

$mvn -D aaa=aaa -version Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /usr/local/Cellar/maven/3.8.6/libexec Java version: 1.8.0_312, vendor: Amazon.com Inc., runtime: /Users/user/Library/Java/JavaVirtualMachines/corretto-1.8.0_312/Contents/Home/jre Default locale: zh_CN, platform encoding: UTF-8 OS name: "mac os x", version: "12.4", arch: "x86_64", family: "mac"

$mvnd -D aaa=aaa -version Exception in thread "main" java.lang.IllegalArgumentException: Missing argument for option -D at org.mvndaemon.mvnd.client.DefaultClient.setSystemPropertiesFromCommandLine(DefaultClient.java:146) at org.mvndaemon.mvnd.client.DefaultClient.main(DefaultClient.java:106)

walnut-tom avatar Jul 01 '22 17:07 walnut-tom

Same here, but I'm glad there is already an open issue for that with a "fix" too :)

nandorholozsnyak avatar Jul 07 '22 11:07 nandorholozsnyak

True with -D aaa=aaa but works OK without space, with -Daaa=aaa

cstamas avatar Jul 07 '22 11:07 cstamas

And the -D is "inspired" by Java -D and is defined without space as well. I never used the form with space actually :smile:

cstamas avatar Jul 07 '22 11:07 cstamas

Yes true it works without space with -D, and it works with this format too --define=property=value but if it really wants to support the Maven based properties then it should be working with the space too. :D

nandorholozsnyak avatar Jul 07 '22 11:07 nandorholozsnyak

use mvn command, I never used the form with space actually too.

but I use org.apache.maven.shared:maven-invoker:3.2.0 invoke maven/mvnd like this:

public class InvokerListClass {

    public static void main(String[] args) throws MavenInvocationException {
        Invoker invoker = new DefaultInvoker();
        invoker.setMavenHome(new File("/Users/xxx/maven-mvnd-0.8.0-darwin-amd64"));
        invoker.setMavenExecutable(new File("mvnd"));
        final InvocationRequest invocationRequest = new DefaultInvocationRequest();
        Properties properties = new Properties();
        properties.setProperty("artifact", "com.h2database:h2:1.4.200");
        invocationRequest.setProperties(properties);
        invocationRequest.setGoals(Collections.singletonList("org.apache.maven.plugins:maven-dependency-plugin:3.2.0:list-classes"));
        invoker.execute(invocationRequest);
    }
}

walnut-tom avatar Jul 07 '22 15:07 walnut-tom