Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In multi-module dev mode, the DevUtil compile fails for a sub-module although compile mojo compilation suceeds. #1777

Open
scottkurz opened this issue Dec 7, 2023 · 0 comments
Labels

Comments

@scottkurz
Copy link
Member

scottkurz commented Dec 7, 2023

SYMPTOM

The problem, for a multi-module project, is a compilation error in the compile done after dev mode detects changes, BUT without a corresponding failure simply doing mvn compile. In other words, the compile done by compiler:compile is fine... the compile done by the IDE is fine... but ONLY the dev mode compile fails.

Symptom like:

C:\ydosppa\apps\JarVersionConflict\guide-maven-multimodules\finish\war3\src\main\java\io\openliberty\guides\multimodules\web\HeightsBean.java:50: error: cannot find symbol
        this.feet = io.openliberty.guides.multimodules.lib.Converter.getFeet3(cm);
                                                                    ^
  symbol:   method getFeet3(int)
  location: class Converter
C:\ydosppa\apps\JarVersionConflict\guide-maven-multimodules\finish\war3\src\main\java\io\openliberty\guides\multimodules\web\HeightsBean.java:61: error: cannot find symbol
        this.inches = io.openliberty.guides.multimodules.lib.Converter.getInches3(cm);
                                                                      ^
  symbol:   method getInches3(int)
  location: class Converter
2 errors

though again mvn compile is fine.

RECREATE CONDITIONS

As mentioned below, it might only be a problem when there is a common parent shared by multiple sub modules in the reactor build.

Also the issue likely only becomes a true problem when there is a different version of a dependency used across different submodules. Otherwise, having extra entries on a sub-module's classpath isn't necessarily going to matter.

However, say we have WAR1 and WAR2 each depending on XYZ JAR V1 and XYZ JAR V2. This is generally fine to do with the classloader structure in Liberty. But the respective modules must only be compiled against the right V1 vs. V2 JAR (if there are compile-time diffs).

CODE TO LOOK AT

Looking at this in the debugger, I can see a likely problem in the code in DevMojoUtil.updateChildProjectArtifactPaths(File, List<String>, List<String>), at line 758 in which we loop through the children of the parent POM.
We loop through this sequence, which I'll annotate an excerpt of with comments:

https://github.com/OpenLiberty/ci.maven/blob/liberty-maven-3.10/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/DevMojo.java#L778

             // Get the submodule artifacts
             compileArtifacts = projectModule.getCompileArtifacts();
             ...

             // Here 'compileClasspathElements' is passed in from the method caller; it's a collection that initially has the classpath elems of the PARENT pom, but we add each child to it.
             compileClasspathElements.addAll(project.getCompileClasspathElements());
             ...

             // Now, to this reference to the child's compile artifacts we add the full parent set, even though this might be filled with entries coming from other children
             compileArtifacts.addAll(compileClasspathElements);

RECREATE

See instructions at: https://github.com/scottkurz/lmp1777-recreate

@scottkurz scottkurz changed the title In multi-module dev mode the DevUtil compile adds classpath elements from the greater project rather than compiling a sub-module only with its own dependencies. In multi-module dev mode, the DevUtil compile fails for a sub-module although compile mojo compilation suceeds. Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant