I am currently struggling with Maven: I have a complex project consisting of several nested modules and for some of these modules I have similar configurations in POM.
I want to make it clean. In fact, I would like to define the general runnable-jar configuration and activate it in some modules.
Here is a POM snippet that I would like to split between several projects:
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptors> <descriptor>src/main/assembly/runnable-jar-assembly.xml</descriptor> </descriptors> <archive> <manifest> <mainClass>${mainClass}</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-runnable-jar</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
In some of the POMS, I would like to do something like:
<properties> <mainClass>my.main.Class</mainClass> </properties> <import>src/main/pom/runnable-jar-pom.xml</import>
I was looking for a mean to import some XML fragments into the POM or to define the entire macro of the XML nodes.
For what I found, the closest solution would be to identify the profile in the parent POM and activate it in some submodules by checking the file. See this related question . But I ran into the problem that the {basedir} property is not set correctly inherited / set.
It is very surprising to me that I need to do something to crack something basic (= usually). How do you usually deal with this in Maven?
Raphael jolivet
source share