I'm a newbie to Maven. I'm trying to setup a local Archiva 1.3.6 server to act as a repository server for a project's internal artifact, as well as mirror to external repos. Things work fine except for snapshots. I'm using Maven version 3.0.5.
Here are the mirror settings in my settings.xml file
<mirrors>
<mirror>
<id>internal</id>
<mirrorOf>external:*</mirrorOf>
<name>My Maven Repository</name>
<url>http://my.repo.server:9000/archiva/repository/internal/</url>
</mirror>
</mirrors>
During the build, Maven tries to download the snapshot artifact from the wrong repository. I have 2 repositories set in the parent's parent pom.xml: internal and snapshots.
<repositories>
<repository>
<id>internal</id>
<url>http://my.repo.server:9000/archiva/repository/internal/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://my.repo.server:9000/archiva/repository/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
In the project's pom.xml I have the following dependency:
<dependency>
<groupId>com.mygroup</groupId>
<artifactId>metadata-framework</artifactId>
<version>1.0.3.SNAPSHOT</version>
</dependency>
During the build Maven tries to do this:
Downloading:
.../archiva/repository/**snapshots**/com/mygroup/metadata-framework/1.0.3.SNAPSHOT/maven-metadata.xml
Downloaded:
.../archiva/repository/**snapshots**/com/mygroup/metadata-framework/1.0.3.SNAPSHOT/maven-metadata.xml (795 B at 16.9 KB/sec)
Downloading:
.../archiva/repository/**internal**/com/mygroup/metadata-framework/1.0.3.20130908.081541-1/cems-metadata-framework-1.0.3.20130908.081541-1.pom
[WARNING] The POM for com.myground:metadata-framework:jar:1.0.3.20130908.081541-1 is missing, no dependen
cy information available
I verified the files in snapshot repo is correct, that it has properly generated maven-metadata.xml and etc. it appears that Maven downloaded the metadata correctly from snapshot repo, determined the right timestamped version, but somehow it decided to download the actual file from internal repo instead of snapshots, which lead to 404 and failed build.
I have no idea how Maven works, please help.
#lee - Here's how I download custom artifacts from an internal snapshots repo within Archiva. I use this config every day.
settingsl.xml:
Let's say I have a virtual repo named "help".
help is comprised of outside-facing repos and 2 internal-facing repos. Those 2 internal-facing repos are:
help-internal
help-snapshots
Under the <mirrors> section, I declare:
<mirror>
<id>help</id>
<mirrorOf>*, !help-snapshots</mirrorOf>
<name>The Help Repository</name>
<url>http://blah:8080/archiva/repository/help/</url>
</mirror>
Under the <servers> section, I declare:
<server>
<id>help</id>
<username>my_user_name</username>
<password>{my_encrypted_pwd}</password>
</server>
<server>
<id>help-snapshots</id>
<username>my_user_name</username>
<password>{my_encrypted_pwd}</password>
</server>
And now the final bit. In my projects' pom's that use in-house snapshots, I include this:
<repositories>
<repository>
<id>help-snapshots</id>
<url>http://blah:8080/archiva/repository/help-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
More concisely, and without modifying any pom.xml, you could define an all repository group in archiva which contains both internal and snapshots, and then add the following in your .m2/settings.xml:
<mirrors>
<mirror><id>myGroup</id><mirrorOf>*</mirrorOf>
<url>http://my.repo.server:9000/archiva/repository/all/</url>
</mirror>
</mirrors>
<profiles>
<profile><id>alwaysactive</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository><id>unused</id><url>unused</url></repository>
</repositories>
</profile>
<profiles>
I know this post is old by in order for maven to search in a snapshot repository the version should end with "-SNAPSHOT" (rather than ".SNAPSHOT")
Related
I have an internal Nexus repository in Maven where some plugins are deployed. There are some dependency jar file that are not present in the nexus repository while some are there. Is it possible to configure maven to search for the dependency jar files in internal repository and if not present search in the maven central repository.
Update
Made the similar configuration as in answer of JimHawkins. But still I guess its looking only in the nexus internal repositories for the dependencies. Here are some of the debus messges it prints:
[DEBUG] Using mirror Nexus (<internal-repo>) for central (repo1.maven.org/maven2).
[DEBUG] Using mirror Nexus (<internal-repo>) for Nexus (my.repository.com/repo/path)
[ERROR] Unresolveable build extension: Plugin <plugin-name> or one of its dependencies
could not be resolved: Failure to find org.co dehaus.plexus:plexus-utils:jar:1.1 in <internal-repo>
was cached in the local repository
If you modify your personal maven settings.xml (located in <HOME>/.m2) like shown below, maven searches your Nexus for dependencies, instead of looking in maven central rpository. If maven doesn't find them in Nexus, Nexus will download them from the maven central repository and than provide it to maven.
Every dependency is also stored in your local maven repository on your workstation, after maven fetched it from Nexus
You can tell Nexus to search for new artifacts not only in maven central repository, but also in other public repos (such as JBoss public repository).
See also: Maven configuration
Use these settings in settings.xml:
<mirrors>
<!--
mirror | Specifies a repository mirror site to use instead of a
given repository. The repository that | this mirror serves has an ID
that matches the mirrorOf element of this mirror. IDs are used | for
inheritance and direct lookup purposes, and must be unique across
the set of mirrors. | <mirror> <id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this
Mirror.</name> <url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://your.internal-nexus.com/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
This question already has answers here:
Use public maven repository with ivy
(3 answers)
Closed 7 years ago.
Id like to use Sonatype Nexus as a company-internal maven/ivy repository. My goal is that every request goes to nexus, and if nexus does not (yet) contain the requested artifact, it should delegate the request to the official maven repository. All artifacts that were downloaded from the official maven repository should be saved on nexus (as a backup). In addition, I want to be able to save my own artifacts the server for other project to use them (e.g. internal libraries)
In a past project, we have set up a Sonatype Nexus server to be used as a mirror for the maven repository which worked fine. Now I'm struggeling with an project which uses Ivy to accomplish the same with the existing nexus installation.
In the maven project, we had the following in settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<interactiveMode />
<usePluginRegistry />
<offline />
<pluginGroups />
<servers>
<server>
<id>deployment</id>
<username>[USERNAME]</username>
<password>[PASSWORD]</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://mavenserver:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
How can I accomplish the same with Ivy?
As long as you are using Ivy to access Maven repositories and not some custom defined Ivy format you can use the approach documented in the Nexus Repository Manager documentation.
Also check out the examples project for a working example.
And if you are using Ant you can also use Eclipse Aether instead of Ivy. More to that also in the docs and examples.
In my setting.xml from .m2 folder, the following configs are applied to get jar files from local nexus repository:
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>central</mirrorOf>
<url>http://192.168.0.172:9090/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
In my pom.xml, an external repository declared to get jar files not presented in central repository:
<repositories>
<repository>
<id>spring-snasphot</id>
<url>https://repo.spring.io/snapshot</url>
</repository>
</repositories>
Despite of the fact that these so called "missing artifacts" are existed in their corresponding folder in .m2, but I always get
Missing artifact ....
What is wrong with my configurations?
Thanks in advance.
Finally I just figured it out. Having deleted files excluding jar file from corresponding folder, and then updating maven project solved the problem.
The configuration looks ok. But something must be going on...
If you delete those snapshot artifacts from your local repository and retry (for ex: mvn dependency:go-offline) do you see an attempt is made to download the artifact from https://repo.spring.io/snapshot ?
The additional repository seems to contain snapshots but the are not enabled for that repository. But I'm not sure whats the default. The artifacts may be not found because of the update policy. They are locally available but too old so maven tries to update them but fails (have you tried mvn -X ? that may give an indication what fails when resolving those artifacts).
What may be an option is to add the spring snapshots repo to your nexus (snapshot repo enabled) and set the mirrorOf in settings xml to <mirrorOf>*</mirrorOf>.
The mirror of central only might was intended so: just an experiment :)
It is always a good thing to verify the settings maven actually sees are the ones you think they are:
mvn help:effective-settings
mvn help:effective-pom
I build weekly a large third-party project (apache sling) in Jenkins. I've got jenkin's settings.xml set up to use my own archiva server to download all dependencies (using the mirror section).
However, I haven't figured out how to get the build to upload snapshots my own snapshots repository when doing a 'deploy'. It instead tries to upload the snapshots to an apache.org snapshots server and fails.
Is there a way to configure settings.xml to override the snapshots server in a similar way it's possible to override the repository? This has to be done without editing the project's pom.xml.
The reason I need to do this is because I need access to some of the snapshot versions as dependencies in another project, and I don't want to have to manually upload them all into archiva.
Here's my settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/Users/Shared/Jenkins/.m2/repository</localRepository>
<servers>
<server>
<id>astra.internal</id>
<username>-deleted-</username>
<password>-deleted-</password>
</server>
<server>
<id>astra.snapshots</id>
<username>-deleted-</username>
<password>-deleted-</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central-proxy</id>
<name>Local proxy of central repo</name>
<url>http://-deleted-.com/repository/internal</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>snapshots</id>
<name>Local proxy of snapshots</name>
<url>http://-deleted-.com/repository/internal</url>
<mirrorOf>snapshots</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>Repository Proxy</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<!-- ******************************************************* -->
<!-- repositories for jar artifacts -->
<profile>
<!-- ******************************************************* -->
<repositories>
<repository>
<id>astra.internal</id>
<url>http://-deleted-.com/repository/internal/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>astra.snapshots</id>
<url>http://-deleted-.com/repository/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
You can overwrite the Distribution management section with command line parameters.
mvn clean deploy -DaltDeploymentRepository=ui-snapshots::default::http://localhost:8081/artifactory/libs-snapshot-local/
Have a look at the maven deploy plugin.
Alternatively, you should be able to use the Jenkins post build step. There you need to specifically provide the Repo url anyway.
The location of the repository is part of the pom.xml, the distributionManagement often in one of the upper-most parents. So it is not something you can set from the settings.xml.
There's a good chance that you can change it with the distMgmtSnapshotsUrl property, see org.apache:apache:13:pom, assuming the sling-project uses this as its (indirect) parent.
As far as I know you have to edit the pom file for the project and have this section (with your server settings of course):
<distributionManagement>
<repository>
<id>archiva.internal</id>
<name>Internal Release Repository</name>
<url>dav:http://localhost:8080/repository/internal</url>
</repository>
<snapshotRepository>
<id>archiva.snapshots</id>
<name>Internal Snapshot Repository</name>
<url>http://localhost:8080/repository/snapshots</url>
</snapshotRepository>
</distributionManagement>
Would it help you to put it in a company wide pom you inherit from?
By accident we discovered that one of our dependencies (spring-data-jpa 1.1.0.RELEASE, see its pom-file) includes a <repository>.
This means that our builds directly go to that repository, circumventing our own central Maven repository.
However, we want our builds to be controlled: all artifacts should come from our department's Maven repository, and that we configure to have or get everything we need from the places we want.
Question: How can we instruct Maven to ignore <repositories> from dependent artifacts' pom-files?
You can disable a repository like this:
<repository>
<id>spring-libs-release</id>
<url>http://repo.springsource.org/libs-release</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
Or you can try using a mirrorOf declaration, to use a single repository:
<mirrors>
<mirror>
<id>internal-repository</id>
<name>Maven Repository Manager running on repo.mycompany.com</name>
<url>http://repo.mycompany.com/proxy</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>