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?
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 have a Maven build job in Jenkins and in the "Build" section, I have given Maven Version and Root POM and in the "Goals and Options" filed, I am executing the pom with customized goals. I need to write the output of the execution to a file, I tried below
clean install -Dmaven.test.skip=true -nsu -l output.log
clean install -Dmaven.test.skip=true -nsu -DoutputFile=output.log
clean install -Dmaven.test.skip=true -nsu -Doutput=output.log
Nothing works for me. Could anyone please help in either the above way or any other option available to direct the output log to a file?
According to mvn -help, the following works for me:
clean install -l output.log
The file is stored to the job workspace, if you want to publish it as an artifact, you need to add a Publish artifact or Publish document post-step (or Publish document post-build option in Maven project).
In Opendaylight, Whenever a change I made, I will build the whole project instead of specific project. mvn clean install -DskipTests=true.. Is there any way to skip the whole build and build the particular pom.xml of project.. E.g In ovsdb, If I want to run southbound project alone what i have to do?
There can be a better way but the workaround I use is :
I use a bash script to copy the jars + config files.
If I make code changes to a module,
I build the modified module
Execute the script. to copy the built jar file, config files to the specific folder location inside System folder of the unziped ODL distribution.
I restart ODL. bin/karaf clean.
Part of the bash script which I use to update common jars+config
local.sh:
elif [ $1 == common ]; then
cp /home/user/workspaces/workspace-odl/myproject/common/implementation/target/common-impl-2.0.0-SNAPSHOT.jar /home/user/controller/myproject-karaf-2.0.0-SNAPSHOT/system/com/myproject/common-impl/2.0.0-SNAPSHOT/common-impl-2.0.0-SNAPSHOT.jar
cp /home/user/workspaces/workspace-odl/myproject/common/model/target/common-model-2.0.0-SNAPSHOT.jar /home/user/controller/myproject-karaf-2.0.0-SNAPSHOT/system/com/myproject/common-model/2.0.0-SNAPSHOT/common-model-2.0.0-SNAPSHOT.jar
cp /home/user/workspaces/workspace-odl/myproject/common/config/src/main/resources/initial/89-common.xml /home/user/controller/myproject-karaf-2.0.0-SNAPSHOT/system/com/myproject/common-config/2.0.0-SNAPSHOT/common-config-2.0.0-SNAPSHOT-config.xml
rm /home/user/controller/myproject-karaf-2.0.0-SNAPSHOT/etc/opendaylight/karaf/89-common.xml
echo "Updated common"
Execution:
./local.sh common
This will copy the updated jars, and the next time you will run ODL, updated jars will be picked up.
This is fast, and doesn't require me to rebuild whole ODL project.
If you are using for first time build the whole project using command
mvn clean install -DskipTests -Dcheckstyle.skip=true
For subsequent changes say you have changed in southbound-impl build southbound-impl using above command.
Next build southbound-karaf using above command. Then you can start the karaf to test. for target/assembly/bin/karaf.[sh|bat]
Assuming you have the appropriate entries in you Maven settings.xml, you can build any module in an OpenDaylight Maven project by running Maven in its folder; for ovsdb southbound:
cd southbound
mvn clean install
Alternatively, from the project's root:
mvn -f southbound clean install
If you only want to build a single module (none of its children):
mvn -pl southbound clean install
(These are all standard Maven options.)
OpenDaylight includes a few nice extras you can use to iterate on builds more quickly:
the q profile skips all goals which don't contribute to the resulting artifact (static analysis, tests, documentation...):
mvn -f southbound clean install -Pq
updated JARs can be installed directly in a pre-existing Karaf system folder using the addInstallRepositoryPath variable:
mvn -f southbound clean install -DaddInstallRepositoryPath=.../karaf/system
(replacing ... with the appropriate path).
These can be combined, so
mvn -f southbound clean install -DaddInstallRepositoryPath=.../karaf/system -Pq
builds and installs the JARs in an existing Karaf (which can even be running — it will re-load the bundles).
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 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