Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: How to deploy with deploy-file and custom wagon

I'm trying to use a custom maven wagon extension to deploy a jar to my own repository. Can I somehow configure in settings.xml that it recognizes the custom url scheme to be used with the specific wagon or do I have to always modify pom files to contain the wagon extension?


There doesn't need to be a base pom or any pom available when using the deploy-file. Settings.xml is the only place which is guaranteed to be there, but I can't figure out how to use it to define extensions.

like image 494
JtR Avatar asked Mar 02 '09 14:03

JtR


People also ask

Can we deploy using Maven?

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 use of mvn deploy command in Maven?

mvn deploy This command is used to deploy the artifact to the remote repository. The remote repository should be configured properly in the project pom. xml file distributionManagement tag. The server entries in the maven settings.

What is difference between mvn install and 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.


2 Answers

OK, ok, a correction: you cannot define the <build> element inside a <profile> defined in settings.xml. You could activate the profile in settings.xml, but define it in your base-pom.

Sorry, the only other way I could think of (probably what are you looking for), is to copy the extension jar directly under $M2_HOME/lib. All $M2_HOME/lib/*.jar are put in the classpath, so this must virtually have the same effect as an <extension>.

The extension however is better, because you can more easily control which version of the extension is used (e.g. trough the base-pom).

OK just try copying the extension jar under

    $M2_HOME/lib
like image 54
siddhadev Avatar answered Sep 22 '22 01:09

siddhadev


I don't know if the comment above by Brian Fox is still valid in 2013. But in the end I had to create a minimal pom.xml in the directory where I tried to upload the artifact to enable the wagon build extension.

I had to add groupId, artifactId and version to the pom.xml so that Maven would not complain although I provided them to the deploy-file goal on the commandline (I guess deploy-file would only care about the commandline parameters though):

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion>
<groupId>your-groupId</groupId>
<artifactId>your-artifactId</artifactId>
<version>your-version</version>
<build>
  <extensions>
    <extension>
      <groupId>org.apache.maven.wagon</groupId>
      <artifactId>wagon-ssh</artifactId>
      <version>2.4</version>
    </extension>
  </extensions>
</build>
</project>

With this simple "pom.xml" in place I could execute the deploy-file finally using scp as the protocol:

mvn deploy:deploy-file -Durl=scp://shell.sourceforge.net:/home/project-web/... -DrepositoryId=repoId -Dfile=my-file.jar -DgroupId=your-groupId -DartifactId=your-artifactId -Dversion=your-version -Dpackaging=jar
like image 37
void256 Avatar answered Sep 19 '22 01:09

void256