We're trying to migrate our project configured with gradle 4.0 into gradle 5.6 (latest). Looks like there's a dependency issue with httpclient (apache) component that generate this exception during the Publish of the war package.
This is a gradle project, root (container) project has included a war plugin for packaging, jfrog artifactory 4.9.8 for publishing, all the subprojects are java projects with their dependency list provided (included httpclient 4.5.9 and httpcore 4.4.11).
-- root
plugins {
id 'war'
id 'maven-publish'
id 'org.sonarqube' version '2.7'
id 'net.researchgate.release' version '2.6.0'
id 'com.github.spotbugs' version '2.0.0' apply false
id 'com.jfrog.artifactory' version '4.9.8'
}
-- subprojects
dependencies {
..
compile 'org.apache.httpcomponents:httpclient:4.5.9'
..
configurations.all {
force 'org.apache.httpcomponents:httpcore:4.4.11'
force 'org.apache.httpcomponents:httpclient:4.5.9'
}
}
./gradlew artifactoryPublish
What went wrong:
Execution failed for task ':artifactoryDeploy'.
INSTANCE
Caused by: java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.getDefaultRegistry(PoolingHttpClientConnectionManager.java:109)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:116)
at org.jfrog.build.client.PreemptiveHttpClient.<init>(PreemptiveHttpClient.java:57)
at org.jfrog.build.client.ArtifactoryHttpClient.getHttpClient(ArtifactoryHttpClient.java:145)
at org.jfrog.build.client.ArtifactoryHttpClient.getHttpClient(ArtifactoryHttpClient.java:140)
at org.jfrog.build.client.ArtifactoryHttpClient.executeGetRequest(ArtifactoryHttpClient.java:184)
at org.jfrog.build.client.ArtifactoryHttpClient.getVersion(ArtifactoryHttpClient.java:154)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBaseClient.getArtifactoryVersion(ArtifactoryBaseClient.java:109)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.tryChecksumDeploy(ArtifactoryBuildInfoClient.java:705)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.uploadFile(ArtifactoryBuildInfoClient.java:664)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.doDeployArtifact(ArtifactoryBuildInfoClient.java:367)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.deployArtifact(ArtifactoryBuildInfoClient.java:355)
at org.jfrog.build.extractor.clientConfiguration.client.ArtifactoryBuildInfoClient.deployArtifact(ArtifactoryBuildInfoClient.java:340)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.deployArtifacts(DeployTask.java:262)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.prepareAndDeploy(DeployTask.java:113)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.collectProjectBuildInfo(DeployTask.java:50)
at org.jfrog.gradle.plugin.artifactory.task.DeployTask.taskAction(DeployTask.java:44)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:49)
Related
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.
I'm trying to set up a project building Kotlin code with Gradle. I've followed instructions here on how to set up the build.gradle file but am receiving an error
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0'
}
}
apply plugin: 'kotlin'
With this I get the error:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'kjsonparser'.
Could not resolve all files for configuration ':classpath'.
Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0.
Required by:
project :
Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0.
Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0/kotlin-gradle-plugin-1.2.0.pom'.
Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0/kotlin-gradle-plugin-1.2.0.pom'.
java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
I've also tried the "newer" way of specifing the plugin
plugins {
id "org.jetbrains.kotlin.jvm" version "1.2.0"
}
Which gives this error:
What went wrong:
Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.0'] was not found in any >of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact >'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.2.0')
Searched in the following repositories:
Gradle Central Plugin Repository
Version of Gradle
gradle -version
------------------------------------------------------------
Gradle 4.4
Kotlin (and openjdk)
kotlin -version
Kotlin version 1.2.0 (JRE 1.8.0_151-8u151-b12-0ubuntu0.17.10.2-b12)
Running on Ubuntu 17.10
I've never worked with Gradle before so not sure if I'm missing anything in the build file
Try this. It works:
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
I never use the buildscript block.
Try this instead:
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.4.31'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.4.31'
}
I am trying out a simple gradle spring boot application as per the below URL
https://spring.io/guides/gs/spring-boot/
This is my build.gradle file
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'my-jar'
version = '1.0.0'
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-web"
testCompile "junit:junit"
}
I am using a local artifactory and my init.gradle has the buildscript configuration which is below
buildscript {
repositories {
maven {
url 'http://mylocalartifactory:8081/'
}
}
dependencies { classpath "org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE" }
}
I get the below error when i try to run gradlew build
What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter-web:.
Looks like the version is not getting applied for the dependency.
What I understand is that the version will be defaulted by the spring-boot plugin .
Am I missing something ?
It works fine if I mention the version number in the dependency
dependencies {
compile "org.springframework.boot:spring-boot-starter-web:1.5.2.RELEASE"
testCompile "junit:junit"
}
Though I can make it work , it beats the purpose of using spring boot if I need to manually specify the spring version jar dependency .
Kindly revert back if you see any issue in my build.gradle or init.gradle
Objective:
Use gradle to build TomEE project.
Gradle Script:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.apache.tomee.gradle:tomee-embedded:7.0.1'
}
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.apache.tomee.tomee-embedded'
repositories {
mavenLocal()
mavenCentral()
}
Gradle call: gradle tomee-embedded
Execution failed for task ':tomee-embedded'.
org.gradle.api.logging.LoggingManager.setLevel(Lorg/gradle/api/logging/LogLevel;)Lorg/gradle/api/logging/LoggingManager;
Error cause by:
Caused by:
java.lang.NoSuchMethodError:
org.gradle.api.logging.LoggingManager.setLevel(Lorg/gradle/api/logging/LogLevel;)Lorg/gradle/api/logging/LoggingManager;
Did I happen to miss to add gradle dependency? Shouldnt gradle know that it has to add its APIs as well? Do i do it manually? I tried adding to classpath all gradle api libraries but with no success. Anyone has ideas?
I think it got fixed in 7.0.2, gradle API changed on that area
I am new to Gradle so any help with this error will be highly appreciated.
I am building a REST based service using Spring-boot. I want to publish the JAR file to the local maven repository so that my web application can use it. After trying many things, I finally settled for maven-publish plugin. Here is my build.gradle file
//Needed for spring-boot
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.8.RELEASE")
}
}
apply plugin: 'eclipse'
// Apply the groovy plugin to add support for Groovy
apply plugin: 'groovy'
//apply Spring-boot plugin
apply plugin: 'spring-boot'
apply plugin: 'maven-publish'
// In this section you declare where to find the dependencies of your project
repositories {
mavenLocal()
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
}
group = "com.proto"
publishing {
publications {
maven(MavenPublication) {
groupId "${project.group}"
artifactId "${project.name}"
version "${project.jar.version}"
artifact sourceJar { classifier "sources" }
from components.java
pom.withXml {
asNode().appendNode('parent')
.appendNode('groupId', 'org.springframework.boot').parent()
.appendNode('artifactId', 'spring-boot-starter-parent').parent()
.appendNode('version', '1.1.8.RELEASE')
asNode().appendNode('repositories').appendNode('repository')
.appendNode('id', 'spring-releases').parent()
.appendNode('url', 'http://repo.spring.io/libs-release')
}
}
}
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
jar {
baseName = 'my-api'
version = '0.0.1'
}
task('execJar', type:Jar, dependsOn: 'jar') {
baseName = 'my-api'
version = '0.0.1'
classifier = 'exec'
from sourceSets.main.output
}
bootRepackage {
withJarTask = tasks['execJar']
}
// In this section you declare the dependencies for your production and test code
dependencies {
// We use the latest groovy 2.x version for building this library
compile 'org.codehaus.groovy:groovy-all:2.3.6'
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
// tag::jetty[]
compile("org.springframework.boot:spring-boot-starter-web")
// {
// exclude module: "spring-boot-starter-tomcat"
// }
// compile("org.springframework.boot:spring-boot-starter-jetty")
// end::jetty[]
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// We use the awesome Spock testing and specification framework
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
testCompile 'junit:junit:4.11'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('cglib:cglib:3.1')
}
// tag::wrapper[]
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
My problem is that, when I run:
gradle publishToMavenLocal
I get the following error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':publishMavenPublicationToMavenLocal'.
> Failed to publish publication 'maven' to repository 'MavenLocal'
> Unable to initialize POM pom-default.xml: Cannot find parent: org.springframework.boot:spring-boot-starter-parent for project: com.proto:proto-api:jar:0.0.1 for project com.proto:proto-api:jar:0.0.1
My gradle environment details:
------------------------------------------------------------
Gradle 2.1
------------------------------------------------------------
Build time: 2014-09-08 10:40:39 UTC
Build number: none
Revision: e6cf70745ac11fa943e19294d19a2c527a669a53
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_72 (Oracle Corporation 24.72-b04)
OS: Linux 3.13.0-39-generic amd64
What am I missing?
Thank you in advance for your help.
Ok, I have fixed the issue.
I am behind our corporate firewall, and had configured proxy correctly for gradle in ~/.gradle/gradle.properties file. But, I missed setting proxies for maven in ~/.m2/settings.xml file.
I configured our internal nexus repository to handle this issue but setting proxies block should work as well. Click here for maven settings.xml documentation
Same as #aardee, I am sitting behind our corporate firewall but it seems that my proxy settings (settings.xml) for maven local did not change anything. Fortunately we have our own maven repository that can proxy out and so I just replaced the repository in the generated pom and made sure that our company maven repository knows the relevant spring repos.
pom.withXml {
asNode().appendNode('parent')
.appendNode('groupId', 'org.springframework.boot').parent()
.appendNode('artifactId', 'spring-boot-starter-parent').parent()
.appendNode('version', '1.1.8.RELEASE')
asNode().appendNode('repositories').appendNode('repository')
.appendNode('id', 'spring-releases').parent()
.appendNode('url', 'http://my.mavenRepo.com/releases}
Replace http://my.mavenRepo.com/releases with your own maven repository.