maven plugin: "Failed to read artifact descriptor for" - maven

For my build process, I need two custom maven plugins (see here). It works fine when deploying it to my local maven repository with mvn install.
However, I need to make it accessible for other developer's in my team and integration testing.
I noticed that you could setup a light-weight maven repository on github so that's what I did for now: https://github.com/rweng/mvn-repo
This works fine for normal dependencies like ch.yax.yocto.yocto-server, however, it fails for my plugins with the message
[WARNING] The POM for com.arcanio.maven.plugin:velocity:jar:0.1-SNAPSHOT is missing, no dependency information available**
[ERROR] Plugin com.arcanio.maven.plugin:velocity:0.1-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.arcanio.maven.plugin:velocity:jar:0.1-SNAPSHOT: Could not find artifact com.arcanio.maven.plugin:velocity:pom:0.1-SNAPSHOT -> [Help 1]
I tried substituting the github url in my repositories section through file:///, Though I doubt the problem lies here. I also doubt that this is a proxy problems, as many users with the same error reported.
Is is possible that mvn install deploys s.th. different than my deployment command
mvn -DaltDeploymentRepository=snapshot-repo::default::file:/Users/robin/Code/mvn-repo/ clean deploy
Thanks in advance for any hints how to solve this.
EDIT
I just moved the plugin from my local repository to the github repository and notice the following changes.
D com/arcanio/maven/plugin/maven-metadata.xml
D com/arcanio/maven/plugin/maven-metadata.xml.md5
D com/arcanio/maven/plugin/maven-metadata.xml.sha1
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/maven-metadata.xml
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/maven-metadata.xml.md5
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/maven-metadata.xml.sha1
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.jar
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.jar.md5
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.jar.sha1
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.pom
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.pom.md5
D com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-20130206.084855-1.pom.sha1
D com/arcanio/maven/plugin/velocity/maven-metadata.xml
D com/arcanio/maven/plugin/velocity/maven-metadata.xml.md5
D com/arcanio/maven/plugin/velocity/maven-metadata.xml.sha1
?? com/arcanio/maven/plugin/maven-metadata-local.xml
?? com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/_maven.repositories
?? com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/maven-metadata-local.xml
?? com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-SNAPSHOT.jar
?? com/arcanio/maven/plugin/velocity/0.1-SNAPSHOT/velocity-0.1-SNAPSHOT.pom
?? com/arcanio/maven/plugin/velocity/maven-metadata-local.xml
So mvn install really does generate something different. Does anyone know why? I thought mvn install was basically the same as mvn deploy but to the local repository.
EDIT
Using mvn -DuniqueVersion=false fixes the unique versions. See here.
EDIT
uniqueVersion=false does not work anymore with maven 3. So the problem stays the same, the timestamped versions are not found in the repository. I think I might be missing a artifactid-snapshot pom.
SOLUTION
Solution found here:
The repository must be added as pluginRepository:
<pluginRepositories>
<pluginRepository>
<id>rweng-plugins</id>
<url>https://github.com/rweng/mvn-repo/raw/master</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>

The best solution for such things is to install a repository manager in your company.

Related

How to deal with vanished Maven repository (caching)?

