As far as I can tell, deploying a third-party binary artifact using maven is done like so:
mvn deploy:deploy-file -DgroupId=<group-id> \
-DartifactId=<artifact-id> \
-Dversion=<version> \
-Dpackaging=<type-of-packaging> \
-Dfile=<path-to-file> \
-DrepositoryId=<id-to-map-on-server-section-of-settings.xml> \
-Durl=<url-of-the-repository-to-deploy>
Suppose that my repository is accessible using scp, so for instance in the above command
-Durl=scpexe://example.org//users/mvnrepo/maven
Using maven 3, this deployment command fails with an error message.
The workaround I used was to copy two jars: wagon-ssh-common-2.2.jar
and wagon-ssh-external1.0.jar
to my $M2_HOME/lib
directory.
Hence my question: Why is it that Maven cannot retrieve the appropriate wagons by itself?
(and, how to have it do that if it is possible?)
Wagons are Maven extensions. You can add them as follows:
<project>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0</version>
</extension>
</extensions>
</build>
</project>
For more details you can check the Maven Wagon page.
As a straight and short answer : adding a third party require that you have :
Further Considerations
I assume you want to use a third party library, not just publishing you own one.
If you want to use a third party library, you really should look for an existing repository hosting it. I'm pretty sure you have already searched, but it's the better way to do it. If you find one, just add it to your maven repo cache.
Next, if you don't find one, you can add it to your own repo, assuming you HAVE on. I don't really know if you are familiar with this, and it may sound obvious, so please forgive me. but A repository is not only a file server. Carlspring kinldy talked about Nexus in order to give an example. There is also Artifactory, and many others. They are true app servers. So, you must have your own one. They have interfaces that allow you to add artifacts, providing some information about it (at least group, id, version).
Finally, Maven deals with dependency paradigm. This is not a formal, but just pieces of consideration :
All those informations should be placed in pom.xml, and they would really be placed by the author (see 1), or at least provided when you use it in Maven (see 2). In all cases, they come from pom.xml ... auto generated or not ... so you'll need a pom.xml :).
Indeed, publishing or using libraries leads to the same problems : you must provide information about what the you dev in order to be used in the more automatted and trustable manner. It's sometimes quite ugly, but this is the better way to do it.
Once again, please forgive me if that sounds obvious. But by experience, when you don't manage to do something with Maven, it's quite often because it's not the good way to do it, even your process is very very smaller than "The Greatest Developpement Process" that should drive every one :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With