When running from CLI mvn package assembly:single
you must (see update) provide the required properties for the single goal which explains why would you say that it is error prone.
But, if you add the following plugin definition to your pom under build plugins section:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-cli</id>
<phase>never</phase> <!-- or undefined -->
<goals>
<goal>single</goal>
</goals>
<configuration>
...
</configuration>
</execution>
</executions>
</plugin>
When running mvn clean package
the assembly plugin won't run the single goal because it is not binded to any phase.
When running mvn clean package assembly:single
, after the package phase is done the assembly:single will be run with the configuration from your pom because it's execution id is default-cli
.
update
To correct myself, if running from CLI, the executions
tag is not only unnecessary but even semantically incorrect to use.
Just for the reference, with this plugin definition:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptor>path/to/descriptor</descriptor>
</configuration>
</plugin>
the command mvn assembly:single
is equivalent to command mvn assembly:single -Ddescriptor=path/to/descriptor
. When run it outputs to console:
[INFO] --- maven-assembly-plugin:2.4:single (default-cli) @ fm-js ---
The first definition is useful if you want to use the plugin both from command line and during some phase with different configurations.
As to your question, exactly as you asked, IMHO, it is not possible without reprogramming the plugin. My suggestion is in non-portable or portable form, respectively:
- wrap the command
mvn package assembly:single
in a shell script
- write a Groovy script with gmaven-mojo plugin that summons the command
mvn package assembly:single