Cant resolve rar dependencies in Gradle - maven

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.

Related

Gradle cannnot resolve some dependencies while Maven can

I have a Gradle project that requires org.eclipse.hudson:hudson-core:3.3.3. It has been working fine until today, when it just says:
Could not resolve org.eclipse.hudson:hudson-remoting:3.0.3
I created a Maven project with only hudson-remoting:3.0.3, it works fine. The jar is also there on the Maven Central. Gradle is able to resolve hudson-remoting:3.0.2 though, but hudson-core:3.3.3 requires hudson-remoting:3.0.3. What is going on?
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.eclipse.hudson:hudson-remoting:3.0.3'
}
The projects uses bundled Gradle 6.8, created by IntelliJ.

Gradle Dependency Problem when Upgrading to Gradle 6

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.

Generate Project: HUGE downloads

I created my first LibGDX project using the Libgdx Project generator. I then opened the project in IntelliJ, upon which it asked me to index the repositories in the build.gradle file. The remote repositories in question were:
Maven2
all of the oss.sonatype snapshots
all of the oss.sonatype releases
All together this totalled about 5 to 6 GB of stuff, that intelliJ happily started downloading. Because it was taking ages to complete, I started looking through some of those repositories. Typically the point of using repo managers like gradle is that for the libraries you're using, you don't downloading the whole thing, just the parts you need. However, sonatype snapshots and releases are full of huge amounts of files and lots and lots of different versions/releases.
My question is: Is supposed to be downloading all of those files or did I miss something? Is there a way I can only download the bits and pieces that I need?
Here is my complete build.gradle:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "HelloWorld"
gdxVersion = '1.9.6'
roboVMVersion = '2.3.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}
}
tasks.eclipse.doLast {
delete ".project"
}
Not required to download all injected library with all versions.
If you build with gradle then it only download required artifact with only version that you injected.
Indexing a maven repository
A maven repository is made up of artifact and different versions of those artifact. My guess is that when an IDE like IntelliJ for example reads the remote repository, it will create a separate local cache/mini database of library names+versions available in the repository on machine. That is the indexing part. This makes searching for library names/latest versions etc much faster, as it is now being done consulting the index on your machine instead of accessing the repository each time.
Its nothing major and won't affect your builds, but what your IDE is simply telling is that whenever its looking for a version/dependency name (during auto-complete etc) its having to go online and check for those details (instead of just checking the local cache).
Advantage of indexing - search speed
Disadvantage - you have to ensure the index is kept up to date otherwise your won't always get up to date search results (new versions etc) also somehow 5 to 6 GB is download is painful.
You can disable this notification, If you want by clicking Disable:
Unindexed remote maven repositories found. Disable...
or on Mac OSX Go to
IntellijIDEA > Preferences > Appearance & Behavior > Notifications > Unindexed maven repositories gradle detection > Uncheck
Leave Unindexed remote maven repo, each time if artifact with particular version not found in local repo then it search to remote.

Dependenciies in Gradle not working correctly

We have a project that is using Java 1.5 and we are trying to convert from Maven to Gradle.
We have a repository that is local to us containing all the versions of all the jars we need as the dev environment has no access to the internet.
The problem we are seeing is that it cannot find the commons-io jar and keeps trying to goto the external maven repo. we have not even set that up so where is it finding it from?
we have repositories and dependencies set up in the All projects section as follows
allprojects {
apply plugin: 'java'
sourceCompatibility = 1.5
targetCompatibility = 1.5
project.tasks.withType(AbstractCompile, { AbstractCompile ac -> ac.options.bootClasspath = "C:/Program Files/java/1.5.0_14/jre/lib/rt.jar" })
repositories {
mavenLocal()
maven { url "http://internalrepo/maven-local" }
}
dependencies {
compile "org.apache.commons:commons-io:1.3.2"
}
But its reporting
Could not resolve org.apache.commons:commons-io:1.3.2.
inconsistent module metadata found
even though it works fine in Maven using mvn install
Gradle will never query a repo that isn't set up. mavenlocal() is misspelled (should be mavenLocal()), which will make the build fail. "Inconsistent metadata" could mean that the group ID, artifact ID, or version in the POM doesn't match the one in the build script. mavenLocal() should only be used if the Gradle build needs to exchange artifacts with local Maven builds.
Found the issue,
Unbeknownst to me there was a hidden repo in the maven settings.xml in the maven install folder.
Adding that resolved the issue.

How to configure a plugin to depend on a specific version of gradle?

I am writing a set of Gradle plugins, but I want to control the specific versions of groovy and gradle that are used.
I don't want the plugins to depend on whatever versions of Gradle/Groovy are installed, like the following would do:
dependencies {
compile localGroovy()
compile gradleApi()
}
Another reason I don't want to use the local method - when you use a proper dependency specification, Gradle then knows about the source code for those libs and the IDE plugins can hookup the source automatically.
Below are the relevant sections of my build script:
allprojects { Project iProject ->
apply plugin: 'idea'
apply plugin: 'maven'
repositories {
jcenter()
}
}
subprojects { Project iProject ->
apply plugin: 'groovy'
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.2'
}
}
project(':eclipsei2g') {
group = 'eclipsei2g'
version = '0.0.1-SNAPSHOT'
dependencies {
compile 'org.gradle:gradle-core:2.0'
}
}
project(':g2idea13') {
group = 'g2idea13'
version = '0.0.1-SNAPSHOT'
dependencies {
compile 'org.gradle:gradle-core:2.0'
compile 'org.gradle-plugins:gradle-ide:2.0'
}
}
When I run this I get an error resolving the gradle-ide dependency:
Could not resolve all dependencies for configuration ':g2idea13:compile'.
> Could not find org.gradle:gradle-ide:2.0.
Searched in the following locations:
http://jcenter.bintray.com/org/gradle/gradle-ide/2.0/gradle-ide-2.0.pom
http://jcenter.bintray.com/org/gradle/gradle-ide/2.0/gradle-ide-2.0.jar
Required by:
g2idea13:g2idea13:0.0.1-SNAPSHOT
There doesn't seem to be anything on the jcenter repository since 0.9 for the plugins stuff.
I also tried 'org.gradle:gradle-ide:2.0'.
Is this even how I should be doing this? Is there another way to specify a specific gradle version? Am I just using the wrong repository? I couldn't even get gradle-core to resolve on mavenCentral(). Is there an official Gradle repository somewhere that I should be using?
gradleApi() is the way to go. There isn't currently a public list of dependencies for Gradle plugins.

Resources