I was wondering how I could add go compilation int...
# community-support
n
I was wondering how I could add go compilation into my project. My main project is kotlin multiplatform and before building that I want to invoke the go compiler to build a shared library that can then be bundled in the resulting jar. Like how a source set has
java
kotlin
resources
etc. How would I add a folder corresponding to
go
?
a
Well, there's nothing stopping you from just creating a
src/main/go
directory (or any other directory, for the Golang source files. In build scripts you could represent it with a dir.
Copy code
val golangMainSources = layout.projectDirectory("src/main/go")
For JVM languages, Gradle has interfaces for representing source sets (e.g. SourceDirectorySet), but there's no language agnostic equivalent https://github.com/gradle/gradle/issues/727
Did you also want it to appear as a source set in your IDE? If you're using IntelliJ, you can add custom sources with the IDEA plugin. I've added custom source dirs before, but it's not a very ergonomic plugin to use, and now days I just don't bother.