How to make the Maven Deploy Plugin only upload a specific file?

I want to add two zips to an already published version in Nexus. Essentially, they are a zipped up demo of the application and an extended version of the same application, also zipped.

Using the Deploy plugin, I defined two executions in my pom, one for each file and bound them to the deploy phase. Here's the one for the demo:

<execution>
   <id>deploy-essential</id>
      <phase>deploy</phase>
      <goals>
         <goal>deploy-file</goal>
      </goals>
      <configuration>
         <file>${project.build.directory}/${project.artifactId}-${project.version}-demo.zip</file>
         <groupId>${project.groupId}</groupId>
         <artifactId>myproject</artifactId>
         <version>${project.version}</version>
         <classifier>demo</classifier>
         <repositoryId>nexus</repositoryId>
         <url>${targetrepository}</url>
         <generatePom>false</generatePom>
      </configuration>
   </execution>

I expected Maven to upload the file and update the metadata tothe given G/A/V coordinates when this execution comes up. Instead, though, it uploads the given file and it's sister file containing the full version to the given coordinates and then uploads both of them again to their original coordinates.

It then goes on to do all of this again for the second execution. Here's an excerpt from my log:

[INFO] --- maven-deploy-plugin:2.7:deploy-file (deploy-demo) @ bundle ---
Downloading: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/maven-metadata.xml
2 KB   

Downloaded: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/maven-metadata.xml (2 KB at 4.8 KB/sec)
Uploading: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/myproject-1.2.6-20121130.102624-5-demo.zip
...           
Uploaded: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/myproject-1.2.6-20121130.102624-5-demo.zip (13032 KB at 23105.2 KB/sec)
Downloading: http://nexus/repositories/snapshots/mygroup/myproject/maven-metadata.xml
533 B      

Downloaded: http://nexus/repositories/snapshots/mygroup/myproject/maven-metadata.xml (533 B at 34.7 KB/sec)
Uploading: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/maven-metadata.xml
2 KB    

Uploaded: http://nexus/repositories/snapshots/mygroup/myproject/1.2.6-SNAPSHOT/maven-metadata.xml (2 KB at 89.4 KB/sec)
Uploading: http://nexus/repositories/snapshots/mygroup/myproject/maven-metadata.xml
533 B   

Uploaded: http://nexus/repositories/snapshots/mygroup/myproject/maven-metadata.xml (533 B at 32.5 KB/sec)
Downloading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml
861 B   

Downloaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml (861 B at 3.8 KB/sec)
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/bundle-1.2.6-20121130.102625-3-full.zip
...           
Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/bundle-1.2.6-20121130.102625-3-full.zip (13065 KB at 18531.7 KB/sec)
Downloading: http://nexus/repositories/snapshots/mygroup/bundle/maven-metadata.xml
410 B      

Downloaded: http://nexus/repositories/snapshots/mygroup/bundle/maven-metadata.xml (410 B at 8.5 KB/sec)
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml
861 B   

Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml (861 B at 27.1 KB/sec)
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/maven-metadata.xml
410 B   

Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/maven-metadata.xml (410 B at 5.1 KB/sec)
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/bundle-1.2.6-20121130.102625-3-demo.zip
...           
Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/bundle-1.2.6-20121130.102625-3-demo.zip (13032 KB at 13631.1 KB/sec)
Uploading: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml
861 B      

Uploaded: http://nexus/repositories/snapshots/mygroup/bundle/1.2.6-SNAPSHOT/maven-metadata.xml (861 B at 56.1 KB/sec)

This is not a big thing for SNAPSHOTs, but it completely blocks releases since Nexus is configured to reject redeployments.

I don't think this behaviour is intended, and I am sure I missing something. Can I somehow get Maven to only upload the file I actually configured?

Answers


Why not using the assembly plugin which can attach artifacts to your current deployment or use the build-helper-maven-plugin which can simply attach other artifacts to your build. Using the deploy plugin during a usual build is the wrong way.


Because you didn't disable the default deploy mechanism, it is still being executed. You need something like this:

        <plugin>
            <artifactId>maven-deploy-plugin</artifactId>
            <executions>
                <!-- disable standard deploy -->
                <execution>
                    <id>default-deploy</id>
                    <phase>none</phase>
                </execution>
                <execution>
                    <id>deployEssential</id>
                    <phase>deploy</phase>
                    ...
                </execution>
            </executions>
        </plugin>

An alternative to using the built-in deploy plugin (which is meant for deploying maven artifacts):

  • Disable the built-in deployment mechanism
  • Enable wagon-maven-plugin for the deploy phase
  • Add FTP credentials to HOME/.m2/settings.xml
  • Execute mvn deploy to copy the FTP file

<!-- disable standard deploy -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>3.0.0-M1</version>
  <executions>
    <execution>
      <id>default-deploy</id>
      <phase>none</phase>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>wagon-maven-plugin</artifactId>
  <version>1.0</version>
  <executions>
    <execution>
      <id>deploy-release</id>
      <phase>deploy</phase>
      <goals>
        <goal>upload</goal>
      </goals>
      <configuration>
        <serverId>nexus</serverId>
        <url>${targetrepository}</url>
        <fromDir>${project.build.directory}</fromDir>
        <toDir>${project.version}</toDir>
        <includes>${project.artifactId}-${project.version}-demo.zip</includes>
      </configuration>
    </execution>
  </executions>
</plugin>

Need Your Help

Angular ui-select multiple and ui-validate

jquery css angularjs jquery-ui angular-ui-select

In my angular app I use the ui-select (angular-ui-select).

Add rating functionality in message board portlet in liferay

liferay liferay-6

I have to give rating functionality in message board portlet. for that I have created hook and override view.jsp file of message board portlet. I have added "liferay-ui:rating" tag as