Using Nexus repository instead of public Maven in Idea Intellij - maven

How can I force Idea Intellij to download from Nexus repository instead of Maven Public repo?
Where can I configure that in Idea properties?
It's not defined in pom.xml files and I'd prefer not to.

Not sure if it will work also on Idea Intellij ( I am using spring source studio - eclipse clon) , but should because maven configuration is in settings.xml in .M2 directory which is located in your home directory. Just use something like this ( my server is running on nexus-server:8081):
<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">
<servers>
<server>
<id>releases</id>
<username>user-name</username>
<password>your-password</password>
</server>
<server>
<id>snapshots</id>
<username>user-name</username>
<password>your-password</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus-server:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Disable 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>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

Related

Nexus group by SNAPSHOT

I have Nexus with builds repository. How I can group my versions on folders named snapshot-x.x ?
Repository have snapshot type. User deployment have all privileges.
I run maven as mvn versions:set -DnewVersion=$VERSION and mvn clean deploy -B -Pbuild -Dbuild.version=$VERSION
My settings.xml work only releases repo ;-(
<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">
<servers>
<server>
</server>
</servers>
<profiles>
<profile>
<id>build</id>
<repositories>
<repository>
<id>nexus-repo</id>
<name>Nexus repo</name>
<url>http://<MY-HOST>:8081:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-repo</id>
<name>Nexus repo </name>
<url>http://<MY-HOST>:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<altDeploymentRepository>
-DaltDeploymentRepository=builds::default::http://deployment:<MY_PASS>#<MY-HOST>:8081/content/repositories/builds
</altDeploymentRepository>
</properties>
</profile>
</profiles>
</settings>
<activeProfiles>
<activeProfile>build</activeProfile>
</activeProfiles>
I'm not sure what you are asking for? A repository has a fixed format which comprises of groupId:artifactId:version ?
There you see com/soebes/examples/j2ee is the groupId: com.soebes.examples.j2eee and than artifactId: app plus the version 1.1.2-SNAPSHOT with the underlying versions for a single SNAPSHOT

How to set up maven?

How to set up Maven (settings.xml) and Artifactory to access all repositories through Artifactory?
My current settings are as follows and I even fail to get the Maven-deploy plugin
to execute. The error is that it was not found in any repos (local + artifactory)
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>xxx</username>
<password>xxx</password>
<id>central</id>
</server>
<server>
<username>xxx</username>
<password>xxx</password>
<id>snapshots</id>
</server>
</servers>
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>repo</name>
<url>http://[host]:[port]/artifactory/repo</url>
<id>repo</id>
</mirror>
</mirrors>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://[host]:[port]/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://[host]:[port]/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://[host]:[port]/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://[host]:[port]/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
[host]:[port] are real in file and so is [username][password] checked that 3 times.
[ERROR] No plugin found for prefix 'deploy' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\[username]\.m2), repo (http://[host]:[port]/artifactory/repo)] -> [Help 1]
Artifactory can generate the right settings.xml file for you. Look for Maven Settings link on the right side menu of the home screen.

Prefetch maven-metadata.xml with nexus

With the maven3 configuration file settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<!--<host>webproxy</host>-->
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://richter-local.de:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<servers>
<server>
<id>nexus</id>
</server>
</servers>
<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>
<updatePolicy>interval:10080</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>interval:10080</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>interval:10080</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>interval:10080</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
<interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
</settings>
and a nexus maven proxy (version 2.7.2-03) I have to wait for a bunch of very slow downloads of maven-metadata.xml file every day after 00:00 a.m. (take about 5 mintues together for some KB which ought to be transfered within seconds). How can I prefetch those file in order to download them my local nexus instance?
It sounds like you have one or more proxy repositories that have remotes that are responding very slowly. Once a day the cache timeouts for these expires, resulting in very slow retrieval.
See here for information on how to debug this, and configure Nexus to prevent the issue from occurring again:
https://support.sonatype.com/entries/25884097-Troubleshooting-slow-maven-metadata-xml-download-speeds

How to disable usage of public maven repo

I've setup a maven repository(Artifactory) in my LAN which has no internet access. I've also change my maven settings.xml to use this internal repo only. However when I try to create a maven project, it still try to access the public repo(http://repo1.maven.org/maven2) for some downloads. Where has I done wrong?
For example, when I perform the following:
mvn archetype:generate -DgroupId=demo.john -DartifactId=struts2demo
-DarchetypeGroupId=org.apache.struts
-DarchetypeArtifactId=struts2-archetype-starter
-DinteractiveMode=false
there is the following waring reported:
... ...
[INFO] Generating project in Batch mode
[WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
org.apache.maven.wagon.TransferFailedException: repo1.mavne.org
at org.apache.maven.wagon.shared. ...
... ...
Sometimes the it build successfully with this waring, but sometime it won't.
Below is my maven's settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<id>central</id>
<username>admin</username>
<password>password</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>my-company-repo</id>
<name>A maven repo in local network</name>
<url>http://my.internal.server/artifactory/repo<url>
</mirror>
<mirrorOf>*</mirrorOf>
</mirrors>
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://my.internal.server/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://my.internal.server/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://my.internal.server/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://my.internal.server/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

maven local repository proxy external

I am supporting an Archiva internal repository in an organization where some build environments don't have access to the open internet to fetch dependencies. I thought I could configure Archiva as a mirror for everything external (mirror with mirrorOf set to "external.*,!snapshots") and set it up with proxies so that, if one of my builds asks for something that is not in Archiva, it will use the proxies to go get the dependencies from the external sources I set up with proxies. After that, it would be cached in Archiva and would not have to be fetched from outside.
So I have proxies in my Archiva config for codehaus, sonatype (several), the basic Central, Cloudera for Hadoop stuff etc.; but I can't find a configuration that keeps my builds from trying to go directly to the external sources (which they can't reach) and yet satisfies the things that are not already in my Archiva by using the proxies.
Is there some trick configuration I'm missing here? Or do I need to switch to Artifactory or Nexus to get this kind of functionality?
You need to set the maven settings on each of the build environments to point to your archiva instance.
e.g in $user.home/.m2/settings.xml
<mirror>
<id>InternalMirror</id>
<mirrorOf>*</mirrorOf>
<name>Internal Mirror.</name>
<url>http://archivaserver/archivaPath/</url>
</mirror>
I haven't used Archiva before, but I have done this successfully with Nexus
Switching to a nexus will be moer preferable.
I have attached a settings.xml which can be used for nexus....
<?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>F:\m2\repository</localRepository>
<pluginGroups>
<pluginGroup>org.codehaus.sonar</pluginGroup>
</pluginGroups>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>your-host-id</host>
<port>8080</port>
</proxy>
</proxies>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*,!sonar</mirrorOf>
<url>http://nexus-repo-url/content/groups/public</url>
<name>Nexus</name>
</mirror>
</mirrors>
<profiles>
<profile>
<id>NexusProfile</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.5</jdk>
</activation>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>nexus</id>
<name>default-repos</name>
<url>http://nexus-repo-url/content/groups/default-repos</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>nexus</id>
<name>default-repos</name>
<url>http://nexus-repo-url/content/groups/default-repos</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>nexus</id>
<name>default-repos</name>
<url>http://nexus-repo-url/content/groups/default-repos</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>nexus</id>
<name>default-repos</name>
<url>http://nexus-repo-url/content/groups/default-repos</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>NexusProfile</activeProfile>
</activeProfiles>
<servers>
<server>
<id>nexus</id>
<username>anonymous</username>
<password>password</password>
</server>
</servers>
</settings>
I recommend you read http://maven.apache.org/guides/mini/guide-mirror-settings.html for configuring your settings.
And I recommend you to use Archiva 1.4 version series which is more performant.
We are currently rewriting the ui see a real sample https://archiva-repository.apache.org/archiva/index.html?request_lang=en .
If you want your own version you must download a snapshot from here: https://builds.apache.org/view/A-F/view/Archiva/job/archiva-all-maven-3.x-jdk-1.6/

Resources