tags:

views:

6

answers:

0

I have the following 3 pom.xml files:

My parent pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                           http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mycompany</groupId>
    <artifactId>app</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <modules>
        <module>tool</module>
        <module>installer</module>
    </modules>
</project>

The tool project's pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mycompany</groupId>
    <artifactId>tool</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.mycompany</groupId>
        <artifactId>app</artifactId>
        <version>1.0</version>
    </parent>

    <build>
        <finalName>Tool</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeTransitive>true</excludeTransitive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
            <resource>
                <directory>${basedir}/target/dependency</directory>
            </resource>
        </resources>
    </build>

    <dependencies>
        <dependency>
            <groupId>customDependency1</groupId>
            <artifactId>customDependency1</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
</project>

The installer project's pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mycompany</groupId>
    <artifactId>installer</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.mycompany</groupId>
        <artifactId>app</artifactId>
        <version>1.0</version>
    </parent>

    <build>
        <finalName>Installer</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>customDependency2</groupId>
                                    <artifactId>customDependency2</artifactId>
                                    <version>1.0</version>
                                </artifactItem>
                                <excludeTransitive>true</excludeTransitive>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.mycompany</groupId>
                                    <artifactId>tool</artifactId>
                                    <version>1.0</version>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>target/classes/resources</outputDirectory>
                                    <destFileName>Tool.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                            <excludeTransitive>true</excludeTransitive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
            <resource>
                <directory>${basedir}/target/dependency</directory>
            </resource>
        </resources>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.mycompany</groupId>
            <artifactId>tool</artifactId>
            <version>1.0</version>
            <exclusions>
                <exclusion>
                    <groupId>customDependency1</groupId>
                    <artifactId>customDependency1</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>customDependency2</groupId>
            <artifactId>customDependency2</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
</project>

Everything works well except I'm expecting the final directory structure to look like this:

Installer.jar
  - <customDependency2 expanded>
  - resources
    - Tool.jar
      - <customDependency1 expanded>
      - <Tool's other resources>
    - <Installer's other resources>

Instead, thought, it looks like this:

Installer.jar
  - <customDependency1 expanded>
  - <customDependency2 expanded>
  - resources
    - Tool.jar
      - <customDependency1 expanded>
      - <Tool's other resources>
    - <Installer's other resources>
    - <Tool's other resources>

All of the tool project's dependencies are added to the installer project as well.

Could anyone tell me why this is and what I can do to prevent it from happening?

Any comments/suggestions are much appreciated.

Thanks,

B.J.