Search code examples
mavennexusmaven-assembly-plugin

How to upload ZIP file to Nexus using Maven and avoid creating pom artifact in Nexus?


In my project I have couple of files that I pack into a ZIP file and upload it to a Nexus repository.

I implemented both actions using Maven assembly plugin:

POM.XML

<groupId>com.ddd.tools</groupId>
<artifactId>mytool</artifactId>
<version>2.1.0</version>
<packaging>pom</packaging>

<name>Tool</name>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <!-- File bin.xml saves information about which files are to be included to the ZIP archive. -->
                <descriptor>bin.xml</descriptor>
                <finalName>${pom.artifactId}-${pom.version}</finalName>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

BIN.XML

<assembly ...>
    <id>bin</id>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>src/release</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>Tool.exe</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

Now, when I look in Nexus I see TWO artifacts:

    <dependency>
      <groupId>com.ddd.tools</groupId>
      <artifactId>mytool</artifactId>
      <version>2.1.0</version>
      <type>pom</type>
    </dependency>

and

<dependency>
  <groupId>com.ddd.tools</groupId>
  <artifactId>mytool</artifactId>
  <version>2.1.0</version>
  <classifier>bin</classifier>
  <type>zip</type>
</dependency>

I'm only interested in the latter ZIP artifact because it is the ZIP file I uploaded.

How can I get rid of the first POM artifact from Nexus? Or is there any scenario where I could need it?


Solution

  • I believe what you want to do is possible when using raw repos in Nexus 3. AFAIK, the pom is required for an actual artifact upload, per khmarbaise