How to force gradle to add dependencies to the module path instead of the class path in eclipse?

送分小仙女□ 提交于 2021-01-29 19:23:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!