There used to be a repository that supplied us a certain version of a certain package - au.csiro.aehrc.variant-spark:variant-spark_2.12:jar:0.4.0-a0-dev1. Let's pretend the repository was at 12.3.4.567. In my settings.xml, I have an entry for it:
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>3rdParty</id>
<url>https://12.3.4.567:8081/repository/maven-group</url>
</repository>
When that repository was up and running, I was able to acquire the package and my mvn build succeeds. Other, newer developers can't build with the same configuration, because that repository no longer can supply them the jar file. If I comment out that repository in my settings.xml, my build fails:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 57.864 s
[INFO] Finished at: 2022-12-16T06:35:31-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project my-project:
Could not resolve dependencies for project gov.x.y:my-project:jar:1.1.0-SNAPSHOT:
Could not find artifact au.csiro.aehrc.variant-spark:variant-spark_2.12:jar:0.4.0-a0-dev1
in central (https://repo1.maven.org/maven2) -> [Help 1]
If I remove the comment characters in my settings.xml, it builds again.
I don't have a good feel for how Maven caching works. There appears to be some kind of caching of mvn artifacts on my local machine that gets found based on a repository key. I'm afraid that at some point the cache will be modified, and I will no longer be able to build.
How can I make my development world a safer place and also make au.csiro.aehrc.variant-spark:variant-spark_2.12:jar:0.4.0-a0-dev1 (and its dependencies) available to other developers? (BTW, I haven't been able to find that version of variant-spark on any public repositories.) Is there a way I can work backwards from my local Maven artifacts such that we could create a local repository to supply the artifacts?
I'm open to hearing about kludgy, simple safeguards as well as how to do things the right way.
You have now found out why it is so important to use artifacts published to Maven Central or somewhere similar that won't go away. Your build server should have found this a while back - you may want to consider setting one up for the next time something breaks.
Right now, I would suggest:
back up your computer (or at least the .m2 folder).
set up a local repository manager like Nexus or Artifactory and install these files in it in the same location so others can use it immediatlye.
create a virtual repository that invisibly merges this local repository with Maven Central
tell everybody to set up their settings.xml to use that as a mirror.
This should get everybody up and running again.
Then, strongly reconsider if depending on an artifact only present in your office is a good idea. Is it elsewhere under a different name? Can you utilize something else? Can you get the source so you can fork and maintain it yourself?

How to update release artifacts in Maven?

I have the following case:
- Maven project compiles fine on one machine where artifact A (release one) exists in that machine's local Maven repository,
- artifact A was removed from the remote repository.
How can we be sure that the project builds fine on a new machine where local Maven repository is empty?
Try the install task install-file to put the jar into your local repo from your local hard drive:
mvn install:install-file -Dfile=<path-to-file>
See maven.apache.org for more details.
Few cases :
One, if you own artifact A and use <repository> to keep the versions in sync. You can anytime rebuild your project on the new machine to fetch the artifact.
Second, If artifact A is owned by you and you didn't use repositories until now, you can simply bump up its version and deploy it on the remote server(<repository>) and consume the new version on the machine where you want to. Use <repositories> in your pom.xml to specify the remote path as follows :
<repository>
<id>clojars</id>
<name>Clojars Maven Repository</name>
<url>http://clojars.org/repo/</url>
</repository>
Third, if you don't own the artifact A and it exists in a public maven central repositories, all you need to do is rebuild the correct dependency to fetch it over the net.
Worst case, the artifact A used is owned by you and doesn't exist in a public central repository. You can still copy-paste the jar file using any mode and move it to the machine's /m2/repository where you require it. But do note in such case you shouldn't reach this case ever again.
Also in the last case, you can copy it into your project and use it as suggested by #Adam
mvn install:install-file -Dfile=<path-to-file>

Maven can't find dependencies [dependencyResolutionException]

I added a Maven dependency to my project and my project compiles locally, while it doesn't compile on server. It can not resolve the newly added dependency.
This is my pom.xml file:
<repositories>
<repository>
<id>rep</id>
<name>Repository</name>
<url>http://artifacts.com/rep</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.project.rest</groupId>
<artifactId>common</artifactId>
<version>2.0.5</version>
</dependency>
</dependencies>
And this my console output with an error:
Downloading: http://artifacts.com/rep/com/project/rest/common/2.0.5/common-2.0.5.pom
[WARNING] The POM for com.project.rest:common:jar:2.0.5 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.154s
[INFO] Finished at: Tue Feb 03 06:58:35 BRT 2015
[INFO] Final Memory: 9M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project server: Could not resolve dependencies for project org.server:
server:jar:2.5.1-SNAPSHOT: The following artifacts could not be resolved: com.project.rest:common:jar:2.0.5:
Could not find artifact com.project.rest:common:jar:2.0.5 in rep (http://artifacts.com/rep) -> [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
(I hid all real URLs and package.)
What could be the problem?
The first line "Downloading:..." only says that maven tries to download the artifact. It is no statement about success. If maven is successful you will get another line starting with "Downloaded: ..."
So in your case maven was not able to download the file. Check the logged url in your browser if it does exist and if it is protected.
BTW <updatePolicy>always</updatePolicy> is quite uncommon for release repos, because releases should not change any more.
Make sure your repository is configured properly. Try to search, in your repo, for
com.project.rest:common of version 2.0.5.
Is this your own project? some jar that you have built? are you sure you deployed it to your repo? if it is not in your repo, try to search for it in your local repo (usually .m2/repository/com/project...)
DependencyResolutionException
(source: Maven Confluence)
This error generally occurs when Maven could not download dependencies. Possible causes for this error are:
The POM misses the declaration of the <repository> which hosts the artifact.
The repository you have configured requires authentication and Maven failed to provide the correct credentials to the server. In this case, make sure your ${user.home}/.m2/settings.xml contains a <server> declaration whose <id> matches the <id> of the remote repository to use. See the Maven Settings Reference for more details.
The remote repository in question uses SSL and the JVM running Maven does not trust the certificate of the server.
There is a general network problem that prevents Maven from accessing any remote repository, e.g. a missing proxy configuration.
You have configured Maven to perform strict checksum validation and the files to download got corrupted.
Maven failed to save the files to your local repository, see LocalRepositoryNotAccessibleException for more details.
In Maven 3 if you just had a failed download and have fixed it (e.g. by uploading the jar to a repository) it will cache the failure. To force a refresh add -U to the command line.
In case of a general network-related problem, you could also consult the following articles:
Configuring a Proxy
Security and Deployment Settings
Guide to Remote Repository Access through Authenticated HTTPS
The project you mentioned doesn't contains POM i.e. it is not a MAVEN project. The .m2(look this at c drive or where you have installed) repository contains all the dependencies folders look there whether it contains the required project or not i.e. com.project.rest.
Like suggested by console output, you can check the Maven Wiki page (http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException) for more information on where the problem might lay.
Given the information you provided. I would guess we are looking at the point one issue:
The POM misses the declaration of the which hosts the artifact.
Maven repositories are of three types: local, central and remote.
In your case, your local repository contains the project specific artifacts, but the central repository doesn't.
Local repository is on your local machine. When you run a Maven build, Maven automatically downloads all the dependency jars into the local repository.
Central repository is web repository provided by a community and it contains a number of commonly used libraries, found here https://repo1.maven.org/maven2/.
Remote repository is developer's own custom repository containing required libraries or other project jars. Developer defines these repositories in POM file using tags.
I would suggest the following:
check your repository tag, if the repository is correct
check if the repository contains the artifacts specified in your dependency tag
If you are using IntelliJ IDE (Jetbrains) and code is correct then
Check the TOGGLE OFFLINE MODE button. If we enable offline mode, then IDE do not let maven download a dependency and it cannot found the library that causes error.
So make sure your project is build in ONLINE mode.

Run Maven Enforcer Plugin rule on command line

I would like to enforce the requireReleaseDeps rule of the Maven Enforcer Plugin on a Maven project without any POM configuration simply as a command line call.
According to the docs I should be able to just pass in the rules parameter like so
mvn enforcer:enforce -Drules=requireReleaseDeps
or maybe this should work
mvn enforcer:enforce -Drules=org.apache.maven.plugins.enforcer.RequireReleaseDeps
However both of these calls result in
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (default-cli) on project hel
lo-world: The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce are missing or in
valid -> [Help 1]
Anybody know if this usage scenario actually works somehow or do I have to dive into debugging the plugin at this stage to figure this out?
It works with the 3.0.0-M3 version:
mvn org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce -Drules=requireReleaseDeps
With the version 3.0.0-M3 of the plugin and newer release the enforcer goal now supports the rules parameter and command line execution without config in the pom. See more at https://maven.apache.org/enforcer/maven-enforcer-plugin/enforce-mojo.html#commandLineRules
Unfortunately there is currently no such functionality but there is already a JIRA Issue for that.
It is available from 3.0.0. The Jira issue from accepted answer got resolved: https://issues.apache.org/jira/browse/MENFORCER-142
mvn enforcer:enforce -Drules=alwaysPass,alwaysFail
Worked for me using Atlassian's fork of the plugin:
mvn org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-atlassian-m01:enforce -Drules=...
I had to declare their plugin repository:
<pluginRepositories>
....
<pluginRepository>
<id>atlassian-3rdparty</id>
<url>https://maven.atlassian.com/3rdparty</url>
</pluginRepository>
</pluginRepositories>
Hope this helps.

Maven3.0.3 + artifactory 2.5 + ubuntu 11.10 Failed to resolve dependency

I just have this weird problem using maven + artifactory. I have a project which I first build using maven-compiler 2.3.2, and maven2. It build successfully and I was able to deploy in artifatory 2.5.
Eventually I've added several modules and one requires the use of maven-compiler-plugin 2.4, which also requires me to install maven3, because I'm having several errors otherwise. So my app is working again.
But when I checkout on a new machine and maven compiles, I got the ff error:
Could not resolve dependencies for project com.xxxjar:0.0.1-SNAPSHOT: Failed to collect depend
encies for <list of jars>. Failure to find <snapshot> in <repo> was cached in the local repository, resolution will not be reattempted until the update interval of <repo> has elapsed or updates are forced.
What's weird is that when I carry over, my m2 directory from the first machine where I have first develop with maven2, it compiles without error. So clearly some setting or jar is being missed by maven3?
Also I tried setting my snapshot repository "maven snapshot version" setting to Unique as stated from other forums. I also tried almost all possible combinations that I can configure in artifactory repository setting.
My pom.xml distribution setting:
<distributionManagement>
<!-- <repository>
<id>release</id>
<name>xx</name>
<url>xx-repo-release</url>
</repository> -->
<snapshotRepository>
<id>snapshots</id>
<name>xx</name>
<url>xx-snapshots</url>
</snapshotRepository>
</distributionManagement>
Additional info:
When I run install in another machine I have:
2012-05-25 17:21:32,316 [pool-1-thread-3] [WARN ] (o.a.e.DownloadServiceImpl:343) - Sending HTTP error code 409: The repository 'xx-repo-release' rejected the artifact 'xx-repo-release:com/xx/xx/0.0.1-SNAPSHOT/xx-0.0.1-SNAPSHOT.pom' due to its snapshot/release handling policy..
2012-05-25 17:21:32,342 [pool-1-thread-13] [WARN ] (o.a.e.DownloadServiceImpl:343) - Sending HTTP error code 409: The repository 'xx-repo-release' rejected the artifact 'xx-repo-release:com/xx/xx/0.0.1-SNAPSHOT/xx-0.0.1-SNAPSHOT.pom' due to its snapshot/release handling policy..
2012-05-25 17:21:32,350 [pool-1-thread-7] [WARN ] (o.a.e.DownloadServiceImpl:343) - Sending HTTP error code 409: The repository 'libs-release-local' rejected the artifact 'libs-release-local:com/xx/xx/0.0.1-SNAPSHOT/xx-0.0.1-SNAPSHOT.pom' due to its snapshot/release handling policy..
settings.xml are the same for both machine. And also same version of maven. Why is it pointing to release?
Thanks,
czetsuya
I think another solution might be to run the following command:
mvn clean install -U
The problem is dependency issue. I have a model module which is under a parent pom project. While I was able to deploy the model module in the remote repository, I forgot to deploy it's parent which causes the problem.
Solution: http://czetsuya-tech.blogspot.com/2012/05/could-not-resolve-dependencies-for.html
I have pointed to an artifactory 3.1.1.1 instalation and have the above problem in a project who declare the dependency for log4j:log4j:1.2.17.
When a looked for that dependency on artifactory in GAVC search only appears the pom in the jcenter-cache repo.
The solution for me was running the following command:
mvn clean install -U
After that a looked again for log4j:log4j:1.2.17 with GAVC and now appears pom an jar. Of course in my laptop on $HOME/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar was downloaded.
Thanks to mike.tihonchik.

Resources