Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

How to --add-exports for kotlin project #852

Closed
mgroth0 opened this issue May 1, 2018 · 3 comments
Closed

How to --add-exports for kotlin project #852

mgroth0 opened this issue May 1, 2018 · 3 comments

Comments

@mgroth0
Copy link

mgroth0 commented May 1, 2018

I'd like to use some internal JavaFX code. I tried this:

allprojects {
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java).all {
        kotlinOptions {
            jvmTarget = "1.8"
//            freeCompilerArgs = listOf("--add-exports", "javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED")
        }
    }
    tasks.withType(JavaCompile::class.java).all {
        options.compilerArgs = listOf("--add-exports", "javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED")
        options.isFork = true // required for above?
        options.forkOptions.executable = "javac" // required for above?
    }
}

I tried using the --add-exports option in both the JavaCompile and KotlinCompile parts. For KotlinCompile I just get Invalid argument: --add-exports, and gradle doesn't even start the build. For JavaCompile the build runs fine but acts as if the option was not there and I get Symbol is declared in module 'javafx.graphics' which does not export package 'com.sun.javafx.tk'

@JLLeitschuh
Copy link
Contributor

A few things, your code could be simplified by doing the following:

allprojects {
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        kotlinOptions {
            jvmTarget = "1.8"
//            freeCompilerArgs = listOf("--add-exports", "javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED")
        }
    }
    tasks.withType<JavaCompile> {
        options.compilerArgs = listOf("--add-exports", "javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED")
        options.isFork = true // required for above?
        options.forkOptions.executable = "javac" // required for above?
    }
}

Secondly, I don't think this is a Gradle Kotlin DSL issue, but instead seems like an issue/question about the Kotlin compiler. Perhaps you should try Stack Overflow or the Kotlin forums.

@MERGHOOB
Copy link

MERGHOOB commented Jul 2, 2019

why options.isFork and options.forkOptions.executable is required for --add-epxorts?

@elect86
Copy link
Contributor

elect86 commented Jul 15, 2019

@MERGHOOB apparently because of this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants