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...
Related
I am getting below error while running Gradle build in Unix terminal.
Could not resolve all files for configuration ':imcalmsvc-service:compileClasspath'.
Could not find javax.inject:javax.inject:1.0.
Searched in the following locations:
- https://jcenter.bintray.com/javax/inject/javax.inject/1.0/javax.inject-1.0.pom
- https://repo.maven.apache.org/maven2/javax/inject/javax.inject/1.0/javax.inject-1.0.pom
However, there is no error while doing Eclipse-> Gradle refresh.
The error means the dependency wasn't found in either JCenter or Maven Central. When you are usure about the exact name of dependency or which repositories it is uploaded to, I recommend a search engine like mvnrepository.com. It aggregates metadata from a lot of different Maven repositories and even shows you how to use them in Gradle.
In your case, you can find the javax.inject library here. Notice that the only published version is simply 1 and not 1.0. Change this and it should work.
I'm trying append a private dependency into my project (react-native-android) via Maven. Unfortunately I'm get following error message when I try to build ./gradlew assembleDebug my project.
Error message returned as below:
> FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not resolve com.facebook.react:react-native:0.19.+.
Required by:
project :app > project :react-native-i18n
> Failed to list versions for com.facebook.react:react-native.
> Unable to load Maven meta-data from https://xxxPRIVATE_REPOxxx/android/com/facebook/react/react-native/maven-metadata.xml.
> Could not get resource 'https://xxxPRIVATE_REPOxxx/android/com/facebook/react/react-native/maven-metadata.xml'.
> Could not GET 'https://xxxPRIVATE_REPOxxx/android/com/facebook/react/react-native/maven-metadata.xml'. Received status code 403 from server: Forbidden
Code example
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url "https://xxxPRIVATE_REPOxxx/android" }
}
dependencies {
implementation project(':react-native-i18n')
implementation 'com.android.support:support-v4:+'
implementation 'xxxPRIVATE_DEPENDENCYxxx:1.0.+'
}
I have read numerous post and research on maven and gradle's topic. Here's my finding towards my issues:
Meaning that my sequence of declaring maven by right will get the "correct/suitable" module from the first declared maven instead of the following (maven xxxPRIVATE_REPOxxx)
The order of declaration determines how Gradle will check for dependencies at runtime. If Gradle finds a module descriptor in a particular repository, it will attempt to download all of the artifacts for that module from the same repository. You can learn more about the inner workings of dependency downloads.
Returning of 403 Forbidden does not necessary mean I do not have access to the repo I'm trying to access, but also missing of resource.
Hence I made an assumption here... During the download of project dependencies, Maven loop through both maven repo (maven google & xxxPRIVATE_REPOxxx) to get the suitable lib. However when it reaches xxxPRIVATE_REPOxxx, it failed to locate maven-metadata.xml therefore result with https://xxxPRIVATE_REPOxxx/android/com/facebook/react/react-native/maven-metadata.xml and 403 Forbidden.
My question:
Should there be a way to indicate which dependency to get from which Maven?
I was imaging something like this
implementation 'xxxPRIVATE_DEPENDENCYxxx:1.0.+' : xxxPRIVATE_REPOxxx (You know what I mean)
I have tried:
Upgrading my Android-Plugin to 3.5.0
Upgrading my Gradle version to 5.6.4
./gradlew clean and re-build after steps 1 and 2
Turns out the issue was because the react native dependencies use by 3rd party library (react-native-i18n) was too low. You can find it at react-native-i18n's build.gradle.
dependencies {
compile 'com.facebook.react:react-native:0.12.+'
}
Hence my fix to this was update the code to
compile 'com.facebook.react:react-native:+'
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.
Issues which I am facing are related to gradle build. I would like to explain what I am doing.
I created a remote repository on a remote server and I am able to access it from browser (the shared folder under which I have kept some dependency Jars).
Now I want to use that remote repository in my build.gradle (like a remote maven repository) and so I added snippet like this:
apply plugin: 'maven'
repositories{
maven {
//URL of the remote repository
url "http://IP:Port/SharedPath"
}
}
dependencies {
//Dependencies which are there in remote repository.
compile group: "GroupName", name: "DependencyName", version: "Version"
compile group: "GroupName1", name: "DependencyName1", version: ""
}
When I am running gradle build, I am getting error message like this:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not find :cachedb.jar:.
Searched in the following locations:
http://IP:Port/SharedPath/GroupName/DependencyName/Version/DependencyName-Version.pom
http://IP:Port/SharedPath/GroupName/DependencyName/Version/DependencyName-Version.jar
Required by:
:site-export-tool:unspecified
> Could not find :cachejdbc:.
Searched in the following locations:
http://IP:Port/SharedPath/GroupName1/DependencyName1//DependencyName1-.pom
http://IP:Port/SharedPath/GroupName1/DependencyName1//DependencyName1-.jar
Required by:
:site-export-tool:unspecified
I don't understand why it is searching the file at the path: url / GroupName / DependencyName / Version / DependencyName-Version.jar
While it should check for the jar at the path in URL only and not under some folder structure on the name of GroupName and DependencyName and so on... or simply say, I dont want to pass GroupName (it is possible?)
Please NOTE: I tried this also:
compile files ('lib/DependencyName-Version.jar',
'lib/DependencyName1.jar')
Please be notified that, When I am keeping those dependencies in my local system and defining them in flatDir, I am NOT facing any issue in that case.
I am trying to use remote repository because we in our organization want to use a centralized location.
Please let me know if I need to do anything with gradle configuration or gradle version which I am using (gradle 2.13) or anything in build.gradle only, I dont understand what is wrong which I am doing here. Stuck from past 2 days :-(
Thanks a ton in Advance!
This is because gradle expects standard maven repository structure when you use maven {url ".."}, which is
/$groupId[0]/../${groupId[n]/$artifactId/$version/$artifactId-$version.$extension
See https://cwiki.apache.org/confluence/display/MAVENOLD/Repository+Layout+-+Final
Either follow that structure or you can try using Ivy repository with custom layout.
https://docs.gradle.org/current/userguide/dependency_management.html#sec:defining_custom_pattern_layout_for_an_ivy_repository
I'm developing a very basic Gradle plugin (mainly to get experience) and I've published a version to my Bintray repository which should be viewable here.
I've linked my repository to JCenter (and can find my plugin here) and now, to test it all works, I'm trying to download those artifacts from a Gradle build script and apply my plugin to a mock project:
apply plugin: 'semver'
apply plugin: 'java'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.tagc:semver-plugin:0.1.0'
}
}
semver {
versionFilePath = 'version.properties'
}
However, Gradle can't resolve that dependency and throws this exception:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'TestSemver'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.github.tagc:semver-plugin:0.1.0.
Searched in the following locations:
https://jcenter.bintray.com/com/github/tagc/semver-plugin/0.1.0/semver-plugin-0.1.0.pom
https://jcenter.bintray.com/com/github/tagc/semver-plugin/0.1.0/semver-plugin-0.1.0.jar
Required by:
:TestSemver:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.703 secs
This is because JCenter doesn't seem to be hosting my files (under com/github/tagc). I'm not sure why this is the case. After getting a confirmation that my repository is linked with JCenter, are there any additional steps I need to take to make it host my uploaded files so that I can access them in the way shown in the build script? Or is just that it takes some time for the files to appear on JCenter? It's been about 5 hours since my repository was linked to JCenter.
Any help or advice would be appreciated.
It turns out that I just needed to be patient and let JCenter update. It's on there now, and my build script runs fine.
Considering that it takes a fair amount of time to update (~12 hours for me), I think that the user experience might be improved by letting first-time users know that there's a lengthy update process and that they haven't simply missed a step. This would remove some of the anxiety of wondering "Have I missed a step, and if so will I be waiting forever?"
Other than that, the Bintray UX is absolutely wonderful.