Maven uses the -D syntax for user properties (too). I guess this is just
because it is familiar and "user options" for direct invocations was an
afterthought. Properties works for all plugins but most of them are not used
interactively/direct like the archetype plugin. I dont think it is particular
good but its just the way it is. Commonly used properties in builds are things
like -DskipTests=true
BTW you might not have noticed but there is a indirection at work. You set
maven properties and the plugin has goals (aka mojos) which by default observe
(those) properties. If you look at the goal documentation for an plugin you can
see which of its settings have user properties or default expressions which
expand properties with the ${name} syntax. This indirection is good if you run
the goals in a pom, a bit more confusing for the interactive goals:
http://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html
Gruss
Bernd
--
http://bernd.eckenfels.net
-----Original Message-----
From: "Utku Gültopu" <[email protected]>
To: [email protected]
Sent: Mi., 08 Juni 2016 0:28
Subject: Why does archetype plugin use -D before parameters?
Normally, -D is used to specify a system property to the JVM. However, when I
check out the following invocation of the archetype plugin:
mvn archetype:generate -DgroupId=com.mycompany -DartifactId=SampleApp
-DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
The invocation is like:
java
-classpath
/usr/local/apache-maven-3.3.9/boot/plexus-classworlds-2.5.2.jar
-Dclassworlds.conf=/usr/local/apache-maven-3.3.9/bin/m2.conf
-Dmaven.home=/usr/local/apache-maven-3.3.9
-Dmaven.multiModuleProjectDirectory=/Users/username/Documents/Maven_Archetype_Test
org.codehaus.plexus.classworlds.launcher.Launcher archetype:generate
-DgroupId=com.mycompany
-DartifactId=SampleApp
-DarchetypeArtifactId=maven-archetype-webapp
-DinteractiveMode=false
Options coming after the class name (i.e, after
"org.codehaus.plexus.classworlds.launcher.Launcher”) are passed to the main
method of the application. Hence, the options
-DgroupId=com.mycompany
-DartifactId=SampleApp
-DarchetypeArtifactId=maven-archetype-webapp
-DinteractiveMode=false
are not sent to the JVM but to
org.codehaus.plexus.classworlds.launcher.Launcher. Yet, these options
“masquerade” as JVM options (unless these options are not set to be System
Properties in Launcher class or somewhere else).
I wonder the reason for this. Why not simply specify the arguments as
-groupId=com.mycompany
-artifactId=SampleApp
-archetypeArtifactId=maven-archetype-webapp
-interactiveMode=false
but as
-DgroupId=com.mycompany
-DartifactId=SampleApp
-DarchetypeArtifactId=maven-archetype-webapp
-DinteractiveMode=false
?
Regards
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]