Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to Binary plugins #337

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/misc.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
Expand Down
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=21.0.4-librca
gradle=8.9
gradle=8.10
47 changes: 46 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
`kotlin-dsl`
alias(libs.plugins.spotless)
}

repositories {
Expand All @@ -8,7 +9,6 @@ repositories {

dependencies {
implementation(libs.plugin.springBoot)
implementation(libs.plugin.springDependencyManagement)
implementation(libs.plugin.spotless)
implementation(kotlin("allopen", "2.0.10"))
implementation(kotlin("gradle-plugin", "2.0.10"))
Expand All @@ -17,3 +17,48 @@ dependencies {
implementation(kotlin("stdlib-jdk8", "2.0.10"))
implementation(kotlin("noarg", "2.0.10"))
}

spotless {
kotlin {
ktlint()
}
}

gradlePlugin {
val dependencyManagement by plugins.creating {
id = "hu.bsstudio.dependency-management"
implementationClass = "hu.bsstudio.DependencyManagement"
}
val integrationTestingConventions by plugins.creating {
id = "hu.bsstudio.integration-testing-conventions"
implementationClass = "hu.bsstudio.IntegrationTestingConventions"
}
val javaConventions by plugins.creating {
id = "hu.bsstudio.java-conventions"
implementationClass = "hu.bsstudio.JavaConventions"
}
val kotlinConventions by plugins.creating {
id = "hu.bsstudio.kotlin-conventions"
implementationClass = "hu.bsstudio.KotlinConventions"
}
val kotlinTestingConventions by plugins.creating {
id = "hu.bsstudio.kotlin-testing-conventions"
implementationClass = "hu.bsstudio.KotlinTestingConventions"
}
val spotlessConventions by plugins.creating {
id = "hu.bsstudio.spotless-conventions"
implementationClass = "hu.bsstudio.SpotlessConventions"
}
val springAppConventions by plugins.creating {
id = "hu.bsstudio.spring-app-conventions"
implementationClass = "hu.bsstudio.SpringAppConventions"
}
val springModuleConventions by plugins.creating {
id = "hu.bsstudio.spring-module-conventions"
implementationClass = "hu.bsstudio.SpringModuleConventions"
}
val testingConventions by plugins.creating {
id = "hu.bsstudio.testing-conventions"
implementationClass = "hu.bsstudio.TestingConventions"
}
}
14 changes: 0 additions & 14 deletions buildSrc/src/main/kotlin/dependency-management.gradle.kts

This file was deleted.

21 changes: 21 additions & 0 deletions buildSrc/src/main/kotlin/hu/bsstudio/DependencyManagement.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package hu.bsstudio

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply

class DependencyManagement : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.apply(JavaConventions::class)

project.repositories.apply {
add(mavenCentral())
}

project.dependencies.apply {
add("api", enforcedPlatform("org.springframework.boot:spring-boot-dependencies:3.3.3"))
add("api", enforcedPlatform("org.springframework.shell:spring-shell-dependencies:3.3.1"))
add("api", enforcedPlatform("org.springframework.cloud:spring-cloud-dependencies:2023.0.3"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package hu.bsstudio

import org.gradle.api.Plugin
import org.gradle.api.Project

class IntegrationTestingConventions : Plugin<Project> {
override fun apply(project: Project) {
// project.pluginManager.apply(TestingConventions::class)
//
// val sourceSets = project.extensions.configure<SourceSetContainer>("sourceSets") {}
// val intTest = sourceSets.create("intTest") {
// compileClasspath += get("main").output
// runtimeClasspath += get("main").output
// }
//
// val intTestImplementation by project.configurations.getting {
// extendsFrom(project.configurations.getByName("implementation"))
// }
// val intTestRuntimeOnly by project.configurations.getting {
// extendsFrom(project.configurations.getByName("runtimeOnly"))
// }
//
// project.dependencies {
// add("intTestImplementation","org.springframework.boot:spring-boot-starter-test") {
// exclude(module = "hamcrest") // require developers to use KoTest
// exclude(module = "org.assertj") // require developers to use KoTest
// }
// add("intTestImplementation","io.kotest:kotest-runner-junit5:5.9.1")
// }
//
// val integrationTest = project.tasks.register<Test>("integrationTest") {
// description = "Runs integration tests."
// group = "verification"
//
// testClassesDirs = sourceSets["intTest"].output.classesDirs
// classpath = sourceSets["intTest"].runtimeClasspath
// shouldRunAfter("test")
//
// useJUnitPlatform()
//
// testLogging {
// showStandardStreams = true
// }
// }
//
// project.tasks.named("check") { dependsOn(integrationTest) }
}
}
27 changes: 27 additions & 0 deletions buildSrc/src/main/kotlin/hu/bsstudio/JavaConventions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package hu.bsstudio

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure

class JavaConventions : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.apply(JavaLibraryPlugin::class)

project.extensions.configure(JavaPluginExtension::class) {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

project.configurations.apply {
getByName("compileOnly") {
extendsFrom(getByName("annotationProcessor"))
}
}
}
}
19 changes: 19 additions & 0 deletions buildSrc/src/main/kotlin/hu/bsstudio/KotlinConventions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package hu.bsstudio

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.jetbrains.kotlin.allopen.gradle.SpringGradleSubplugin
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
import org.jetbrains.kotlin.noarg.gradle.KotlinJpaSubplugin

class KotlinConventions : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.apply {
apply(JavaConventions::class)
apply(KotlinMultiplatformPluginWrapper::class)
apply(SpringGradleSubplugin::class)
apply(KotlinJpaSubplugin::class)
}
}
}
16 changes: 16 additions & 0 deletions buildSrc/src/main/kotlin/hu/bsstudio/KotlinTestingConventions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package hu.bsstudio

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply

class KotlinTestingConventions : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.apply(TestingConventions::class)
project.dependencies.apply {
add("testImplementation", "io.mockk:mockk-jvm:1.13.12")
add("testImplementation", "com.ninja-squad:springmockk:4.0.2")
add("testImplementation", "io.kotest:kotest-assertions-core-jvm:5.9.1")
}
}
}
40 changes: 40 additions & 0 deletions buildSrc/src/main/kotlin/hu/bsstudio/SpotlessConventions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package hu.bsstudio

import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure

class SpotlessConventions : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.apply(SpotlessPlugin::class)

project.extensions.configure(SpotlessExtension::class) {
kotlin {
ktlint()
toggleOffOn()
}
java {
importOrder()
removeUnusedImports()
cleanthat()
googleJavaFormat()
}
kotlinGradle {
ktlint()
}
flexmark {
target("**/*.md")
flexmark()
}
yaml {
target("**/*.yml", "**/*.yaml")
jackson()
.yamlFeature("WRITE_DOC_START_MARKER", false)
.yamlFeature("MINIMIZE_QUOTES", true)
}
}
}
}
34 changes: 34 additions & 0 deletions buildSrc/src/main/kotlin/hu/bsstudio/SpringAppConventions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package hu.bsstudio

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.TestReportAggregationPlugin
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.withType
import org.gradle.testing.jacoco.plugins.JacocoReportAggregationPlugin
import org.springframework.boot.gradle.plugin.SpringBootPlugin

class SpringAppConventions : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.apply {
apply(SpringModuleConventions::class)
apply(SpringBootPlugin::class)
apply(JacocoReportAggregationPlugin::class)
apply(TestReportAggregationPlugin::class)
}

project.tasks.withType(Jar::class) {
// if this convention is used we only expect bootJars to be built
// it will disable the default jar task
enabled = false
}

project.tasks.named("test") {
finalizedBy(
project.tasks.named("testAggregateTestReport"),
project.tasks.named("testCodeCoverageReport"),
)
}
}
}
11 changes: 11 additions & 0 deletions buildSrc/src/main/kotlin/hu/bsstudio/SpringModuleConventions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package hu.bsstudio

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply

class SpringModuleConventions : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.apply(DependencyManagement::class)
}
}
Loading