I have my company parent pom in releases repository on a company Nexus instance.
I have mirror settings of <mirrorOf>external:*,!central</mirrorOf>, I don't want to proxy central since our Nexus is a bit slow.
When I have a maven project, with parent set like:
<parent>
<groupId>com.acme.maven</groupId>
<artifactId>parent-pom</artifactId>
<version>2</version>
<relativePath />
</parent>
and the parent-pom project is not available in local repository the build will fail -- this is as expected so far.
However if I download the parent-pom using dependency:get goal, the pom file gets downloaded to local repository. However when I try to build the project it fails with:
[exec] [ERROR] The project com.acme:test:0.0.1-SNAPSHOT (/home/acme/pom.xml) has 1 error
[exec] [ERROR] Non-resolvable parent POM: Failure to find com.acme.maven:parent-pom:pom: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 and 'parent.relativePath' points at no local POM # line 5, column 13 -> [Help 2]
Now if I remove the _remote.repositories file (and only that file) from .m2/repository/com/acme/maven/parent-pom/2/ the build will succeed.
I have some kind of a workaround, but manually removing internal files from maven repository doesn't sound like a good idea. How can avoid it?
Also I have no idea why is this happening, some explanation will be much appreciated.
Other approaches:
maven-ant tasks dependencies task works (_remote.repositories file doesn't appear at all)
trying to build with -U
using dependency:copy fails
using dependency:list on a pom.xml having the parent-pom as dependency also fails
_remote.repositories content:
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Mon Sep 14 19:59:41 CEST 2015
parent-pom-2.pom>internal-repo=
I think the answer is here:
Maven 3.0+ enforces that downloaded artifacts were resolved from a
repository url/id that matches an url available for the current
session.
..
IIRC there is a CLI option that you can enabled in Maven 3.1.1 that
tells Maven "I know what I am doing and don't make that check this
time" i.e.
--legacy-local-repository
Indeed adding --legacy-local-repository to the dependency:get invocation makes it not produce the _remote.repositories, and the parent-pom can be resolved.
Ant's dependencies task behaviour can, I think, be explained by it using Maven 2 code.
Related
All
Need to get maven to copy central dependencies to local filesystem repository mirror. Can't work out how to do this in maven (3.3.1).
We have:
[1] maven central, which for the UK is: "http://uk.maven.org/maven2"
[2] local remote filesystem repository mirror: "c:/mylocalRepository"
[3] local repo "c:/users/myuser/.m2/repository"
Version of maven is 3.3.1 (doing a migration from 2.0.10).
We need to run our system without connecting to central (behind firewalls) and also without using a repository manager (Nexus, Archiva or the like) - it's something we would like to change but cannot change our infrastructure immediately. Please don't reply just saying do this.
Therefore we need our dependencies in a local file system that maven will then be use as a mirror of central.
I can't find a way to configure maven to build this - I'm getting dependencies - jar + pom and then using
To install jars:
mvn org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file
-Durl="file:///{repositoryPath}"
-DrepositoryId="InternalRepo"
-Dfile="{jarFile}"
-DpomFile="{pomFile}"
-DrepositoryLayout=default
-DgroupId={groupId}
-DartifactId={artifactId}
-Dversion={version}
-Dpackaging=jar
-s "C:/apache-maven-3.3.1/conf/settings_centralRepo.xml"
To install Poms:
mvn org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file
-Durl="file:///{repositoryPath}"
-DrepositoryId="InternalRepo"
-Dfile="{pomFile}"
-DpomFile="{pomFile}"
-DrepositoryLayout=default
-DgroupId={groupId}
-DartifactId={artifactId}
-Dversion={version}
-Dpackaging=pom
-s "C:/apache-maven-3.3.1/conf/settings_centralRepo.xml"
Ideally would like a configuration that we could put in the parent pom that would trigger all dependencies to be copied over. However the documentation implies this is for build artifacts rather than dependencies. There's usually a way in maven, but it can be hard to find.
Any help much appreciated - I've currently jury-rigged a script to do this and it tedious and labour intensive.
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.
Attended Spring Core training recently. When I installed the projects after the course and converted the projects as a Maven project, I get the following error.
Project build error: Non-resolvable parent POM: The repository system is offline but the artifact com.springsource.training.core-spring:parentCoreSpringProject:pom:
4.0.0.CI-SNAPSHOT is not available in the local repository. and 'parent.relativePath' points at wrong local POM
I tried adding relative-path too, but it did not help.
<parent>
<groupId>com.springsource.training.core-spring</groupId>
<artifactId>parentCoreSpringProject</artifactId>
<version>4.0.0.CI-SNAPSHOT</version>
</parent>
The message is pretty clear - the pom points to a repository that you don;t have access to.
Either get access, or change the repository it points to.
(maven downloads required dependencies(jar files) from a server and apparently you don't have access to specified server but you can use public servers/repositories instead)
I am trying to build an old Maven project and I'm getting the error:
[ERROR] Failed to execute goal on project myapp: Could not resolve dependencies for project com.initech.myapp:war:${buildVersion}: Failure to find tangosol:tangosol-coherence:jar:3.3-rc1 in http://mvnrepo.initech.com/archiva/repository/initechrepo was cached in the local repository, resolution will not be reattempted until the update interval of initechrepo has elapsed or updates are forced -> [Help 1]
I looked in the pom.xml of MyApp and there is no mention of "tangosol" and there is no parent POM so I figure this must be a transitive dependency.
Normally, I can use the Maven Dependency plugin on the command line with mvn dependency:tree to display transitive dependencies. However, since the dependency is missing, the build fails and errors out instead of displaying the tree.
How can I get the cause of missing transitive dependency even if the build is failing?
EDIT: I am aware of why it failed, the artifact is missing from our local repository and the central repository, the question is which of my dependencies is asking for it.
There should be a better way, but if you run the command in debug mode (ie -X so the full command becomes mvn -X dependency:tree) then you'll see the trace printed out before the build dies:
...
[DEBUG] org.springmodules:spring-modules-cache:jar:0.9:compile
[DEBUG] opensymphony:oscache:jar:2.3:compile
[DEBUG] tangosol:tangosol-coherence:jar:3.3-rc1:compile
[DEBUG] oro:oro:jar:2.0.8:compile
[DEBUG] org.apache.jcs:jcs:jar:1.3:compile
[DEBUG] concurrent:concurrent:jar:1.0:compile
...
better answers are welcome.
I am wondering why maven didn't download the required dependency from the MAVEN CENTRAL REPO , if it is not available in your local repository.
mvn dependency:tree is useful to see the hierarchy , that means it can tell you which jar will depend on which others jars.
So, what i can guess from here is that required jar tangosol-coherence is missing in your internal nexus repository. i.e
http://mvnrepo.initech.com/archiva/repository/initechrepo
So, to overcome this problem either you have to install the required jar in your internal nexus repository or as a temporary solution you can download that jar and put it into your local system repository, so that you can have a successful build.
Thanks
The following issue appear in the Markers view when importing my Maven pom files with m2eclispe:
Failure to transfer junit:junit:jar:3.8.1 from (http://nexus.xyz.com/content/groups/public) was cached in the local repository,
resolution will not be reattempted until the update interval of central has elapsed or updates are forced.
Original error: Could not transfer artifact junit:junit:jar:3.8.1 from/to central (http://xyz.com/content/groups/public):
The operation was cancelled. pom.xml /project line 1 Maven Configuration Problem
Do I need to add a plugin exclusion filter for m2e to my pom?
Seems like Maven is configured to download any artifacts from your corporate Maven repository. This is a common setup. Usually the corporate Maven repository acts as a proxy to the Maven Central Repository, which contains most of the open source libraries like JUnit. But this doesn't seem to work in your setup. The attempt to download JUnit fails and your are getting this error.