Hi, I am in the process of upgrading a Spring Boot Gradle project, I have gotten it from Java 8 to 11. Now I need to upgrade Gradle to get the project built and running on Java 17.
It contains 4 tasks, that performs text replacement of application version number for the build. When compiling it outputs the following message, one for each task:
Task :filter1
Execution optimizations have been disabled for task ':filter1' to ensure correctness due to the following reasons:
Gradle detected a problem with the following location: '/.../build/resources/main/templates'. Reason: Task ':bootJarMainClassName' uses this output of task ':filter1' 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
for more details about this problem
The tasks are defined as follows:
import org.apache.tools.ant.filters.ReplaceTokens
task filter1(type: Copy) {
from 'src/main/resources/templates/layout.html'
into "$buildDir/resources/main/templates"
filter(ReplaceTokens, tokens: [VERSION: version])
filteringCharset = 'UTF-8'
}
task filter2(type: Copy) {
from 'src/main/resources/templates/layout2.html'
into "$buildDir/resources/main/templates"
filter(ReplaceTokens, tokens: [VERSION: version])
filteringCharset = 'UTF-8'
}
task filter3(type: Copy) {
from 'src/main/resources/templates/layout_small.html'
into "$buildDir/resources/main/templates"
filter(ReplaceTokens, tokens: [VERSION: version])
filteringCharset = 'UTF-8'
}
task filter4(type: Copy) {
from 'src/main/resources/banner.txt'
into "$buildDir/resources/main"
filter(ReplaceTokens, tokens: [VERSION: version])
filteringCharset = 'UTF-8'
}
build.dependsOn ([filter1,filter2,filter3,filter4])
bootJar.dependsOn ([filter1,filter2,filter3,filter4])
I am not very familiar with build script programming, so I dont understand what the problem actually is. Other than the fact the syntax has changed between version 6 and 7.
Can anybody explain to me whats going on, and what needs to be done to fix it?
Since the tasks are tied to the Spring Boot Plugin the following might also be of relevance:
// located in build.gradle after the 'import' statement and before the task definitions:
buildscript {
ext {
bootVersion = '2.7.18'
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:$bootVersion"
classpath 'org.apache.ant:ant:1.7.1'
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'groovy'