Is there a way to find out what properties/functio...
# gradle
n
Is there a way to find out what properties/functions are available for a block?
g
What kind block? If you talking about Kotlin-DSL just use autocomplete, also trick with
this.<autocomplete>
works pretty well if you don’t want to see suggestions from top level DSLs Ultimate solution, works also for Groovy, just open plugin/extension/task class and check public methods
n
I'm using Kotlin Native with Sublime so auto-complete isn't available.
This is the block I am talking about:
Copy code
sourceSets["main"].component {
    target("linux_x64")
    outputKinds(EXECUTABLE)
}
If outputKinds is commented out then the Kotlin Native project will build, however a Klib is generated instead of a binary. Using the new Kotlin Native Gradle plugin.
g
I thought that the main point of Kotlin-DSL is to have autocompletion
Easiest thing is to go to declaration, but with just text editor I suppose you cannot do this, so the only way for you is go to sources of the plugin
Also, unfortunately all this sourceSets DSL is too dynamic, maybe to configure outputKinds you should use Convention configuration (dynamic way to extend existing API in Gradle Groovy), but not exactly sure about this case
As I understand you can do something like this:
Copy code
sourceSets["main"].component {
    target("linux_x64")
    if (this is KotlinNativeMainComponent) {
        outputKinds.add(OutputKind.KLIBRARY)
        outputKinds.add(OutputKind.EXECUTABLE)
    }
}
Maybe there is a some better way. I would create an issue about this.
👍 1
unfortunately all this sourceSets DSL is too dynamic
Just checked sources of K/N plugin, it’s just looks like Java plugin dsl, but implementation is completely different and not so dynamic. I suppose K/N should provide type safe accessor for
main
sourceSet, so it will allow to configure outputKinds in a type safe way
1
but now, because you lookup for source set by name, you don’t have access to outputKinds (this is property only available on
main
source set, we have to check sourceSet type
n
As in getSourceByName function?
g
getSourceByName?
You also, probably, can use somehing like:
Copy code
sourceSets.filterIsInstance<KotlinNativeMainComponent>().first().apply {
    target("linux_x64")
    outputKinds.add(OutputKind.KLIBRARY)
    outputKinds.add(OutputKind.EXECUTABLE)
}
But imho it’s too much
n
Where are the sources for the new plugin? Couln't find a link to the sources from this web page: https://plugins.gradle.org/plugin/org.jetbrains.kotlin.native
g
n
With the new plugin there doesn't appear to be a way to pass through compiler options (eg entry point).
Tried the following for setting the entry point:
Copy code
if (this is AbstractKotlinNativeBinary) {
    	additionalCompilerOptions.add("-e")
		additionalCompilerOptions.add("org.example.http_client_test.main")
}
Doesn't have any effect.
g
AbstractKotlinNativeBinary? What is
this
?
Looks like
additionalCompilerOptions
is related on K/N compile task, not extension
Or maybe something like:
Copy code
sourceSets["main"].component {
    binaries.configureEach {
        additionalCompilerOptions.add("-e")
    }
}
👍 1
but not sure