I've imported an existing Gradle project to IntelliJ IDEA. I keep getting a notification:
Unindexed remote maven repositories found. Disable...
The following repositories used in your gradle projects were not indexed yet:
http://repo1.maven.org/maven2
If you want to use dependency completion for these repositories artifacts,
Open Repositories List, select required repositories and press "Update" button (show balloon)
So, I've opened the Repositories List and as you might imagine there is http://repo1.maven.org/maven2 with the Type=Remote and Updated=Never. The problem is, when I click on the Update button, IDEA takes a few minutes and then reports an error.
java.lang.RuntimeException:
org.codehaus.plexus.repository.exception.ComponentLookupException:
java.util.NoSuchElementException
role: org.apache.maven.execution.MavenExecutionRequestPopulator
roleHint:
What should I do now? How can I solve this problem? I'm not looking for a way to disable notifications for this. Restarting IDEA doesn't help, trying to Update the repository index fails immediately after the next attempt.
This is a known bug:
https://youtrack.jetbrains.com/issue/IDEA-102693
There is zip file with a patch attached to the bug, and as far as I see it will soon be included as a official patch for version 14.1.
I had the exact same problem but the other answers didn't help in anyway.
The problem was the mavenCentral() commands in my build.gradle.
buildscript {
repositories {
mavenCentral()
}
}
repositories {
mavenCentral()
}
The solution was to replace mavenCentral() with the following lines:
maven {
url("https://plugins.gradle.org/m2/")
}
Problem caused after idea update. Maven settings resets to bundled version. Solution for that problem is in setting of maven version to latest version.
Similar to #osexp2003, I deleted my repository folder under .m2 and restart intellij.
IntelliJ -> Preferences -> Build, Execution, Deployment -> Repositories -> selected http://repo1.maven.org/maven2 and clicked on update in the dialog.
I faced same problem, solved by it changing maven home in IntelliJ. In IntelliJ go to:
File-> Setting-> Build, Execution, Deployment-> Build Tools->Maven
Change Maven Home Directory from bundled to local installed. for me the option available was:
/usr/share/maven
I have same problem.
My experience is deleting ~/.gradle dir will work fine, no more warning again.
I think this is because the ~/.gradle dir is first used by my Eclipse(Spring Tool Suite), so the files inside there are not registered in IDEA's internal index db, so cause the warning.
Here is what i'v done:
First, i chose "Open Repositories List", then click update in the dialog,
then it will take too long time to complete the action.
Then i checked the ~/.gradle, it's very big, it even contains android sdk related jars, this is why it's so slow.
So, i deleted ~/.gradle, then reopen IDEA, no more warning again.
I checked ~/.gradle again, it only contains my dependency jars.
Changing mavencentral() to jcenter() fixed this problem for me using IntelliJ IDEA 2017.1.
Related
I have set gradle up to use a local maven repository (gmaven_stable file) using the "offline.gradle" file method in the ".gradle\init.d" directory.
I constantly update the local maven repo with already downloaded files in the gradle dependency cache (.gradle\caches\modules-2\files-2.1).
However, I have realized that gradle still downloads some dependencies during "gradle sync" and "compile time" most of which I am already having in my local maven repo. Dependencies like "junit" , "google play services" and many others are always downloaded whenever I hit "Build" or "Run" button in Android Studio.
I would much appreciate if I would be guided to stop this behaviour in gradle. I am spending a lot of time gathering dependencies to build my local maven repo because of low and costly internet access in my area. It is quite annoying whenever that scarce internet I have access to is used by "Gradle" to re-download those dependencies I have already cached in my local maven repo.
Gradle has a built-in option that will avoid network access:
The --offline command line switch tells Gradle to always use dependency modules from the cache, regardless if they are due to be checked again. When running with offline, Gradle will never attempt to access the network to perform dependency resolution. If required modules are not present in the dependency cache, build execution will fail.
https://docs.gradle.org/current/userguide/dynamic_versions.html#sec:offline-mode
I constantly update the local maven repo with already downloaded files in the gradle dependency cache (.gradle\caches\modules-2\files-2.1).
You should not be manually messing with Gradle's internal cache folder. Instead, you place your JARs in a folder else where you can access them such as your home directory. Then, you can configure a flat directory repository:
repositories {
flatDir {
dirs("mylibs")
}
}
https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
You will also need to download and define various Gradle plugins that are used in your project as well and configure them the same way as the application repositories:
// settings.gradle.kts
pluginManagement {
repositories {
flatDir {
dirs("mylibs")
}
}
}
I have a hosted Sonatype Nexus repository on a local network. It has a Maven group containing a proxy repository for the public Maven repository. In the past this configuration was superb and I encountered few issues.
I recently configured https and ssl on the Nexus repository as Docker would not easily log into insecure Nexus Docker registries during CI/CD processes. I did end up re-configuring the Maven repositories at this point.
Then I updated build.gradle:
repositories {
maven {
credentials {
username "${nexusUsername}"
password "${nexusPassword}"
}
name = 'RepositoryName'
url = "https://${nexusURL}:${nexusPort}/repository/maven-public"
}
}
with the nexus* variables defined in ~/.gradle/gradle.properties:
nexus<Variable>=<value>
I have also added the appropriate certificate to the java jre keystore with the keytool and added the certificate in Idea's settings (File > Settings... : Tools > Server Certificates).
When trying to download dependencies (through the Maven proxy) using Gradle (by clicking "import changes" on the pop-up notification in Intellij Idea) the Build output shows "Could not resolve: <dependency>" for each dependency. This behavior is consistent across all of my projects (even ones that previously were able to resolve dependencies).
I have, under most circumstances, been able to get the dependencies to resolve through Nexus when running a Gradle task (:dependencies, :idea, :build) from the project's build.gradle file from a command line. The resulting downloads are not available to the project in Idea. However, after the dependencies have been resolved once, the artifacts are cached in Nexus's Maven proxy repository allowing Gradle/Idea to correctly resolve all dependencies.
What could be causing Gradle/Idea's failure to resolve artifacts through Nexus's Maven proxy? Is there a way to get Gradle/Idea to correctly resolve dependencies through the Nexus Maven group/proxy?
For now I've just added mavenCentral() to the repository list in build.gradle but I would prefer to only include the Nexus Maven group in the future. Caching resources for 1GB/s download is really nice. I would also like to better understand Gradle/Idea and what is causing this issue.
More information:
Intellij Idea has been reinstalled to version 2018.2.6 Build #IC-182.5107.16 during the process of trying to fix this issue. The old version is lost to history.
Gradle has been updated to version 4.10.2. Previous version was 4.5.1.
I've printed each of the nexus* variables via println to ensure the values were correct.
No configuration of Idea's settings for Gradle (local Gradle distribution, default Gradle wrapper, Gradle 'wrapper' task configuration) managed to resolve dependencies.
Every configuration of deleting at least one of ./.idea, ./.gradle, and ~/.gradle/caches was tried.
Idea is not in offline-mode. Sequences of toggling offline-mode and "Refresh all Gradle projects" did not change the outcome.
I have run an Idea configuration of Gradle's dependencies task with --warning-mode all --debug and compared the log to the output of gradle dependencies --warning-mode all --debug on command line. The logs seem to be producing the same statements (in wildly different orders) until the "Could not resolve:" message appears in the Idea output. I did not find any nearby error messages that would explain the failure. If it would help diagnose the issue I can upload those files.
I have tried setting the repository to point directly at the Nexus Maven proxy instead of the Maven group. This did not allow Gradle/Idea to resolve dependencies.
Should I be using a http/https proxy for Gradle? I don't understand the goal of using a proxy in this context.
I have not done anything with Grail. I don't know what Grail is and suspect I do not currently need it.
OS is Windows 10.
Dependencies are not resolved when using compile or implementation in build.gradle.
Transitive dependencies don't seem to be relevant.
I must not have added the certificate to the correct jre installation. I added it more recently and the issue was resolved.
Also, superstitious notes for anyone else having a similar issue:
I added the certificate (a wildcard certificate) under the alias (using the -alias command line parameter for keytool): *.example.com
I also added it under an alias for the full address: nexus.example.com
I don't know whether either of those had any impact on Idea/Gradles' success in resolving artifacts. I believe it was working before I added the second alias.
I am using Artifactory as my artifact store, and have set this up so that it is being used as a proxy and cache for jcenter. This generally is working fine apart from for dependencies declared in the buildscript block in my main build.gradle.
My block looks like
buildscript {
repositories {
//proxies jcenter
maven {
url "https://<myArtiInstance>/artifactory/repo"
credentials {
username artifactory_reader_username
password artifactory_reader_password
}
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
classpath "com.android.tools.build:gradle:2.1.2"
}
}
which gives the error when running gradlew clean build (2.10)
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find builder.jar (com.android.tools.build:builder:2.1.2).
Searched in the following locations:
https://<myArtiInstance>/artifactory/repo/com/android/tools/build/builder/2.1.2/builder-2.1.2.jar
If I wack the above url into my (authenticated) browser, I get the jar and can see its put into the arti cache.
All my other proxied dependencies seem to work so I am a bit confused as to whats going on.
At present I am wondering if this is a bug with Gradle 2.10 or something, as this used to work as I can see previous cached versions of that artifact in my arti box.
Thanks for any help or pointers :)
EDIT: If I roll back to com.android.tools.build:gradle:2.1.0 which is not in my cached repo either, build completes fine and it caches it. For some reason it does not like 2.1.2, I wonder why?!
EDIT2: Still having issues, now its taken issue with https://<myArtiInstance>/artifactory/repo/com/google/guava/guava/15.0/guava-15.0.jar which gives a similar error to the above
* What went wrong:
A problem occurred configuring root project '<name>'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find guava.jar (com.google.guava:guava:15.0).
Searched in the following locations:
https://<myAriInstance>/artifactory/repo/com/google/guava/guava/15.0/guava-15.0.jar
This is again from a dependecency specified inside the buildscript block. Any ideas whats going on? This time is transative so I cant just swap the version. The only strange thing I notice from the error messages is that its looking for guava.jar at the url ending in guava-15.0.jar...
So it turns out inspecting the output of gradlew clean build --debug for a second time, I noticed everything was being obtained from the local ~/.gradle/cache, apart from the failing jars above. rm the cache and everything works fine, and the transitive dependencies can be obtained from the url given in the error msg. Subsequent builds which retreive from local cache work fine. Seems to me that something had corrupted the local cache (maybe partial download of complete resources i.e. pom, jar etc for the dependency) and that the gradle error msg was incorrect.
EDIT: testing just deleting the jar from cache and still compiles fine...
While experimenting with Grails 3 under IntelliJ I found the following warning:
Unindexed remote maven repositories found. Disable...
The following repositories used in your gradle projects were not indexed yet:
https://repo.grails.org/grails/core
If you want to use dependency completion for these repositories artifacts,
Open Repositories List, select required repositories and press "Update" button (show balloon)
If I am trying to resolve an issue, I get next error:
FileNotFoundException: Resource nexus-maven-repository-index.properties does not exist in IntelliJ
I would prefer to know, what does it mean? If repository is marked as "remote", then why the problem is absence of some (local?) file?
UPDATE
I think this is not related with Grails actually.
How to know more details on error, occurring in Indexed Maven Repositories Window in IntelliJ on Update button?
The popup message says
Resource nexus-maven-repository-index.properties does not exist in IntelliJ
If you're using your custom repository
AND it is Nexus 3.x
chances are high that you forgot to set up a Task to publish your maven repository indexes.
Log in via browser.
Go to Administration/System/Tasks/Create Task/Create Publish Maven indexes Task
Set it for an hourly publish. Done.
For me the solution was to delete the folder ~/.m2/repository. This made Maven to re-index everything correctly.
Failed trials, that may work for someone else:
Build, Execution, Deployment → Build Tools → Maven → Repositories : Selecting the repositories and click updates.
Build, Execution, Deployment → Build Tools → Maven: Giving more memory JVM
Delete folder ~/.IntelliJIdea2016.3/system/caches
You can try using grails/repo and grails/plugins instead of grails/core.
For example, in build.gradle:
repositories {
mavenLocal()
maven { url 'http://repo.grails.org/grails/repo' }
maven { url 'http://repo.grails.org/grails/plugins' }
}
I tested on IntelliJ Community 15 with Grails 3.0.9, JVM Version: 1.8.0_45, Apache Maven 3.3.9 and Gradle 2.3.
The same error occurs for Artifactory users. Solved with sanya's hint. Make sure the local repositories are included.
After that the repo works:
I've had faulty indexes after fresh install (from Snap ubuntu).
It has been solved by changing the MAVEN HOMe PATH
I've switched from "bundled" to "/usr/share/maven"
None of the solutions aforementioned solved my issue in my case
I'm trying to use this Sonatype Eclipse plugin for the first time to handle an existing (huge) software that I can build with maven form the command line.
I have configured the plugin to use my maven 2.2.1 installation instead of the built-in Maven 3.
In Eclipse I have 25 projects (loaded through the root pom.xml) and 4 of them have compilation errors; the maven console contains a lot of lines like this one:
Missing artifact commons-logging:commons-logging:jar:1.0.4:compile
I have all the jars in my repository and the M2_REPO classpath variable correctly defined. Why the plugin doesn't see all the jars?
The .classpath file of those projects simply references "MAVEN2_CLASSPATH_CONTAINER", there isn't a list of the jars.
The pom.xml in Eclipse shows an error on the first line for the missing jars but I can build from the command line!
Any idea? I need help! I will try to move to NetBeans if I don't solve this problem.
Thank you.
You may need to to tell Eclipse to force update:
Project -> Maven -> Update Maven Project
and then make sure you have selected:
Force Updates of Snapshots/Releases
this happens when mvn install copies some jar files into Maven repository and Eclipse had checked this repo BEFORE this jar has been copied there.
If Dependency management is enabled when the above problems occur in Eclipse you can Project > Maven > Disable Dependency Management and then \Project > Maven > Enable Dependency Management. This normally remove any dependency errors in the pom.xml.
Also do as #Nishant indicated in his answer above after the above steps to complete the projects dependencies.
right click on your project > Maven > Update Dependencies
then
right click on your project > Maven > Update Project configuration
Assuming you M2Eclipse plugin is installed correctly this should solve the issue. Also, check if there is an option right click project > Maven > Enable dependency Management select that.
Using Eclipse Kepler, the removing and re-adding of the maven nature fixed this same issue I was having. What this process actually did was modify the .settings/org.eclipse.m2e.core.prefs file, changing the line
resolveWorkspaceProjects=false
to
resolveWorkspaceProjects=true
So you could probably make this change manually if you had to.
Adding my 2c for future Googlers:
Whenever this problem shows up, I delete the corresponding folder from the m2 repository (on a mac it's on ~/.m2/repository) and build again from eclipse with clean install.
Works every single time.
Close eclipse IDE and open it again, this issue should be fixed.
Just to add yet another possible resolution, if you have a multi-project build with interdependencies, if you have a repository defined in a child project pom to resolve a specific dependency that only that project depends on and it is relying on a partent project for it's other resolutions it fails to see those dependencies in the child project (even though it works from the command line).
Move the repo definition to the parent pom.
The lack of jars in the build path suggests you haven't enabled Maven dependencies. Right-click on the project, select Maven, select "Enable Maven Dependency Management". This allows M2Eclipse to reference your POM.
I finally found a workaround. It is surely a bug in m2eclipse, however the problem disappeared when I added quartz-1.6.0.pom next to quartz-1.6.0.jar in .m2\repository\opensymphony\quartz\1.6.0\
The pom is not present at http://repo1.maven.org/maven2/opensymphony/quartz/1.6.0/ but you can extract it from quartz-1.6.0-bundle.jar linket at http://jira.opensymphony.com/browse/QUARTZ-482
It's a strange solution but it worked on the PCs of my collegues too.
None of the other suggestions worked, but the following steps worked for me (SpringSource Tool Suite 2.6.1):
Back up the contents of the local Maven repository
Delete the repository
Project > Maven > Update Dependencies
Replace anything not available in a public repository from the backup
If disabling and enabling project dependency management doesn't help (usualy it helps) you can modify .classpath file in your project and add a line:
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
After eclipse restart dependencies should be added.
I had this same problem happened to me. On the CLI clean install, then on eclipse delete the dependency, paste it again and that did the trick.
Remove all the artifacts except the jar in maven local repository
Late answer: In my case I had multiple profiles in settings.xml. Building worked since the correct profile was selected in the Maven Build run config, but the editors showed errors because the profile was not selected via Project -> Maven -> Select Maven Profiles ...