gpt4 book ai didi

java - Gradle - 将目录添加到类路径

转载 作者:搜寻专家 更新时间:2023-10-30 21:29:47 26 4
gpt4 key购买 nike

我的应用程序在目录下查找配置文件时要求类路径上有一个 \config 目录。我目前有这样配置的依赖项,尽管这可能不是使目录对我的应用程序可用的正确方法:

dependencies {
... //runtime, compile dependencies pulled from repositories
runtime files('config')
}

我正在使用 application 插件为我的项目创建一个独立的 zip。如果我的 \config 目录有 \config\subdirfile1file2,那么插件会生成一个 build\install 目录结构如下:

| build
| --|install
| ----|bin
| ------ projectName
| ------ projectName.bat
| ----|lib
| ------ dependency1.jar
| ------ dependency2.jar
| ------|subdir
| ------ file1
| ------ file2

这对我的应用程序不起作用,因为它明确需要一个 \config 目录

但是,这是我需要的目录结构:

| build
| --|install
| ----|bin
| ------ projectName
| ------ projectName.bat
| ----|lib
| ------ dependency1.jar
| ------ dependency2.jar
| ----|config
| ------|subdir
| ------ file1
| ------ file2

如何让 gradle 添加另一个目录到构建中并将其指定为生成的启动脚本的类路径的一部分?

最佳答案

应用插件documentation说:

Static files to be added to the distribution can be simply added to src/dist

我会尝试将您的配置目录放入 src/dist/lib 并继续使用 runtime files('src/dist/lib/config') 将其添加到您的类路径>

注意:解决this defect意味着配置必须进入 src/dist

下的 /lib

关于java - Gradle - 将目录添加到类路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35545405/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com