Integrate the local maven plugin with remote repository - maven

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.

Related

Download Maven artifacts in Jenkins from another repo if one fails

In my Jenkins build I have a settings.xml file for pulling Maven dependencies. An artifact, if not found, should be downloaded from another Maven repo not specified in a settings file. Can this be done using code in Jenkinsfile? Any thought will be greatly appreciated.

Maven repository usage to download artifacts

I have added a repository to download artifacts and I have seen maven using that repository to download artifacts, but only for particular artifacts of that repository maven tries to download from mvn central repository. When I chek that artifact on added repository it's available. What could be the issue ? In which situations maven tries to download from central repository ?
Specific issues is highlighted in ,
Magnolia Demo project mvn build failed due to not able to fetch magnolia-setproperty-maven-plugin
All the Maven dependencies are first downloaded from your local repository, then if they are not found, Maven will try in any remote repository that you define in your POM file or the settings.xml and for last it will try to download from Maven Central.

Trouble publishing rpm artifact to yum snapshot repo using Gradle

I've been trying to publish a rpm file (built using Gradle-custom plugin) to a yum snapshot repo using Gradle (nexus-yum plugin installed on repo). However, the upload fails and I get an error 400. I further understand that this is because my build script is attempting to upload my rpm artifact to a release repo instead of the snapshot repo. It would be great if anyone could share thoughts as to where I could be going wrong ?
Are you specifying the snapshots area of your repo?
The answer to : using gradle to deploy features.xml to nexus? explains how to update your maven settings.xml to exclude locations from a public repo and upload archives to releases area (same applies for snapshot)
Of course if you are publishing to a snapshot dir you must have a -SNAPSHOT extension.

How to deploy JAR to Maven remote repository

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.

maven could not resolve dependency via my local nexus repository

I have setup an in-house Sonatype Nexus repository and configure the maven to check my local Nexus instead of getting artifacts directly from public repositories.
http://www.sonatype.com/books/nexus-book/reference/config-sect-intro.html
Our project was able to download the most artifacts except one artifact in Maven central.
Here is the build error:
Failed to execute goal on project shindig-gadgets: Could not resolve dependencies for project org.apache.shindig:shindig-gadgets:jar:3.0.0-SNAPSHOT: Could not find artifact com.ibm.icu:icu4j:jar:4.6 in nexus (http://my_nexus_repository:8081/nexus/content/groups/public) -> [Help 1]
I see that icu4j-4.6.jar does exist in the Maven central repository. On my local nexus repository, it doesn't exist. I see only icu4j-4.6.pom exists on my local nexus repository.
It's not like my nexus repository setting is totally broken. maven project has successfully downloaded numerous jar files from multiple public repositories via my local nexus maven repository except icu4j-4.6.jar.
I don't understand why I'm having a problem with only icu4j-4.6.jar. Would it be incorrectly cached on either my local maven or nexus maven repository?
If it was incorrectly cached, how can I clean the local maven or nexus maven repository?
The similar problem is described at
Missing maven dependency using nexus setup
icu4j-4.6.jar does not show up in the search list. Only icu4j-4.6.pom shows up in the search list. I don't think is Snapshot VS Release issue because icu4j-4.6.jar seems release jar.
Is it possible that the nexus repo just stopped responding for a while? You can try mvn -X (or -d?) to get detailed info about what is going on. You might also try configuring an alternative repo.
Perhaps you haven't enabled remote index downloads from Maven Central. This would explain why only the POM file appears in your local search (The only file which has been downloaded via the proxy repo).
There might be another issue causing the download failure for the jar itself.... I suppose try and solve one problem at a time :-)
Try adding -U to your mvn arguments to force an update of your local repository.
You could also have corrupt meta data in the repo. In which case, delete that artifact from the repo's cache and let it refresh.
If the artifact in question was cached in properly from the proxy repository, using mvn -U will fix the problem
However if you are seeing pom on your nexus ,this usually happens when the artifact from the proxy repository is not cached in properly. The way to fix is
1) Browse to the component in the Proxy Repository.
2) Invalidate the cache for the repository and reindex the Nexus repository.
3) run mvn clean -U

Resources