If i call
mvn clean install
maven knows that clean
is a lifecycle and install
is a phase of the default lifecycle
if i call
mvn deploy
maven will execute all phases of the default lifecycle sequentially.
Is there a way to call the default lifecycle by giving a lifecyle name (instead of executing the last phsae of the lifecycle)?
EDIT: So the question is: is there a command
mvn lifecyclename
that start execution of the default lifecycle?
There is no command to run a lifecycle based on lifecycle name. So you can’t do a mvn Default
and expect it to run upto Default:deploy
. You will have to mention a task of a cycle like test
, package
, clean
and the life-cycle that owns this task will get active.
It does not make sense to have life-cycle as an argument. It will be confusing. For example running mvn clean
is the Clean life-cycle or clean task?
Or, it will be more verbose to type mvn clean
will run Clean life cycle; and mvn clean:clean
will run Clean life cycle until clean task.
mvn后面接的不是goal就是phase,不是插件名字:插件的目标
形式的则全部是phase
Maven has three life cycle. Executing a task (say task_N
) of any of the life cycle will result in executing the whole life-cycle until that task (task_N
). The three life cycles are Clean
, Default
, and Site
.
For more details see here Introduction to Maven Life-cycles and task order
You see when you execute say, mvn test these are the things gets executed in that order
validate > initialize > generate-sources > process-sources > generate-resources > process-resources > compile > process-classes > post-process > generate-test-sources > process-test-sources > generate-test-resources > process-test-resources > test-compile > process-test-classes > test
You can’t skip any of the default tasks. You may hook plugins that gets gets executed during a task.
mvn clean
does not invoke the whole clean lifecycle. In fact there is a clean phase in the clean lifecycle. And the command executes this phase and not the lifecycle.
As far as I know you cannot execute an isolated lifecycle phase.
But you can execute an isolated plugin goal .
mvn deploy:deploy
That won’t trigger any plugin execution tied to deploy phase. But you can always add more plugin execution to the command line. So I better go with a profile skipping all plugins executions.
If you want to execute a myplugin:mygoal that was tied to deploy phase then
mvn myplugin:mygoal deploy:deploy
But the configuration of the execution must be in the cli.
But you better skip plugin executions that you do not want. only skip test and integration-test in command line. But you can achieve that with a profile that sets the configuration for the default cycle to skip.
<profiles>
<profile>
<id>skip</id>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
...
```
And then summon with
mvn deploy -Pskip
“`