如何强制gradle将依赖项添加到模块路径而不是eclipse中的类路径?
问题描述:
我有一个gradle javafx库,它像这样build.gradle lokks:
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" ]
}
具有需要javafx的模块信息:
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;
}
我在eclipse中运行我的项目,但是每次刷新项目时,所有依赖项都放在类路径而不是模块路径中.然后,每次我的项目刷新时,我都必须手动将它们放回模块路径中.如何使gradle设置模块路径中的依赖项?
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 ?
答
我正在我的root build.gradle(使用Gradle 6.7)中使用此版本
I am using this one in my root build.gradle (with Gradle 6.7)
subprojects {
apply plugin: "java"
java {
modularity.inferModulePath = true
}
repositories {
jcenter()
}
}