OpenLiberty / ci.maven

Maven plugins for managing Liberty profile servers #devops
Apache License 2.0
130 stars 91 forks source link

Dev mode does not show errors if upstream module already installed in .m2 #1201

Closed ericglau closed 3 years ago

ericglau commented 3 years ago
  1. Use this project: https://github.com/OpenLiberty/guide-maven-multimodules/tree/master/finish
  2. Run mvn install to install the project to ~/.m2
  3. Delete jar/src/main/java/io/openliberty/guides/multimodules/lib/Converter.java
  4. Run mvn clean io.openliberty.tools:liberty-maven-plugin:3.3.5-M3-SNAPSHOT:dev
  5. Dev mode should give an error at this point because the war module has Java code that depends on the deleted class in the jar module. However, dev mode has no error because the compilation dependency was found in ~/.m2. But when you go to http://localhost:9080/converter/ and enter a value and click Submit, it gets a NoClassDefFoundError at runtime:
    ...
    Caused by: java.lang.NoClassDefFoundError: io.openliberty.guides.multimodules.lib.Converter

Consider using something like https://maven.apache.org/plugins/maven-dependency-plugin/purge-local-repository-mojo.html to remove each module from ~/.m2 before running its build lifecycle in dev mode, so that if a downstream module depends on it, it should fail. But do not purge ear projects (so that https://github.com/OpenLiberty/ci.maven/issues/1176 will still work.)

scottkurz commented 2 years ago

The #1570 fix addresses this problem without adding/purging from the local .m2 repository.