Unable to find conflict from the error message "Could not resolve" - elasticsearch

I am using gradle build system and trying to upgrade to ES7 from 5.6. My base package's (lets call it core) build.gradle has the ES dependencies
api ('org.elasticsearch.client:elasticsearch-rest-high-level-client:7.12.1') {
exclude group: 'com.fasterxml.jackson.module', module: 'jackson-module'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
}
api 'org.elasticsearch.client:transport:7.12.1'
api 'org.elasticsearch.plugin:transport-netty4-client:7.12.1'
api ('org.springframework.data:spring-data-elasticsearch:4.2.1') {
//exclude group: 'org.elasticsearch', module: 'elasticsearch'
exclude group: 'com.fasterxml.jackson.module', module: 'jackson-module'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
}
The module which depends on it has build.gradle
api project(':core')
While building the code I get the error
> Could not resolve org.elasticsearch.client:elasticsearch-rest-high-level-client:7.12.1.
Required by:
project :httpquinn
> Could not resolve org.elasticsearch.client:elasticsearch-rest-high-level-client:7.12.1.
> Could not get resource 'http://maven-internal:8080/repository/internal/org/elasticsearch/client/elasticsearch-rest-high-level-client/7.12.1/elasticsearch-rest-high-level-client-7.12.1.module'.
> Could not GET 'http://maven-internal:8080/repository/internal/org/elasticsearch/client/elasticsearch-rest-high-level-client/7.12.1/elasticsearch-rest-high-level-client-7.12.1.module'. Received status code 500 from server: Unable to fetch artifact resource.
> Could not resolve org.elasticsearch.client:transport:7.12.1.
Required by:
project :httpquinn
> Could not resolve org.elasticsearch.client:transport:7.12.1.
> Could not get resource 'http://maven-internal:8080/repository/internal/org/elasticsearch/client/transport/7.12.1/transport-7.12.1.module'.
> Could not GET 'http://maven-internal:8080/repository/internal/org/elasticsearch/client/transport/7.12.1/transport-7.12.1.module'. Received status code 500 from server: Unable to fetch artifact resource.
I tried restricting the versions using strictly
api ('org.elasticsearch.client:elasticsearch-rest-high-level-client:7.12.1') {
version {
strictly '7.12.1'
}
}
api ('org.elasticsearch.client:transport:7.12.1') {
version {
strictly '7.12.1'
}
}
I am not able to identify from where the conflict is arising.

Related

Exclude package from jar in Gradle 6.4.1

I am using Gradle 6.4.1 and i am getting conflict for package com.jayway.jsonpath in org.apache.drill.exec:drill-jdbc-all:1.18.0 and spring-boot-starter-data-jpa.
So I want to exclude com.jayway.jsonpath package from drill-jdbc-all.jar
compile ('org.apache.drill.exec:drill-jdbc-all:1.18.0') {
exclude group: 'com.jayway.jsonpath'
exclude module: 'json-path'
}
compile group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'
Even tried this
configurations {
all {
compile.exclude module: 'com.jayway.jsonpath'
}
}
But still its showing
The class hierarchy was loaded from the following locations:
com.jayway.jsonpath.spi.mapper.JacksonMappingProvider: file:/Users/abc/.gradle/caches/modules-2/files-2.1/org.apache.drill.exec/drill-jdbc-all/1.18.0/6a0b608238f4a431684cd73d132d7467bc2c3967/drill-jdbc-all-1.18.0.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of com.jayway.jsonpath.spi.mapper.JacksonMappingProvider
Per the Excluding transitive dependencies section of the 6.4.1 docs, give this a try:
dependencies {
...
implementation('org.apache.drill.exec:drill-jdbc-all:1.18.0') {
exclude group: 'com.jayway.jsonpath', module: 'json-path'
}
...
}

With the new update of JDA 4.2.0 the new built JAR file on the VPS returns NoClassDefFoundError

With the new update of JDA 4.2.0 trying to run the jar file on the VPS fails.
I have tried various options, such as
creating a fat jar
searching for other similar issues
source 1
source 2
Yet none of these options seemed to work, since the VPS console output stays unchanged:
Error: Could not find or load main class ...
Caused by: java.lang.NoClassDefFoundError: net/dv8tion/jda/api/hooks/ListenerAdapter
So my current question is, what should my gradle.build look like, or is this a problem of the VPS not refreshing correctly? Or perhaps another problem I'm not aware of.
As for what my gradle.build looks like:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
}
}
apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'
group '...'
version '2.0-SNAPSHOT'
repositories {
mavenCentral()
jcenter(
)
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
compile 'net.dv8tion:JDA:4.2.0_168'
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.20'
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'
compile 'com.vdurmont:emoji-java:5.1.1'
}
jar {
manifest {
attributes(
'Main-Class': '...'
)
}
}
NOTE: In the previous snapshot of 1.0-SNAPSHOT this following gradle.build worked to start up the project:
plugins {
id 'java'
id 'application'
}
group '...'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
jcenter()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
compile 'net.dv8tion:JDA:3.5.0_329'
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.20'
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'
compile 'com.vdurmont:emoji-java:5.1.1'
}
You can use this build.gradle to build a working shadow jar:
plugins {
id 'application' // this allows you to set a mainClassName
id 'com.github.johnrengelman.shadow' version '6.0.0' // this adds the shadowJar task
}
group '...'
version '2.0-SNAPSHOT'
mainClassName = 'your main class goes here' // this sets the main class property in your manifest automatically
repositories {
jcenter() // jcenter is a superset of mavenCentral
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
compile 'net.dv8tion:JDA:4.2.0_191'
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.20'
compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'
compile 'com.vdurmont:emoji-java:5.1.1'
}
Run the shadowJar gradle task to compile your jar file. This will then be placed inside build/libs and has the format [name]-all.jar. Do not forget to replace the mainClassName with the fully qualified name of your main class.

Could not find method exclude() for arguments on object of type org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency

I used to have
implementation(group: "com.domain.package", name: "lib-name", version: "$ver") {
exclude group: 'com.android.support'
exclude group: 'com.squareup.okhttp3'
exclude group: 'com.google.dagger'
}
When I import as aar
implementation (files('libs/lib-name.aar')) {
exclude group: 'com.android.support'
exclude group: 'com.squareup.okhttp3'
exclude group: 'com.google.dagger'
}
I got the following error.
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method exclude() for arguments [{group=org.apache.commons}] on object of type
org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency.
Wonder what went wrong?
Note: I have check on Could not find method exclude() for arguments [{module=support-v4}], which ensure the extra parenthesis is there, that I have done. But it is not helping.
the problem might be the parenthesis location:
try:
implementation (files('libs/lib-name.aar'), {
exclude group: 'com.android.support'
exclude group: 'com.squareup.okhttp3'
exclude group: 'com.google.dagger'
})
in step of
implementation (files('libs/lib-name.aar')) {
exclude group: 'com.android.support'
exclude group: 'com.squareup.okhttp3'
exclude group: 'com.google.dagger'
}

Exclude dependencies

