How to deploy JAR to Maven remote repository - maven

Is there any way to put my JAR file in remote repository, so my maven project can get this JAR file from any place via Internet?
I have downloaded and did some fixes in the ReportNG project: https://github.com/dwdyer/reportng .
Using ANT I have compiled this project into JAR, now I want to put it into remote Maven repository, but don't know how I can do that.
Could somebody please suggest me the way, how I can perform that?

If it is a released version you want to make available in maven central follow this guide: http://maven.apache.org/guides/mini/guide-central-repository-upload.html
I'm no github professional but since a maven repo is just a file structure with some meta-data you can put it anywhere maven can read it (ftp, http, ...). so you could create a git repo to host your maven artifacts. see http://cemerick.com/2010/08/24/hosting-maven-repos-on-github/ for an example. (it may be outdated - github may have something like maven repo hosting, I just dont know)

A lightweight way to create your own maven repository is to store it on github. See Hosting a Maven repository on github for more details

I followed sonatype open source project maven deployment guide https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide and successfully deployed the latest version of reportNG into maven central repository. Now maven have both 1.1.3 and 1.1.4
http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.uncommons%22%20AND%20a%3A%22reportng%22

You should do a pull request to the github project. If the maintainer likes your fix he will put it in the next version.
If you need your fix in a remote repo NOW then you'll have to setup your own maven repository.

Related

Integrate the local maven plugin with remote repository

I have created a simple maven plugin and installed it in my local repo(.m2). Now I want to use that plugin with a git repo(maven project). How can I do that?
Currently, I am trying to build my git repo using Jenkins and it throws below error-
[ERROR] Plugin sample.plugin:hello-maven-plugin:0.0.1-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact sample.plugin:hello-maven-plugin:jar:0.0.1-SNAPSHOT
I believe simply changing the pom file of my git repo won't work. What should I do so that it resolves the plugin dependency by looking into the .m2 dir first
Your Jenkins probably deploys to a Nexus or Artifactory server. That server is also the right place to manage your plugin.

How to update maven package after commit/pull-request

I am using a package https://github.com/dhatim/fastexcel, resently there was a commit in their repo, but the version had not been changed in Readme(description) of package in git hub, how can I update the package using maven?
I tried to run mvn release:update-versions, but I get this error
Then I run mvn release:update-versions -X
This is my pom.xml
The git repo is not equal the maven lib. You download maven libraries from the offical maven repository. The maintainer of the library needs to upload his artifact to the central repository when he builds a new release after that you can use this.
To see which version is usable you can use a maven search website like https://search.maven.org.
The dependency org.dhatim:fastexcel has a version 0.9.4 (same as the github release).
So it seems the developer already uploaded it but did not correct his Readme in the repository. So you can just use 0.9.4 in your pom.xml.
So always check the maven search site and if something is missing you can always add an issue to github to ask the developer uploading it.
There are also this more or less recommended possibilites to get library as a workaround:
Checkout and build the project by your self and add the jar file to:
something like nexus as own repository hosting (a organization normally has a maven proxy which could be used)
add it to the pom.xml as system scope dependency where the jar must be located on your system
use mvn install on the fastexcel project and change the version in your pom.xml to 0-SNAPSHOT

tell maven to get JAR dependency from given URL

Unfortunately, my project has an external dependency that was never published to any Maven repository. The only way I can get it is by direct download from github (they pushed the binary to github).
One (bad) way is to download the jar manually and commit/push it to my code repository (git). It wouldn't help me to manually deploy this artifact in my local binary repository because I share this project with external contributors that cannot access my private binary repo.
I wonder if maven has a better way to handle this? (Given that I can't upload the artifact to my repo or public repo).
I know that npm allows getting some dependencies from URL. Does maven support it as well?
AFAIK there is no nice way to handle this. You could
Write a script that downloads the jar and installs it in your local Maven repository. This script could be shared through your code repository.
Include downloading and installing the artifact into the Maven build process (by writing a Maven plugin or using the antrun plugin)
Set up a nexus in the cloud that everyone in your team can access.

Maven cannot find richfaces 3.3.x in Central repo

I am trying to follow this tutorial:
http://docs.jboss.org/richfaces/latest_3_3_X/en/cdkguide/html_single/
I am hitting a roadblock with the maven commands.
First the org.richfaces.cdk version 3.3.3.Final was not found in the central repository, so I had to manually install version 4.2.2.Final to my local repository by downloading the file maven-richfaces-resources-plugin-4.2.2.Final.jar
I then had to manually install the org.richfaces.cdk plugin to my local respository.
Next, to run the command in section 4.1. I had to change archetype:create to archetype:generate. Running this command showed that maven couldn't find META-INF/archetype.xml in the jar file. I am stuck at this point. Any pointers?
Per this thread, that version of richfaces is in the JBoss Maven Repo, not Central
https://community.jboss.org/thread/172034?_sscc=t
In general, Software Vendors maintain their own Maven repos and do not push out every release to Central. SpringSource, Atlassian, and Oracle (java.net) come to mind.
Archetypes are dependencies just like project dependencies / plugins, so you will likely need to add the JBoss repository to your pom.xml or settings.xml in order for the archetype to work. See the above link for how to do that.
I figured it out! noahz's answer helped but wasn't the complete solution. I am still going to accept his answer. After substituting the Atlassion repo for the Jboss maven repo in settings.xml, I was still seeing the 'BUILD FAILURE' error saying it couldn't find the richfaces artifact. Maven was still looking in the central repo not in the Atlassian repo. So after a bit of research found that the central repo could be overriden with a tag. Follow this link:http://maven.apache.org/guides/mini/guide-mirror-settings.html.
Build is now successful.

Maven Repository

I have downloaded all artifacts in maven repository. Now I copied the repository folder content to other computer running maven. I have to access this new repository for maven commands but it is trying to connect to net for downloading artifacts required. What should I do??
Is there any way of using such repository created manually??
Are you using snapshot versions of your dependencies? If so, Maven might still try to connect to a remote repository to check if there is a new version available. However, you can avoid this by using -o (=offline), like this:
mvn -o <your_command>
Did you set the correct path to the maven repository in your settings.xml file?
This is happening because you might have a different version of Maven on your new machine and thus, it will try to install all the new compatible plugins while you try to build it. So there is no way to get around it except for using exactly the same maven version and same settings

Resources