Tom
Tom

Reputation: 363

Deploy maven tar.gz artifact as build output without assembly plugin

In my Maven build, I call a script that produce some tar.gz artifact. How to specify to maven groupId, artifactId, version and packaging, so it deployed final tar.gz to artifactory during mvn deploy?

My challenge it that this is possible to achieve with assembly plugin, but not when artifact is output if arbitrary script.

For example: let's assume that my shell produce ABC.tar.gz with some groupId and artifactId. And my version is 0.0.1. I want to deploy ABC.tar.gz to artifactory so in pom file of next projects, I was able to reference it like:

<dependency>
  <groupId>my_group</groupId>
  <artifactId>ABC</artifactId>
  <version>0.0.1</version>
  <type>tar.gz</type>
</dependency>

And maven download ABC.tar.gz into .m2.

For set of reasons, I do not want to use assembly plugin.

Upvotes: 3

Views: 6490

Answers (1)

Tunaki
Tunaki

Reputation: 137084

You can use the build-helper:attach-artifact goal of the Build Helper Maven Plugin:

Attach additional artifacts to be installed and deployed.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.10</version>
  <executions>
    <execution>
      <id>attach-artifacts</id>
      <phase>package</phase>
      <goals>
        <goal>attach-artifact</goal>
      </goals>
      <configuration>
        <artifacts>
          <artifact>
            <file>${project.build.directory}/path/to/targz</file>
            <type>tar.gz</type>
          </artifact>
        </artifacts>
      </configuration>
    </execution>
  </executions>
</plugin>

This will attach the tar.gz file with the same groupId, artifactId and version as of your current Maven project. This additional artifact will be deployed and installed just like the main artifact of the project.

Upvotes: 3

Related Questions