The project structure is as follows:
parent:
<modules>
<module>child1</module>
<module>child2</module>
</modules>
child1:
<modules>
<module>project1</module>
<module>project1-1</module>
</modules>
child2:
<modules>
<module>project2</module>
<module>project2-1</module>
</modules>
I have two questions:
-
The code for
project1
andproject1-1
is almost identical, with only dependencies and a few code changes for different runtime environments.
I am currently copying the code fromproject1
exactly toproject1-1
with a few modifications, but this makes it a bit of a hassle for me to subsequently maintain (two copies of the code need to be maintained when new features are added). Is there a more reasonable way to do this? -
Also when compiling with maven, sometimes I want to compile only
project1
inchild1
andproject2
inchild2
. Sometimes I want to compile onlyproject1-1
inchild1
andproject2-1
inchild2
. I would like to be able to manage the compilation changes through a profile, but since the module definitions are spread across multiple poms, how should the profile be written?