Can't compile project using Gradle and Kotlin - gradle

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.

Related

Trying to modularize Gradle SpringBoot Project but getting "Error: cannot find symbol" when trying to build?

I had a working single-module Java project I am trying to break up into two modules: a library, and an application module. I pulled out the Java libraries from the top level build.gradle and stuffed them in the library build.gradle, and kept the SpringBoot/Docker/MySQL related dependencies in the application build file. Running ./gradlew build causes errors due to "cannot find symbol" errors on the lombok stuff in the App.
I added a top level settings.gradle (code below), pulled out all the Java libraries and put into the library/build.gradle (code below), and added a reference to library in the application/build.gradle (code below).
settings.gradle:
rootProject.name = 'order-routing'
include 'library'
include 'application'
library/build.gradle:
buildscript {
repositories { mavenCentral() }
}
plugins {
id "io.spring.dependency-management" version "1.0.5.RELEASE"
}
apply plugin: 'project-report'
apply plugin: 'java'
ext { springBootVersion = '2.1.6.RELEASE' }
jar {
baseName = 'order-routing-library'
version = '0.0.1-SNAPSHOT'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
compileOnly 'com.google.code.gson:gson:2.8.5'
runtimeOnly 'com.h2database:h2:1.4.197'
compile 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
compile('org.springframework.boot:spring-boot-starter')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'com.google.cloud.sql:mysql-socket-factory-connector-j-8:1.0.14'
}
and application/build.gradle (notice I added "compile project(':library')") :
buildscript {
ext { springBootVersion = '2.1.6.RELEASE' }
repositories { mavenCentral() }
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}
plugins {
id "io.spring.dependency-management" version "1.0.5.RELEASE"
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
id "org.flywaydb.flyway" version "5.2.4"
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'project-report'
apply plugin: "maven"
apply plugin: 'docker'
repositories {
mavenCentral()
}
dependencies {
compile 'mysql:mysql-connector-java'
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile project(':library')
}
sourceCompatibility = 8
targetCompatibility = 8
compileJava.options.compilerArgs.add '-parameters'
compileTestJava.options.compilerArgs.add '-parameters'
configurations {
all*.exclude group: "org.hibernate", module: "hibernate-entitymanager"
all*.exclude group: "org.apache.tomcat", module: "tomcat-jdbc"
}
flyway {
url = 'jdbc:mysql://localhost/ordb'
user = 'flyway'
table = 'schema_version'
}
bootJar {
baseName = 'order-routing-application'
version = '0.0.1-SNAPSHOT'
mainClassName = 'com.pokemonmerch.orderrouting.OrderRoutingApplication'
}
Expected result: run './gradlew build' and see a successful build.
Actual: Getting "error: cannot find symbol" on a bunch of lombok generated methods
As I understood you're trying to use lombok in the application module, but you added it as a compileOnly dependency to the library module. So, because it's compileOnly it's not passed as a transitive dependency to the application module.
Please add lombok dependecies to the application module directly or change compileOnly to compile(what I don't recommend to do).
P.S. Don't forget to turn on Annotation Processing in your IDE.
Actually, what I suggest - it's to create build.gradle in the root folder (order-routing/build.gradle) and move common dependencies there, under the subprojects sections (https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:subproject_configuration)

Configuring Clean LibGDX Project with Kotlin Sync Failed invalid type code:82

I am trying to configure clean libgdx project with kotlin.First i generated a clean project with libgdxs tool then even though i did everything in official documentation i am having sync failed
Cause: invalid type code: 82
I did everything written here:
https://github.com/libgdx/libgdx/wiki/Using-libGDX-with-Kotlin
Main project directory build.gradle:
buildscript {
ext.kotlinVersion = '1.3.11'
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "my-gdx-game"
gdxVersion = '1.9.9'
roboVMVersion = '2.3.5'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "kotlin"
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"
}
}
project(":android") {
apply plugin: "android"
apply plugin: "kotlin-android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
}
}
project(":core") {
apply plugin: "kotlin"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
}
}
tasks.eclipse.doLast {
delete ".project"
}
desktop folder build.gradle i only changed apply plugin java to apply plugin kotlin
core folder build.gradle i only changed apply plugin java to apply plugin kotlin
Please try to add
sourceCompatibility = 1.8
targetCompatibility = 1.8
In your build.gradle check it once
project(":core") {
apply plugin: "kotlin"
dependencies {
sourceCompatibility = 1.8
targetCompatibility = 1.8
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
}
}

Error with java8 and Kotlin

