Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[*]
indent_size = 2
indent_size = 4
indent_style = space
tab_width = 2
tab_width = 4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ val userColorFlow = dataStore.flow("userColor", Color.valueOf(0xFFFFFFFF), Color

License
-------
Copyright 2023 DataStore Delegates Contributors
Copyright 2026 DataStore Delegates Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
55 changes: 0 additions & 55 deletions build.gradle

This file was deleted.

49 changes: 49 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import util.TestOutput

buildscript {
repositories {
mavenCentral()
google()
}

dependencies {
classpath(libs.android.gradle)
classpath(libs.kotlin.gradle)
}
}

plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.nexus.publish)
}

allprojects {
repositories {
mavenCentral()
google()
}

tasks.withType(Test::class).configureEach {
TestOutput.configure(this)
}
}

/*
* Below is the functionality to publish the `library` module to Maven Central (Sonatype) using the
* plugin `io.github.gradle-nexus.publish-plugin`. This functionality is included in this (root)
* `build.gradle` because that's what the plugin expects; if this changes in the future then we
* should migrate this functionality into the `publish.gradle` file instead.
*/
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = System.getenv("SONATYPE_TOKEN_USERNAME")
password = System.getenv("SONATYPE_TOKEN_PASSWORD")
}
}
}
8 changes: 8 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
`kotlin-dsl`
}

repositories {
google()
mavenCentral()
}
File renamed without changes.
47 changes: 47 additions & 0 deletions buildSrc/src/main/kotlin/release/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package release

import groovy.util.Node
import org.gradle.api.artifacts.ConfigurationContainer
import org.gradle.api.artifacts.Dependency
import org.gradle.kotlin.dsl.get

object Dependencies {

fun appendAll(
node: Node,
configurations: ConfigurationContainer,
) {
configurations["api"].dependencies.forEach { dependency ->
append(
dependency = dependency,
node = node,
scope = "compile"
)
}

configurations["implementation"].dependencies.forEach { dependency ->
append(
dependency = dependency,
node = node,
scope = "runtime"
)
}
}

private fun append(
dependency: Dependency,
node: Node,
scope: String
) {
if (dependency.name == "unspecified" || dependency.group == null || dependency.version == null) {
return
}

with(node.appendNode("dependency")) {
appendNode("groupId", dependency.group)
appendNode("artifactId", dependency.name)
appendNode("version", dependency.version)
appendNode("scope", scope)
}
}
}
15 changes: 15 additions & 0 deletions buildSrc/src/main/kotlin/release/LibraryInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package release

data class LibraryInfo(
val artifactId: String,
val groupId: String,
val version: Version,
) {
data class Version(
val major: Int,
val minor: Int,
val patch: Int,
) {
val name = "${major}.${minor}.${patch}"
}
}
74 changes: 74 additions & 0 deletions buildSrc/src/main/kotlin/release/PublicationManager.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package release

import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.MavenPublication

object PublicationManager {
@JvmStatic
fun configure(
project: Project,
publication: MavenPublication,
vararg artifacts: Any,
) {
val libraryInfo = ReleaseInfo.getLibraryInfo(project)

project.group = libraryInfo.groupId
project.version = libraryInfo.version.name

publication.apply {
groupId = libraryInfo.groupId
artifactId = libraryInfo.artifactId
version = libraryInfo.version.name

setArtifacts(artifacts.asIterable())

pom {
configure(
libraryInfo = libraryInfo,
project = project
)
}
}
}

private fun MavenPom.configure(
libraryInfo: LibraryInfo,
project: Project,
) {
description?.set("Property Delegation for the AndroidX DataStore")
name?.set(libraryInfo.groupId + ":" + libraryInfo.artifactId)
url?.set("https://github.com/brianwernick/DataStoreDelegates")

developers {
developer {
name?.set("Brian Wernick")
email?.set("brian@devbrackets.com")
organization?.set("DevBrackets")
organizationUrl?.set("https://devbrackets.com")
}
}

licenses {
license {
name?.set("The Apache License, Version 2.0")
url?.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

scm {
connection?.set("scm:git:github.com/brianwernick/DataStoreDelegates.git")
developerConnection?.set("scm:git:ssh://github.com/brianwernick/DataStoreDelegates.git")
url?.set("https://github.com/brianwernick/DataStoreDelegates/tree/main")
}

// The generated POM doesn't include dependencies for Android artifacts,
// so we manually add them here
withXml {
Dependencies.appendAll(
node = asNode().appendNode("dependencies"),
configurations = project.configurations
)
}
}
}
38 changes: 38 additions & 0 deletions buildSrc/src/main/kotlin/release/ReleaseInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package release

import org.gradle.api.Project
import java.io.File
import java.util.Properties

object ReleaseInfo {
private const val KEY_ARTIFACT_ID = "ARTIFACT_ID"
private const val KEY_GROUP_ID = "GROUP_ID"

private const val KEY_VERSION_MAJOR = "VERSION_MAJOR"
private const val KEY_VERSION_MINOR = "VERSION_MINOR"
private const val KEY_VERSION_PATCH = "VERSION_PATCH"

fun getLibraryInfo(project: Project): LibraryInfo {
val properties = readProperties(project)

val version = LibraryInfo.Version(
major = properties[KEY_VERSION_MAJOR].toString().toInt(),
minor = properties[KEY_VERSION_MINOR].toString().toInt(),
patch = properties[KEY_VERSION_PATCH].toString().toInt()
)

return LibraryInfo(
artifactId = properties[KEY_ARTIFACT_ID].toString(),
groupId = properties[KEY_GROUP_ID].toString(),
version = version
)
}

private fun readProperties(project: Project): Properties {
val file = File("${project.rootDir}/buildSrc/libraryInfo.properties")

return Properties().apply {
load(file.inputStream())
}
}
}
12 changes: 12 additions & 0 deletions buildSrc/src/main/kotlin/util/ProjectConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package util

import org.gradle.api.JavaVersion

@Suppress("ConstPropertyName")
object ProjectConfig {
const val compileSdk = 37
const val minSdk = 23
const val targetSdk = compileSdk

val javaVersion = JavaVersion.VERSION_11
}
Loading
Loading