Reputation: 594
I am using Gradle in a new IntelliJ project. We have an internal Sonatype Nexus repository and I have declared that in build.gradle
. I also added the dependency to the build script.
group 'com.companyName'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven{
url 'http://host:port/nexus/content/repositories/releases'
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile group: 'com.companyName', name:'abc', version: '2.2.7'
}
As you can tell this is a brand new project. IntelliJ will build the project but wont resolve the external dependency. When I look in the Gradle projects view in IntelliJ there is a red squiggly line under the dependency and it says Unable to resolve dependency
. I know the dependency exists and I can use it in Maven projects.
I've search around without any solution, tried all different settings in the intelliJ project also. Any ideas?
Upvotes: 0
Views: 5870
Reputation: 556
Issues like unable to resolve dependencies(even after checking that there are no typos) could be because of firewall settings.
Check with your security department on how to fix it.
In some organizations, they've local mirror. In gradle.properties
you'll have to give that path in distributionUrl
Also in build.gradle
use corresponding path in repositories.
Upvotes: 1
Reputation: 31
I had a similar problem with IntelliJ 2017.1 connecting to Artifactory. I opened a Terminal, ran "./gradlew tasks" and, as a side-effect, the dependency was downloaded.
Upvotes: 1
Reputation: 38734
From discussion comments on the original post:
There seem some caches be corrupt.
Delete the .gradle
folder in your project and ~/.gradle/caches
, then try to resolve the dependencies again.
Upvotes: 1