-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organize Gradle structure to be re-usable (#16)
* Change to composite build * Tweak idea config * Remove unused imports
- Loading branch information
1 parent
a474102
commit 0bfc19d
Showing
16 changed files
with
426 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
alias(libs.plugins.ktlint.gradle.plugin) | ||
alias(libs.plugins.detekt.gradle.plugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register(libs.plugins.aws.appconfig.openfeature.provider.base.get().pluginId) { | ||
id = libs.plugins.aws.appconfig.openfeature.provider.base.get().pluginId | ||
implementationClass = "io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.BasePlugin" | ||
} | ||
register(libs.plugins.aws.appconfig.openfeature.provider.java.get().pluginId) { | ||
id = libs.plugins.aws.appconfig.openfeature.provider.java.get().pluginId | ||
implementationClass = "io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.JavaPlugin" | ||
} | ||
register(libs.plugins.aws.appconfig.openfeature.provider.kotlin.get().pluginId) { | ||
id = libs.plugins.aws.appconfig.openfeature.provider.kotlin.get().pluginId | ||
implementationClass = "io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.KotlinPlugin" | ||
} | ||
register(libs.plugins.aws.appconfig.openfeature.provider.lint.kotlin.get().pluginId) { | ||
id = libs.plugins.aws.appconfig.openfeature.provider.lint.kotlin.get().pluginId | ||
implementationClass = "io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.KotlinLintPlugin" | ||
} | ||
register(libs.plugins.aws.appconfig.openfeature.provider.test.get().pluginId) { | ||
id = libs.plugins.aws.appconfig.openfeature.provider.test.get().pluginId | ||
implementationClass = "io.github.lavenderses.aws_appconfig_openfeature_provider.plugin.TestPlugin" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.detekt.gradle.plugin) | ||
implementation(libs.kotlin.gradle.plugin) | ||
implementation(libs.ktlint.gradle.plugin) | ||
implementation(libs.lombok.gradle.plugin) | ||
implementation(libs.spotbugs.gradle.plugin) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenCentral() | ||
google() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") | ||
|
||
dependencyResolutionManagement { | ||
@Suppress("UnstableApiUsage") | ||
repositories { | ||
mavenCentral() | ||
google() | ||
gradlePluginPortal() | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic" |
60 changes: 60 additions & 0 deletions
60
...main/kotlin/io/github/lavenderses/aws_appconfig_openfeature_provider/plugin/BasePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package io.github.lavenderses.aws_appconfig_openfeature_provider.plugin | ||
|
||
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.api.plugins.JavaTestFixturesPlugin | ||
import org.gradle.jvm.tasks.Jar | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension | ||
|
||
class BasePlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
group = "io.github.lavenderses" | ||
|
||
with(pluginManager) { | ||
// first party plugin | ||
apply(TestPlugin::class.java) | ||
|
||
// third party | ||
apply(JavaLibraryPlugin::class.java) | ||
apply(JavaTestFixturesPlugin::class.java) | ||
apply(libs.findPlugin("kotlin-jvm").get().get().pluginId) | ||
} | ||
|
||
with(repositories) { | ||
mavenCentral() | ||
} | ||
|
||
with(extensions.getByType<JavaPluginExtension>()) { | ||
sourceCompatibility = PROJECT_JDK.javaVersion | ||
targetCompatibility = PROJECT_JDK.javaVersion | ||
} | ||
|
||
with(extensions.getByType<KotlinJvmProjectExtension>()) { | ||
compilerOptions { | ||
this.jvmTarget.set(PROJECT_JDK.jvmTarget) | ||
} | ||
} | ||
|
||
with(dependencies) { | ||
// third party | ||
api(libs.findLibrary("jetbrains-annotations").get()) | ||
api(libs.findLibrary("log4j-slf4j2-impl").get()) | ||
api(libs.findLibrary("slf4j-api").get()) | ||
|
||
// bom | ||
implementation(platform(libs.findLibrary("aws-bom").get())) | ||
} | ||
|
||
tasks.withType<Jar> { | ||
group = "io.github.lavenderses" | ||
archiveBaseName.set("aws-app-config-openfeature-provider-java") | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
.../main/kotlin/io/github/lavenderses/aws_appconfig_openfeature_provider/plugin/Extension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@file:Suppress("MatchingDeclarationName") | ||
|
||
package io.github.lavenderses.aws_appconfig_openfeature_provider.plugin | ||
|
||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalog | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.api.artifacts.dsl.DependencyHandler | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
data class JdkVersion( | ||
val string: String, | ||
val number: Int, | ||
val javaVersion: JavaVersion, | ||
val jvmTarget: JvmTarget, | ||
) | ||
|
||
private val VERSION: JavaVersion = JavaVersion.VERSION_17 | ||
|
||
val Project.PROJECT_JDK: JdkVersion | ||
get() = JdkVersion( | ||
string = VERSION.majorVersion, | ||
number = VERSION.majorVersion.toInt(), | ||
javaVersion = VERSION, | ||
jvmTarget = JvmTarget.JVM_17, | ||
) | ||
|
||
val Project.libs: VersionCatalog get() = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
||
fun DependencyHandler.implementation(dependencyNotation: Any) { | ||
add("implementation", dependencyNotation) | ||
} | ||
|
||
fun DependencyHandler.api(dependencyNotation: Any) { | ||
add("api", dependencyNotation) | ||
} | ||
|
||
fun DependencyHandler.testImplementation(dependencyNotation: Any) { | ||
add("testImplementation", dependencyNotation) | ||
} | ||
|
||
fun DependencyHandler.testFixturesImplementation(dependencyNotation: Any) { | ||
add("testFixturesImplementation", dependencyNotation) | ||
} |
22 changes: 22 additions & 0 deletions
22
...main/kotlin/io/github/lavenderses/aws_appconfig_openfeature_provider/plugin/JavaPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.lavenderses.aws_appconfig_openfeature_provider.plugin | ||
|
||
import io.freefair.gradle.plugins.lombok.LombokPlugin | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class JavaPlugin: Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
// first party | ||
apply(BasePlugin::class.java) | ||
|
||
// third party | ||
apply(LombokPlugin::class.java) | ||
// TODO | ||
// apply(SpotBugsPlugin::class.java) | ||
} | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...otlin/io/github/lavenderses/aws_appconfig_openfeature_provider/plugin/KotlinLintPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package io.github.lavenderses.aws_appconfig_openfeature_provider.plugin | ||
|
||
import io.gitlab.arturbosch.detekt.Detekt | ||
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask | ||
import io.gitlab.arturbosch.detekt.DetektPlugin | ||
import io.gitlab.arturbosch.detekt.extensions.DetektExtension | ||
import io.gitlab.arturbosch.detekt.report.ReportMergeTask | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.gradle.kotlin.dsl.register | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jlleitschuh.gradle.ktlint.KtlintExtension | ||
import org.jlleitschuh.gradle.ktlint.KtlintPlugin | ||
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType | ||
|
||
class KotlinLintPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply(KtlintPlugin::class.java) | ||
apply(DetektPlugin::class.java) | ||
} | ||
|
||
with(extensions.getByType<KtlintExtension>()) { | ||
version.set(libs.findVersion("ktlint").get().requiredVersion) | ||
debug.set(true) | ||
verbose.set(true) | ||
android.set(false) | ||
outputToConsole.set(true) | ||
outputColorName.set("RED") | ||
ignoreFailures.set(false) | ||
reporters { | ||
reporter(ReporterType.HTML) | ||
} | ||
filter { | ||
exclude("**/generated/**") | ||
include("**/kotlin/**") | ||
} | ||
} | ||
|
||
with(extensions.getByType<DetektExtension>()) { | ||
parallel = true | ||
config.setFrom(file("${rootProject.rootDir}/config/detekt/detekt.yml")) | ||
buildUponDefaultConfig = true | ||
} | ||
|
||
val reportMerge = tasks.register<ReportMergeTask>("reportMerge") { | ||
output.set(rootProject.layout.buildDirectory.file("reports/detekt/merge.xml")) | ||
input.from(tasks.withType<Detekt>().map { it.xmlReportFile }) | ||
} | ||
|
||
with(tasks.withType<Detekt>()) { | ||
configureEach { | ||
jvmTarget = target.PROJECT_JDK.javaVersion.toString() | ||
reports { | ||
html { require(true) } | ||
xml { require(true) } | ||
md { require(true) } | ||
} | ||
finalizedBy(reportMerge) | ||
ignoreFailures = false | ||
} | ||
} | ||
|
||
with(tasks.withType<DetektCreateBaselineTask>()) { | ||
forEach { it.jvmTarget = target.PROJECT_JDK.string } | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...in/kotlin/io/github/lavenderses/aws_appconfig_openfeature_provider/plugin/KotlinPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.lavenderses.aws_appconfig_openfeature_provider.plugin | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class KotlinPlugin: Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
// first party plugin | ||
apply(BasePlugin::class.java) | ||
apply(KotlinLintPlugin::class.java) | ||
} | ||
|
||
with(dependencies) { | ||
implementation(libs.findLibrary("jackson-module-kotlin").get()) | ||
implementation(libs.findLibrary("kotlin-reflect").get()) | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...main/kotlin/io/github/lavenderses/aws_appconfig_openfeature_provider/plugin/TestPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.lavenderses.aws_appconfig_openfeature_provider.plugin | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.testing.Test | ||
import org.gradle.kotlin.dsl.withType | ||
|
||
class TestPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
with(target) { | ||
tasks.withType<Test>() { | ||
useJUnitPlatform() | ||
} | ||
|
||
with(dependencies) { | ||
// bom | ||
testImplementation(platform(libs.findLibrary("mockito-bom").get())) | ||
|
||
// third party | ||
testImplementation(libs.findLibrary("assertk").get()) | ||
testImplementation(libs.findLibrary("junit-jupiter-engine").get()) | ||
testImplementation(libs.findLibrary("kotlin-test").get()) | ||
testImplementation(libs.findLibrary("kotlin-test-junit5").get()) | ||
testImplementation(libs.findLibrary("kotlin-reflect").get()) | ||
testImplementation(libs.findLibrary("mockito-junit-jupiter").get()) | ||
testImplementation(libs.findLibrary("mockito-inline").get()) | ||
testImplementation(libs.findLibrary("mockito-kotlin").get()) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
group = "io.github.lavenderses" | ||
description = "OpenFeature Provider third-party implementation for AWS AppConfig in Java" |
Oops, something went wrong.