Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 267
Urs Reupke Avatar asked Nov 30 '12 12:11

Urs Reupke


People also ask

What does mvn clean deploy do?

clean : removes files generated at build-time in a project's directory ( target by default) install : installs the package into the local repository, for use as a dependency in other projects locally.

How does maven deploy plugin work?

The deploy plugin is primarily used during the deploy phase, to add your artifact(s) to a remote repository for sharing with other developers and projects. This is usually done in an integration or release environment.

What is the difference between mvn install and mvn deploy?

mvn:install copies your packaged Maven module to your local repository (by default, in ~/. m2/repository ), to be accessed by other local Maven builds. mvn:deploy uploads your packaged Maven module to another (usually remote) repository, to be accessed by other, not necessarily local, Maven builds.

What is a .deploy file?

Introduction. StreamBase deployment files are XML configuration files used for two primary purposes: To specify which application modules will run in which containers, along with any container connections, module parameters, or trace instructions to configure at application start time.


1 Answers

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>
like image 195
Justin Rowe Avatar answered Oct 13 '22 03:10

Justin Rowe