Skip to content

Commit

Permalink
chore: prepare for 2.0.0-rc01 release
Browse files Browse the repository at this point in the history
- Adds maven publishing configuration for both the library and the Gradle plugin.
- Updates the version in `app.properties` to `2.0.0-rc01`.
- Adds necessary metadata to the POM files, including project description, licenses, developers, and SCM information.
- Configures publishing to Maven Central using the SonatypeHost.CENTRAL_PORTAL.
- Adds signing for all publications.
- Makes the `main` function in `Main.kt` private, as it's only for debugging purposes.
- Refactors project properties into a dedicated class.
  • Loading branch information
rafaeltonholo committed Nov 23, 2024
1 parent 7a4bc00 commit f81fd84
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ temp.kt
integrity-check/
local.properties
.s2c/
publishing.properties

github_issue_[0-9]*.svg

Expand Down
2 changes: 1 addition & 1 deletion app.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=2.0.0-alpha01
VERSION=2.0.0-rc01
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import dev.tonholo.s2c.conventions.AppProperties

plugins {
id("dev.tonholo.s2c.conventions.publication")
id("dev.tonholo.s2c.conventions.detekt")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("dev.tonholo.s2c.conventions.common")
id("dev.tonholo.s2c.conventions.publication")
org.jetbrains.kotlin.jvm
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
id("dev.tonholo.s2c.conventions.common")
org.jetbrains.kotlin.multiplatform
com.github.gmazzo.buildconfig
id("dev.tonholo.s2c.conventions.publication")
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.vanniktech.maven.publish.SonatypeHost

plugins {
com.vanniktech.maven.publish
}
Expand All @@ -10,3 +12,40 @@ publishing {
}
}
}

mavenPublishing {
coordinates(
groupId = group.toString(),
artifactId = project.name,
version = version.toString(),
)
pom {
inceptionYear.set("2024")
url.set("https://github.com/rafaeltonholo/svg-to-compose")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}

developers {
developer {
id.set("rafaeltonholo")
name.set("Rafael Tonholo")
email.set("rafael@tonholo.dev")
}
}

scm {
url.set("https://github.com/rafaeltonholo/svg-to-compose")
connection.set("scm:git:git://github.com/rafaeltonholo/svg-to-compose.git")
developerConnection.set("scm:git:ssh://git@github.com/rafaeltonholo/svg-to-compose.git")
}
}

publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

signAllPublications()
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,14 @@
package dev.tonholo.s2c.conventions

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

private const val GROUP = "dev.tonholo.s2c"

internal object AppProperties {
private var _appProperties: Properties? = null
private val appProperties
get() = requireNotNull(_appProperties) {
"Missing app.properties initialization. " +
"Did you miss applying the 'dev.tonholo.s2c.conventions.common' in the current project?"
}
internal object AppProperties : ProjectProperties(
propertiesName = "app.properties",
ownerPluginName = "dev.tonholo.s2c.conventions.common",
) {
val group: String get() = GROUP
val version: String
get() = requireNotNull(appProperties["VERSION"]?.toString()) {
get() = requireNotNull(properties["VERSION"]?.toString()) {
"VERSION property not found in app.properties"
}

fun init(project: Project) {
val propertiesFile = project
.file("app.properties")
.takeIf { it.exists() }
check(propertiesFile != null) {
"The app.properties file is missing in the root project."
}
try {
propertiesFile
.reader()
.use { reader ->
_appProperties = Properties().apply { load(reader) }
}
} catch (e: IOException) {
throw IllegalStateException("Failed to read properties from app.properties", e)
}
}

inline fun forEach(action: (Map.Entry<String, Any>) -> Unit) {
appProperties
.mapKeys { (key, _) -> key.toString() }
.forEach(action)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package dev.tonholo.s2c.conventions

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

internal abstract class ProjectProperties(
private val propertiesName: String,
private val ownerPluginName: String,
) {
private var _properties: Properties? = null
val properties
get() = requireNotNull(_properties) {
"Missing app.properties initialization. " +
"Did you miss applying the '$ownerPluginName' in the current project?"
}

open fun init(project: Project) {
val propertiesFile = project
.file(propertiesName)
.takeIf { it.exists() }
check(propertiesFile != null) {
"The $propertiesName file is missing in the root project."
}
try {
propertiesFile
.reader()
.use { reader ->
_properties = Properties().apply { load(reader) }
}
} catch (e: IOException) {
throw IllegalStateException("Failed to read properties from app.properties", e)
}
}

inline fun forEach(action: (Map.Entry<String, Any>) -> Unit) {
properties
.mapKeys { (key, _) -> key.toString() }
.forEach(action)
}
}
16 changes: 16 additions & 0 deletions svg-to-compose-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.vanniktech.maven.publish.GradlePlugin
import com.vanniktech.maven.publish.JavadocJar

plugins {
`kotlin-dsl`
dev.tonholo.s2c.conventions.gradle.plugin
Expand All @@ -19,6 +22,19 @@ kotlin {
compilerOptions.freeCompilerArgs.add("-Xcontext-receivers")
}

mavenPublishing {
configure(
GradlePlugin(
javadocJar = JavadocJar.Dokka("dokkaGenerate"),
sourcesJar = true,
)
)
pom {
name.set("SVG/XML to Compose Gradle Plugin")
description.set("A Gradle plugin that converts SVG or an Android Vector Drawable (AVG) to Android Jetpack Compose Icons.")
}
}

dokka {
moduleName.set("SVG/XML to Compose Gradle Plugin")
}
Expand Down
18 changes: 18 additions & 0 deletions svg-to-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform

plugins {
dev.tonholo.s2c.conventions.kmp
dev.tonholo.s2c.conventions.testing
Expand All @@ -22,6 +25,21 @@ kotlin {
}
}

mavenPublishing {
mavenPublishing {
configure(
KotlinMultiplatform(
javadocJar = JavadocJar.Dokka("dokkaGenerate"),
sourcesJar = true,
)
)
}
pom {
name.set("SVG/XML to Compose Library")
description.set("A KMP Library that converts SVG or an Android Vector Drawable (AVG) to Android Jetpack Compose Icons.")
}
}

dokka {
moduleName.set("SVG/XML to Compose Library")
}
2 changes: 1 addition & 1 deletion svg-to-compose/src/jvmMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlin.system.exitProcess
* This is only for debugging purposes.
* Should never be used in production.
*/
fun main() {
private fun main() {
AppConfig.debug = true
AppConfig.silent = false
val suffix = "63"
Expand Down

0 comments on commit f81fd84

Please sign in to comment.