Gradle Eclipse Classpath Exception: FAILURE: Build failed with an exception - gradle

I am getting the error as attached in the image above whenever I am trying to run gradle eclipse.
I keep on getting this eclipseClassPath exception.
The Gradle Version, I am using is 3.1
Someone suggested me to use gradle version 2.14 because it won't work with the latest version of gradle.
My build.gradle file is below:
buildscript {
ext {
springBootVersion = '1.2.3.RELEASE'
springCloudConnectorsVersion = '1.2.3.RELEASE'
jarName = 'comOrderAudit'
jarVersion = ' -jar build/libs/app-0.0.1-SNAPSHOT.jar'
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.5.0.RELEASE")
}
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
apply plugin: 'spring-boot'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'jacoco'
dependencies {
compile("org.springframework.boot:spring-boot-starter-actuator") {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
compile "org.springframework.boot:spring-boot-starter-test"
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
compile("org.springframework.boot:spring-boot-starter-aop") {
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
"org.springframework.cloud:Spring-cloud-core:${springCloudConnectorsVersion}"
compile "org.springframework.cloud:spring-cloud-spring-service-connector:${springCloudConnectorsVersion}"
compile "org.springframework.cloud:spring-cloud-cloudfoundry-connector:${springCloudConnectorsVersion}"
compile 'org.codehaus.jettison:jettison:1.3.8'
compile 'com.datastax.cassandra:cassandra-driver-core:2.1.8'
compile 'com.google.code.gson:gson:2.3.1'
compile 'org.springframework.boot:spring-boot-starter-log4j2'
compile 'org.springframework:spring-oxm'
compile 'org.simpleframework:simple-xml:2.7.1'
compile 'io.springfox:springfox-swagger2:2.0.0'
compile 'io.springfox:springfox-swagger-ui:2.0.0'
compile 'com.wordnik:swagger-jersey2-jaxrs_2.10:1.3.8'
compile 'com.mangofactory:swagger-springmvc:1.0.2'
compile 'com.datastax.cassandra:cassandra-driver-core:2.1.8'
compile 'com.google.code.gson:gson:2.3.1'
testCompile "junit:junit:4.12"
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile 'commons-dbcp:commons-dbcp:1.4'
}
task updateVersion{
Properties props = new Properties()
File propsFile = new File("src/main/resources/application.properties")
props.load(propsFile.newDataInputStream())
println(props.getProperty("buildNumber")+"v")
Integer nextbuildnum = (((props.getProperty("buildNumber")) as Integer) + 1)
props.setProperty('buildNumber', nextbuildnum.toString())
def date = new Date()
def formattedDate = date.format('yyyyMMddHHmmss')
props.setProperty("buildTimeStamp", formattedDate)
props.store(propsFile.newWriter(), null)
props.load(propsFile.newDataInputStream())
}
test {
testLogging {
events 'started', 'passed'
}
jacocoTestReport{
group = "Reporting"
description = "Generate Jacoco coverage reports."
additionalSourceDirs = files(sourceSets.main.java)
reports {
xml.enabled = false
html.enabled = true
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ['**/model/**'])
})
}
}
}

I found the answer through extensive search.
Looks like the issue was with Spring boot version used in the gradle.
With Gradle version 3.1, the recommended spring boot version is 1.4.x releases.
If I am to use spring boot version 1.2.3 the gradle version I should be using is 2.14.
just changed the spring boot version and the build was success.
For more answers you can take a look at this page here.

Related

How to start up this project using the gradle command line?

