I have the following Gradle (kotlin-dsl) project layout
tools-root
|- tools-ui // reactjs
|- tools-main // springboot
It is required to copy the tool-ui/build directory to the tools-main/build/resources/main/static directory, before the tools-main springboot jar is created. The belows tasks and dependencies are created to achieve this in tools-main/build.gradle.kts
// Copy WebUI build to SpringBoot Jar
val copyWebUi = tasks.register<Copy>("copyWebUi") {
dependsOn(tasks.getByPath(":tools-ui:build"))
from(project(":tools-ui").layout.buildDirectory)
into(layout.buildDirectory.dir("resources/main/static/simconfig"))
}
tasks.getByName<BootJar>("bootJar") {
dependsOn(copyWebUi)
}
However it gives the below warnings during build.
> Task :tools-main:copyWebUi
Execution optimizations have been disabled for task ':tools-main:copyWebUi' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: 'C:\tools-root\tools-main\build\resources\main\static\simconfig'.
Reason: Task ':tools-main:bootJarMainClassName' uses this output of task ':tools-main:copyWebUi' without declaring an explicit or implicit dependency.
This can lead to incorrect results being produced, depending on what order the tasks are executed.
Please refer to https://docs.gradle.org/7.3.3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
> Task :tools-main:bootJar
> Task :tools-main:inspectClassesForKotlinIC
> Task :tools-main:jar
Execution optimizations have been disabled for task ':tools-main:jar' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: 'C:\tools-root\tools-main\build\resources\main'.
Reason: Task ':tools-main:jar' uses this output of task ':tools-main:copyWebUi' without declaring an explicit or implicit dependency.
This can lead to incorrect results being produced, depending on what order the tasks are executed.
Please refer to https://docs.gradle.org/7.3.3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
How to resolve this error?
I am not sure I have understood anything from the link provided in the error message.
I found an alternate way to resolve this error using the Springboot gradle plugin's BootJar task.
// Copy WebUI build to SpringBoot Jar
tasks.getByName<BootJar>("bootJar") {
dependsOn(":tools-ui:build")
from(project(":tools-ui").buildDir) {
into("BOOT-INF/classes/static/")
}
}
This task configuration will directly copy the UI build files to the springboot application jar. And this doesn't emit the "implicit dependencies" warning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With