Maven missing project required libraries after cloning repo - maven

A team member has shared his project with me on bitbucket and he used maven to manage his dependencies. After cloning the repo (using mercurial) into my workspace (Eclipse) and downloading maven, m2e and all the other required set up files i was able to get all of the project libraries except for 4.
After downloading the project, i ran several mvn commands to clean, install and hopefully download these missing jars. When i ran mvn -e command i get this long error that does nothing to help. Do i have to find and download these 4 jars and put them in my maven repo?
Command output: mvn -e
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.769s
[INFO] Finished at: Mon Apr 09 17:42:17 CDT 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Dugsi_Manager: Could not resolve depen
dencies for project org.bixin.dugsi:Dugsi_Manager:war:0.1.0.BUILD-SNAPSHOT: The
following artifacts could not be resolved: org.eclipse.persistence:eclipselink:j
ar:2.2.0, org.eclipse.persistence:javax.persistence:jar:2.0.3, org.vaadin:icepus
h-gwt:jar:0.1.2, org.jqurantree:jquran:jar:1.0.0: Could not find artifact org.ec
lipse.persistence:eclipselink:jar:2.2.0 in spring-maven-release (http://maven.sp
ringframework.org/release) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
EDIT:
I just need to share my local repository with all other team members that clone my project. External jars that dont use maven have to be manually installed into my local repo, this creates a problem because i cant share my local repo? Any ideas

You can either install these JARs in your local repository, or setup an own (possibly private) maven repository for you to share with your team. Sonatype provides with Nexus OSS an open-source based software to easily set up a repository (which also proxies remote ones if you like).

Related

Why deploying maven packages on terminal throws an error but the maven package ends up being published on GitHub packages anyway?

