Multiple Repositories in build.gradle is not working (jzy3d) (MultiModuleProject) - java

I've got a problem with my Java project in gradle. I'm using several dependencies with gradle, one of it is the jzy3d.api. I have included it in the build.gradle file and added the url to the repositories but it doesn't find it. I've added the repository for it as it is located here: http://maven.jzy3d.org/releases/org/jzy3d/jzy3d-api/1.0.2/
But the Error Message seems like that it isn't searching there. Can please someone tell me why?
Here is my build.gradle and the Error Message:
plugins {
id 'java'
id 'idea' // optional, for IntelliJ IDEA project
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
maven {
url "https://maven.jzy3d.org/releases"
}
mavenCentral()
}
dependencies {
testCompile 'org.junit.jupiter:junit-jupiter:5.6.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
compile group: 'org.jzy3d', name: 'jzy3d-api', version: '1.0.2'
compile group: 'org.jfree', name: 'jfreechart', version: '1.5.0'
}
Execution failed for task ':BusinessLayer:compileJava'.
> Could not resolve all files for configuration ':BusinessLayer:compileClasspath'.
> Could not find org.jzy3d:jzy3d-api:1.0.2.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/jzy3d/jzy3d-api/1.0.2/jzy3d-api-1.0.2.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :BusinessLayer > project :DataLayer
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
When I'm adding something to the url, for example url "https://maven.jzy3d.org/releases/maven2" the Error Message says:
Could not find org.jzy3d:jzy3d-api:1.0.2.
Searched in the following locations:
- https://maven.jzy3d.org/releases/maven2/org/jzy3d/jzy3d-api/1.0.2/jzy3d-api-1.0.2.pom
- https://repo.maven.apache.org/maven2/org/jzy3d/jzy3d-api/1.0.2/jzy3d-api-1.0.2.pom
So I think that for some reason it don't want to search in the https://maven.jzy3d.org/releases directory...

Related

Couldn't find org.gradle.api dependency

I try to use DefaultTask and can't add the org.gradle.api.* dependency.
I added dependency from the https://mvnrepository.com/artifact/org.gradle/api/1.0:
// https://mvnrepository.com/artifact/org.gradle/api
implementation group: 'org.gradle', name: 'api', version: '1.0'
but the project still does not "see" org.gradle... library:
gradle build execution result:
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.gradle:api:1.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/gradle/api/1.0/api-1.0.pom
Full build.gradle:
plugins {
id 'java'
}
test{
testLogging.showStandardStreams = true
}
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/org.apache.commons/commons-email
implementation group: 'org.apache.commons', name: 'commons-email', version: '1.5'
// https://mvnrepository.com/artifact/org.gradle/api
implementation group: 'org.gradle', name: 'api', version: '1.0'
}
Why has the dependency doesn't been found?
From the official doc https://docs.gradle.org/7.4.1/userguide/custom_tasks.html#sec:custom_tasks_standalone_project, its build.gradle is very simple.
plugins {
id 'groovy'
// id 'java' <----- use this if written in Java
}
dependencies {
implementation gradleApi()
}
You don't have to specify org.gradle:api in dependencies{} nor mavenCentral() in repositories{}. The one you found in https://mvnrepository.com is a very old version. I guess they host the JARs themselves.

Not able to add dependency through build.gradle file

Whenever i am trying to add dependency in the project through build.gradle , it is not able to add dependency. Instead it throws warning as
Could not resolve: junit:junit:4.12
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings
CONFIGURE SUCCESSFUL in 1s
I have tried every hook to resolve it, but was not able to.
Please find below build.gradle file which i am using
apply plugin: 'java'
apply plugin: 'idea'
group 'practice'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
As per mvnrepository.com, for Gradle it has been mentioned as
// https://mvnrepository.com/artifact/junit/junit
testCompile group: 'junit', name: 'junit', version: '4.12'
The link is given below.
https://mvnrepository.com/artifact/junit/junit/4.12
If it does not work, try to add the repository as given below.
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
junit version 12 also available in maven repo, you can check following link.
http://repo1.maven.org/maven2/junit/junit/4.12/
Sometimes, we have seen sporadic issue because of corrupt file.
You can delete the .gradle file and you can rerun with command like gradle clean build.

Gradle to use a jar-with-dependencies in compile task

