lukasz-antoniak commented on PR #2000:
URL: 
https://github.com/apache/cassandra-java-driver/pull/2000#issuecomment-2582431197

   I have diagnosed why removing Maven clean plugin solves the problem.
   
   When I run `mvn verify` phase and `maven-clean-plugin` is not present, we 
can notice the following log:
   ```
   [DEBUG] New compile source roots:
     /Users/Developer/GitHub/cassandra-java-driver/guava-shaded/src/main/java
     
/Users/Developer/GitHub/cassandra-java-driver/guava-shaded/target/generated-sources/annotations
   [DEBUG] CompilerReuseStrategy: reuseCreated
   [DEBUG] useIncrementalCompilation disabled
   [INFO] Nothing to compile - all classes are up to date
   ```
   On the other hand, if we run the same with `maven-clean-plugin` enabled, we 
see:
   ```
   [DEBUG] New compile source roots:
     /Users/Developer/GitHub/cassandra-java-driver/guava-shaded/src/main/java
     
/Users/Developer/GitHub/cassandra-java-driver/guava-shaded/target/generated-sources/annotations
   [DEBUG] CompilerReuseStrategy: reuseCreated
   [DEBUG] useIncrementalCompilation disabled
   ```
   Log `Nothing to compile - all classes are up to date` indicates that all 
sources are compiled and up to date. This corresponds to this [part of 
code](https://github.com/apache/maven-compiler-plugin/blob/maven-compiler-plugin-3.8.1/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java#L850).
 For a source file to be considered up-to-date compiled, it needs to ([source 
code](https://github.com/sonatype/plexus-compiler/blob/master/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/util/scan/StaleSourceScanner.java#L94)):
   1. Have a present corresponding target file.
   2. Modification timestamp of compiled class later than source file.
   
   Above logic has drawn my attention to the target classes and how clean 
plugin impacts the behaviour.
   
   Maven clean plugin disabled:
   ```
   $ java8
   $ mvn clean install -DskipTests
   $ ls -l 
./guava-shaded/target/classes/com/google/common/primitives/LexicographicalComparatorHolderSubstitution.class
   -rw-r--r--  1 lukasz staff  1498 Jan 10 09:26 
./guava-shaded/target/classes/com/google/common/primitives/LexicographicalComparatorHolderSubstitution.class
   $ java11
   $ mvn verify ....
   $ ls -l 
./guava-shaded/target/classes/com/google/common/primitives/LexicographicalComparatorHolderSubstitution.class
   -rw-r--r--  1 lukasz staff  1498 Jan 10 09:26 
./guava-shaded/target/classes/com/google/common/primitives/LexicographicalComparatorHolderSubstitution.class
   ```
   
   Maven clean plugin enabled:
   ```
   $ java8
   $ mvn clean install -DskipTests
   $ ls -l 
./guava-shaded/target/classes/com/google/common/primitives/LexicographicalComparatorHolderSubstitution.class
   ls: 
./guava-shaded/target/classes/com/google/common/primitives/LexicographicalComparatorHolderSubstitution.class:
 No such file or directory
   $ ls -l ./guava-shaded/target/classes/com/                                   
                                       
   total 0
   drwxr-xr-x  3 lukasz staff  96 Jan 10 09:34 datastax
   ```
   
   This shows that Maven clean plugin removes compiled 
`LexicographicalComparatorHolderSubstitution` class from 
`com/google/common/primitives` directory. This is **desired** as the class has 
been copied by shaded plugin to 
`com/datastax/oss/driver/shaded/guava/common/primitives/LexicographicalComparatorHolderSubstitution.class`.
 It becomes also clear why removing the clean plugin works - compiled source 
files under `target/com/google/common/primitives` are still present when 
running `mvn verify`.
   
   If we remove Maven clean plugin, resulting shaded Guava JAR has two 
`LexicographicalComparatorHolderSubstitution` classes, whereas only one should 
be present.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to