I have been using Clojure, ClojureScript, lein, shadow-cljs, re-frame,
reagent, Emacs, and CIDER to work on a Clojure/ClojureScript dynamic
web app project.
Now, I am trying to make depencies be private Maven packages hosted
for free on GitHub packages. Ok, I managed to publish a package!
After the successful attempt to publish my first maven package, it
ended up with the name of repository-name.repository-name
which looks ugly. As I was trying to tweak it, I ended up changing
this line on my project.clj file:
:pom-addition [:distribution-management [:repository [:id "github"]
[:name "GitHub Packages"]
[:url "https://maven.pkg.github.com/organization-name/repository-name"]]])
Instead of [:url "https://maven.pkg.github.com/organization-name/repository-name"] I
tweaked it to be [:url "https://maven.pkg.github.com/organization-name"].
Now, things got really weird in my opinion.
After executing the terminal command to publish it:
➜ mvn deploy -DaltReleaseDeploymentRepository="${REPO}" -DaltSnapshotDeploymentRepository="${REPO}"
The terminal throws:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.563 s
[INFO] Finished at: 2022-10-28T12:33:16-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project project-name: Failed to retrieve remote metadata project-name:project-name/maven-metadata.xml: Could not transfer metadata project-name:project-name/maven-metadata.xml from/to github (https://maven.pkg.github.com/organization-name): transfer failed for https://maven.pkg.github.com/organization-name/project-name/project-name/maven-metadata.xml, status: 422 Unprocessable Entity -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Now, when I go to https://github.com/orgs/my-organization/packages, the package was indeed published!
And with the name of repository-name instead of repository-name.repository-name.
Why is that so? If the build failed, why is the packaged being published?
Also, what would be standard name for Maven packages on GitHub
packages (especially considering these are Maven packages for a
Clojure project)?

Error when trying to 'mvn clean install' Gerrit's replication plugin

This is probably a newbie question, but I'm new to Maven.
I'm trying to build Gerrit's replication plugin, "since the master branch (and thus Gerrit 2.5) no longer supports replication out of the box."
So I did clone https://gerrit.googlesource.com/plugins/replication and executed mvn clean install inside the new directory. The error message is:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building replication 1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.gerrit:gerrit-plugin-api:jar:2.6-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.840s
[INFO] Finished at: Thu Apr 25 17:30:10 BRT 2013
[INFO] Final Memory: 6M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project replication: Could not resolve dependencies for project com.googlesource.gerrit.plugins.replication:replication:jar:1.1-SNAPSHOT: Failure to find com.google.gerrit:gerrit-plugin-api:jar:2.6-SNAPSHOT in https://gerrit-api.commondatastorage.googleapis.com/release/ was cached in the local repository, resolution will not be
reattempted until the update interval of gerrit-api-repository has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
It looks like this URL isn't valid: https://gerrit-api.commondatastorage.googleapis.com/release/ -- but like I said, I'm new to Maven so I'm not sure how to proceed. I did some research, but I don't know what I'm looking for.
Any pointer would be highly appreciated. Thanks in advance.
A couple of things -
You are missing the gerrit-plugin-api.jar. This currently isn't provided upstream, so you must build it yourself. I believe running mvn install from a Gerrit repository will package and add this jar to your system.
You don't want to run install, you just want to run package on the plugin. mvn package will put the .jar in the target/ folder, which you then copy to your plugins folder inside your Gerrit installation.
Good luck!
Like Brad mentioned, I am missing the gerrit-plugin-api.jar. Unfortunately, I was not able to build it, since the Gerrit repos seem to be facing issues lately, as mentioned in other threads (this one, for instance - from two days ago).
Anyway, below are my additional steps based on Brad's answer (hopefully this may help others):
git clone https://gerrit.googlesource.com/gerrit
cd gerrit/gerrit-plugin-api/
mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Gerrit Code Review - Plugin API 2.7-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.google.gerrit:gerrit-sshd:jar:2.7-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for com.google.gerrit:gerrit-httpd:jar:2.7-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for com.google.gerrit:gerrit-pgm:jar:2.7-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.342s
[INFO] Finished at: Fri Apr 26 10:52:54 BRT 2013
[INFO] Final Memory: 5M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project gerrit-plugin-api: Could not resolve dependencies for project com.google.gerrit:gerrit-plugin-api:jar:2.7-SNAPSHOT: The following artifacts could not be resolved: com.google.gerrit:gerrit-sshd:jar:2.7-SNAPSHOT, com.google.gerrit:gerrit-httpd:jar:2.7-SNAPSHOT, com.google.gerrit:gerrit-pgm:jar:2.7-SNAPSHOT: Failure to find com.google.gerrit:gerrit-sshd:jar:2.7-SNAPSHOT in https://gerrit-maven.commondatastorage.googleapis.com was cached in the local repository, resolution will not be reattempted until the update interval of gerrit-maven has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
EDIT
These are the steps that worked for me, in case someone else faces the same issue.
git clone https://gerrit.googlesource.com/gerrit
Check available 'versions'
git branch -r
git checkout -b 2.5 origin/stable-2.5
The steps didn't work on the master branch in my environment, and I'm using 2.5...
So yeah, 2.5.
cd gerrit
mvn clean install
This will rebuild the entire universe, go grab a cup of coffee. :)
.. when done
cd gerrit-plugin-api/
mvn package
This also takes some time...
If everything goes fine, you can copy the jar at the target folder, like:
cp target/<large-name>.jar ~/replication.jar
Finally install it (from ~):
ssh -p 29418 localhost gerrit plugin install -n name \ - <replication.jar
Details on how to install Gerrit plugins are here.
The thing is, now I'm getting another error, something like:
"A binding to (something) was already configured at (something)."
But that's another story / thread / post...
Thanks and good luck!
Do a mvn -P all clean install on the toplevel, not inside gerrit-plugin-api.
The fastest way to fix is is to change the pom.xml and use a version that is not a snapshot. I was trying to build the delete-project for the stable-2.6 branch and was facing the same issue. All that needs to be done is to change the Gerrit-ApiVersion:
<Gerrit-ApiType>plugin</Gerrit-ApiType>
- <Gerrit-ApiVersion>2.6-SNAPSHOT</Gerrit-ApiVersion>
+ <Gerrit-ApiVersion>2.6-rc2</Gerrit-ApiVersion>
</properties>
<name>Delete Project Gerrit Plugin</name>
Building off of #Conaaando's answer, I performed these exact steps and successfully am using the plugin. Steps courtesy of http://asheepapart.blogspot.com/2013/12/how-to-build-gerrit-replication-plugin.html
git clone --recursive https://gerrit.googlesource.com/gerrit
You need the --recursive here because the plugins are actually git submodules and won't otherwise be cloned along with your repo.
If you've already cloned, you can run git submodule init; git submodule update
cd gerrit
git checkout -b stable-2.7 origin/stable-2.7
mvn install -DskipTests=true -Dmaven.javadoc.skip=true
It's not necessary to skip the tests or generating Java Doc, but it will greatly improve your compile time and decrease the amount of memory maven uses
cd gerrit-plugin-api
mvn package -Dmaven.javadoc.skip=true
This creates the jar that will be necessary for the replication plugin to get built
cd plugins/replication
mvn package -Dmaven.javadoc.skip=true
At this point, you have compiled and packaged the replication jar! All you need to do now is register it with your Gerrit server. For simplicity, I'll pretend your gerrit server is running at gerrit.example.com. These steps copy the replication jar to your review server and then instruct the review server to install the plugin from that copied location.
scp target/replication-2.7.jar gerrit.example.com:/tmp/
ssh -p 29418 gerrit.example.com gerrit plugin install -n replication /tmp/replication-2.7.jar

