Maven - two sources folders with precedence

35 views Asked by At

I have the following situation. I have two different source folders, say src/main/java and src/main/java2. The two folders are something like two "branches" of the same project. First folder contains all Java files. Second folder contains only a small subset of the same files, in a different version.

I want to create two profiles: first is "normal" profile, where I only build src/main/java files; second is the "second branch" profile, where I build all files from both folders, with precedence to second folder: if a file is contained in both folders, the src/main/java2 one must be used.

First profile is simple to implement. I cannot create second profile.

I have seen lots of answers using build-helper-maven-plugin. However in this case the compile phase gives an error:

error: duplicate class

Any idea? Thank you.

0

There are 0 answers