-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce 'evas-build' and 'evas-publish' plugins
- Loading branch information
Showing
14 changed files
with
266 additions
and
195 deletions.
There are no files selected for viewing
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,40 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
`java-gradle-plugin` | ||
} | ||
|
||
repositories { | ||
google { | ||
mavenContent { | ||
includeGroupByRegex("com\\.android.*") | ||
includeGroupByRegex("com\\.google.*") | ||
includeGroupByRegex("androidx.*") | ||
} | ||
} | ||
|
||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
implementation(gradleKotlinDsl()) | ||
implementation(kotlin("gradle-plugin:${deps.versions.kotlin.get()}")) | ||
implementation("org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin:${deps.versions.kotlin.get()}") | ||
implementation("com.android.tools.build:gradle:${deps.versions.androidGradlePlugin.get()}") | ||
implementation("org.jetbrains.compose:org.jetbrains.compose.gradle.plugin:${deps.versions.compose.get()}") | ||
|
||
implementation("org.jetbrains.kotlinx.atomicfu:org.jetbrains.kotlinx.atomicfu.gradle.plugin:0.25.0") | ||
implementation("org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin:0.15.1") | ||
implementation("com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin:0.29.0") | ||
implementation("org.jetbrains.kotlinx.benchmark:org.jetbrains.kotlinx.benchmark.gradle.plugin:${deps.versions.kotlinxBenchmark.get()}") | ||
} | ||
|
||
gradlePlugin.plugins.create("evas") { | ||
id = "evas-build" | ||
implementationClass = "EvasBuildPlugin" | ||
} | ||
|
||
gradlePlugin.plugins.create("evas-publish") { | ||
id = "evas-publish" | ||
implementationClass = "EvasPublishPlugin" | ||
} |
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,7 @@ | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("deps") { | ||
from(files("../dependencies.toml")) | ||
} | ||
} | ||
} |
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,16 @@ | ||
import conventions.androidLibraryConventions | ||
import conventions.binaryCompatibilityValidatorConventions | ||
import conventions.kotlinMultiplatformConventions | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class EvasBuildPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
version = providers.gradleProperty("evas.version").get() | ||
group = "io.sellmair" | ||
|
||
target.kotlinMultiplatformConventions() | ||
target.androidLibraryConventions() | ||
target.binaryCompatibilityValidatorConventions() | ||
} | ||
} |
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,14 @@ | ||
import conventions.publishingConventions | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin | ||
|
||
class EvasPublishPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
|
||
plugins.apply(MavenPublishPlugin::class.java) | ||
plugins.apply(com.vanniktech.maven.publish.MavenPublishPlugin::class.java) | ||
|
||
target.publishingConventions() | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
buildSrc/src/main/kotlin/conventions/androidLibraryConventions.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 conventions | ||
|
||
import com.android.build.gradle.LibraryExtension | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
|
||
fun Project.androidLibraryConventions() { | ||
plugins.withId("com.android.library") { | ||
extensions.configure<LibraryExtension> { | ||
compileSdk = 34 | ||
defaultConfig { | ||
minSdk = 15 | ||
namespace = "io.sellmair.${project.name}" | ||
} | ||
} | ||
|
||
extensions.configure<KotlinMultiplatformExtension> { | ||
androidTarget().publishLibraryVariants("release") | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
buildSrc/src/main/kotlin/conventions/binaryCompatibilityValidatorConventions.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,16 @@ | ||
package conventions | ||
|
||
import kotlinx.validation.ExperimentalBCVApi | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
internal fun Project.binaryCompatibilityValidatorConventions() = | ||
plugins.withId("org.jetbrains.kotlinx.binary-compatibility-validator") { | ||
extensions.configure<kotlinx.validation.ApiValidationExtension> { | ||
@OptIn(kotlinx.validation.ExperimentalBCVApi::class) | ||
klib { | ||
enabled = true | ||
strictValidation = true | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
buildSrc/src/main/kotlin/conventions/kotlinMultiplatformConventions.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,43 @@ | ||
package conventions | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.testing.AbstractTestTask | ||
import org.gradle.api.tasks.testing.logging.TestLogEvent | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper | ||
|
||
internal fun Project.kotlinMultiplatformConventions() { | ||
plugins.withType<KotlinMultiplatformPluginWrapper>().all { | ||
extensions.configure<KotlinMultiplatformExtension> { | ||
/* Targets */ | ||
|
||
|
||
/* | ||
Jvm options | ||
*/ | ||
jvmToolchain(17) | ||
|
||
/* | ||
Kotlin Compiler Options | ||
*/ | ||
@OptIn(ExperimentalKotlinGradlePluginApi::class) | ||
compilerOptions { | ||
if (!project.path.startsWith(":samples")) { | ||
explicitApi() | ||
} | ||
} | ||
} | ||
|
||
/* Tests */ | ||
tasks.withType<AbstractTestTask>().configureEach { | ||
outputs.upToDateWhen { false } | ||
testLogging { | ||
showStandardStreams = true | ||
events = setOf(TestLogEvent.PASSED, TestLogEvent.FAILED, TestLogEvent.SKIPPED) | ||
} | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
buildSrc/src/main/kotlin/conventions/publishingConventions.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,69 @@ | ||
package conventions | ||
|
||
import com.vanniktech.maven.publish.KotlinMultiplatform | ||
import org.gradle.api.Project | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin | ||
import org.gradle.kotlin.dsl.assign | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.maven | ||
import org.gradle.kotlin.dsl.withType | ||
|
||
internal fun Project.publishingConventions() { | ||
plugins.withType<MavenPublishPlugin>().configureEach { | ||
/* Publish locally to the 'build/repository' folder. Can be useful to check publication issues locally */ | ||
extensions.configure<PublishingExtension> { | ||
repositories { | ||
maven(rootDir.resolve("build/repository")) { | ||
name = "local" | ||
} | ||
} | ||
|
||
/* Publish to GitHub packages */ | ||
repositories { | ||
maven("https://maven.pkg.github.com/sellmair/evas") { | ||
name = "github" | ||
credentials { | ||
username = providers.gradleProperty("evas.github.user").orNull | ||
password = providers.gradleProperty("evas.github.token").orNull | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* Publish to maven central */ | ||
plugins.withType<com.vanniktech.maven.publish.MavenPublishPlugin>().all { | ||
extensions.configure<com.vanniktech.maven.publish.MavenPublishBaseExtension> { | ||
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL) | ||
signAllPublications() | ||
configure(KotlinMultiplatform(sourcesJar = true)) | ||
|
||
pom { | ||
name = "Evas" | ||
inceptionYear = "2024" | ||
url = "https://github.com/sellmair/evas" | ||
description = provider { project.description } | ||
|
||
licenses { | ||
license { | ||
name = "MIT License" | ||
url = "https://opensource.org/licenses/MIT" | ||
} | ||
} | ||
|
||
scm { | ||
url = "https://github.com/sellmair/evas" | ||
} | ||
|
||
developers { | ||
developer { | ||
id = "sellmair" | ||
name = "Sebastian Sellmair" | ||
email = "sebastian@sellmair.io" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,17 @@ | ||
[versions] | ||
kotlin = "2.0.0" | ||
androidGradlePlugin = "8.5.1" | ||
compose = "1.6.11" | ||
coroutines = "1.9.0-RC" | ||
kotlinxBenchmark = "0.4.11" | ||
ktor = "2.3.12" | ||
|
||
[libraries] | ||
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } | ||
coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } | ||
coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" } | ||
kotlinxBenchmarkRuntime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinxBenchmark" } | ||
|
||
ktorClientCore = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } | ||
ktorClientCio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } | ||
ktorClientDarwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" } |
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
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
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
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
Oops, something went wrong.