Jenkins Build fails while compiling java code using Maven

I have a Java application and I am able to compile it using maven on CLI, I have a couple of build scripts to deploy the Java code to a remote server and compile the code using Maven but unfortunately the build fails while compiling it using my build script for Jenkins. When I try to compile the code on the remote server the build is successful. The error log is as follows:
[WARNING] The POM for org.im4java:im4java:jar:1.3.2 is missing, no dependency information available
[WARNING] The POM for com.aliyun:aliyun-openservices:jar:1.0.0-20120705 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] GuestPath Project ................................. SUCCESS [5.183s]
[INFO] guestchat biz module .............................. FAILURE [4.001s]
[INFO] GuestChat Web Common .............................. SKIPPED
[INFO] GuestChat Portal Webapp ........................... SKIPPED
[INFO] guestchat openapi Webapp .......................... SKIPPED
[INFO] guestchat chat server ............................. SKIPPED
[INFO] guestchat service dashboard Webapp ................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.518s
[INFO] Finished at: Wed Sep 19 10:49:39 CST 2012
[INFO] Final Memory: 9M/23M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project guestchat-biz:
Could not resolve dependencies for project com.guestops.guestchat:guestchat-biz:jar:1.0.0-SNAPSHOT:
The following artifacts could not be resolved:
org.im4java:im4java:jar:1.3.2, com.aliyun:aliyun-openservices:jar:1.0.0-20120705:
Failure to find org.im4java:im4java:jar:1.3.2 in http://repo.maven.apache.org/maven2
was cached in the local repository, resolution will not be reattempted until
the update interval of central has elapsed or updates are forced -> [Help 1]
I hope I am being clear enough, any help is highly appreciated. I can provide with more details if needed..Thanks in advance!
I think you should try to do the following:
Try to compile the project locally but make sure you're downloading the artifacts from the maven repository. Radically you can do it by renaming your ~user/.m2/repository and running ''mvn clean install''
If it compiles - your local maven is configured properly and its not a pom.xml issue. Also the remote repositories are configured right in maven. In this case its a jenkins issue or rather the issue of maven installed on the same machine with jenkins or maybe some network/security related issue (like a connection to the remote repository is firewalled and not accessible from the jenkins machine and so on).
I would suggest to check out the repository configuration on that maven, or if you want checkout the source code of your project on the jenkins machine and manually run the first step described above from that machine. You should see that the code can't be compiled and get the same error you're getting now.
Now if in during the step 1 the project can't be compiled - its just because you have had a dependency on the lacking module and they were somehow presenting in your local repository (I assume previously it could be compiled locally) and since we're kind of running a clean installation the local repository 'gets purged'. In this case you should find out where do your dependencies come from.
Things like
mvn dependency:tree on the failing module
Can be helpful here.
Hope this will help somehow
2 possible quick solutions:
If it compiles locally, then go to the build configuration on Jenkins and check the "Poll SCM" option to do polling on every build.
Run from the command line on Jenkins server mvn clean install and make sure that the artifacts are available in maven repository after the build. If they are not, download the jars of the relevant versions and put them in the local maven repository (on Jenkins server).
Good luck!
This is what the error message tells you:
The following artifacts could not be resolved:
org.im4java:im4java:jar:1.3.2,
com.aliyun:aliyun-openservices:jar:1.0.0-20120705: Failure to find
org.im4java:im4java:jar:1.3.2 in http://repo.maven.apache.org/maven2
So you have references in your pom for im4java 1.3.2 and aliyun-openservices 1.0.0-20120705, but these cannot be found in the general maven repo. If you do a search for im4java in mvnrepository.com, you'll see that it only has version 1.2, so it is reasonable that it would fail. aliyun-openservices package doesn't exist there at all.
So, where should those be found? Maybe you have installed them locally only and not to Jenkins machine?
What you can do then, is either
(recommended) set up an intranet maven repo where you would deploy the needed libraries and reference that or
install them locally on the machine running Jenkins
Both of these should fix the issue.
A quick look on maven repository, only version 1.2.0 is available and not version 1.3.2 (which you are using).
Does your code compile with a maven build?
I suggest you try to review the repository setting on the jenkins instance

