is it possible to set kotlin options in a gradle P...
# gradle
r
is it possible to set kotlin options in a gradle Plugin<Project>
o
assuming you can make sure the kotlin plugin is applied, yes, you can do anything you can do in a normal project
only difference is that there's no precompiled extensions, so you'll have to reference the types of those extensions, e.g. if you're working in kotlin,
configure<KotlinJvmProjectExtension>
r
Thank you for the response @octylFractal
im trying to disable warnings regarding experimentalCoroutinesAPI in a plugin
Copy code
open class ExperimentalExtension seems like it can be overriden to do this
o
don't think you should override anything
e.g. I would do
Copy code
the<KotlinJvmProjectExtension>().target.compilations.forEach {
    it.kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs = freeCompilerArgs + listOf("-Xopt-in=kotlin.RequiresOptIn")
    }
}
but that's just my preferred style, you can use
configure<KotlinJvmProjectExtension>
with nested blocks as well
😵 1
💯 1
r
ohh nice one . Thanks for that
thats exactly what i was looking for
g
If you use Precompiled Script Plugins you will get type safe accessors and it would be a lot easier to use Gradle APIs, it will work exactly like in build.gradle.kts
r
@octylFractal I dont seem to have access to compilations. . target is a instance of Project correct ?
@gildor so Im trying to apply the logic to a existing plugin. so many modules can inherit from it.
o
I'm confused by what you mean
I explicitly said
the<KotlinJvmProjectExtension>().target
, which should make the type self-evident (look at the fields of
KotlinJvmProjectExtension
)
it's not a variable you need to supply in any way though, so it realistically shouldn't matter
r
o
it's plural
also, that wont compile in any fashion, not sure if that's just pseudo code
all plugin actions typically happen in
apply
r
yea its pseudo , its encapsulated in the apply(target: Project) function
but yea target.compilations doesn't seem to exsits
o
no idea, it's def. a field on any KotlinTarget
I would double check that
target
refers to the
this.target
there, and not your
target: Project
👍 1
r
O wait, yea Im dumb. Completely missed that 😅 . yea your right , it was ref the wrong target
my bad thanks
hey got one more question, have any of run into issues with artifactory , with gradle 6.3 and above?
particularly with it not being able to handle custom protocols like artifactory://
o
I don't recall if my artifactory-deployed projects use 6.3+
r
Yea keep running into this issue. funny enough if I build the project with gradlew it builds. but I can't sync the project in android studio
it might just be a ide issue not a gradle . since it resolves via gradlew