On 16.01.2017, at 14:50, Marshall Schor <m...@schor.com> wrote:
> 
> I'm fine with either approach. I suspect different projects may find each
> approach, or even a 3rd approach (e.g., Peter's idea of just migrating at some
> point), best for their project.  I would hope to include a short chapter in 
> the
> uv3-guide describing a bit of a cookbook for each of these approaches :-).
> 
> One thing I don't yet understand: if we have two "generated-sources" in 
> target/,
> each defining identically named JCas classes, the compile targets for these
> can't both be target/classes/.  Anyone know the Maven convention for handling
> this so two different JARs can be built?

I expect that we'd need something like:

1) 1 execution for the maven-jcasgen-v2-plugin
2) 1 execution for the maven-jcasgen-v3-plugin
3) 1 execution of the maven-compiler-plugin compile the v2 code
4) 1 execution of the maven-compiler-plugin compile the v3 code
5) 1 execution of the maven-compiler-plugin compile the main code 
   against either the v2 or the v3 code - doesn't matter too much
   because the API is the same and they should be binary compatible
6) 1 execution of the maven-jar-plugin to package the main classes and attach 
them to the artifact
7) 1 execution of the maven-jar-plugin to package the v2 jcas classes and 
attach them to the artifact
8) 1 execution of the maven-jar-plugin to package the v3 jcas classes and 
attach them to the artifact

However, I cannot figure out atm if/how it is possible to tweak Maven
such that we can control the sourcepaths properly in steps 3, 4, and 5.
The "includes/excludes" of the compiler plugin are no help here because they are
relative to the source paths and the v2 and v3 classes will have the same 
names/packages.
The maven-build-helper plugin is also no help, because it only allows to *add* 
source folders,
but not to remove them...

I general,  I've found one approach that works with excludes in the Maven JAR 
plugin,
but that only kicks in after everything has been compiled - we probably
are going to hit problems when we start even compiling.

http://blog.sonatype.com/2010/01/how-to-create-two-jars-from-one-project-and-why-you-shouldnt/

That article also mentions the user of the Maven Assembly Plugin for
complicated cases. 

I didn't dig into detail into how DL4J does it for their native API and
platform-specific library JARs where they use classifiers.

I just found another approach which shows how to use multiple POMs but only
a single source folder - but that just for completeness. I don't see how it 
would help:

https://maven.apache.org/guides/mini/guide-using-one-source-directory.html
  
Cheers,

-- Richard

Reply via email to