Resource nexus-maven-repository-index.properties does not exist - java

I'm using a remote artifactory repo.
I add this repo to settings.xml file wich plased in the <user>/.m2/ folder:
<settings>
<mirrors>
<mirror>
<id>artifactory</id>
<name>artifactory</name>
<url>http://example.com/artifactory/repo</url>
<mirrorOf>external:*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>artifactory</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>snapshots</id>
<name>snapshots-only</name>
<url>http://example.com/artifactory/snapshots-only</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
In Idea settings in the "Build Tools -> Maven -> Repositories" page I see url to my artifactory repo. But when I click on "Update" button, I get error message
java.lang.RuntimeException: java.io.FileNotFoundException: Resource nexus-maven-repository-index.properties does not exist
How to solve this trouble?
Windows 8
Maven 3.2.1
Idea 2017.1.5

Have you tried bumping the memory for the importer then restarting the IntelliJ? (worked for me)
Build, Execution, Deployment → Build Tools → Maven → Importing → VM options for importer
https://stackoverflow.com/a/42394767/2242239

Related

Maven failing to download artifact from central repository

I have two private JFrog repositories setup. One repository handles releases and the other handles snapshots. Here is how I have defined this in my settings.xml file.
<settings>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<servers>
<server>
<id>central</id>
<username>private-repo-username</username>
<password>private-repo-password</password>
</server>
<server>
<id>snapshots</id>
<username>private-repo-username</username>
<password>private-repo-password</password>
</server>
</servers>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>a0d2olsx0t222-artifactory-primary-0-releases</name>
<url>https://my-private-repo.jfrog.io/artifactory/libs-release</url>
</repository>
<repository>
<id>snapshots</id>
<name>a0d2olsx0t222-artifactory-primary-0-snapshots</name>
<url>https://my-private-repo.jfrog.io/artifactory/libs-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
Multiple of my internal dependencies in my multi-module maven project are getting this error:
[ERROR] Failed to execute goal on project platform-utils: Could not resolve dependencies for project
design.colspalinva:platform-utils:jar:2.2.1-SNAPSHOT: The following artifacts could not be resolved:
com.maxmind.geoip2:geoip2:jar:2.12.0, org.apache.ant:ant:jar:1.10.5: Could not find artifact
com.maxmind.geoip2:geoip2:jar:2.12.0 in central (https://my-private-repo.jfrog.io/artifactory/libs-
release) -> [Help 1]
From the look of it, it doesn't appear that Maven is trying to reach out to the official Maven Central repo for those dependencies, rather failing on my private repository. I was under the impression that if the private repository does not contain the specific artifact, it will attempt to reach out to Maven Central.
It has no problem downloading my Spring dependencies from Maven Central.
If you like to redirect all access of central from Maven to your own repository manager you have to configure the settings.xml as follows:
<! language:language-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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://IP:PORT/repository/repo</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
The Maven settings.xml configuration you shared seems to be OK. You are overriding the built-in central and snapshot repositories of Maven, which is the correct way to make sure that Maven send requests by default to Artifactory.
Adding a Mirror Any setting, as suggested in the other answer, means that in addition to overriding built-in Maven repositories, you can use the Mirror Any setting to redirect all requests to a Maven repository through Artifactory, including those defined inside POMs of plug-ins and third party dependencies.
According to the log you shared Maven does attempt to resolve the artifacts via Artifactory - https://my-private-repo.jfrog.io/artifactory/libs-release
The issue seems to be related to resolution of a specific artifact(s)in Artifactory.
I'm assuming that libs-release is a virtual Maven repository and that it contains at least one remote Maven repository pointing at Jcenter or Maven Central (if not please start by looking at Maven Repositories).
To debug the issue:
(1) Try resolving the artifact directly from Artifactory using cURL or a web browser, for example:
curl -Uuser:pass https://my-private-repo.jfrog.io/artifactory/libs-release/com/maxmind/geoip2/geoip2/2.12.0/geoip2-2.12.0.jar
(2) If you manage to resolve the artifact, it mean that Artifactory is properly configured and Maven should be able to resolve. If not, try looking for the reason performing a trace, for example:
curl -Uuser:pass https://my-private-repo.jfrog.io/artifactory/libs-release/com/maxmind/geoip2/geoip2/2.12.0/geoip2-2.12.0.jar?trace