We have a project that make use of 'jrs-rest-java-client', version: '6.3.1'
The site we used to get the jar from has a certificate issue since September. https://jaspersoft.artifactoryonline.com
We then had to get the jar from a different site.
https://jaspersoft.jfrog.io/
The problem is that a dependency require is missing, but if we use the jar that has "-jar-with-dependencies" it is working. I tried by downloading that jar locally and changing the .gradle to use the local version.
What I would prefer is to have the build to fetch that version directly without having to download first.
How do we specify what jar to use?
dependencies {
compile fileTree(dir: 'lib',
includes: [
'ojdbc8.jar',
])
//compile group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1'
compile group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', USETHISONE: 'jar-with-dependencies'
//compile files("${buildDir}/jrs-rest-java-client-6.3.1-jar-with-dependencies.jar")
}
I have now tried as suggested;
repositories {
mavenCentral()
// to handle broked jasper reports dependencies
maven {
url 'http://jasperreports.sourceforge.net/maven2'
url 'https://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/'
url "https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases"
}
}
dependencies {
implementation project(':common:project-common-properties')
implementation project(':common:project-common-mail')
implementation fileTree(dir: 'lib', includes: [
'ojdbc8.jar'
])
implementation group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', classifier: 'jar-with-dependencies'
}
I'm still getting errors at build time...
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':services:notificationService:compileClasspath'.
> Could not find com.jaspersoft.jasperserver:jasperserver-dto:6.3.0.
Required by:
project :services:notificationService > com.jaspersoft:jrs-rest-java-client:6.3.1
That library is not required if the jrs-rest-java-client-6.3.1-jar-with-dependencies.jar is used.
Thanks all,
The solution was, as seen if the video (Thanks!)
adding a new url:
url "https://jaspersoft.jfrog.io/jaspersoft/jrs-ce-releases"
From the jfrog repo, it shows you how to do this:
compile(group: 'com.jaspersoft', name: 'jrs-rest-java-client', version: '6.3.1', classifier: 'jar-with-dependencies')
Add the repo for gradle:
repositories {
jcenter {
name "jaspersoft-releases"
url "https://jaspersoft.jfrog.io/jaspersoft/jaspersoft-clients-releases"
}
}
I'd recommend switching from compile to implementation and using a shorthand to declare the dependency:
implementation "com.jaspersoft:jrs-rest-java-client:6.3.1:jar-with-dependencies"
Give a man a fish and you feed him for a day. Teach him how to fish and you feed him for his life time.
I decided to record a short clip of how I found the appropriate repositories for the artifacts you needed, on jfrog:

auto gradle downloading from svn repository

I have problems with configure my build.gradle for download jar and pom from svn repository. For example, i have url:
https://svn.code.sf.net/p/springframework/svn/repos/repo-ext/javax/xml/crypto/xmldsig/1.0/
and i want did like this compile group: 'com.sun.xml.wss', name: 'xws-security', version: '3.0'
Also, manual download is wrong way.
UPD this is build.gradle file of backend project
apply plugin: 'java'
dependencies {
compile group: 'org.glassfish.metro', name: 'wssx-api', version: '2.1.1-b09'
compile group: 'com.sun.xml.wss', name: 'xws-security', version: '3.0'
compile project(':pp-backend')
}
If you're not downloading from maven central (which is configured in Gradle by default), you should configure the repository to download from using the 'repositories' closure:
repositories {
mavenCentral()
maven {
url 'https://svn.code.sf.net/p/springframework/svn/repos/repo-ext/'
}
}
Then, in the 'dependencies' closure, just add:
compile group: 'javax.xml.crypto', name: 'xmldsig', version: '1.0'
See more info in Dependency Management Basics

gradle unable to find artifact in maven repository

I am doing a simple gradle build and I have deployed a particular artifact to my internal sonatype maven repo
My build.gradle file looks like this:
apply plugin: 'java'
sourceCompatibility = 1.8
version = '1.0'
repositories {
mavenCentral()
maven {url "http://maven.ebay.com/nexus/content/repositories/sre-snapshots/"}
}
dependencies {
compile group: "com.typesafe", name: "config", version: "1.3.0"
//compile project(':metrics')
compile group: 'com.ebay.telemetry', name: 'client-library', version: '0.1-SNAPSHOT'
compile group: "org.slf4j", name: "slf4j-jdk14", version: "1.7.12"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
I run this command on the command line: gradle build
I get this error:
> Could not find net.alchim31:metrics-influxdb:0.7.1-ebay-SNAPSHOT.
Searched in the following locations:
https://repo1.maven.org/maven2/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/metrics-influxdb-0.7.1-ebay-20150708.054833-4.pom
http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/metrics-influxdb-0.7.1-ebay-20150708.054833-4.jar
However when I go to http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/
I see the following files :
metrics-influxdb-0.7.1-ebay-20150708.054830-3.pom
metrics-influxdb-0.7.1-ebay-20150708.054830-3.jar
So why is gradle looking for metrics-influxdb-0.7.1-ebay-20150708.054833-4.jar when my repo has metrics-influxdb-0.7.1-ebay-20150708.054830-3.jar
It seems like you have declared another dependency besides the one you showed above. It should probably look something like this:
compile group: 'net.alchim31', name: 'metrics-influxdb', version: '0.7.1-ebay-SNAPSHOT'
If you find this dependency declaration, you might also find the source of the problem.
The second possibility is, that your maven-metadata.xml (at http://maven.ebay.com/nexus/content/repositories/sre-snapshots/net/alchim31/metrics-influxdb/0.7.1-ebay-SNAPSHOT/maven-metadata.xml) is messed up and points towards the nonexisting build 4.

Categories