Maven: Full reactor summary after resume a build with mvn goal -rf :module - maven

I'm using maven to manage the build of a large project that it's divided in several modules that are built from the root. So, in this case, maven will use the reactor functionality to build each module in the correct order.Something like this:
root/pom.xml
sp1/pom.xml
sp2/pom.xml
sp3/pom.xml
sp4/pom.xml
I build the project with maven from root directory using the command
mvn clean install
If the build is OK, maven will print the reactor summary:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Root Project ....................................... SUCCESS [ 18.271 s]
[INFO] sp1 ................................................ SUCCESS [ 2.034 s]
[INFO] sp2 ................................................ SUCCESS [ 22.770 s]
[INFO] sp3 ................................................ SUCCESS [03:39 min]
[INFO] sp4 ................................................ SUCCESS [04:39 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46:34 min
[INFO] Finished at: 2017-10-04T17:08:11+00:00
[INFO] Final Memory: 256M/1599M
[INFO] ------------------------------------------------------------------------
But, What happens if one of build phase of one of the subproject fails?. For example, some tests in the sp2 subproject fail and I fix them and relaunch the build from the sp2 with this command
mvn clean install -rf :sp2
The project is built correctly. Then, maven prints the reactor, but not the full reactor, only from sp2. Something like this:
```
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] sp2 ................................................ SUCCESS [ 22.770 s]
[INFO] sp3 ................................................ SUCCESS [03:39 min]
[INFO] sp4 ................................................ SUCCESS [04:39 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 46:34 min
[INFO] Finished at: 2017-10-04T17:08:11+00:00
[INFO] Final Memory: 256M/1599M
[INFO] ------------------------------------------------------------------------
My question is: Is it possible to obtain the full reactor summary (including the modules that have been built in the previous execution?)

Reactor Build Order is resolved during Reactor Sorting which leads into a deterministic sequence of execution for the list of projects. The command --resume-from (-rf) as used in:
mvn clean install -rf :sp2
resumes reactor build from the specified project, where the order is similar to as was already been decided, it simply traverses the remaining of the projects in the list which is the updated Reactor Build Order and hence the Reactor Summary corresponds to the new build order.

Related

Bintray 409 conflict - mvn release plugin uploading jar twice?

I'm struggling to push releases to Bintray in full.
From what I can tell, the issue seems to be caused by the maven release plugin trying to push the sources jar twice -- hence the HTTP 409 conflict response being returned.
So far I've not been able to locate the cause. Help would be appreciated!
I can see the jars on bintray up to the point that it fails, indicating it doesn't seem to be a credentials issue
Appending ;override=1 to the end of the url seemingly allows the release to succeed (I'm still new at this, so not 100% sure what I should be seeing)
Another collaborator is able to release fine - he's using a slightly older version of maven (downgrading from 3.6 to 3.5 is my next step, but it seems unusual/odd/unlikely?)
mvn test/package/install etc are fine - no concerns there
the version number is a full release number, not a snapshot (e.g. 1.2.3, not 1.2.3-SNAPSHOT)
edit: similar results are found using both Windows and Ubuntu (virtualbox guest)
Here's a snippet of what I believe to be the relevant parts of the mvn output, but can post more if needed.
[INFO] [INFO] --- maven-install-plugin:3.0.0-M1:install (default-install) # YYY-core ---
[INFO] [INFO] Installing /home/XXX/YYY/target/checkout/YYY-core/target/YYY-core-VERSION.jar to /home/XXX/.m2/repository/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION.jar
[INFO] [INFO] Installing /home/XXX/YYY/target/checkout/YYY-core/pom.xml to /home/XXX/.m2/repository/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION.pom
[INFO] [INFO] Installing /home/XXX/YYY/target/checkout/YYY-core/target/YYY-core-VERSION-sources.jar to /home/XXX/.m2/repository/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-sources.jar
[INFO] [INFO] Installing /home/XXX/YYY/target/checkout/YYY-core/target/YYY-core-VERSION-sources.jar to /home/XXX/.m2/repository/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-sources.jar
[INFO] [INFO] Installing /home/XXX/YYY/target/checkout/YYY-core/target/YYY-core-VERSION-javadoc.jar to /home/XXX/.m2/repository/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-javadoc.jar
[INFO] [INFO]
[INFO] [INFO] --- maven-deploy-plugin:3.0.0-M1:deploy (default-deploy) # YYY-core ---
[INFO] [INFO] Uploading to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION.jar
[INFO] [INFO] Uploaded to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION.jar (1.2 MB at 112 kB/s)
[INFO] [INFO] Uploading to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION.pom
[INFO] [INFO] Uploaded to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION.pom (4.9 kB at 824 B/s)
[INFO] [INFO] Uploading to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-sources.jar
[INFO] [INFO] Uploaded to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-sources.jar (781 kB at 96 kB/s)
[INFO] [INFO] Uploading to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-sources.jar
[INFO] [INFO] Uploading to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-javadoc.jar
[INFO] [INFO] Uploaded to bintray-YYY-ZZZ: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-javadoc.jar (3.8 MB at 218 kB/s)
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary for YYY-parent VERSION:
[INFO] [INFO]
[INFO] [INFO] YYY-parent ...................... SUCCESS [ 18.058 s]
[INFO] [INFO] YYY-core ........................ FAILURE [01:37 min]
[INFO] [INFO] YYY-core-testing ................ SKIPPED
[INFO] [INFO] YYY-B-core ...................... SKIPPED
[INFO] [INFO] YYY-B-testing ................... SKIPPED
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 01:56 min
[INFO] [INFO] Finished at: 2020-03-28T03:33:28Z
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy (default-deploy) on project YYY-core: ArtifactDeployerException: Failed to deploy artifacts: Could not transfer artifact com.github.YYY:YYY-core:jar:sources:VERSION from/to bintray-YYY-ZZZ (https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1): Failed to transfer file: https://api.bintray.com/maven/YYY/ZZZ/YYY/;publish=1/com/github/YYY/YYY-core/VERSION/YYY-core-VERSION-sources.jar. Return code is: 409, ReasonPhrase: Conflict. -> [Help 1]
Since your pom file isn't attached, I am relying on this example.
The 409 conflict is because you are publishing the same file name to the same path twice.
From the attached logs it looks like you are deploying YYY-core-VERSION-sources.jar twice (it has 2 entries of Installing and Uploading in the log). This means that you are trying to publish a jar with the same name and to the same path. This causes the conflict.
I don't know from the input you gave why you have two identical sources files. One solution, as you have mentioned, is to use the override flag ;override=1 as shown in the Upload API example. I would also take a look why you have 2 files while another collaborator has, probably, only one.

TeamCity/Maven DONT make modules be 'SKIPPED'

Lets say I've a root project called R. And it has modules A, B, C and D as submodules but each is an application.
Whenever I use teamcity/maven and there is an error it skips other modules whether its a compile/test.
So,
Whenever compiling it shows
R................SUCCESS
A................SUCCESS
B................FAILURE
C................SKIPPED
D................SKIPPED
And I want to see results in both C and D. How can I achieve this using teamcity/maven. Is there any parameter?
If you use mvn --fail-at-end all modules will be gone through but the failure will be shows only at the end of the build.
This option must be used carefully, but can be useful. The build never fails, regardless of the project result. All failures are ignore, the build just continues. On your project:
mvn clean install --fail-never (or just --fn)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Module A .............................................. SUCCESS [2.583s]
[INFO] Module B .............................................. SUCCESS [0.086s]
[INFO] Module C .............................................. FAILED [1.598s]
[INFO] Module D .............................................. SUCCESS [0.051s]
[INFO] Reactor ............................................... SUCCESS [0.921s]
[INFO] ------------------------------------------------------------------------
[INFO] Error for project: Module C (during install)
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
Please refer to /Users/clement/workspaces/experiments/Project/module-C/target/surefire-reports for the individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] + Ignoring failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Sun May 09 10:43:41 CEST 2010
[INFO] Final Memory: 31M/79M
[INFO] ------------------------------------------------------------------------
Module C failed, D is not skipped, and the global build is successful.
After that in the Teamcity you can add build failure condition for checking the results and failed the build if found any errors

How can I force Maven clean install to only show the summary of build?

The -q option is a bit too quiet for me, only shows debug and errors.
Is there any way I can force Maven to output only the summary?
ie:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] project ........................................... SUCCESS [ 2.437 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:30 min
[INFO] Finished at: 2016-04-15T10:35:15-05:00
[INFO] Final Memory: 221M/1383M
[INFO] ------------------------------------------------------------------------
Something like this will work:
(mvn clean install -l temp.build.log; grep -B 1 -A 500 Reactor\ Summary temp.build.log; rm temp.build.log)

How to compile all maven modules even if tests fail, but fail overall build if any tests fail

Context: I want to compile and test all modules in a multi-module project but if any fail either compilation or tests I want the overall build to fail.
Default configurations either stop on the first failure or skip modules after a test failure
Running:
mvn clean install
stops at the first failing module.
If you add:
mvn clean install -fae //fail at end
then all modules are run, but if tests fail then any dependent modules are skpped:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Module A ............................................. SUCCESS [15.210s]
[INFO] Module B ............................................. SUCCESS [10.923s]
[INFO] Module C ............................................. FAILED [1.731s]
[INFO] Module D ............................................. SUCCESS [3.791s]
[INFO] Module E ............................................. SUCCESS [1.488s]
[INFO] Module F ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module G ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module H ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module I ............................................. SUCCESS [1.690s]
[INFO] -----------------------------------------
Another option to force all modules to compile is:
mvn clean install -fn //fail never
but this results in the build passing when tests fail
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Module A ............................................. SUCCESS [15.210s]
[INFO] Module B ............................................. SUCCESS [10.923s]
[INFO] Module C ............................................. FAILED [1.731s]
[INFO] Module D ............................................. SUCCESS [3.791s]
[INFO] Module E ............................................. SUCCESS [1.488s]
[INFO] Module F ............................................. SUCCESS [9.062s]
[INFO] Module G ............................................. SUCCESS [16.324s]
[INFO] Module H ............................................. SUCCESS [4.032s]
[INFO] Module I ............................................. SUCCESS [1.690s]
[INFO] ------------------------------------------------------------------------
[INFO] Error for project: Module C (during install)
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
Please refer to C:\MavenBuildDir\ModuleC\surefire-reports for the
individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] + Ignoring failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30 minutes 38 seconds
[INFO] Finished at: Fri May 23 16:42:08 BST 2014
[INFO] Final Memory: 39M/185M
Can anyone advise a set of options to achieve the following:
compile all modules
run tests on all modules
If a module's tests fail but the code compiles dependent modules still get compiled and tested
Responses much appreciated - otherwise we have to run the tests repeatedly on the build server if there are multiple issues - burning a lot of time.
I would suggest to use:
mvn -Dmaven.test.failure.ignore=true --fail-at-end clean install
I would suggest to split it into two mvn calls:
mvn clean compile
mvn -fae install
The first call will fail, if there are compile errors. The second call will reuse the compiled .class-files, since "clean" is omitted. It will fail at the end, if there are test failures. But compilation has already been finished for ALL modules.
Here is a different approach: parse maven output. So either you
pipe it into some grep like command:
mvn clean install -fn | perl -pe 'END { exit $status } $status=1 if /BUILD FAILURE/;'
See https://github.com/backuitist/maven-fae-seriously
configure your CI server to do it:
See https://stackoverflow.com/a/28683700/303737

Maven build failing when deploying, build succeeds when compiling

I am using Gitlab_ci to trigger a maven script when code is pushed.
The script executes:
mvn compile
[...]
[INFO] project ............................................ SUCCESS [1.312s]
[INFO] project-api ........................................ SUCCESS [1.416s]
[INFO] project-api-impl ................................... SUCCESS [0.329s]
[INFO] project-webapp ..................................... SUCCESS [0.192s]
[INFO] project-webapp-exec ................................ SUCCESS [0.026s]
[INFO] project-webapp-it .................................. SUCCESS [2.052s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
mvn tomcat7:deploy
[INFO] project............................................ SUCCESS [1.840s]
[INFO] project-api ........................................ SUCCESS [2.524s]
[INFO] project-api-impl ................................... FAILURE [0.257s]
[INFO] project-webapp ..................................... SKIPPED
[INFO] project-webapp-exec ................................ SKIPPED
[INFO] project-webapp-it .................................. SKIPPED
And I get the following error:
[ERROR] Failed to execute goal on project project-api-impl: Could not resolve dependencies for project eu.project:project-api-impl:jar:0.6-DEVELOPMENT: Failure to find eu.project:project-api:jar:0.6-DEVELOPMENT in http://repo.maven.apache.org/maven2
Since the project builds successfuly (the WAR is created), I can't understand why when executing deploy, build fails.
[Also, I am not sure whether to mark this as homework. The assignment's goal is to create a tomcat web application and manually deploy to a server to test. Since maven / continuous integration wasn't a requisit, I believe this should not be marked as a homework question]

Resources