【问题标题】:How to force gradle to add dependencies to the module path instead of the class path in eclipse?如何强制gradle将依赖项添加到模块路径而不是eclipse中的类路径?
【发布时间】:2020-07-28 23:42:59
【问题描述】:

我有一个像这样 build.gradle lokks 的 gradle javafx 库:

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 的模块信息:

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在模块路径中设置依赖?

【问题讨论】:

    标签: java eclipse gradle


    【解决方案1】:

    我在我的根 build.gradle 中使用这个(使用 Gradle 6.7)

    subprojects {
        apply plugin: "java"
        java {
            modularity.inferModulePath = true
        }
        repositories {
            jcenter()
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-12
      • 1970-01-01
      • 2014-01-09
      • 1970-01-01
      • 1970-01-01
      • 2017-01-28
      • 1970-01-01
      相关资源
      最近更新 更多