-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
391 additions
and
201 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,17 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(Kotlin.stdlib) | ||
implementation(Kotlin.gradlePlugin) | ||
|
||
implementation("com.mooncloak.kodetools.kenv:kenv-core:_") | ||
} | ||
|
||
gradlePlugin { | ||
plugins.register("parcelable.variables") { | ||
id = "parcelable.variables" | ||
implementationClass = "BuildVariablesPlugin" | ||
} | ||
} |
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,28 @@ | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
maven("https://plugins.gradle.org/m2/") | ||
mavenCentral() | ||
google() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
@Suppress("UnstableApiUsage") | ||
repositories { | ||
mavenCentral() | ||
google() | ||
gradlePluginPortal() | ||
maven("https://repo.repsy.io/mvn/mooncloak/public") | ||
} | ||
} | ||
|
||
plugins { | ||
// This is the plugin we use to handle our dependency versions. See the versions.properties file for the latest versions. | ||
// See https://jmfayard.github.io/refreshVersions | ||
id("de.fayard.refreshVersions") version "0.60.5" | ||
|
||
// See root build.gradle.kts file for the rest of the plugins applied. | ||
} | ||
|
||
rootProject.name = "build-logic" |
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,48 @@ | ||
import com.mooncloak.kodetools.kenv.Kenv | ||
import com.mooncloak.kodetools.kenv.properties | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
abstract class BuildVariablesPlugin : Plugin<Project> { | ||
|
||
override fun apply(target: Project) { | ||
projectBuildVariables[target.name] = BuildVariables( | ||
kenv = Kenv { | ||
system() | ||
properties(file = target.rootProject.layout.projectDirectory.file("library.properties").asFile) | ||
} | ||
) | ||
} | ||
} | ||
|
||
class BuildVariables internal constructor( | ||
private val kenv: Kenv | ||
) { | ||
|
||
val group: String | ||
get() = kenv["group"].value | ||
|
||
val version: String | ||
get() = kenv["version"].value | ||
|
||
val versionCode: Int | ||
get() = TODO("Use git commit count.") | ||
} | ||
|
||
val Project.buildVariables: BuildVariables | ||
get() { | ||
var variables = projectBuildVariables[this.name] | ||
|
||
if (variables == null) { | ||
this.logger.warn("The '${BuildVariablesPlugin::class.simpleName}' was not applied to project with name '${this.name}'. Attempting to load root project build variables.") | ||
} | ||
|
||
if (this != this.rootProject) { | ||
variables = projectBuildVariables[this.rootProject.name] | ||
} | ||
|
||
return variables | ||
?: error("Failed to load required build variables. Make sure the '${BuildVariablesPlugin::class.simpleName}' is applied to the project.") | ||
} | ||
|
||
private val projectBuildVariables = mutableMapOf<String, BuildVariables>() |
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,11 @@ | ||
@file:Suppress("MemberVisibilityCanBePrivate") | ||
|
||
object LibraryConstants { | ||
|
||
object Android { | ||
|
||
const val compileSdkVersion = 34 | ||
const val minSdkVersion = 21 | ||
const val targetSdkVersion = 34 | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
build-logic/src/main/kotlin/parcelable.multiplatform.gradle.kts
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,109 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl | ||
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinTest | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
} | ||
|
||
kotlin { | ||
applyDefaultHierarchyTemplate() | ||
|
||
js { | ||
browser { | ||
testTask { | ||
enabled = false | ||
} | ||
} | ||
nodejs { | ||
testTask { | ||
enabled = false | ||
} | ||
} | ||
|
||
binaries.executable() | ||
} | ||
|
||
@OptIn(ExperimentalWasmDsl::class) | ||
wasmJs { | ||
browser { | ||
testTask { | ||
enabled = false | ||
} | ||
} | ||
nodejs { | ||
testTask { | ||
enabled = false | ||
} | ||
} | ||
|
||
binaries.executable() | ||
} | ||
|
||
//@OptIn(ExperimentalWasmDsl::class) | ||
// TODO: Re-enable when library supports WASI: wasmWasi() | ||
|
||
linuxArm64() | ||
linuxX64() | ||
|
||
mingwX64() | ||
|
||
macosX64() | ||
macosArm64() | ||
|
||
iosArm64() | ||
iosX64() | ||
iosSimulatorArm64() | ||
|
||
tvosArm64() | ||
tvosX64() | ||
tvosSimulatorArm64() | ||
|
||
watchosArm32() | ||
watchosArm64() | ||
watchosX64() | ||
watchosSimulatorArm64() | ||
|
||
androidTarget { | ||
publishAllLibraryVariants() | ||
} | ||
|
||
jvm() | ||
|
||
explicitApi() | ||
|
||
// Ensure xml test reports are generated | ||
tasks.named("jvmTest", Test::class).configure { | ||
reports.junitXml.required.set(true) | ||
} | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
compilerOptions.jvmTarget = JvmTarget.JVM_11 | ||
} | ||
|
||
tasks.withType<KotlinTest> { | ||
if (targetName == "tvosSimulatorArm64" || targetName == "watchosSimulatorArm64") { | ||
enabled = false | ||
} | ||
} | ||
|
||
// Don't run npm install scripts, protects against | ||
// https://blog.jetbrains.com/kotlin/2021/10/important-ua-parser-js-exploit-and-kotlin-js/ etc. | ||
tasks.withType<KotlinNpmInstallTask> { | ||
args += "--ignore-scripts" | ||
} | ||
|
||
tasks.withType<KotlinCompilationTask<*>>().configureEach { | ||
compilerOptions { | ||
freeCompilerArgs.add("-Xexpect-actual-classes") | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
build-logic/src/main/kotlin/parcelable.publish.gradle.kts
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,118 @@ | ||
plugins { | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
version = rootProject.version | ||
group = rootProject.group | ||
|
||
afterEvaluate { | ||
publishing { | ||
repositories { | ||
maven { // TODO: Update to use mavenCentral | ||
url = uri("https://repo.repsy.io/mvn/chrynan/public") | ||
|
||
credentials { | ||
username = (project.findProperty("repsyUsername") | ||
?: System.getenv("repsyUsername")) as? String | ||
|
||
password = (project.findProperty("repsyPassword") | ||
?: System.getenv("repsyPassword")) as? String | ||
} | ||
} | ||
} | ||
|
||
if (plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) { | ||
// already has publications, just need to add javadoc task | ||
val javadocJar by tasks.creating(Jar::class) { | ||
from("javadoc") | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
publications.all { | ||
if (this is MavenPublication) { | ||
artifact(javadocJar) | ||
mavenCentralPom() | ||
} | ||
} | ||
|
||
// create task to publish all apple (macos, ios, tvos, watchos) artifacts | ||
val publishApple by tasks.registering { | ||
publications.all { | ||
if (name.contains(Regex("macos|ios|tvos|watchos"))) { | ||
val publicationNameForTask = name.replaceFirstChar(Char::uppercase) | ||
dependsOn("publish${publicationNameForTask}PublicationToSonatypeRepository") | ||
} | ||
} | ||
} | ||
} else { | ||
// Need to create source, javadoc & publication | ||
val java = extensions.getByType<JavaPluginExtension>() | ||
|
||
java.withSourcesJar() | ||
java.withJavadocJar() | ||
|
||
publications { | ||
create<MavenPublication>("lib") { | ||
from(components["java"]) | ||
mavenCentralPom() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun MavenPublication.mavenCentralPom() { | ||
pom { | ||
name.set("serialization-parcelable") | ||
description.set("Android Parcelable support for the Kotlinx Serialization library.") | ||
url.set("https://github.com/chRyNaN/serialization-parcelable") | ||
|
||
organization { | ||
url.set("https://chrynan.codes") | ||
name.set("chRyNaN") | ||
} | ||
|
||
issueManagement { | ||
url.set("https://github.com/chRyNaN/serialization-parcelable/issues") | ||
system.set("Github Issues") | ||
} | ||
|
||
licenses { | ||
license { | ||
name.set("The Apache License, Version 2.0") | ||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id.set("ckeenan") | ||
name.set("Chris Keenan") | ||
url.set("https://github.com/chRyNaN") | ||
roles.set(setOf("Primary serialization-parcelable developer. 💪")) | ||
} | ||
} | ||
|
||
scm { | ||
connection.set("https://github.com/chRyNaN/serialization-parcelable.git") | ||
developerConnection.set("https://github.com/chRyNaN/serialization-parcelable.git") | ||
url.set("https://github.com/chRyNaN/serialization-parcelable") | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
setRequired { | ||
findProperty("signing.keyId") != null | ||
} | ||
|
||
publishing.publications.all { | ||
sign(this) | ||
} | ||
} | ||
|
||
// TODO: remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed | ||
project.tasks.withType(AbstractPublishToMaven::class.java).configureEach { | ||
dependsOn(project.tasks.withType(Sign::class.java)) | ||
} |
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,12 @@ | ||
#### Dependencies and Plugin versions with their available updates. | ||
#### Generated by `./gradlew refreshVersions` version 0.60.5 | ||
#### | ||
#### Don't manually edit or split the comments that start with four hashtags (####), | ||
#### they will be overwritten by refreshVersions. | ||
#### | ||
#### suppress inspection "SpellCheckingInspection" for whole file | ||
#### suppress inspection "UnusedProperty" for whole file | ||
|
||
version.com.mooncloak.kodetools.kenv..kenv-core=1.2.0 | ||
|
||
version.kotlin=2.0.20 |
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.