Deploy artifacts into two different remote repositories - Maven?

Need to deploy a artifacts from two remote repositories based on environment specific. So I tried by using profiles in distribution management in pom.xml
<profiles>
<profile>
<id>dev-repository</id>
<activation>
<property>
<name>devRepo</name>
<value>true</value>
</property>
</activation>
<properties>
</properties>
<distributionManagement>
<repository>
<id>dev</id>
<url>https://nexus/dev</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
</profile>
<profile>
<id>qa-repository</id>
<activation>
<property>
<name>!devRepo</name>
</property>
</activation>
<properties>
</properties>
<distributionManagement>
<repository>
<id>qa</id>
<url>https://nexus/qa</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
</profile>
</profiles>
Tried Activating the profiles
> mvn clean deploy -PdevRepo
I am getting the following error.
Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
seems like pom can't recognize the distributionMangement tags.
But It's working fine without profiles for single distributionManagement.
Any one please advise on this ?
Reference
Setting up Maven to allow deployment to different repositories easily
Deployment issue with Maven Plugin
Instead of using profiles, I would define a distributionManagement with a url of the form <url>https://nexus/${target.repo}</url>
Then you can do something like mvn clean deploy -Ptarget.repo=dev.

Maven build problem: Installed external Maven 3.6 yet getting build error for plugin 2.5

I'm using Eclipse Kepler and JDK 1.8. I have created a Maven project in eclipse. The in built maven that comes with eclipse has a version 3.0.4. There was an error in creating the maven project saying
"Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5".
But the folder structure was created. Since the inbuilt maven within eclipse was not able to build it. I downloaded and setup full maven from the maven.apache.org. I verified the same by running the command mvn -v which showed the version of Maven that I have installed i.e. 3.6.
Then I added a java class under Maven_Project_Root/src/main/java. Then tried to build it. Again received the following error:
"Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5"
-It will be much appreciated if somebody can help.
The Maven server do not support HTTP anymore. You must configure the maven repositories with HTTPS url's in your local maven configuration file, in your home folder yourname/.m2/settings.xml.
Here is an example that you may copy:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>https://repo1.maven.org/maven2/</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>https://repo1.maven.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

Eclipse Maven Not Downloading Sources and Javadoc from Configured Nexus Repository

I have configured in my global m2 settings the Nexus Repository that my organization is using.
When doing mvn install it downloads the packages from the Nexus Repo, which shows the configuration is alright.
When using maven in eclipse however, it appears that whenever I do a Maven > Update Project, and eclipse tries to download the new packages added in pom.xml, it is still downloading from Maven Repo.
I have already configured the following:
Under Preferences > Maven > Installations, this is pointing to my maven files
Under Preferences > Maven > User Settings, this is pointing to my settings.xml under my user folder and configured to the nexus repository
However, I am not sure why are packages still not retrieved from nexus repo still.
My settings.xml
<settings>
<profiles>
<profile>
<id>MyId</id>
<repositories>
<repository>
<id>MyRepo</id>
<url>MyCompanysNexusRepoUrl</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>MyRepo</id>
<url>MyCompanysNexusRepoUrl</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>MyId</activeProfile>
</activeProfiles>
</settings>
The settings.xml for using a repository manager like Nexus should look like this:
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url> MyCompanysNexusRepoUrl</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>
If you are working in a network with restriction, you might have to add proxy details in eclipse.

Why does maven build only when the Nexus Anonymous user is active?

I am building my code using maven and we have our repositories on Nexus. The only way I manage to run a successfully mvn install from the command console is when I enable the Anonymous user from the Nexus settings.
In order to make sure I have all the needed rights I added in the settings.xml the admin user.
<settings>
<servers>
<server>
<id>serverIDblabla</id>
<username>NexusAdminUser</username>
<password>NexusAdminPass</password>
</server>
</servers>
<profiles>
<profile>
<id>myIDblabla</id>
<repositories>
<repository>
<id>repositoryID</id>
<url>https://.../repository/myrepository/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
...
I use:
apache maven 3.2.1
Nexus 3.0.0 -03
Any suggestions?

Categories

Resources