如何强制gradle将依赖项添加到模块路径而不是eclipse中的类路径? [英] How to force gradle to add dependencies to the module path instead of the class path in eclipse?

查看:112
本文介绍了如何强制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()
    }
}

这篇关于如何强制gradle将依赖项添加到模块路径而不是eclipse中的类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