I am following the instruction here https://ktor.io/quickstart/quickstart/gradle.html#intellij-start-a-project to build a simple web server with Netty in Kotlin.
Here is my build.gradle
group 'Example'
buildscript {
ext.kotlin_version = '1.3.61'
ext.ktor_version = '1.3.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'
mainClassName = 'MainKt'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
kotlin {
experimental {
coroutines "enable"
}
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "io.ktor:ktor-server-netty:$ktor_version"
compile "ch.qos.logback:logback-classic:1.2.3"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
I want to be able to start the server up without using IntelliJ.
I have tried
gradle tasks --all
but I cannot find any task that can let me to start up the netty-powered server.
I tried startScripts but it complaints about Deprecated Gradle features
What is the command line to start up the sever? Or do I need to make further changes to the gradle file?
You applied and configured the application plugin therefore the run task is what you're looking for. So:
./gradlew run
should launch your application.

Gradle bootRun from parent folder in multi-module project

I have my Gradle project, which has 2 modules: project A and project B, where the latter depends on the former. Note that both projects are Spring Boot applications, so when I execute gradle bootRun from their respectives directories, they will start fine.
The problem is that I want to start, from parent directory, the service of project A when I execute gradle bootRun, and it is starting project B. It seems that I am missing some Gradle config.
build.gradle (project A)
group = 'com.oni'
version = '0.0.2-SNAPSHOT'
sourceCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
compile 'org.javassist:javassist:3.18.2-GA'
testCompile("de.flapdoodle.embed:de.flapdoodle.embed.mongo")
}
build.gradle (project B)
group = 'com.oni'
version = '0.0.2-SNAPSHOT'
sourceCompatibility = 1.8
dependencies {
def withoutInflux = { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-data-mongodb' }
compile project(':projectA'), withoutInflux
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.7'
}
build.gradle(parent)
buildscript {
ext {
springBootVersion = '2.0.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
// mavenLocal()
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter')
testImplementation('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.influxdb:influxdb-java')
compile('org.mockito:mockito-core')
compile('ma.glasnost.orika:orika-core:1.4.2')
compile 'com.google.guava:guava-annotations:r03'
}
}
settings.gradle(parent)
rootProject.name = 'project'
include 'projectA'
include 'projectB'
Thanks in advance.
You can run this by using
./gradlew :projectA:bootRun
./gradlew :projectB:bootRun

Can't compile project using Gradle and Kotlin

After bumping up kotlin-gradle-plugin from 1.1.4-3 to 1.1.50 (or 51), as well as all Kotlin related libraries I got error like below when trying to import gradle files:
Unable to build Kotlin project configuration
Details: java.lang.reflect.InvocationTargetException: null
Caused by: java.lang.NoSuchMethodError: kotlin.reflect.jvm.internal.KClassImpl.getData()Lkotlin/reflect/jvm/internal/ReflectProperties$LazyVal;
Compilation works fine when using older version of plugin (1.1.4-3).
Full gradle file:
apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: "net.ltgt.apt"
apply plugin: 'idea'
apply plugin: 'org.jetbrains.dokka'
def daggerVersion = "2.11"
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.9"
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'
classpath "net.ltgt.gradle:gradle-apt-plugin:0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
dependencies {
compile "com.google.appengine:appengine-api-1.0-sdk:${appengineVersion}"
compile "com.google.appengine:appengine-endpoints-deps:${appengineVersion}"
compile "com.google.dagger:dagger:${daggerVersion}"
compile 'com.google.endpoints:endpoints-framework:2.0.5'
compile project(':backend')
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
apt "com.google.dagger:dagger-compiler:${daggerVersion}"
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "com.google.code.gson:gson:2.8.2"
compile 'org.thymeleaf:thymeleaf:3.0.7.RELEASE'
compile 'com.warrenstrange:googleauth:1.1.2'
compile 'org.mindrot:jbcrypt:0.4'
testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testCompile "org.mockito:mockito-core:2.+"
testCompile "com.google.appengine:appengine-api-labs:${appengineVersion}"
testCompile "com.google.appengine:appengine-api-stubs:${appengineVersion}"
testCompile "com.google.appengine:appengine-tools-sdk:${appengineVersion}"
testCompile "com.google.appengine:appengine-testing:${appengineVersion}"
}
appengine {
stage {
enableJarClasses = true
}
}
repositories {
mavenCentral()
}
compileKotlin{
kotlinOptions{
jvmTarget = 1.8
}
}
dokka {
outputFormat = 'html'
outputDirectory = file("${buildDir}/javadoc")
}
sourceSets {
main.java.srcDirs += 'src/main/java'
main.java.srcDirs += 'build/generated/source/kapt/main'
main.kotlin.srcDirs += 'src/main/kotlin'
}
idea {
module {
sourceDirs += file("./build/generated/source/kapt/main")
excludeDirs -= file("$buildDir")
excludeDirs += file("$buildDir/dependency-cache")
excludeDirs += file("$buildDir/libs")
excludeDirs += file("$buildDir/tmp")
}
}
EDIT - SOLUTION
Just to elaborate Jack's answer:
I had to locate gradle-wrapper.properties and change the distribution url to:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
I came across the same issue.
Use gradle 3.4(+) will solve it for me.

Execution of gradle bootRun fails

I'm trying to run my springboot app... It all started when i added the eureka spring-cloud plugin to my gradle.build file:
compile 'org.springframework.cloud:spring-cloud-starter-eureka'
And when i run "gradle bootRun", i get this error:
Caused by: java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.8.0_91\bin\java.exe". CreateProcess error=206, File name too long.
My build.gradle is:
import java.text.SimpleDateFormat
buildscript {
ext {
springBootVersion = '1.3.2.RELEASE'
elasticSearchVersion = '2.2.0'
groovyVersion = '2.4.5'
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'io.spring.gradle:dependency-management-plugin:0.5.5.RELEASE'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
classpath 'org.kordamp.gradle:stats-gradle-plugin:0.1.5'
}
}
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'org.kordamp.gradle.stats'
def buildDate = new SimpleDateFormat('yyyyMMdd-hhmmss').format(new Date())
version = '1.0.RC1.' + buildDate
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
ext['elasticsearch.version'] = elasticSearchVersion
ext['groovy.version'] = groovyVersion
ext['guava.version'] = '18.0'
ext['lombok.version'] = '1.16.6'
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}"
mavenBom "org.springframework.cloud:spring-cloud-starter-parent:Brixton.M5"
mavenBom 'io.spring.platform:platform-bom:2.0.2.RELEASE'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-aop')
compile('org.springframework.boot:spring-boot-starter-cache')
compile('org.springframework.cloud:spring-cloud-starter-hystrix')
compile 'org.jadira.usertype:usertype.extended:5.0.0.GA'
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-rest')
//compile('org.springframework.data:spring-data-rest-hal-browser')
compile('org.springframework.boot:spring-boot-devtools')
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.projectlombok:lombok')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
compile "org.elasticsearch:elasticsearch:${elasticSearchVersion}"
compile 'commons-lang:commons-lang'
compile 'commons-codec:commons-codec'
compile 'commons-collections:commons-collections'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
compile 'org.springframework.boot:spring-boot-starter-freemarker'
compile 'de.codecentric:spring-boot-admin-starter-client:1.3.2'
compile 'org.flywaydb:flyway-core'
compile('com.domingosuarez:oneltico:0.1.2')
compile("org.springframework:spring-jms")
compile("org.apache.activemq:activemq-broker")
compile 'org.apache.activemq:activemq-pool'
compile 'org.springframework.cloud:spring-cloud-starter-eureka'
compile 'com.mashape.unirest:unirest-java:1.4.9'
runtime "org.postgresql:postgresql:9.4-1203-jdbc42"
testCompile('org.springframework.boot:spring-boot-starter-test')
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
springBoot {
executable = true
}
I take the plugin out and it executes correctly.
I know it should be a Windows problem long paths, but how can i give a solution?
tim_yates was right, thanks!
i grab the code from the link and paste it into the end of my build.gradle file, it worked like a gem!
The code i added is:
task pathingJar(type: Jar) {
dependsOn configurations.runtime
appendix = 'pathing'
doFirst {
manifest {
attributes "Class-Path": configurations.runtime.files.collect {
it.toURL().toString().replaceFirst('/file:/+/', '/')
}.join(' ')
}
}
}
bootRun {
dependsOn pathingJar
doFirst {
classpath = files("$buildDir/classes/main", "$buildDir/resources/main", pathingJar.archivePath)
}
}
Note: i added some simple quotes (') from the linkcode to get it worked though..

Spring Batch with Grails

im currently using grails 3.0.3 along with gradle 2.5 and hoping to generate a plugin that will use Spring Batch. I've just created a plugin via the command line, and update the build.gradle with just the
compile "org.springframework.boot:spring-boot-starter-batch"
However the batch folder does not seem to downloaded to the local .m2 cache and therefore the import org.springframework.batch libs not available.
The following is the build.gradle. Just wondering if anybody could suggest the reasons why?
Thanks
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
}
}
plugins {
id "io.spring.dependency-management" version "0.5.2.RELEASE"
id "com.jfrog.bintray" version "1.2"
}
version "0.1-SNAPSHOT"
group "org.grails.plugins"
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "spring-boot"
apply plugin: "org.grails.grails-plugin"
apply plugin: "org.grails.grails-gsp"
// Used for publishing to central repository, remove if not needed
apply from:'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/grailsCentralPublishing.gradle'
apply from:'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle'
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
provided 'org.springframework.boot:spring-boot-starter-logging'
provided "org.springframework.boot:spring-boot-starter-actuator"
provided "org.springframework.boot:spring-boot-autoconfigure"
provided "org.springframework.boot:spring-boot-starter-tomcat"
provided "org.grails:grails-web-boot"
provided "org.grails:grails-dependencies"
provided 'javax.servlet:javax.servlet-api:3.1.0'
testCompile "org.grails:grails-plugin-testing"
console "org.grails:grails-console"
//compile "org.springframework.boot:spring-boot-starter-batch:1.2.5.RELEASE"
compile "org.springframework.boot:spring-boot-starter-batch"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}

Resources