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
Related
I have corporate Jenkins where I don't have access to Manage Jenkins option. I want to make a build of my java app using maven.
When I try to run mvn clean install:
dir("test/test2/project") {
sh "mvn clean install -Dmaven.test.skip=true"
}
I get the following error:
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/var/jenkins/workspace/test/test2/project). Please verify you invoked Maven from the correct directory.
I was trying to add mvn -f /var/jenkins/workspace/test/test2/project/pom.xml (I have pom file in the folder) but it did not work.
I also tried
withEnv(["PATH+MAVEN=${tool 'maven-3.5.0'}/bin:${env.JAVA_HOME}/bin"]) {
sh "mvn --batch-mode -V -U -e clean install -Dmaven.test.skip=true"
which also did not work.
I would like to point to maven and java which are installed on the agent but can't seem to sucseed.
Any idea?
Can you try something like below?
dir("test/test2/project") {
sh "mvn clean install"
}
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.
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
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.
I've added some gradle task to my project. However, I still want to continuous build to run maven. My first attempt was to add an explicit script
script:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
- mvn test -B
This doesn't work. I tried to rename the build.gradle file. This doesn't work either. I probably need to remove gradlew but before that, is there a better solution?