Georgi Georgiev
Georgi Georgiev

Reputation: 1623

Maven build skips clean and validate phases

I am using IntelliJ IDE. My project is maven project. What is bothering me is that when for example choose "Install" phase from Maven Toolbar and click "Run Maven Build"enter image description here,

the clean phase is not executed:

"C:\Program Files\Java\jdk-9.0.1\bin\java" -Dmaven.multiModuleProjectDirectory=A:\custom_software_projects\IdeaProjects\power_management "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\lib\idea_rt.jar=53577:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.3.2 install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building power_server 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ power_server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ power_server ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ power_server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory A:\custom_software_projects\IdeaProjects\power_management\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ power_server ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ power_server ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ power_server ---
[INFO] 
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (default) @ power_server ---
[INFO] Building jar: A:\custom_software_projects\IdeaProjects\power_management\target\power_server-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO] 
[INFO] --- maven-dependency-plugin:3.0.2:unpack-dependencies (unpack-sigar) @ power_server ---
[INFO] log4j:log4j:jar:1.2.17 already exists in destination.
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ power_server ---
[INFO] Installing A:\custom_software_projects\IdeaProjects\power_management\target\power_server-1.0-SNAPSHOT.jar to C:\Users\ggeorgiev\.m2\repository\Power_Management_Server\power_server\1.0-SNAPSHOT\power_server-1.0-SNAPSHOT.jar
[INFO] Installing A:\custom_software_projects\IdeaProjects\power_management\pom.xml to C:\Users\ggeorgiev\.m2\repository\Power_Management_Server\power_server\1.0-SNAPSHOT\power_server-1.0-SNAPSHOT.pom
[INFO] Installing A:\custom_software_projects\IdeaProjects\power_management\target\power_server-1.0-SNAPSHOT-jar-with-dependencies.jar to C:\Users\ggeorgiev\.m2\repository\Power_Management_Server\power_server\1.0-SNAPSHOT\power_server-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO] 
[INFO] --- maven-antrun-plugin:1.4:run (Copying jar-with-dependecnies and fixing LF in .sh scripts) @ power_server ---
project.artifactId
[INFO] Executing tasks
     [copy] Copying 1 file to A:\custom_programs\power_server
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.291 s
[INFO] Finished at: 2018-02-10T21:42:17+02:00
[INFO] Final Memory: 17M/56M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

So, as you see the first step taken is maven-resources-plugin:2.6:resources. From what I understood from maven docs is that when we specify a phase all previous phases are executed up to the chosen one. Per maven doc:

This command executes each default life cycle phase in order (validate, compile, package, etc.), before executing install. You only need to call the last build phase to be executed, in this case, install

Why is it skipping the clean and validate phases?

Edit:

I also have the clean phase in the Run Configuration section, but the result is the same: enter image description here

Upvotes: 2

Views: 5083

Answers (2)

blurfus
blurfus

Reputation: 14031

The default lifecycle does not include clean in it. Check the docs

Quote:

For example, the default lifecycle comprises of the following phases (for a complete list of the lifecycle phases, refer to the Lifecycle Reference):

  • validate - validate the project is correct and all necessary information is available
  • compile - compile the source code of the project
  • test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package - take the compiled code and package it in its distributable format, such as a JAR.
  • verify - run any checks on results of integration tests to ensure quality criteria are met
  • install - install the package into the local repository, for use as a dependency in other projects locally
  • deploy - done in the build environment, copies the final package to the remote repository for sharing with other developers and projects.

Also, the validate phase is not associated with the default lifecycle of packaging .jar files.

Check the Default Lifecycle Bindings for JAR files at the bottom of the docs

Upvotes: 2

Oleg
Oleg

Reputation: 6314

Maven has 3 different builtin lifecycles

There are three built-in build lifecycles: default, clean and site.

install is part of the default lifecycle and there is no reason for clean to execute when you do install.

As to validate it has no built in binding as you can see here which means that it's not going to execute:

Furthermore, a build phase can also have zero or more goals bound to it. If a build phase has no goals bound to it, that build phase will not execute.

Upvotes: 7

Related Questions