3

I have a compressed tar.gz file and I want use it as dependency for other projects.

I am unable upload it in maven repository with the following command because maven doesn't support tar.gz packaging :

mvn install:install-file -Dfile=/path-to-file/XXX-0.0.1-SNAPSHOT.tar.gz -DpomFile=/path-to-pom/pom.xml

Sample pom.xml

<project>

  <modelVersion>4.0.0</modelVersion>
  <name>XXX</name>
  <groupId>com.example.file</groupId>
  <artifactId>xxx</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>tar.gz</packaging>

</project>

If I use the above mentioned command with rar packaging then maven does upload XXX-0.0.1-SNAPSHOT.tar.gz file but with .rar extension.

Beside developing maven plugin for custom package, is there any way to upload tar.gz in maven repository and later use it in other project as dependency?

(Note: I just want to use tar.gz and not any other compression e.g rar, etc).

Muhammad Ali Qasmi
  • 121
  • 1
  • 1
  • 6
  • Only possible as an attached artifact not as main artifact. Apart from that. Where does the `tar.gz` package come from? Maven build? – khmarbaise Aug 19 '15 at 07:21
  • possible duplicate of [Upload artifacts to Nexus, without Maven](http://stackoverflow.com/questions/4029532/upload-artifacts-to-nexus-without-maven) – Mark O'Connor Aug 19 '15 at 13:01

1 Answers1

5

@khmarbaise, thanks you guided correctly. The problem is solved using attached artifact. Here is a snippet from my pom.xml :

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <version>1.7</version>
      <extensions>true</extensions>
      <executions>
        <execution>
          <id>attach-artifacts</id>
          <phase>package</phase>
          <goals>
            <goal>attach-artifact</goal>
          </goals>
          <configuration>
            <artifacts>
              <artifact>
                <file>xxx-0.0.1-SNAPSHOT.tar.gz</file>
                <type>tar.gz</type>
                <classifier>optional</classifier>
              </artifact>
            </artifacts>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Similarly the dependency can be added in other project as follows:

<dependencies>
    <dependency>
     <groupId>your.group.id</groupId>
     <artifactId>xxx</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <classifier>optional</classifier>
     <type>tar.gz</type>
    </dependency>
  </dependencies>
Muhammad Ali Qasmi
  • 121
  • 1
  • 1
  • 6
  • I was looking for a way to actually add the rar (resource adapter archive) to the repository as it was being packaged in one of my other assemblies and this helped. Thanks – sarmahdi Apr 18 '16 at 23:32