devonfw / devon4j

devonfw Java stack - create enterprise-grade business apps in Java safe and fast
Apache License 2.0
83 stars 87 forks source link

archetype build broken with ci-friendly-maven #389

Closed hohwille closed 3 years ago

hohwille commented 3 years ago

With issue #85 we introduced ci-friendly-maven also for our archetype. Now, @suvmanda has found out a new bug with this approach that can be reproduced by the following steps:

devon java create com.demo.example
cd example
mvn clean install
cd core
mvn clean install

The first build is successful:

[INFO] example ............................................ SUCCESS [  0.588 s]
[INFO] example-api ........................................ SUCCESS [  3.981 s]
[INFO] example-core ....................................... SUCCESS [ 11.830 s]
[INFO] example-server ..................................... SUCCESS [  2.396 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

However, the second one failes with:

[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.demo:example-core >------------------------
[INFO] Building example-core 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.758 s
[INFO] Finished at: 2021-05-06T11:26:32+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project example-core: Could not resolve dependencies for project com.demo:example-core:jar:1.0.0-SNAPSHOT: Failed to collect dependencies at com.demo:example-api:jar:1.0.0-SNAPSHOT: Failed to read artifact descriptor for com.demo:example-api:jar:1.0.0-SNAPSHOT: com.demo:example:pom:${revision} was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
hohwille commented 3 years ago

I just looked at the installed parent POM of the project ($M2_REPO/com/demo/example/1.0.0-SNAPSHOT/example-1.0.0-SNAPSHOT.pom) and it contains:

  <version>${revision}</version>

Even worse also the POM of the API module was not flattened either ($M2_REPO/com/demo/example-api/1.0.0-SNAPSHOT/example-api-1.0.0-SNAPSHOT.pom):

  <version>${revision}</version>

So it has not been flattened and that is definetly a bug.

hohwille commented 3 years ago

The flatten-maven-plugin is only added to dependencyManagement in our application template (archetype): https://github.com/devonfw/devon4j/blob/fbbdb7326cc016b12fb5b8eb63f40a5b5de7b0af/templates/server/src/main/resources/archetype-resources/pom.xml#L276

However, it is never added to the build and therefore does not resolve variables such as ${revision}. Therefore the build is entirely broken. We have to fix this quickly as this will also break projects, trainings or tutorials done on the latest archetype. @suvmanda thanks for figuring out this bug. This is an excellent finding that we should have already found with issue #85 and PR #382. Anyhow great that we now are aware and can fix it before any harm has happened.