To disable compile , clean , validate test in maven - maven

I am looking for ways to only run maven test phase, I tried this but it didn't work. Any pointers to fix this would help
mvn test -Dmaven.clean.skip=true -Dmaven.validate.skip=true -Dmaven.compile.skip=true

You can run mvn surefire:test, but it is recommended to run the other phases before.

Related

Execute maven install phase without executing maven compile

Working with a multi-module project. Want to run maven commands as follows:
mvn clean compile
Then maven install phase without again executing maven compile
Not possible.
You would need to call the goals directly, phases cannot be run separately.
you can (now) skip phases by directly calling the goal via
mvn <plugin>:<goal>
e.g.
mvn compiler:compile
see this answer for details.
for install it should be mvn install:install

Why should run first mvn clean clover2:setup install clover2:clover, then: mvn sonar:sonar

Based on the question Sonar + Clover only runs on src-instrumented, it is suggested using first mvn clean clover2:setup install clover2:clover, then: mvn sonar:sonar.
Just wonder why we cannot use mvn clean clover2:setup install clover2:clover sonar:sonar?
In the past it was the recommended way to run goal sonar:sonar alone. This is no more the case since SonarQube Scanner for Maven stopped trying to run unit tests + collect coverage for you by forking a new Maven lifecycle.
General advice is now to run goals in a single command. For example mvn clean package sonar:sonar
In the case of Clover the clover:setup goal will alter the Maven Model to make all other plugins (like surefire) use instrumented classes instead of original source code. This is indeed a problem because it will prevent SonarQube to match class files. So in your case you should either stick with two separate goals, or manually configure sonar.sources to refer to original source code.
Compared the maven logs and found the possible reason:
The "mvn clean clover2:setup install clover2:clover sonar:sonar" seems having issue to find the Source dirs. The log shows it uses ${project}\target\clover\src-instrumented and ${project}\target\generated-sources\annotations as the source dirs.
If explicitly specify src/main/java, then this single command works well. The only tricky thing is why running the goals separately doesn't need to specify sonar.sources but the plugin can still find the right folder for source dirs.

Gradle equivalent for mvn clean verify

I have a project which is based on gradle .I have to run the command which is equivalent for mvn clean verify .As I am new to both gradle and maven ,and have been exposed to only 3 command of both .I want to run a gradle equivalent for mvn clean verify .I searched on websites but still have not got the answer .Can some please help me to know what will be the gradle equivalent for "mvn clean verify"
gradle clean verify
or if you are using gradle wrapper:
./gradlew clean verify

What is the purpose of sonar-maven3-plugin?

I want to analyze a Maven 3 project. I found the following plugins:
org.codehaus.mojo:sonar-maven-plugin:2.0
org.codehaus.sonar:sonar-maven-plugin:3.6.2
org.codehaus.sonar:sonar-maven3-plugin:3.6.2
So I can run Sonar analysis with 3 ways:
mvn org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (or simply mvn sonar:sonar since the package is org.codehaus.mojo)
or
mvn org.codehaus.sonar:sonar-maven-plugin:3.6.2:sonar
or
mvn org.codehaus.sonar:sonar-maven3-plugin:3.6.2:sonar
What is the most appropriate way for me?
Regarding the different groupIDs of the plugins you mentioned, this is explained here:
What is the difference between org.codehaus.mojo:sonar-maven-plugin and org.codehaus.sonar:sonar-maven-plugin?
The documentation is clear about that: you just have to execute mvn sonar:sonar to run your analysis, no need to worry about anything else - SonarQube handles that for you.

Executing a specific Maven phase

Is there any way to execute a specific phase in a maven build. For example, if I only want to run those plug-ins that execute in the pre-integration-phase, does Maven provide a means to do that?
e.g.
mvn pre-integration-phase
You can't call the life-cycle-phase itself but you can call the goals of the plugins which are bound to the life-cycle-phases.
mvn compile:testCompile
mvn failsafe:integration-test
but usually this shouldn't be needed...
No. You'd have to run the plugins manually.

Resources