I have an app where I'm using retrolambda so in the build.gradle I have
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Everything is fine unless I add the support for Kotlin.
Adding the Kotlin plugin I get the following error:
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
I have found many questions and answers similar to this one but non of the solutions apply in my case.
This is my build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.3.1'
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
// Required because retrolambda is on maven central
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'kotlin-android'
plugins {
id "me.tatarka.retrolambda" version "3.3.1"
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
compileOptions.incremental = false
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
multiDexEnabled true
applicationId "mypackage"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "0.1"
vectorDrawables.useSupportLibrary = true
jackOptions {
enabled false
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
compileOptions {
incremental true
}
buildTypes {
release {
debuggable false
minifyEnabled true
zipAlignEnabled true
renderscriptDebuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
debuggable true
signingConfig signingConfigs.debug
minifyEnabled false
versionNameSuffix "_dev"
}
}
}
def supportVersion = '25.3.1'
dependencies {
def daggerVer = 2.8
apt "com.google.dagger:dagger-compiler:$daggerVer"
compile "com.google.dagger:dagger:$daggerVer"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:design:$supportVersion"
compile "com.android.support:cardview-v7:$supportVersion"
compile "com.android.support:recyclerview-v7:$supportVersion"
compile "com.android.support:gridlayout-v7:$supportVersion"
compile "com.android.support:support-annotations:$supportVersion"
compile "com.android.support:preference-v7:$supportVersion"
compile "com.android.support:support-v4:$supportVersion"
compile "com.android.support:support-vector-drawable:$supportVersion"
compile "com.android.support:palette-v7:$supportVersion"
def firebase = '10.2.0'
compile "com.google.firebase:firebase-crash:$firebase"
compile "com.google.firebase:firebase-auth:$firebase"
compile 'com.firebaseui:firebase-ui-auth:1.2.0'
def rxbinding = '2.0.0'
compile "com.jakewharton.rxbinding2:rxbinding:$rxbinding"
compile "com.jakewharton.rxbinding2:rxbinding-support-v4:$rxbinding"
compile "com.jakewharton.rxbinding2:rxbinding-appcompat-v7:$rxbinding"
compile "com.jakewharton.rxbinding2:rxbinding-design:$rxbinding"
compile "com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:$rxbinding"
compile "com.jakewharton.rxbinding2:rxbinding-leanback-v17:$rxbinding"
compile 'joda-time:joda-time:2.5'
compile 'com.ryanharter.auto.value:auto-value-parcel-adapter:0.2.5'
compile 'com.jakewharton.timber:timber:4.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.clans:fab:1.6.4'
compile 'me.relex:circleindicator:1.2.2#aar'
compile 'com.github.paolorotolo:appintro:4.1.0'
//architecture
compile "android.arch.lifecycle:runtime:1.0.0-alpha1"
compile "android.arch.lifecycle:extensions:1.0.0-alpha1"
annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha1"
def retrofit2 = '2.2.0'
def okhttp3 = '3.4.1'
compile "com.squareup.retrofit2:retrofit:$retrofit2"
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofit2"
compile "com.squareup.retrofit2:converter-gson:$retrofit2"
compile "com.squareup.retrofit2:converter-scalars:$retrofit2"
compile "com.squareup.okhttp3:okhttp:$okhttp3"
compile "com.squareup.okhttp3:okhttp-urlconnection:$okhttp3"
compile "com.squareup.okhttp3:logging-interceptor:$okhttp3"
compile 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
compile 'com.github.MFlisar:RxBus2:0.1'
def butter_knife = '8.4.0'
apt "com.jakewharton:butterknife-compiler:$butter_knife"
compile "com.jakewharton:butterknife:$butter_knife"
def leak_canary = '1.4'
debugCompile "com.squareup.leakcanary:leakcanary-android:$leak_canary"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary"
testCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary"
apt 'com.gabrielittner.auto.value:auto-value-with:1.0.0'
apt 'com.google.auto.value:auto-value:1.2'
apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'
apt 'com.ryanharter.auto.value:auto-value-gson:0.3.2-rc1'
provided 'javax.annotation:jsr250-api:1.0'
provided 'com.google.auto.value:auto-value:1.2'
compile 'com.braintreepayments.api:drop-in:3.0.6'
//other dependencies for testing
def hamcrestVersion = '1.3'
testCompile "org.hamcrest:hamcrest-core:$hamcrestVersion"
testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
testCompile "org.hamcrest:hamcrest-integration:$hamcrestVersion"
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8#aar') {
transitive = true;
}
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'org.jetbrains:annotations:15.0'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
android.packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/rxjava.properties'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion "$supportVersion"
}
}
}
}
With no success I tried this
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
kotlinOptions {
jvmTarget = '1.6'
apiVersion = '1.1'
languageVersion = '1.1'
}
}
and this
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
kotlinOptions {
jvmTarget = '1.8'
apiVersion = '1.1'
languageVersion = '1.1'
}
}
Update
with the last version that uses 1.8 for kotlin I now get a different error:
Error:Execution failed for task ':app:compileDebugKotlin'.
Compilation error. See log for more details
I'm investigating now
This is my top level build.gradle
buildscript {
ext.kotlin_version = '1.1.2-4'
repositories {
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:2.3.0') {
force = true
}
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle file
classpath 'com.google.gms:google-services:3.0.0'
classpath "io.realm:realm-gradle-plugin:2.1.1"
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Retrolambda is not processing the Kotlin bytecode, and you should set the Kotlin compiler to specifically target 1.6 bytecode. This will not break anything in current version of Kotlin as it can generate the older bytecode for the same functionality.
compileKotlin {
kotlinOptions.jvmTarget = "1.6"
}
This is documented in the Kotlin Gradle Plugin attributes
For tests, also add:
compileTestKotlin {
kotlinOptions.jvmTarget = "1.6"
}

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

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.

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..

Resources