我的应用程序在目录下查找配置文件时要求类路径上有一个 \config
目录。我目前有这样配置的依赖项,尽管这可能不是使目录对我的应用程序可用的正确方法:
dependencies {
... //runtime, compile dependencies pulled from repositories
runtime files('config')
}
我正在使用 application
插件为我的项目创建一个独立的 zip。如果我的 \config
目录有 \config\subdir
、file1
、file2
,那么插件会生成一个 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/