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.
Related
I'm having a problem fetching active-mq in my gradle project.
It says Could not find activemq-rar
dependencies {
compile 'org.apache.activemq:activemq-rar:5.15.6'
}
Even after adding the type
dependencies {
compile 'org.apache.activemq:activemq-rar:5.15.6#rar'
}
I remember I have hacked it by adding that dependency manually as an artefact in my Nexus 1 but now when migrated to Nexus 3 and its more strict I can't get this fetched. Any Ideas?
And Nexus 3 is not happy storing rar files at all.
https://issues.sonatype.org/browse/NEXUS-11712
Is this compoennt already in your NXRM repository? If so, since you're running v3.15+, you can simply navigate to the component in NXRM UI and in the right side panel there are dependency snippets that will help you how to include a component in your project. Also, make sure that your build.gradle points to the right repositories.
Here's the config I tried. NXRM proxy to Maven Central:
A minmal build.gradle:
plugins {
id 'java'
}
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
version = '1.0.0-SNAPSHOT'
repositories {
maven {
url 'http://localhost:2001/repository/maven-central'
}
}
dependencies {
implementation 'org.apache.activemq:activemq-rar:5.15.8#rar'
}
Then build your app $ gradle build shich should yield success and you should see the activemq-rar-5.15.8.rar in your repository.
Deploying one of my example JavaFX applications to an Android device via the gluon-mobile Eclipse plugin fails with an IllegalArgumentException in the retrolambda plugin. This is caused by an indirect dependency of my project on jaxb-api-2.3.0.jar which is a multi-release jar. Retrolambda obviously cannot handle the Java 9 parts in this file and instead of just ignoring them throws an exception. How can this be fixed or avoided?
A newer version of retrolambda (2.5.3 instead of 2.5.1) can handle the module-info.class already but not the part in the META-INF/versions/9/...
The problem could be cured by just deleting the META-INF stuff but when I do that manually it is always re-created by the gluon plugin.
Update 1:
Adding
packagingOptions {
exclude '/META-INF/versions/9/javax/xml/bind/ModuleUtil.class'
}
to the android section in the build file does not make any difference. The error message is still the same:
java.lang.IllegalArgumentException
at net.orfjackal.retrolambda.asm.ClassReader.<init>(ClassReader.java:185)
at net.orfjackal.retrolambda.asm.ClassReader.<init>(ClassReader.java:168)
at net.orfjackal.retrolambda.ClassAnalyzer.analyze(ClassAnalyzer.java:25)
at net.orfjackal.retrolambda.Retrolambda$1.visitClass(Retrolambda.java:71)
at net.orfjackal.retrolambda.files.ClasspathVisitor.visitFile(ClasspathVisitor.java:29)
at net.orfjackal.retrolambda.files.ClasspathVisitor.visitFile(ClasspathVisitor.java:11)
at java.nio.file.Files.walkFileTree(Files.java:2670)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at net.orfjackal.retrolambda.Retrolambda.visitFiles(Retrolambda.java:107)
at net.orfjackal.retrolambda.Retrolambda.run(Retrolambda.java:68)
at net.orfjackal.retrolambda.Main.main(Main.java:28)
This can also be verified easily by just running the command line version of retrlambda over the extracted classes of jaxb-api-2.3.0.jar
Update 2:
With Java 9 and the Gluon-VM it fails with:
Execution failed for task ':SingleViewProject - Gluon VMApp:apkDebug'.
> Duplicate files at the same path inside the APK: META-INF/LICENSE.txt
File 1: /Users/mpaus/.m2/repository/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar
File 2: /Users/mpaus/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
jaxb-api-2.3.0.jar is a multi-release jar and the current jfxmobile plugin 1.3.10 can't deal with it.
The plugin, that targets Java 7/8, uses retrolambda to port back to Java 6/7 a given dependency.
Even if you try to remove the module-info.class or the 9 versionMETA-INF.versions.9.javax.xml.bind`, these classes are processed by the retrolambda plugin, and this will lead to the exception posted in the question. Using the latest retrolambda version doesn't help either.
android {
retrolambdaVersion = "2.5.3"
manifest = 'src/android/AndroidManifest.xml'
packagingOptions {
exclude '/module-info.class'
exclude '/META-INF.versions.9.javax.xml.bind/ModuleUtil.class'
}
}
The only way to make it work under Java 8/jfxmobile 1.3.10 is by modifying the plugin, to add the following exception to JFXMobilePlugin:
copyClassesForRetrolambda.include '**/*.class'
copyClassesForRetrolambda.includeEmptyDirs = false
// exception for multi-release jars
copyClassesForRetrolambda.exclude 'META-INF/versions/**/*.class'
copyClassesForRetrolambda.exclude 'module-info.class'
and then build the plugin and use a local snapshot.
The good news is that using the jfxmobile plugin version 2.0.20 and Gluon VM, that targets Java 9+, the above is already included.
If you can switch to Java 9/10, modify your project to use this plugin, create a new project with the Gluon IDE plugin ('single view project with Gluon VM'), or follow this sample, but using the latest version (2.0.20 so far).
buildscript {
repositories {
jcenter()
google()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:2.0.20'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = '...'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile 'com.gluonhq:charm:5.0.0-jdk9'
androidRuntime 'com.gluonhq:charm:5.0.0'
compile 'javax.xml.bind:jaxb-api:2.3.0'
}
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.+'
}
My build.gradle references a local maven pom. I have enabled the mavenLocal() repository and have added the jar as a compile time dependency (eg. my-local-lib, as shown below).
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile (group: 'com.company', name: 'my-local-lib', version: '1.0-SNAPSHOT')
}
Gradle indeed picks it up and adds it as a dependency. My-local-lib, however, is itself dependent on another library as specified in its pom.xml, but gradle fails to pick up the correct version specified in the pom.xml, and instead chooses a much earlier version. This particular jar dependency is not a dependency on any other library.
Is this a known issue? Could it be due to my-local-lib being a SNAPSHOT version? Is there a way that I can enforce gradle to respect the versions specified in the libraries?
Try to add the following piece of code:
configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
}
to build.gradle script.
I am trying to import org.scalatra:scalatra-atmosphere:2.2.0-RC3 into a Scala 2.10 project. The issue is that this package depends on the two non-Scala-versioned packages com.typesafe.akka:akka-actor:2.0.4 and com.typesafe.akka:akka-testkit:2.0.4 (org.scala-lang:scala-library:2.9.2 and org.scalatra:scalatra-json:2.2.0-RC3 should work fine, as they will go to newest). As far as I can tell, the Akka dependencies do not exist on Maven Central, so we have broken packages.
I would like to override org.scalatra:scalatra-atmosphere:2.2.0-RC3's dependencies by hand by replacing the non-Scala-versioned packages with Scala-versioned packages that actually exist:
configurations.all {
resolutionStrategy {
eachDependency { details ->
if (details.requested.group == 'com.typesafe.akka') {
details.requested.name += "_$scalaVersion"
details.useVersion '2.1.0'
}
}
}
}
Unfortunately, this technique appears to be explicitly disallowed as of Gradle 1.4:
What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> new ModuleRevisionId MUST have the same ModuleId as original one. original = com.typesafe.akka#akka-actor new = com.typesafe.akka#akka-actor_2.10
Is there a legitimate way to work around this issue?
Only version changes are supported in 1.4, 1.5 is due to contain support for changing the other attributes of a dependency.
I think your options are variations on excluding the specific dependency and adding it back in by hand. Examples can be found in the docs
dependencies {
compile("org.scalatra:scalatra-atmosphere:2.2.0-RC3) {
exclude group: 'com.typesafe.akka', module: 'akka-actor'
exclude group: 'com.typesafe.akka', module: 'akka-testkit'
}
// assuming you have this available in a repository your build is configured to resolve against
compile 'com.typesafe.akka:akka-actor:2.0.4-MY.LOCAL.VERSION'
}