Note that there are some explanatory texts on larger screens.

plurals
  1. POMaven practice - shared source: install artifact locally, or create shared source sibling project?
    text
    copied!<p>I've got 3 modules (A, B, C) and a parent (P) with several inter-related dependencies. </p> <p>Note that none of these projects package as JARs by default.</p> <p>A needs to package B and C and thus has a dependency declared on them of type 'compile' (and that's fine). </p> <p>B requires (at compile time) some of the source that lives within C. My question is really regarding how this is best accomplished.</p> <p>I see two options:</p> <p>Option 1) Create a 4th project, D, that holds the shared source and packages as a JAR, and declare a dependency in B on D of type 'provided', so that the source is available at compile time but is not packaged. </p> <p>Create a dependency in C on D, with a type of compile, such that the source is included in D. This replicates in the resultant artifacts the same structure/includes that the original project set up would have had. </p> <p>However it means splitting up the source and having an extra (somewhat superfluous for my particular purposes) module. </p> <p>Option 2) Using the maven install plugin and the install lifecycle phase, have C install into the local repository as a JAR and declare a dependency in B on C's JAR - so that the source is pulled out of the local repository and not from a sibling module.</p> <p>I don't mind in this case that B would get access to extra source from C that it might not need. </p> <p>Option 3) ??</p> <p>I'm pretty new to Maven so i'm not sure on the feasability of option 2 or even if it'd be good practice (can you install something that's packaged as a WAR locally as a JAR?). Would this method break from convention, or is there a better way?</p> <p>My other concern is that this would mean that you'd have to call 'maven install' from P, as 'maven package' would not install the dependency and so the build would fail. </p> <p>Any guidance on this would be great</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload