bn.
bn.

Reputation: 7949

Maven assembly plug-in - how to produce artifact with custom file extension?

I am producing an artifact named foo.bar.zip from the following...

My pom.xml plug-in entry looks like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <descriptor>src/assembly/bin.xml</descriptor>
        <finalName>foo.bar</finalName>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
        </execution>
    </executions>
</plugin> 

My descriptor file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<formats>
    <format>zip</format>
</formats>
<fileSets>

etc. etc. 

My question, is how do I produce a file with a custom extension? E.g. with the name foo.bar instead of foo.bar.zip.

Upvotes: 6

Views: 1973

Answers (2)

Tomas Bjerre
Tomas Bjerre

Reputation: 3500

I solved this by combining:

  1. maven-assembly-plugin
  2. copy-rename-maven-plugin
  3. build-helper-maven-plugin

The assembly plugin has a configuration option to not attach the file, so I do that:

<configuration>
    ...
    <attach>false</attach>
</configuration>

Then I use the copy-rename-maven-plugin to rename the file, produced by assembly-plugin, from zip to my custom file type (in my case it is CLI).

After that I use build-helper-maven-plugin to attach the artifact with the custom file type.

Upvotes: 5

Michele Sacchetti
Michele Sacchetti

Reputation: 163

Assembly supports just these formats:

"zip" - Creates a ZIP file format

"tar" - Creates a TAR format

"tar.gz" or "tgz" - Creates a gzip'd TAR format

"tar.bz2" or "tbz2" - Creates a bzip'd TAR format

"jar" - Creates a JAR format

"dir" - Creates an exploded directory format

"war" - Creates a WAR format

You should consider to use antrun plugin in a later goal/phase to rename file extension

Upvotes: 1

Related Questions