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"
}
Related
I tried to download a library. But I think i did something wrong in my build.gradle Project. Because when I try to import the library manually, I get this error:
My Project Gradle File
buildscript {
repositories {
google()
maven {url 'https://jitpack.io'}
}
dependencies {
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3")
}
}
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My App Gradle File
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.ahmetkaan.kediy"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
//...
implementation 'com.github.onecode369:WYSIWYG:4.0'
}
The library says me to add " maven {url 'https://jitpack.io'} " this to my project gradle and " implementation 'com.github.onecode369:WYSIWYG:4.0' " this to my app gradle. I think there is a problem in the project gradle's repositories (maven). Because the library says to me add like this;
allprojects {
repositories {
...
maven {url 'https://jitpack.io' }
}
}
But I can't add allprojects on top of repositories. I am getting an error like:
A problem occurred evaluating root project 'Kediy'.
> Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'
What should I do?
I am trying to create a gradle multi project in spring boot and kotlin. Using gradle kotlin scripts to write build file. This is my root project's build file (build.gradle.kts).
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
val kotlinVersion = "1.4.10"
val springBootVersion = "2.3.4.RELEASE"
val springDependencyManagementVersion = "1.0.10.RELEASE"
id("org.springframework.boot") version springBootVersion apply false
id("io.spring.dependency-management") version springDependencyManagementVersion apply false
kotlin("jvm") version kotlinVersion
kotlin("kapt") version kotlinVersion
kotlin("plugin.spring") version kotlinVersion apply false
}
allprojects {
repositories {
jcenter()
}
group = "org.example"
version = "1.0-SNAPSHOT"
}
subprojects {
apply {
plugin("org.jetbrains.kotlin.jvm")
plugin("org.jetbrains.kotlin.kapt")
plugin("org.jetbrains.kotlin.plugin.spring")
}
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
}
val developmentOnly by configurations.creating
configurations.runtimeClasspath.get().extendsFrom(developmentOnly)
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
api(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
developmentOnly("org.springframework.boot:spring-boot-devtools")
kapt("org.springframework.boot:spring-boot-configuration-processor")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}
}
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
When building (./gradlew build) I'm getting this error:
> Task :adapters:kaptKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':adapters:kaptKotlin'.
> Could not resolve all files for configuration ':adapters:kapt'.
> Could not find org.springframework.boot:spring-boot-configuration-processor:.
Required by:
project :adapters
adapters:drivers:web is one of my subprojects and it is declared in settings.gradle.kts like this.
include("adapters:drivers:web")
PS: If I use annotationprocessor in place of kapt the build is successful. But I'm not sure if annotationprocessor can be used interchangeably with kapt since this will be a kotlin project.
kapt("org.springframework.boot:spring-boot-configuration-processor:$springBootVersion")
It seems kapt doesn't under the dependencies version management..
There is no repositories{} section is defined for you subprojects.
subprojects {
...
repositories {
mavenCentral()
}
}
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"
}
}
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.
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.