Skip to content

A simple Gradle plugin to make all your Android/Kotlin things target JDK 1.8

Notifications You must be signed in to change notification settings

martinbonnin/one-eight

Repository files navigation

Plugin portal

Target Java 8 in all your projects

A very simple Gradle plugin to avoid the Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 error.

The plugin will make your Java/Kotlin/Android task target Java 8:

private fun Project.configureJava() {
  extensions.configure(JavaPluginExtension::class.java) {
    it.sourceCompatibility = JavaVersion.VERSION_1_8
    it.targetCompatibility = JavaVersion.VERSION_1_8
  }
}

private fun Project.configureKotlin() {
  tasks.withType(KotlinCompile::class.java) {
    it.kotlinOptions {
      jvmTarget = JavaVersion.VERSION_1_8.toString()
    }
  }
}

private fun Project.configureAndroid() {
  extensions.configure(com.android.build.gradle.BaseExtension::class.java) {
    it.compileOptions {
      it.sourceCompatibility = JavaVersion.VERSION_1_8
      it.targetCompatibility = JavaVersion.VERSION_1_8
    }
  }
}

Add to your root project:

// root/build.gradle[.kts]
plugins {
  id("net.mbonnin.one.eight").version("0.1")
}

Or using the buildscript:

// root/build.gradle[.kts]
buildscript {
  classpath("gradle.plugin.net.mbonnin:one-eight:0.1")
}

apply(plugin = "net.mbonnin.one.eight")

About

A simple Gradle plugin to make all your Android/Kotlin things target JDK 1.8

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages