Files
spring-security-samples/build.gradle
Josh Cummings 93ebfca7b8 Make Javaformat and AOT work together
Spring JavaFormat seems to process all source directories,
including those that contain AOT-generated sources.

This causes failures for checkFormat as well as checkstyle.
These are failures that we can ignore since the source code
is generated.

Additionally, there is some kind of interaction between
JavaFormat and the Spring Boot AOT support that makes Gradle
think that compileJava and a few other tasks need to depend
on formatMain and formatTest.
2024-09-25 13:35:32 -06:00

74 lines
1.6 KiB
Groovy

plugins {
id "checkstyle"
id "io.spring.javaformat" version "0.0.42"
id 'io.spring.nohttp' version '0.0.11'
}
allprojects {
apply plugin: 'checkstyle'
apply plugin: 'io.spring.javaformat'
dependencies {
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:0.0.42"
}
// Ensure every test task has at least a single test
tasks.withType(Test).configureEach {
afterSuite { desc, result ->
if (result.testCount == 0) {
throw new IllegalStateException("No tests were found. Ensure that useJUnitPlatform was used.")
}
}
}
// Spring Framework 6.1 requires -parameters to be able to introspect method parameter names
tasks.withType(JavaCompile) {
options.compilerArgs.add("-parameters")
}
tasks.matching { it.name == 'formatAot' }.all { task ->
task.enabled = false
}
tasks.matching { it.name == 'formatAotTest' }.all { task ->
task.enabled = false
}
tasks.matching { it.name == 'checkFormatAot' }.all { task ->
task.enabled = false
}
tasks.matching { it.name == 'checkFormatAotTest' }.all { task ->
task.enabled = false
}
tasks.matching { it.name == "checkstyleAot" }.all { task ->
task.enabled = false
}
tasks.matching { it.name == "checkstyleAotTest" }.all { task ->
task.enabled = false
}
}
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
repositories {
mavenCentral()
}
tasks.register('runAllTests') {
var allTasks = rootProject.getAllTasks(true)
var allTestsTasks = allTasks.values().collect { t ->
t.findAll { it.name == 'test' || it.name == 'integrationTest' }
}.flatten()
it.dependsOn {
allTestsTasks
}
}