Dima
Dima

Reputation: 8652

Maven dependency plugin adds artifact named directory

I want to copy files from some artifact. but it always adds a directory with the name of that artifact.

the pom of the artifact to copy from:

<groupId>some.group</groupId>
<artifactId>scheduler-common-test-resources</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Scheduler common test resources</name>
<description>A scheduler test resources</description>
<packaging>pom</packaging>
.
.
.
 <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <configuration>
                <descriptors>
                    <descriptor>lib/assembly.xml</descriptor>
                </descriptors>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

the assembly file:

<assembly>
<id>json</id>
<formats>
    <format>tar.gz</format>
</formats>
<fileSets>
    <fileSet>
        <directory>resources/db</directory>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>alterTables.sql</include>
            <include>createTables.sql</include>
            <include>insertsIntoReminders.sql</include>
        </includes>
        <excludes>
            <exclude>pom.xml</exclude>
        </excludes>
    </fileSet>
</fileSets>

the item to be copied in the artifact pom:

 <artifactItem>
                                <groupId>some.group</groupId>
                                <artifactId>scheduler-common-test-resources</artifactId>
                                <version>1.0.0-SNAPSHOT</version>
                                <outputDirectory>${project.build.directory}/test-classes/db/</outputDirectory>
                                <type>tar.gz</type>
                                <overWrite>false</overWrite>
                            </artifactItem>

result:

its get copied to test-classes/db/scheduler-common-test-resources-1.0.0-SNAPSHOT/

how can i remove the directory with the artifact name?

Upvotes: 2

Views: 273

Answers (1)

Tome
Tome

Reputation: 3354

The assembly-plugin will by default add a baseDirectory, which will, also by default, be ${project.build.finalName}.

In your case, you just have to indicate the plugin that you don't need that directory by adding:

<includeBaseDirectory>false</includeBaseDirectory>

in the assembly descriptor (assembly.xmlfor you). See assembly descriptor documentation.

Upvotes: 2

Related Questions