I have just checked out some projects and need to build them, however I installed Maven quite some time ago (6 months maybe?) and really haven't used it since - the pom.xml
for the project I have doesn't have this "http://repo1.maven.org/myurlhere" anywhere in it - it has the absolute url
where the Maven repo is for the project, but Maven is still trying to download from the general Maven repo:
Macintosh:trunk$ mvn clean install [INFO] Scanning for projects... Downloading: http://repo1.maven.org/url/project/project/x.x/project-x.x.pom [INFO] Unable to find resource 'url.project:project:pom:x.x' in repository central (http://repo1.maven.org/) [INFO] ------------------------------------------------------------------------ [ERROR] FATAL ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. GroupId: url.project ArtifactId: project Version: x.x Reason: Unable to download the artifact from any repository url.project:project:pom:x.x from the specified remote repositories: central (http://repo1.maven.org/)
Can anyone help me with what I'm not doing right?
Basically, I have just checked the projects out from the command line, cd
-ed into the directory and ran mvn clean install
- nothing else.
Any help is greatly appreciated.
Maven Central, a.k.a. the Central Repository, is the default repository for Maven, SBT, Leiningen, and many other JVM based build tools.
the pom.xml for the project I have doesn't have this "http://repo1.maven.org/myurlhere" anywhere in it
All projects have http://repo1.maven.org/ declared as <repository>
(and <pluginRepository>
) by default. This repository, which is called the central repository, is inherited like others default settings from the "Super POM" (all projects inherit from the Super POM). So a POM is actually a combination of the Super POM, any parent POMs and the current POM. This combination is called the "effective POM" and can be printed using the effective-pom
goal of the Maven Help plugin (useful for debugging).
And indeed, if you run:
mvn help:effective-pom
You'll see at least the following:
<repositories> <repository> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>Maven Repository Switchboard</name> <url>http://repo1.maven.org/maven2</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <releases> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>Maven Plugin Repository</name> <url>http://repo1.maven.org/maven2</url> </pluginRepository> </pluginRepositories>
it has the absolute url where the maven repo is for the project but maven is still trying to download from the general maven repo
Maven will try to find dependencies in all repositories declared, including in the central one which is there by default as we saw. But, according to the trace you are showing, you only have one repository defined (the central repository) or maven would print something like this:
Reason: Unable to download the artifact from any repository url.project:project:pom:x.x from the specified remote repositories: central (http://repo1.maven.org/), another-repository (http://another/repository)
So, basically, maven is unable to find the url.project:project:pom:x.x
because it is not available in central.
But without knowing which project you've checked out (it has maybe specific instructions) or which dependency is missing (it can maybe be found in another repository), it's impossible to help you further.
By default, Maven will always look in the official Maven repository, which is http://repo1.maven.org.
When Maven tries to build a project, it will look in your local repository (by default ~/.m2/repository
but you can configure it by changing the <localRepository>
value in your ~/.m2/settings.xml
) to find any dependency, plugin or report defined in your pom.xml
. If the adequate artifact is not found in your local repository, it will look in all external repositories configured, starting with the default one, http://repo1.maven.org.
You can configure Maven to avoid this default repository by setting a mirror in your settings.xml
file:
<mirrors> <mirror> <id>repoMirror</id> <name>Our mirror for Maven repository</name> <url>http://the/server/</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors>
This way, instead of contacting http://repo1.maven.org
, Maven will contact your entreprise repository (http://the/server
in this example).
If you want to add another repository, you can define a new one in your settings.xml file:
<profiles> <profile> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>foo.bar</id> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> <url>http://new/repository/server</url> </repository> </repositories>
You can see the complete settings.xml
model here.
Concerning the clean
process, you can ask Maven to run it offline. In this case, Maven will not try to reach any external repositories:
mvn -o clean
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With