简体   繁体   中英

How do I get Maven to ignore local project for local repository version

I have a multi-module maven project where we shade Google's Guava to relocate the packages into our package tree so that we don't have to worry about version conflicts. I understand that this is a fairly common practice.

Building the jar works fine as does building the system generally. However, when executing the site:site target in Maven it calls compiler:testCompile and at this point the relocated classes can not be found. Let me point out that the earlier testCompile worked just fine.

I suspect that this is because the maven shading project is a peer of the project that fails and that during the second testCompile execution it finds the shading project, looks and finds no classes to compile against and so dies. There is a properly named shaded jar in the target directory and it does contain the classes that are being looked for.

What I think I want to know is: Is there a mechanism to tell maven to look for the jar in the sub-module (the source never existed there) and skip the compiled classes? I suppose as a last resort I could extract the contents of the just built jar into the target/classes directory so they can be found.

Any assistance would be appreciated.

We had the same problem in the past. And ended up with a separate release cycle for shaded artefact and other modules, while they were kept in the same repo:

/pom.xml - root for all child modules, except the shaded one
/shaded/pom.xml - no ref to parent (no <parent> section), own release cycle
/module1/pom.xml - explicit ref to released version of shaded artefact
...
/moduleN/pom.xml

In IDE these files /pom.xml and /shaded/pom.xml were imported as separate projects.

This becomes even more useful later, when re-building shaded modules actually happened only several times a year.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM