Would anyone be kind to remind me how to set the J...
# gradle
h
Would anyone be kind to remind me how to set the JVM target to 1.8 in an mpp gradle file?
o
@h0tk3y
h
Gradle kept refusing to compile and run my jvmTest code in an mpp project with this text:
Copy code
Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6.
Didn't find the solution when googling simply for
gradle set jvm target
and the like (instead I found a lot of solutions that might have worked at some point, but no longer do). Finally googling for the given error message led me to the right stackoverflowpost.
h
There's a example here: `http://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets`:
Copy code
kotlin {
    targets {
        fromPreset(presets.jvm, 'jvm8') {
            compilations.all {
                tasks[compileKotlinTaskName].kotlinOptions { 
                    jvmTarget = '1.8'
                }
            }
        }
    }
}
h
That works too, @h0tk3y, thanks. It's a cleaner solution. I like it.