loizbak commented on issue #27: MCOMPILER-372 - fix test compile issue: added 
dependency test path for modules
URL: 
https://github.com/apache/maven-compiler-plugin/pull/27#issuecomment-571935305
 
 
   Hello,
   
   I added this "second chance" test arefact resolution for following reason:
   project may have a test dependency to a test artifact wich is not in
   reactor projects list.
   For better  explanation, I did the modification you suggested and built
   then compiler plugin.
   
   In target/it/MCOMPILER-372_modularized_testjar, there are at least 2
   projects:
   -> prj1 : defining prj1-tests.jar containing a Prj1Test class
   -> prj2 : test dependency to prj1, containing Prj2Test class extending
   Prj1Test
   
   Integration test is OK.
   
   If I run clean install from *
   target/it/MCOMPILER-372_modularized_testjar *folder,
   there is a problem.
   mvn clean install
   [ERROR] COMPILATION ERROR :
   [INFO] -------------------------------------------------------------
   [ERROR]
   
/C:/Users/frup82455/git/loizbak/maven-compiler-plugin/target/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java:[25,12]
   cannot f
   ind symbol
     symbol:   class Prj1Test
     location: package prj1
   [ERROR]
   
/C:/Users/frup82455/git/loizbak/maven-compiler-plugin/target/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java:[27,31]
   cannot f
   ind symbol
     symbol: class Prj1Test
   [INFO] 2 errors
   [INFO] -------------------------------------------------------------
   [INFO]
   ------------------------------------------------------------------------
   [INFO] Reactor Summary for mcompiler-372 1.0-SNAPSHOT:
   [INFO]
   [INFO] mcompiler-372 ...................................... SUCCESS [
    0.374 s]
   [INFO] prj0-372 ........................................... SUCCESS [
   19.295 s]
   [INFO] prj1-372 ........................................... SUCCESS [
    2.031 s]
   [INFO] prj2-372 ........................................... FAILURE [
   53.307 s]
   [INFO] prj3-372 ........................................... SKIPPED
   [INFO]
   ------------------------------------------------------------------------
   [INFO] BUILD FAILURE
   [INFO]
   ------------------------------------------------------------------------
   
   It fails because  getModuleTestPathElt() tries to find sibling test
   artefact of
   
C:\...\maven-compiler-plugin\target\it\MCOMPILER-372_modularized_testjar\prj1\target\
   *prj1-372-1.0-SNAPSHOT.jar*.
   Reactor project build directory is
   
C:\...\maven-compiler-plugin\target\it\MCOMPILER-372_modularized_testjar\prj1\target\
   *classes*
   
   So method getModuleTestPathEltFromReactorProjects() doesn't match target\
   *prj1-372-1.0-SNAPSHOT.jar* and  target\*classes*.
   No test artefact is provided back and test compilation fails.
   
   I reactivated the "double chance" method and it works fine:
   
   Reactor Summary for mcompiler-372 1.0-SNAPSHOT:
   mcompiler-372 ...................................... SUCCESS [  0.577 s]
   prj0-372 ........................................... SUCCESS [  8.593 s]
   prj1-372 ........................................... SUCCESS [  5.870 s]
   prj2-372 ........................................... SUCCESS [  6.139 s]
   prj3-372 ........................................... SUCCESS [  6.727 s]
   ------------------------------------------------------------------------
   BUILD SUCCESS
   ------------------------------------------------------------------------
   
   It's strange that integration doesn't excercize this test case the same as
   from the command prompt.
   I would appreciate suggestions to improve that integration test, may be 2
   test artifacts resolution flavours : one with prj1\target\*classes *and one
   with prj1\target\*prj1-372-1.0-SNAPSHOT.jar*
   
   Anyway, there are other case where resolution from reactor projets list
   wouldn't work.
   Assume prj2 is build from a standalone folder, prj1 would not be in reactor
   list.
   
   In other work, I can't figure out how to get rid of "double chance" test
   artefact resolution.
   
   Best regards,
   François
   
   Le mar. 7 janv. 2020 à 19:05, Robert Scholte <[email protected]> a
   écrit :
   
   > *@rfscholte* commented on this pull request.
   > ------------------------------
   >
   > In src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
   > 
<https://github.com/apache/maven-compiler-plugin/pull/27#discussion_r363877268>
   > :
   >
   > > +            {
   > +                pathElements.put( entry.getKey().getAbsolutePath(), 
entry.getValue() );
   > +            }
   > +        }
   > +    }
   > +
   > +    /**
   > +     * Get module test path element from module path element
   > +     * @param modulePathElt
   > +     * @return
   > +     */
   > +    private File getModuleTestPathElt( File modulePathElt )
   > +    {
   > +
   > +        // Get test path from reactor projects
   > +        File result = getModuleTestPathEltFromReactorProjects( 
modulePathElt );
   >
   > Can you change this to return getModuleTestPathEltFromReactorProjects(
   > modulePathElt );
   >
   > I can't think of a reason why we need the rest of the code in this method.
   > It would mean something went wrong somewhere else.
   >
   > —
   > You are receiving this because you modified the open/close state.
   > Reply to this email directly, view it on GitHub
   > 
<https://github.com/apache/maven-compiler-plugin/pull/27?email_source=notifications&email_token=AEKICUZCIALIZ4EDDAUUAIDQ4S763A5CNFSM4J33NR7KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCQ5PQPA#pullrequestreview-339408956>,
   > or unsubscribe
   > 
<https://github.com/notifications/unsubscribe-auth/AEKICU3VT4DVWVRURRAU6JTQ4S763ANCNFSM4J33NR7A>
   > .
   >
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to