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

Dev mode recompiles already-compiled classes on initial start #1851

Open
scottkurz opened this issue Dec 13, 2024 · 2 comments · May be fixed by #1858
Open

Dev mode recompiles already-compiled classes on initial start #1851

scottkurz opened this issue Dec 13, 2024 · 2 comments · May be fixed by #1858
Labels

Comments

@scottkurz
Copy link
Member

Dev mode uses the maven-compiler-plugin to do a compile on startup (and then later uses a custom 'javac' command).

However dev mode startup doesn't end up avoiding a recompile if the classes are already locally compiled, whereas running the 'compile' phase typically will to an up-to-date check and avoid an unnecessary recompile.

It seems dev mode doesn't leverage listing files in target/maven-status (more detail below) maybe because we're using a 'null' execution id rather than 'default-compile'.

Recreate

  1. git clone [email protected]:OpenLiberty/guide-getting-started.git ; cd guide-getting-started/finish
  2. mvn clean compile
  3. mvn compile # (notice nothing is rebuilt, the "up to date" message appears)
[INFO] --- compiler:3.11.0:compile (default-compile) @ guide-getting-started ---
[INFO] Nothing to compile - all classes are up to date
  1. mvn liberty:dev # (notice the recompile, or look at timestamps, etc.)
[INFO] Running maven-compiler-plugin:compile on C:\git\guides\guide-getting-started\finish\pom.xml
[INFO] Changes detected - recompiling the module! :input tree
[INFO] Compiling 4 source files with javac [debug target 11] to target\classes

Observation

After doing a mvn compile I see:

target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

whereas after doing mvn compile; mvn liberty:dev I see:

target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
target/maven-status/maven-compiler-plugin/compile/null/createdFiles.lst
target/maven-status/maven-compiler-plugin/compile/null/inputFiles.lst

Question

Should dev mode be using an execution id of 'default-compile' somehow? Somehow it seems to not be setting or ending up with a 'null' in place of the execution id in the maven-status output?

@scottkurz scottkurz changed the title Dev mode recompiles already-compiled on initial start Dev mode recompiles already-compiled classes on initial start Dec 13, 2024
@arunvenmany-ibm
Copy link
Contributor

arunvenmany-ibm commented Jan 7, 2025

Hi @cherylking

I have identified that we are not passing any execution ID to executeMojo() method while running the goal
Made code changes to pass default execution id
image

the change is throwing the error as below
image

I checked the https://github.com/mojo-executor/mojo-executor/blob/main/mojo-executor/src/main/java/org/twdata/maven/mojoexecutor/MojoExecutor.java code and found that whenever there is a executionId available, the code is not initializing configuration. This seems to be a bug in MojoExecutor library
image

I checked out MojoExecutor and made code changes
image

After this changes, mvn compile liberty:dev is not recompiling the java files as expected
image

Shall I go ahead and try to contribute this to mojo-executor ?

@cherylking
Copy link
Member

Shall I go ahead and try to contribute this to mojo-executor ?

@arunvenmany-ibm Can you point me to the repo? Has there been any activity in the repo in the past year? If not, even if you contribute it how would we get a new version published? We could consider cloning the repo into one of our own maybe and make the change, then publish it ourselves. Let's discuss more tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants