25

We use Hudson and the maven-release-plugin to do the release builds. Now I have a project which contains an assembly that puts together all needed components and then packages them into a .tar.gz package with the desired directory structure.

Now I'm trying to get the release-plugin to deploy this package to our Maven repository during the release:perform goal, but only the standard stuff (sources, javadoc, POM) are deployed.

I've already bound the assembly goal to the maven package phase, and the .tar.gz gets build during the release, but not uploaded to the repository. Any hints what I'm doing wrong here ?

Here is the assembly-plugin configuration:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-4</version>
    <configuration>
      <descriptors>
        <descriptor>src/main/assembly/distribution.xml</descriptor>
      </descriptors>
      <finalName>${pom.artifactId}-${pom.version}</finalName>
      <appendAssemblyId>false</appendAssemblyId>
      <tarLongFileMode>warn</tarLongFileMode>
    </configuration>
    <executions>
        <execution>
            <id>dist-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>assembly</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The command I run to build a release is

mvn release:prepare release:perform release:clean
Bastian Spanneberg
  • 1,195
  • 1
  • 10
  • 15

2 Answers2

36

Meanwhile, I found 2 ways of doing what I wanted.

The maven-build-helper-plugin allows to add additional entries to the list of artifacts that should be deployed:

    <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
         <version>1.3</version>
         <executions>
           <execution>
             <id>attach-distribution</id>
             <phase>package</phase>
             <goals>
               <goal>attach-artifact</goal>
             </goals>
             <configuration>
               <artifacts>
                 <artifact>
                   <file>target/${pom.artifactId}-${pom.version}.tar.gz</file>
                   <type>tar.gz</type>
                 </artifact>
               </artifacts>
             </configuration>
           </execution>
         </executions>
       </plugin>

The other is as simple as it gets and someone on the maven-user mailinglist pointed this out. Simple use the assembly:single goal instead of asssembly:assembly. This way the generated artifact is uploaded to the repository during the deploy phase.

    <execution>
        <id>dist-assembly</id>
        <phase>package</phase>
        <goals>
            <goal>single</goal> <!-- that's all :) -->
        </goals>
    </execution>
Bastian Spanneberg
  • 1,195
  • 1
  • 10
  • 15
  • Shame the plugin doesn't allow you to re-define the artifact id – Adam May 25 '16 at 16:38
  • 1
    @Bastian Could you please elaborate the second part where you have explained the 'assembly:single' goal. Where do I need to add the configuration ? also, what are the set of maven command that I need to run in order to generate the tar.gz and then deploy to the nexus repository ? I am new to maven – Rishab Prasad Jun 23 '20 at 06:51
1

Deploying files is not part of the release plugin but of the deploy plugin (release doesn't deploy stuff anywhere by itself but you can configure the deploy plugin to be called during a release).

Normally, the deploy plugin will deploy all artifacts to the remote repository but assemblies aren't artifacts; Maven can't use .tar.gz archives in its repository in any way, so it doesn't make sense to deploy them in the first place.

If you insist to copy useless files into the repository, you must use deploy:deploy-file (see the docs) to deploy a file manually and configure the plugin with an execution to invoke it during the release step. But I still advise against it.

What you're probably looking for is a way to upload an assembly somewhere automatically. I'm not aware of a plugin that does this.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • Thx, that was the way I was on at the moment, though I haven't got it working right now. But according to all infos I've found that seems to be the (only?) way to go if one wants to upload .tar.gz files into a repository. – Bastian Spanneberg Feb 11 '10 at 14:48
  • re insisting on copying useless files into the repo - maven isn't the only tool to use a repository. *.tar.gz files are used by many other packaging tools, e.g. apt, puppet etc – Adam May 25 '16 at 16:45
  • @Adam but those tools have their own repositories and often can't use Maven repositories. So it would make sense to upload to a Puppet repo but not to a Maven repo. – Aaron Digulla May 27 '16 at 11:33
  • 3
    -1 "If you insist to copy useless files into the repository". Judging my installer file "useless" is non constructive IMHO. I want to release that file and store it in the same repo as the rest of my multi-modules projetc's artifacts. So that later I have only one place to look for. I agree that it is maybe not the ultimate best place tough. – baraber Jun 27 '16 at 15:07