I have a gradle Project where I have a dependency on "hudson-core 3.3.3"
compile group: 'org.eclipse.hudson', name: 'hudson-core', version: '3.3.3'
This works without a problem when using Gradle 5.6.2
When I upgrade to Gradle 6.0.1 I receive the following error:
Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
Required by:
project : > org.eclipse.hudson:hudson-core:3.3.3
project : > org.eclipse.hudson:hudson-core:3.3.3 > org.eclipse.hudson:hudson-cli:3.3.3
> Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3.
> inconsistent module metadata found. Descriptor: org.eclipse.hudson:hudson-remoting:3.0.4-SNAPSHOT Errors: bad version: expected='3.0.3' found='3.0.4-SNAPSHOT'
The Repository is always the same:
repositories {
mavenCentral()
maven {
url 'http://repo.jenkins-ci.org/public/'
}
}
Any Ideas why this error happens?
As said by #ToYonos, the problem is in the dependency itself.
Not perfect solutions, but 2 workarounds can be done as explained in Gradle's documentation (v6.7.1):
Exclude that transitive dependency, for example in the current Gradle versions using implementation instead of compile:
implementation('org.eclipse.hudson:hudson-core:3.3.3') {
exclude group: 'org.eclipse.hudson'
exclude module: 'hudson-remoting'
}
Override that transitive dependency version:
implementation('org.eclipse.hudson:hudson-remoting') {
version {
strictly '3.0.2' // As 3.0.3 is having the issue
}
}
In the pom.xml file of hudson-remoting 3.0.3, the version is <version>3.0.4-SNAPSHOT</version>
The issue is quite clear.
I tried with an old Gradle 4.4.1 and I am having the exact same issue. Likewise with Gradle 5.1.1 and your version, 5.6.2
I'm quite sure that if you clean your artefact cache for Gradle 5.6.2, it won't work anymore.
The error is on the repository side.
Another option is to define a repository that will download only a jar:
repositories {
mavenCentral() {
name = "Download only jar repo"
metadataSources { artifact() }
content {
// Use this repository only for org.eclipse.hudson:hudson-remoting
includeVersion("org.eclipse.hudson", "hudson-remoting", "3.0.3")
}
}
mavenCentral()
}
Also since pom is not downloaded you would have to add hudson-remoting dependencies by hand to build.gradle. But luckily for this particular case hudson-core already contains the only dependency commons-codec:commons-codec:1.4 that hudson-remoting needs, so this is not needed.
Note: the order of repositories is important, although in that case it will work either way. If you don't want to care about the order when using repositories with filter check exclusive content filtering.
I am using the Spring Boot Gradle plugin and its dependency management to manage some of my own dependencies across project so I do not need to add an explicit version in the build.gradle.
dependencyManagement {
dependencies {
dependency "foo.bar:my-own-library:12.1"
}
}
The problem is that I need another version "11.9" beside the version "12.1" and that I wanted the plugin to pick the correct version based on a variable.
So I added a resolutioStrategy and some variables in ext:
dependencyManagement {
dependencies {
dependency "foo.bar:our-own-library:12.1"
}
resolutionStrategy {
eachDependency { details ->
//find available version based on src_compat
//set the new version to use via
details.useVersion(newVersion)
// details.target.version yields updated version
}
}
}
ext {
src_compat = 11
extra_versions = ["foo.bar:my-own-library" : ["11.9"]]
}
The target version is set correctly every time but than the old version (12.1) is used for every configuration.
The configurations have no other custom resolutionstrategy.
My assumption was the resolutionStrategy of the plugin is able to override every version when the dependency management of the plugin is used.
Is the resolutionStrategy able to override all versions or do I have to move it the 'normal' gradle configurations?
There's some information about this in the dependency management plugin's documentation.
The dependency management resolution strategy only applies to the plugin's internal configurations, such as those that it uses to resolve the Maven boms that you have imported. As you suspected, if you want the resolution strategy to apply to the resolution of your project's dependencies, you should move it to the normal Gradle configurations.
I have developed an internal plugin. The plugin has its own version. I then use that plugin for a build process in a repository.
If I change the version of the plugin, I have to update the build.gradle to spell our the new version. I have about 100 of these repositories.
Is there a way to specify in my build.gradle to use the latest version of the plugin that can be found in that location?
I could ran a batch file before gradle that find the latest, updates build.gradle with that number and then runs the build process but this is a big work around to a functionality that should be available.
See code below where I call the plugin that I change quite often:
buildscript {
repositories {
maven {
url "c:/git/_TEST/plug-in"
}
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath group: 'com.myplugin.gradle', name: 'com.myplugin.mypluginbuild', version: '1.0'
}
apply plugin: 'com.myplugin.mypluginbuild'
}
if I don't specify the version, it returns an error. Any suggestions?
For those who use plugins{} block, gradle7+ supports dynamic version, which includes + and latest.release.
plugins {
id "your-plugin-id" version "1.0.+"
}
dynamic version doc
It's not possible this way. See the plugins {} block and plugins documentation.
For core plugins you must not provide a version.
For community plugins you have to provide a version.
Maybe script plugins are way to go:
apply from: 'my_script_plugin.gradle'
I have a solution to this question.
The + specified in the version field will do the trick. It will enable gradle to use the latest plug-in automatically.
I.e:
dependencies {
classpath group: 'com.myplugin.gradle', name: 'com.myplugin.mypluginbuild', version: '1.+'
}
I am trying to create a copy of a gradle project that will work in --offline mode. I have automated all steps apart from one. I am not able to automatically download plugin jars into gradle cache.
My offline distribution works by specifying the GRADLE_USER_HOME, downloading all dependencies and bundling the whole gradle cache with the project. Unfortunately we are using a few custom plugins. I could of course make an exception for each one of them and include them manually, with some kind of if statement for the offline mode. But it would be great if I could simply download the jars into the cache.
Is there a way to force gradle to download all dependencies, including the plugin dependencies?
This is what I am doing for the rest of the dependencies:
task resolveAllDependencies {
doLast {
configurations.all { it.resolve() }
}
}
It downloads all dependencies to the local cache. But plugins are of course not included in any of the configurations.
It also seems that even if the plugin gets downloaded in the cache, it still fails in offline mode with the following message: Plugin cannot be resolved from https://plugins.gradle.org/api/gradle because Gradle is running in offline mode
Here's a working solution. It's not perfect, because it hard-codes the gradle plugin repository and changes the script. It's also much more verbose than the current way of using plugins.
Instead of the following simple plugin definition:
plugins {
id 'net.researchgate.release' version '2.3.5'
}
It's possible to define both the repository and the dependency manually and then use the plugin this way:
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'net.researchgate:gradle-release:2.3.5'
}
}
apply plugin: 'net.researchgate.release'
This downloads the plugin into the local gradle cache.
I am creating an android application in android studio. I am adding a library to my project which was downloaded from here . When i was adding this library to my project it was showing an error called "Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.". Please tell me how to fix it.
In top level build.gradle dependencies, paste this classpaths.
I wonder why cant i've seen this method in websites.
Anyway, I fixed it using this way.
dependencies {
//YOUR DEPEDENCIES
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
There come two scenarios here:
If you are using apply plugin: 'com.github.dcendents.android-maven' in your module level gradle.
This plugin is generally used to distribute and upload your library project to bintaray.
In this case, all you have to do is make use of correct combinations of gradle plugin and maven-gradle-plugin.
The combination of the following versions is working for me:
Inside project level gradle
classpath 'com.android.tools.build:gradle:2.3.0+'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
and in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
In module level gradle:apply plugin: 'com.github.dcendents.android-maven'
You can check the compatible versions list from Github
If you are not using it, as it is in your case just remove
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
and
apply plugin: com.github.dcendents.android-maven
Just delete the line "apply plugin: 'android-maven'"
in the beginning of build.gradle,
apply plugin: 'com.android.application'
apply plugin: 'android-maven'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
the project doesn't need maven.
Try to add these lines to your project's build.gradle file into dependencies block:
classpath 'com.github.dcendents:android-maven-plugin:1.2'
Like this
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
}
It just worked for me.
For a Gradle 4.1+ you could do in Project-level build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "com.github.dcendents.android-maven" version "2.0"
}
Add these lines in project.gradle dependencies:
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
Just add this two line in your gradle file
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
For a Gradle 7, I deleted this line in the build.gradle module level:
apply plugin: 'com.github.dcendents.android-maven'
With reference to this answer posted above, I encountered another problem No service of type Factory available in ProjectScopeServices after using it.
I fixed it by including com.github.dcendents:android-maven-gradle-plugin:1.4.1 ( as mentioned in this answer to the above linked question) instead of com.github.dcendents:android-maven-plugin:1.2 in the dependencies in the project gradle.
Don't be too confused. android-maven-gradle-plugin:1.4.1 is only an updated version of the android-maven-plugin:1.2 . As mentioned in the Readme in the git repo for this plugin, dcendents mentioned that he was requested to rename the plugin name by Android maven plugin developers.
This is all depend your gradle version. please check https://github.com/dcendents/android-maven-gradle-plugin i found my solution in there.
dependencies {
// The gradle plugin and the maven plugin have to be updated after each version of Android
// studio comes out
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
finally i can solve this error after trying three days
the solution is very simple just remove the module or library project completely from your project and use gradle dependency instead.
Just copy this in your app module's build.gradle inside dependencies closure
dependencies {
// YOUR OTHER DEPENDENCIES
compile 'com.github.navasmdc:MaterialDesign:1.+#aar'}
to success make this steps when you r online
If in your project any module using this id then you must declare below two dependency at your project level build.gradle file -
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
the problem is that android just, don't know the repos and you must specify the repository like that:
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.github.dcendents:android-maven-gradle-plugin:2.1")
}
}
apply plugin: 'com.github.dcendents.android-maven'
add following under project level gradle file
dependencies {
...
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
Upgrade your Github library version as your Gradle version and Github library version doesn't match.
Check the version compatibility here:
https://github.com/dcendents/android-maven-gradle-plugin
It probably causes from android sdk . So i don't know how to occur it but i solved it following these steps.
If you see these warnings on the begining of the console when you enter cordova build or run etc.
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\anypath (DEPRECATED)
Firstly, need to configure ANDROID_HOME path
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#setting-environment-variables
In windows pc, you should enter path from environment variables settings.
https://www.youtube.com/watch?v=S5wqTSuL3j4 ( this video may help you )
Option-1 Then you can add new gradle version https://gradle.org/install/
Option-2 Replace gradle version on /platforms/android/app/build.gradle
from classpath 'com.android.tools.build:gradle:X.X.X
to classpath 'com.android.tools.build:gradle:3.0.1
You can find the right version of gradle by entering command editor:
gradlew --version or gradle --version
or checking this file in your project then find "distributionUrl"
platforms\android\gradle\wrapper\gradle-wrapper.properties
distributionUrl=\https://services.gradle.org/distributions/gradle-4.4-all.zip
Hope it helps you.