Reputation: 659
I have a maven project that compiles two different projects and then creates classes in this dir: ${project.build.directory}/classes
Where ${project.build.directory} points to the dir that pom.xml exists.
I’m using maven-jar-plugin with different “execution” blocks to make the jar files out of related directories/classes for each project. I’m very new to maven and have difficulty to define the right “include” and “exclude” directories.
This is the structure that my classes reside:
\target\classes\com
\target\classes\com\microsoft
\target\classes\com\google
\target\classes\org
The first jar file needs to be created out of these classes:
\target\classes\com\microsoft
\target\classes\org
And the second jar needs to be created out of these classes:
\target\classes\com\google
Following is the part of “build” block that has “execution” blocks to create these jars. The first jar is called: msn-prod and the other is called: google. As you see, I’ve tried all different combinations to create these jars and none worked - they exist in the following build block as the parts which are commented.
Can somebody please help me on this? Any help is greatly appreciated.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>msn-prod</id>
<goals><goal>jar</goal></goals>
<phase>generate-resources</phase>
<configuration>
<classifier>msn-prod</classifier>
<!-- <classesDirectory>${project.build.directory}/classes/com/microsoft</classesDirectory>
<includes>
<include>**/*.class</include>
</includes>
<classesDirectory>${project.build.directory}/classes/org</classesDirectory>
<includes>
<include>**/*.class</include>
</includes>-->
<classesDirectory>${project.build.directory}/classes</classesDirectory>
<!-- <includes>
<include>**/*.class</include>
</includes>-->
<!-- <excludes>
<exclude>**/com/google/*</exclude>
</excludes>-->
<!-- <excludes>
<exclude>**/google/*.class</exclude>
</excludes>-->
<includes>
<include>**/com/microsoft/*.class</include>
<include>**/org/*.class</include>
</includes>
<finalName>${msn.prod}-${msn.api.version}</finalName>
</configuration>
</execution>
<execution>
<id>google</id>
<goals><goal>jar</goal></goals>
<phase>generate-resources</phase>
<configuration>
<classifier>google</classifier>
<!-- <classesDirectory>${project.build.directory}/classes</classesDirectory>
<includes>
<include>**/com/google/*.class</include>
</includes>-->
<classesDirectory>${project.build.directory}/classes/com/google</classesDirectory>
<includes>
<include>**/*.class</include>
</includes>
<finalName>${google}-${google.api.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 0
Views: 1186
Reputation: 29912
You are violating the Maven best practice of one build artifact per module and therefore running into trouble. Just break it up into multiple projects and it will be easy.
Upvotes: 2