I want to exclude dependencies from a dependency :
dependencies {
...
implementation "org.springframework.security:spring-security-web:$springSecurityVersion" {
exclude "org.springframework:spring-core:$springSecurityVersion"
exclude "org.springframework:spring-beans:$springSecurityVersion"
exclude "org.springframework:spring-context:$springSecurityVersion"
exclude "org.springframework:spring-web:$springSecurityVersion"
}
...
}
I tried a couple of options by changing the syntax sugar but in vain.
Updated Exception :
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.1-bin.zip'.
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsume
...
Apart from that one more line that I see that could be useful is
Could not find method
org.springframework.security:spring-security-web:5.0.4.RELEASE() for
arguments
[build_8wp04892dra2g2ruliafngaad$_run_closure3$_closure5#28d49bbc] on
object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Did you try this syntax, without specifying the version :
implementation ("org.springframework.security:spring-security-web:$springSecurityVersion") {
exclude group: 'org.springframework', module: 'spring-core'
exclude group: 'org.springframework', module: 'spring-beans'
exclude group: 'org.springframework', module: 'spring-context'
exclude group: 'org.springframework', module: 'spring-web'
}
edit : Delete your .gradle directory in your home directory and try again
edit2 : answer's fixed, thanks to op's comment

How to give dependecies in multiproject in Gradle and what is the structure?

I have a multi project to be built using Gradle which has a java Project and it'll be dependancy for web Project. When I build with eclipse i have given depencies of javaProj and webProj to webprojectEAR and it works(after deployed).
.ear file needs to be created using single build run whcih has the following content.
- lib
javaProj.jar
- META-INF
- webProj.war
my project structure as follows
- javaProj
build.gradle
- webProj
build.gradle
- webProjEAR
build.gradle
- settings.gradle
I'm trying to run the webProjEAR/build.gradle file and given as dependency as follows in it.
project(':webProjEAR') {
dependencies {
compile project(':javaProj')
compile project(':webProj')
}
}
it failed with error "Could not resolve all dependencies for configuration 'webProjEAR:testRuntime' .when I run build files separatly I am able to create jar and war files.
Please can anyone help me how dependencies should be mentioned in the build files. And, where are the madatory locations to have a build.gradle file.
=== More Information added to the original question from here ===
My build files are as below. I have made the changes Igor Popov had mentioned.
// javaProj/build.gradle
apply plugin: 'java'
repositories {
flatDir { dirs "../local-repo" }
}
sourceSets {
main {
java.srcDir "$projectDir/src"
resources.srcDir "$projectDir/XML"
}
}
jar {
from ('classes/com/nyl/xsl') {
into 'com/nyl/xsl'
}
}
dependencies {
compile group: 'slf4j-api' , name: 'slf4j-api' , version: '1.5.6'
compile group: 'slf4j-jdk14' , name: 'slf4j-jdk14' , version: '1.5.6'
compile group: 'com.ibm.xml.thinclient_1.0.0' , name: 'com.ibm.xml.thinclient_1.0.0' , version: '1.0.0'
compile group: 'junit', name: 'junit', version: '4.11'
compile group: 'saxon9' , name: 'saxon9'
compile group: 'saxon9-dom' , name: 'saxon9-dom'
compile group: 'xmlunit' , name: 'xmlunit' , version: '1.4'
}
==============================================
// webProj/build.gradle
apply plugin: 'war'
repositories {
flatDir { dirs "../local-repo" }
}
webAppDirName = 'WebContent'
dependencies {
providedCompile group: 'com.ibm.xml' , name: 'com.ibm.xml'
providedCompile group: 'com.ibm.ws.prereq.xdi2' , name: 'com.ibm.ws.prereq.xdi2'
providedCompile group: 'com.ibm.ws.xml.admin.metadata' , name: 'com.ibm.ws.xml.admin.metadata'
providedCompile group: 'guava' , name: 'guava' , version: '11.0.2'
providedCompile group: 'j2ee' , name: 'j2ee'
providedCompile group: 'slf4j-api' , name: 'slf4j-api' , version: '1.5.6'
providedCompile group: 'slf4j-log4j12' , name: 'slf4j-log4j12' , version: '1.5.6'
}
====================================================
// webProjEAR/build.gradle
apply plugin: 'java'
apply plugin: 'ear'
repositories {
flatDir { dirs "../local-repo" }
}
dependencies {
compile project(':javaProj')
compile project(':webProj')
}
ear {
appDirName 'src/main/app'
libDirName 'APP-INF/lib'
from ('../javaProj/build/libs') {
into 'lib'
}
from ('../webProj/build/libs') {
into '/'
}
}
I would like to know what should contain in the roojProj/build.gradle file. Also like to know anything needs to be changed in the above files. Thanks
The overall structure should be something like:
rootProj
javaProj
build.gradle
webProj
build.gradle
webProjEAR
build.gradle
settings.gradle
build.gradle
The settings.gradle file should contain:
include 'javaProj', 'webProj', 'webProjEAR'
For the webProjEAR/build.gradle you can remove the project(':webProjEAR'). So it should look like:
dependencies {
compile project(':javaProj')
compile project(':webProj')
}
To fix the error you get, you should also post all your dependencies for webProjEAR (if you have others that you didn't include).

Resources