Gradle compilation


#1

Hi,

I’m trying to use the gradle plugin to compile my sources using the “-module” flag of the cli compiler. Is there any way of doing that? The documentation of the gradle plugin is almost non existant…

Thanks in advance


#2

AFAIK, the Gradle plugin replies on the Gradle project model instead of module files. Why do you want to use the cli option instead of the mechanism native to Gradle?


#3

I'm trying to add a Gradle build file to LWJGL3 (https://github.com/LWJGL/lwjgl3/issues/16). The project owner wants me to continue to use the module file instead of the kotlin plugin because "in the future it will be used for filtering the supported bindings. You'll be able to do custom builds, for example without OpenCL or with only the core OpenGL functionality, filter out old/obsolete extensions, etc.". Not sure if that's possible with the normal Gradle plugin (without modifying the project structure).

If the first is not possible, is there any way of making the gradle plugin work with non standard paths? I’ve tried mixed compilation (Java + Kotlin) with no luck, unless I put the source on the “src/main/java” and “src/main/kotlin” directories.


#4

I haven't tried the Gradle plugin for Kotlin, but if it does things in the "standard" Gradle way, you'll be able to reconfigure source directories as follows:

sourceSets {
  main {
  java {
           srcDirs = [“foo”]
  }
  kotlin {
           srcDirs = [“bar”]
  }
  }
  test { … } // reconfigurable in the same way as main
}

Further I’d expect Java sources in a Kotlin source directory to be joint-compiled with Kotlin sources (i.e. you can have bidirectional dependencies).

Remember that I haven’t tried the plugin, so take this with a grain of salt.


#5

Custom sourceSets should work with kotlin-plugin 0.9.164 or higher. If it doesn't work, could you report a bug to your tracker with build.gradle file attached?


#6

Ah, maybe that was the issue, then. When I tried this a few weeks ago, it was with a 0.8.xxx version, IIRC.

I’ll try with the latest one and report my findings, thanks!