Skip to content

Commit

Permalink
Apply Spotless formatting to Gradle script plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Aug 11, 2024
1 parent dae525d commit d8ec757
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 65 deletions.
14 changes: 7 additions & 7 deletions gradle/plugins/code-generator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
`kotlin-dsl`
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
gradlePluginPortal()
}

dependencies {
implementation("junitbuild.base:code-generator-model")
implementation(projects.common)
implementation(libs.jackson.dataformat.yaml)
implementation(libs.jackson.module.kotlin)
implementation(libs.jte)
implementation("junitbuild.base:code-generator-model")
implementation(projects.common)
implementation(libs.jackson.dataformat.yaml)
implementation(libs.jackson.module.kotlin)
implementation(libs.jte)
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import junitbuild.generator.GenerateJreRelatedSourceCode

plugins {
java
java
}

val templates by sourceSets.registering
dependencies {
add(templates.get().compileOnlyConfigurationName, dependencyFromLibs("jte"))
add(templates.get().compileOnlyConfigurationName, "junitbuild.base:code-generator-model")
add(templates.get().compileOnlyConfigurationName, dependencyFromLibs("jte"))
add(templates.get().compileOnlyConfigurationName, "junitbuild.base:code-generator-model")
}

val license: License by rootProject.extra
Expand All @@ -16,20 +16,20 @@ val generateCode by tasks.registering

sourceSets.named { it != templates.name }.configureEach {

val sourceSetName = name
val sourceSetTargetDir = rootTargetDir.map { it.dir(sourceSetName) }
val sourceSetName = name
val sourceSetTargetDir = rootTargetDir.map { it.dir(sourceSetName) }

val task = tasks.register(getTaskName("generateJreRelated", "SourceCode"), GenerateJreRelatedSourceCode::class) {
templateDir.convention(layout.dir(templates.map {
it.resources.srcDirs.single().resolve(sourceSetName)
}))
targetDir.convention(sourceSetTargetDir)
licenseHeaderFile.convention(license.headerFile)
}
val task = tasks.register(getTaskName("generateJreRelated", "SourceCode"), GenerateJreRelatedSourceCode::class) {
templateDir.convention(layout.dir(templates.map {
it.resources.srcDirs.single().resolve(sourceSetName)
}))
targetDir.convention(sourceSetTargetDir)
licenseHeaderFile.convention(license.headerFile)
}

java.srcDir(files(sourceSetTargetDir).builtBy(task))
java.srcDir(files(sourceSetTargetDir).builtBy(task))

generateCode {
dependsOn(task)
}
generateCode {
dependsOn(task)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ val allMainClasses by tasks.registering {
}

val prepareModuleSourceDir by tasks.registering(Sync::class) {
from(moduleSourceDir)
from(sourceSets.named { it.startsWith("main") }.map { it.allJava })
into(combinedModuleSourceDir.map { it.dir(javaModuleName) })
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(moduleSourceDir)
from(sourceSets.named { it.startsWith("main") }.map { it.allJava })
into(combinedModuleSourceDir.map { it.dir(javaModuleName) })
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

val compileModule by tasks.registering(JavaCompile::class) {
dependsOn(allMainClasses)
enabled = project in modularProjects
enabled = project in modularProjects
source = fileTree(combinedModuleSourceDir).builtBy(prepareModuleSourceDir)
destinationDirectory = moduleOutputDir
sourceCompatibility = "9"
Expand All @@ -184,22 +184,22 @@ val compileModule by tasks.registering(JavaCompile::class) {
"--module-version", "${project.version}",
))

val moduleOptions = objects.newInstance(ModuleCompileOptions::class)
extensions.add("moduleOptions", moduleOptions)
moduleOptions.modulePath.from(configurations.compileClasspath)
val moduleOptions = objects.newInstance(ModuleCompileOptions::class)
extensions.add("moduleOptions", moduleOptions)
moduleOptions.modulePath.from(configurations.compileClasspath)

options.compilerArgumentProviders.add(objects.newInstance(ModulePathArgumentProvider::class, project, combinedModuleSourceDir, modularProjects).apply {
modulePath.from(moduleOptions.modulePath)
})
modulePath.from(moduleOptions.modulePath)
})
options.compilerArgumentProviders.addAll(modularProjects.map { objects.newInstance(PatchModuleArgumentProvider::class, project, it) })

modularity.inferModulePath = false

doFirst {
options.allCompilerArgs.forEach {
logger.info(it)
}
}
doFirst {
options.allCompilerArgs.forEach {
logger.info(it)
}
}
}

tasks.withType<Jar>().configureEach {
Expand Down Expand Up @@ -315,16 +315,16 @@ checkstyle {

tasks {
checkstyleMain {
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleMain.xml"))
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleMain.xml"))
}
checkstyleTest {
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml"))
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml"))
}
}

pluginManager.withPlugin("java-test-fixtures") {
tasks.named<Checkstyle>("checkstyleTestFixtures") {
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml"))
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleTest.xml"))
}
tasks.named<JavaCompile>("compileTestFixturesJava") {
options.release = extension.testJavaVersion.majorVersion.toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ listOf(9, 17).forEach { javaVersion ->
}

named<Checkstyle>("checkstyle${sourceSet.name.capitalized()}").configure {
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleMain.xml"))
config = resources.text.fromFile(checkstyle.configDirectory.file("checkstyleMain.xml"))
}

if (project in mavenizedProjects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ project.pluginManager.withPlugin("java") {
val javaLanguageVersion = buildParameters.javaToolchain.version.map { JavaLanguageVersion.of(it) }.getOrElse(defaultLanguageVersion)
val jvmImplementation = buildParameters.javaToolchain.implementation.map {
when(it) {
"j9" -> JvmImplementation.J9
else -> throw InvalidUserDataException("Unsupported JDK implementation: $it")
}
"j9" -> JvmImplementation.J9
else -> throw InvalidUserDataException("Unsupported JDK implementation: $it")
}
}.getOrElse(JvmImplementation.VENDOR_SPECIFIC)

val extension = the<JavaPluginExtension>()
val javaToolchainService = the<JavaToolchainService>()

extension.toolchain {
languageVersion = javaLanguageVersion
implementation = jvmImplementation
}
languageVersion = javaLanguageVersion
implementation = jvmImplementation
}

pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
configure<KotlinJvmProjectExtension> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
plugins {
id("me.champeau.jmh")
id("me.champeau.jmh")
}

jmh {
jmhVersion = requiredVersionFromLibs("jmh")
jmhVersion = requiredVersionFromLibs("jmh")
}

dependencies {
jmh(dependencyFromLibs("jmh-core"))
jmhAnnotationProcessor(dependencyFromLibs("jmh-generator-annprocess"))
jmh(dependencyFromLibs("jmh-core"))
jmhAnnotationProcessor(dependencyFromLibs("jmh-generator-annprocess"))
}

tasks.jmhJar {
notCompatibleWithConfigurationCache("https://github.com/melix/jmh-gradle-plugin/issues/229")
notCompatibleWithConfigurationCache("https://github.com/melix/jmh-gradle-plugin/issues/229")
}

pluginManager.withPlugin("checkstyle") {
tasks.named<Checkstyle>("checkstyleJmh").configure {
// use same style rules as defined for tests
config = resources.text.fromFile(project.the<CheckstyleExtension>().configDirectory.file("checkstyleTest.xml"))
}
tasks.named<Checkstyle>("checkstyleJmh").configure {
// use same style rules as defined for tests
config = resources.text.fromFile(project.the<CheckstyleExtension>().configDirectory.file("checkstyleTest.xml"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ tasks {
classpath -= sourceSets.main.get().output
classpath += files(shadowJar.map { it.archiveFile })
}
named<JavaCompile>("compileModule") {
the<ModuleCompileOptions>().modulePath.from(shadowedClasspath.get())
}
named<JavaCompile>("compileModule") {
the<ModuleCompileOptions>().modulePath.from(shadowedClasspath.get())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@ val license: License by rootProject.extra
spotless {

format("misc") {
target("*.gradle.kts", "buildSrc/**/*.gradle.kts", "*.gitignore")
targetExclude("buildSrc/build/**")
target("*.gradle.kts", "gradle/plugins/**/*.gradle.kts", "*.gitignore")
targetExclude("gradle/plugins/**/build/**")
indentWithTabs()
trimTrailingWhitespace()
endWithNewline()
}

format("documentation") {
target("*.adoc", "*.md", "src/**/*.adoc", "src/**/*.md")
targetExclude("**/build", "**/target")
trimTrailingWhitespace()
endWithNewline()
}

pluginManager.withPlugin("java") {

val configDir = rootProject.layout.projectDirectory.dir("gradle/config/eclipse")
val importOrderConfigFile = configDir.file("junit-eclipse.importorder")
val configDir = rootProject.layout.projectDirectory.dir("gradle/config/eclipse")
val importOrderConfigFile = configDir.file("junit-eclipse.importorder")
val javaFormatterConfigFile = configDir.file("junit-eclipse-formatter-settings.xml")

java {
Expand Down

0 comments on commit d8ec757

Please # to comment.