Dinesh Arora
Dinesh Arora

Reputation: 2255

Maven assembly : including a file at the parent level of baseDirectory

I am using maven assembly for a multi module project which looks like this

    PARENT\pom.xml 
      --warModule
         -- pom.xml
         --/target/module-1.war
      --configModule
        --pom.xml
        --target/**module-2.jar**
      --distrib
        --pom.xml
        --src/assembly/assembly.xml

In my distribution module, I want to package and create a jar file which should include only module-1.war and module-2.jar file.

My distrib/pom.xml looks like this

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.wellsfargo.gateway.fx</groupId>
    <artifactId>distrib</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<artifactId>distrib</artifactId>

<properties>
    <izpack.version>5.1.2</izpack.version>
    <izpack.base.dir>${project.build.directory}\${project.artifactId}-${project.version}-fx\izpack</izpack.base.dir>
    <izpack.standalone.compiler.version>4.3.2</izpack.standalone.compiler.version>
</properties>

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
            <descriptors>
                <descriptor>distrib/src/assembly/assembly.xml
                </descriptor>
            </descriptors>

        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

</plugins>

My assembly.xml looks like this http://maven.apache.org/xsd/assembly-2.0.0.xsd"> izpack ${main.basedir} dir false

<fileSets>
    <fileSet>
        <directory>${project.build.directory}</directory>
        <outputDirectory>propdeploy</outputDirectory>
    </fileSet>
</fileSets>
<files>

    <file>
        <source>../warModule/target/module-1.war</source>
        <destName>foreign-exchange-v2.war</destName>
        <outputDirectory>wardeploy</outputDirectory>
    </file>
    <file>
        <source>../configModule/target/module-2.jar</source>
        <destName>module-2.jar</destName>
        <outputDirectory>wardeploy</outputDirectory>
    </file>

</files>

<dependencySets>
    <dependencySet>
        <unpack>true</unpack>
        <useProjectArtifact>true</useProjectArtifact>
    </dependencySet>
</dependencySets>

The problem is that the current does not identifies the parent directory of distribution and complains that noSuchFileFound in location xxxx/distrib/warModule/target/module-v1.war and same for module-v2.war. How do I get the files in the parent folder subpath?

Any ideas?

Upvotes: 3

Views: 2508

Answers (1)

jspek
jspek

Reputation: 446

Explanation:

The main issue is that both the parent POM and child POM both have the same artifactID. Currently both artifactIDs are: <artifactId>distrib</artifactId>.

Because of the ambiguity, Maven assumes that ../ takes you to the parent folder of the Parent POM, in which case there is no /warModule folder in it.

Solution:

  1. Make sure each artifactID is unique.
  2. (Suggestion) Follow Maven guidelines for naming groupIDs, artifactIDs: https://maven.apache.org/guides/mini/guide-naming-conventions.html

Upvotes: 1

Related Questions