[英]How to reference other classesdir in Gradle multi-project build
I am building an API using spring boot.我正在使用 spring 引导构建 API。 I'm using gradle and a multi-project build set up where I have a services-lib project and an api project that depends on the services-lib .
我正在使用 gradle 和一个多项目构建设置,其中我有一个services-lib项目和一个依赖于services-lib的api项目。
Running the api:bootRun tasks in the api project works perfectly fine, but now I'm trying to add the ability to trigger an spring-boot-devtools automatic restart , which requires the bootRun task to have the service-lib classdir in it's classpath(not the jar that is added by the multi-project dependency).运行api:bootRun任务在 api 项目中工作得非常好,但现在我正在尝试添加触发 spring-boot-devtools 自动重启的能力,这需要 bootRun 任务在其类路径中有service-lib classdir (不是多项目依赖添加的jar)。
Adding this to my api's build.gradle does trigger the automatic restart when I run the api:build task (where "C:/foo/bar" is the absolute path to my multi-project root directory).将此添加到我的 api 的 build.gradle 确实会在我运行 api:build 任务时触发自动重启(其中“C:/foo/bar”是我的多项目根目录的绝对路径)。
bootRun {
classpath += files('C:/foo/bar/services-lib/build/classes/java/main')
}
My question is, instead of having to hard code that path, can I set it using something like project(':services-lib')?我的问题是,我可以使用 project(':services-lib') 之类的东西来设置它,而不是硬编码该路径吗?
Well I did figure this out thanks to Kidus' suggestion.好吧,由于 Kidus 的建议,我确实解决了这个问题。
bootRun {
bootRun.systemProperty 'spring.profiles.active', 'dev'
classpath += files('../services-lib/build/classes/java/main')
}
It still means if I change anything about the build output in the services-lib project I have to change it hear but at least now when others check out the project now it will work for them.这仍然意味着,如果我在services-lib项目中更改有关构建 output 的任何内容,我必须更改它,但至少现在当其他人检查该项目时,它现在对他们有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.