My question: How do I set a module path for gradle build?
I\'ve become comfortable working with Java modules from the command line. I do a frequent exe
First please note: I am on Gradle 6.6.1 with Java 15.
This is what I have observed:
in order to make the compile work, every project needs:
java {
modularity.inferModulePath = true
}
this can be turned on at root build.gradle via
subprojects {
apply plugin: "java"
java {
modularity.inferModulePath = true
}
}
in order to use modulepath with gradle run (ServiceLoader working WITHOUT META-INF, reflection restrictions ...) you have to use following application section:
application {
mainModule = 'org.gradle.sample.app' // name defined in module-info.java
mainClass = 'org.gradle.sample.Main'
// DO NOT USE mainClassName = 'org.gradle.sample.Main'
}
Took me quite some time to put all together from several Gradle pages --- but it is all here.
Note:
This will not but non-modular jars to the module-path.