问题
I have a gradle javafx library which build.gradle lokks like this :
plugins {
id 'java-library'
id 'java-library-distribution'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
repositories {
mavenCentral()
jcenter()
}
jar {
archiveName = 'streampi-fx'
}
distributions {
main {
distributionBaseName = 'streampi-fx'
contents {
from 'src/main'
}
}
}
javafx {
version = "14"
modules = [ "javafx.controls", "javafx.fxml" ]
}
with a module-info requiring javafx :
module fr.streampi.fx {
exports fr.streampi.fx.view.icons;
exports fr.streampi.fx.model;
exports fr.streampi.fx.model.io;
exports fr.streampi.fx.model.utils;
exports fr.streampi.fx.view;
requires javafx.base;
requires javafx.controls;
requires transitive javafx.graphics;
}
I'm running my project in eclipse but every time I refresh the project, all dependencies are put to the class path instead of the module path. I then have to put them back manually in the module path every time my projects refreshes. How to make gradle set the dependencies in the module path ?
回答1:
I am using this one in my root build.gradle (with Gradle 6.7)
subprojects {
apply plugin: "java"
java {
modularity.inferModulePath = true
}
repositories {
jcenter()
}
}
来源:https://stackoverflow.com/questions/61238308/how-to-force-gradle-to-add-dependencies-to-the-module-path-instead-of-the-class