maven deploy-file failed with 503: cannot find maven-metadata.xml

I am using Maven to integrate our project with others, maybe in a unpopular way and encountered issue.
We have a project that used to compile with Ant. Ant script is big and awesome, so when we are using Maven for integration, it is decided to keep compiling with Ant.
Now let's say Ant compile output is res-1.0-SNAPSHOT.tar.gz. (any filename can be possible but it IS tar.gz) And I am deploying the file to a nexus-hosted snapshot repository called "snapshots".
I tried to deploy with this command:
mvn deploy:deploy-file \
-DgroupId="com.my-company" \
-DartifactId="res" \
-Dversion="1.0-SNAPSHOT" \
-Dpackaging="tar.gz" \
-Dfile="res-1.0-SNAPSHOT.tar.gz" \
-Durl="http://our-nexus-ip/nexus/content/repositories/snapshots" \
-DrepositoryId="snapshots"
I have a simple settings.xml in ~/.m2 with proxy and server settings. However server settings is not being used in current progress yet, wrong passwords don't get errors.
The output is like this:
[[root#cnbi maven]# ./run.sh
+ mvn deploy:deploy-file -DgroupId=com.my-company -DartifactId=res -Dversion=1.0-SNAPSHOT -Dpackaging=tar.gz -Dfile=res-1.0-SNAPSHOT.tar.gz -Durl=http://135.252.234.142:8081/nexus/content/repositories/snapshots -DrepositoryId=snapshots
Warning: JAVA_HOME environment variable is not set.
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'deploy'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [deploy:deploy-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [deploy:deploy-file]
[INFO] Retrieving previous build number from snapshots
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error retrieving previous build number for artifact 'com.my-company:res:tar.gz': repository metadata for: 'snapshot com.my-company:res:1.0-SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Error transferring file
Server returned HTTP response code: 503 for URL: http://135.252.234.142:8081/nexus/content/repositories/snapshots/com/my-company/res/1.0-SNAPSHOT/maven-metadata.xml
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 51 seconds
[INFO] Finished at: Tue Jun 12 08:44:13 CST 2012
[INFO] Final Memory: 7M/209M
[INFO] ------------------------------------------------------------------------
You see, it fails to find maven-metadata.xml. It is for certain, the file and its folder "com/my-company" do not exist at all in the repository.
Besides any misuse of Maven you may find, my questions are:
1) am I using Maven in the right way? (deploying tar.gz, using deploy:deploy-file...)
2) are there incorrect parameters?
3) what is maven-metadata.xml for? It is not there but Maven insists to find it -- I guess it is generated, am I missing some steps?
The solution might be stupid, I am really not familiar with Maven. Unfortunately it has to be done... Please, help me out of this.
Maven version is 2.0.11. Let me know if you want to know more.
I had the same problem and there was a bug in our nexus.
Using maven3 (with same settings.xml, pom.xml and .m2 repo) solved our problem and its easier than upgrading nexus.
You can check this bug also.
If you're still stuck with using Ant, I would recommend you at least consider adding Ivy to the picture, as your dependency manager. If I recall correctly, it was able to update maven-metadata.xml files in the repository.
Have a look at this example.

Jenkins (hudson) plugin development meet maven-enforcer-plugin:1.1-SNAPSHOT issue

I try to develop one jenkins (a.k.a hudson) plugin, and follow the Tutorial, and generated source code tree after mvn -cpu hpi:create command.
While when I do "mvn package", it reports error like
[INFO] Building Unnamed - com.example.jenkins:redmine2:hpi:1.0-SNAPSHOT
[INFO] task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.apache.maven.plugins:maven-enforcer-plugin
Reason: Error getting POM for 'org.apache.maven.plugins:maven-enforcer-plugin' from the repository: Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.
org.apache.maven.plugins:maven-enforcer-plugin:pom:1.1-SNAPSHOT
from the specified remote repositories:
nexus (http://maven.nexus.local:8888/nexus/content/groups/public)
for project org.apache.maven.plugins:maven-enforcer-plugin
From my nexus server, it has maven-enforcer-plugin:1.0 version only, but this dependence is generated from jenkins by default, anyone can help me to solve it ?
(How) Can I change to plugin-1.0 version.
what can I add in nexus server
I just have basic knowledge of maven.
I fixed it by myself by doing two things.
1. Added Apache snapshot from here into my nexus repo group besides those setting in Tutorial
2. It seems my local maven repo is messed up as well, so I can clean it up and reload from nexus.
And it still use maven-enforcer-plugin:pom:1.1-SNAPSHOT plugins.
Hope it helps you as well.

Resources