Skip to content

Commit

Permalink
Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielThomas committed Oct 19, 2017
1 parent 7d707ea commit bb78ddf
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 42 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins {
apply from: 'gradle/idea.gradle'

dependencies {
compile 'com.netflix.nebula:nebula-gradle-interop:latest.release'
compileOnly 'org.jetbrains.kotlin:kotlin-gradle-plugin:latest.release'
}

Expand Down
124 changes: 88 additions & 36 deletions dependencies.lock
Original file line number Diff line number Diff line change
@@ -1,150 +1,202 @@
{
"compile": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"compileClasspath": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"org.jetbrains.kotlin:kotlin-gradle-plugin": {
"locked": "1.1.3-2",
"locked": "1.1.51",
"requested": "latest.release"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"compileOnly": {
"org.jetbrains.kotlin:kotlin-gradle-plugin": {
"locked": "1.1.3-2",
"locked": "1.1.51",
"requested": "latest.release"
}
},
"default": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"integTestCompile": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"com.netflix.nebula:nebula-test": {
"locked": "6.1.2",
"requested": "6.+"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"integTestCompileClasspath": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"com.netflix.nebula:nebula-test": {
"locked": "6.1.2",
"requested": "6.+"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"integTestRuntime": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"com.netflix.nebula:nebula-test": {
"locked": "6.1.2",
"requested": "6.+"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"integTestRuntimeClasspath": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"com.netflix.nebula:nebula-test": {
"locked": "6.1.2",
"requested": "6.+"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"jacocoAgent": {
"org.jacoco:org.jacoco.agent": {
"locked": "0.7.8"
"locked": "0.7.9"
}
},
"jacocoAnt": {
"org.jacoco:org.jacoco.ant": {
"locked": "0.7.8"
"locked": "0.7.9"
}
},
"kapt": {
"org.jetbrains.kotlin:kotlin-annotation-processing": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"kaptIntegTest": {
"org.jetbrains.kotlin:kotlin-annotation-processing": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"kaptTest": {
"org.jetbrains.kotlin:kotlin-annotation-processing": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"runtime": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"runtimeClasspath": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"testCompile": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"com.netflix.nebula:nebula-test": {
"locked": "6.1.2",
"requested": "6.+"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"testCompileClasspath": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"com.netflix.nebula:nebula-test": {
"locked": "6.1.2",
"requested": "6.+"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"testRuntime": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"com.netflix.nebula:nebula-test": {
"locked": "6.1.2",
"requested": "6.+"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
},
"testRuntimeClasspath": {
"com.netflix.nebula:nebula-gradle-interop": {
"locked": "0.5.0",
"requested": "latest.release"
},
"com.netflix.nebula:nebula-test": {
"locked": "6.1.2",
"requested": "6.+"
},
"org.jetbrains.kotlin:kotlin-stdlib-jre7": {
"locked": "1.1.2-4",
"requested": "1.1.2-4"
"locked": "1.1.2",
"requested": "1.1.2"
}
}
}
27 changes: 21 additions & 6 deletions src/main/kotlin/nebula/plugin/compile/JavaCrossCompilePlugin.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package nebula.plugin.compile

import com.netflix.nebula.interop.versionGreaterThan
import com.netflix.nebula.interop.versionLessThan
import nebula.plugin.compile.provider.DefaultLocationJDKPathProvider
import nebula.plugin.compile.provider.EnvironmentJDKPathProvider
import nebula.plugin.compile.provider.SDKManJDKPathProvider
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.compile.CompileOptions
import org.gradle.api.tasks.compile.GroovyCompile
import org.gradle.api.tasks.compile.JavaCompile
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.File
import kotlin.reflect.full.memberFunctions

class JavaCrossCompilePlugin : Plugin<Project> {
companion object {
Expand All @@ -38,12 +43,22 @@ class JavaCrossCompilePlugin : Plugin<Project> {
val targetCompatibility = convention.targetCompatibility
if (targetCompatibility != JavaVersion.current()) {
with(project.tasks) {
val location by lazy { targetCompatibility.locate() }
val location by lazy { targetCompatibility.locate(project) }
val bootstrapClasspath = location.bootstrapClasspath
val bootClasspath = bootstrapClasspath.joinToString(File.pathSeparator)
withType(JavaCompile::class.java) {
it.options.bootClasspath = location.bootClasspath
if (project.gradle.versionGreaterThan("4.2.1")) {
it.options.bootstrapClasspath = bootstrapClasspath
} else {
it.options.bootClasspath = bootClasspath
}
}
withType(GroovyCompile::class.java) {
it.options.bootClasspath = location.bootClasspath
if (project.gradle.versionGreaterThan("4.2.1")) {
it.options.bootstrapClasspath = bootstrapClasspath
} else {
it.options.bootClasspath = bootClasspath
}
}
project.plugins.withId("kotlin") {
withType(KotlinCompile::class.java) {
Expand All @@ -54,7 +69,7 @@ class JavaCrossCompilePlugin : Plugin<Project> {
}
}

private fun JavaVersion.locate(): JavaLocation {
private fun JavaVersion.locate(project: Project): JavaLocation {
logger.debug("Locating JDK for $this")
val jdkHome = providers
.firstNotNullResult {
Expand Down Expand Up @@ -85,10 +100,10 @@ class JavaCrossCompilePlugin : Plugin<Project> {
val libDir = runtimeJar.parentFile
val jarFiles = listOf(runtimeJar) + ADDITIONAL_JARS.map { File(libDir, "$it.jar") }
val classpath = jarFiles.joinToString(File.pathSeparator)
return JavaLocation(jdkHome, classpath)
return JavaLocation(jdkHome, project.files(classpath))
}

private fun JavaVersion.cannotLocate(): IllegalStateException = IllegalStateException("Could not locate a compatible JDK for target compatibility $this. Change the source/target compatibility, set a JDK_1$majorVersion environment variable with the location, or install to one of the default search locations")

data class JavaLocation(val jdkHome: String, val bootClasspath: String)
data class JavaLocation(val jdkHome: String, val bootstrapClasspath: FileCollection)
}

0 comments on commit bb78ddf

Please sign in to comment.