M'λ'
M'λ'

Reputation: 651

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

I'm using the assembly plugin to package my a swing application with artifactId killer-app with a custom assembly descriptor.

The assembly works fine and I can include whatever I want inside the /killer-app/ directory inside the assembly.

killer-app-archive.zip
 \- killer-app
    \- whatever ...

The problem is that I must include another file at the same level of the /killer-app/ folder inside the archive.

killer-app-archive.zip
 \- killer-app
 |  \- whatever ...
 \- launch.bat

I have been trying to play with the

<includeBaseDirectory>false</includeBaseDirectory>

but that simply remove the /killer-app/ folder, which I must preserve.

Upvotes: 2

Views: 9681

Answers (1)

asgoth
asgoth

Reputation: 35829

Three steps which could solve your problem:

  • change baseDirectory to ../
  • Use FileSets to add the extra files.
  • Use DependencySet to add the project artifact (useProjectArtifact = true)

This should solve your problem. Here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>my-assembly</id>
    <baseDirectory>../</baseDirectory>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <unpack>true</unpack>
            <useProjectArtifact>true</useProjectArtifact>
        </dependencySet>
    </dependencySets>
    <fileSets>
        <fileSet>
            <directory>path/to/resource</directory>
            <includes>
                <include>**/*.bat</include>
            </includes>
            <outputDirectory>/</outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

Upvotes: 9

Related Questions