简体   繁体   中英

How to reference other classesdir in Gradle multi-project build

I am building an API using spring boot. 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 .

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).

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).

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')?

Well I did figure this out thanks to Kidus' suggestion.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM