Open ericglau opened 3 years ago
Addressing the second issue stated above (step 6):
/Users/eric/git/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/HeightsBean.java:50: error: package io.openliberty.guides.multimodules.lib does not exist
this.feet = io.openliberty.guides.multimodules.lib.Converter.getFeet(cm);
^
/Users/eric/git/guide-maven-multimodules/finish/war/src/main/java/io/openliberty/guides/multimodules/web/HeightsBean.java:61: error: package io.openliberty.guides.multimodules.lib does not exist
this.inches = io.openliberty.guides.multimodules.lib.Converter.getInches(cm);
^
2 errors
This is due to how Maven resolves classpath elements for multi module builds. When the jar/src
directory exists, thanks to the Maven reactor the war module's classpath has the following entry for the jar module:
/Users/kathrynkodama/devex/sampleProjects/guide-maven-multimodules/finish/jar/target/classes
Maven uses the reactor to add target directories of upstream modules to the current modules classpath.
When dev mode starts without the jar/src/
directory, the war module's compile classpath elements has the following entry for the jar module:
/Users/kathrynkodama/.m2/repository/io/openliberty/guides/guide-maven-multimodules-jar/1.0-SNAPSHOT/guide-maven-multimodules-jar-1.0-SNAPSHOT.jar
Since the jar module is not being installed to the local repo, the war module cannot resolve the jar module's dependency even after the jar/src
directory is added.
One workaround would be to call mvn compile
from the top-level pom in order to trigger the reactor and have the /guide-maven-multimodules/finish/jar/target/classes
directory added to the classpath. This would also require updating the artifact paths for all of the modules.
We can document this as a limitation for now (as part of OpenLiberty/ci.maven#1199) that dev mode must be started with an existing src/main/java dir with existing Java file(s).
Just looking over this, I think we could close this.
We have a very clear warning explaining what's going on. I also believe we have other limitations in dev mode where we are unable to watch new directories (e.g. I think we might not be able to act to a new resource directory being added, IIRC).
Maybe the next pass we take through the issues backlog we could consider closing.
jar/src
andwar/src/main/java
mvn install
to install the project to ~/.m2 (no compilation errors occur because there is no Java code in the source of any modules)mvn io.openliberty.tools:liberty-maven-plugin:3.3.5-M3-SNAPSHOT:dev
jar/src/main/java/io/openliberty/guides/multimodules/lib/Converter.java
. Dev mode DOES recompile the jar and war modules, but the following compilation error occurs **ear/target/liberty/wlp/usr/servers/defaultServer/apps/guide-maven-multimodules-ear.ear.xml
***In summary, 3 related problems here denoted by , , and above.