Skip to content

Commit

Permalink
chore: Setup publication
Browse files Browse the repository at this point in the history
  • Loading branch information
charlee-dev committed Feb 23, 2024
1 parent dc4a689 commit 5da9671
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 75 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plugins {
id("root.publication")
alias(libs.plugins.kotlinMultiplatform).apply(false)
id("org.jetbrains.dokka") version libs.versions.dokka apply false
}
8 changes: 6 additions & 2 deletions convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

dependencies {
implementation(libs.nexus.publish)
}
implementation(libs.dokka)
}
25 changes: 25 additions & 0 deletions convention-plugins/src/main/kotlin/AppConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2024 Adrian Witaszak - CharLEE-X. Use of this source code is governed by the Apache 2.0 license.
*/

object AppConfig {
const val projectName = "MaterialWeb-ComposeHtml"
const val groupId = "com.charleex"
const val artifactId = "material-web-compose-html"
const val version = "0.0.1"
const val description = "Kotlin Multiplatform library "
const val url = "https://github.com/CharLEE-X/notifiKations"

object Developer {
const val id = "charlee-dev"
const val name = "Adrian Witaszak"
const val email = "[email protected]"
const val organization = "CharLEE-X"
const val organizationUrl = "https://github.com/CharLEE-X"
}

object Licence {
const val name = "Apache 2.0 license"
const val url = "https://www.apache.org/licenses/LICENSE-2.0"
}
}
114 changes: 114 additions & 0 deletions convention-plugins/src/main/kotlin/convention.publication.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Copyright (c) 2024 Adrian Witaszak - CharLEE-X. Use of this source code is governed by the Apache 2.0 license.
*/

import java.util.Properties

plugins {
`maven-publish`
signing
id("org.jetbrains.dokka")
}

ext["signing.key"] = null
ext["signing.password"] = null
ext["ossrh.username"] = null
ext["ossrh.password"] = null

val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
secretPropsFile.reader().use {
Properties().apply {
load(it)
}
}.onEach { (name, value) ->
ext[name.toString()] = value
}
} else {
ext["signing.key"] = System.getenv("SIGNING_KEY")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["ossrh.username"] = System.getenv("OSSRH_USERNAME")
ext["ossrh.password"] = System.getenv("OSSRH_PASSWORD")
}

val dokkaOutputDir = "$buildDir/dokka"

tasks.dokkaHtml {
outputDirectory.set(file(dokkaOutputDir))
}

val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
delete(dokkaOutputDir)
}

val javadocJar = tasks.register<Jar>("javadocJar") {
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
dependsOn(signingTasks)
}

afterEvaluate {
publishing {
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(tasks.register("${name}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
archiveAppendix.set(this@withType.name)
})

// Provide artifacts information required by Maven Central
pom {
name.set(AppConfig.projectName)
description.set(AppConfig.description)
url.set(AppConfig.url)

licenses {
license {
name.set(AppConfig.Licence.name)
url.set(AppConfig.Licence.url)
}
}
developers {
developer {
id.set(AppConfig.Developer.id)
name.set(AppConfig.Developer.name)
email.set(AppConfig.Developer.email)
organization.set(AppConfig.Developer.organization)
organizationUrl.set(AppConfig.Developer.organizationUrl)
}
}
scm {
url.set(AppConfig.url)
}
}
}
}
}

signing {
useInMemoryPgpKeys(
getExtraString("signing.key"),
getExtraString("signing.password")
)
sign(publishing.publications)
}

fun getExtraString(name: String): String = ext[name]?.toString()
?: findProperty(name)?.toString()
?: System.getenv(name)?.toString()
?: ""
51 changes: 0 additions & 51 deletions convention-plugins/src/main/kotlin/module.publication.gradle.kts

This file was deleted.

19 changes: 0 additions & 19 deletions convention-plugins/src/main/kotlin/root.publication.gradle.kts

This file was deleted.

4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
[versions]
compose = "1.5.12"
dokka = "1.8.20"
kobweb = "0.16.2"
kotlin = "1.9.22"
materialWeb = "v1.2.0"
nexus-publish = "2.0.0-rc-1"

[libraries]
dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }

kobweb-core = { module = "com.varabyte.kobweb:kobweb-core ", version.ref = "kobweb" }
kobweb-silk = { module = "com.varabyte.kobweb:kobweb-silk", version.ref = "kobweb" }
kobwebx-markdown = { module = "com.varabyte.kobwebx:kobwebx-markdown", version.ref = "kobweb" }

silk-foundation = { module = "com.varabyte.kobweb:silk-foundation", version.ref = "kobweb" }
silk-icons-fa = { module = "com.varabyte.kobwebx:silk-icons-fa", version.ref = "kobweb" }
silk-icons-mdi = { module = "com.varabyte.kobwebx:silk-icons-mdi", version.ref = "kobweb" }
Expand Down
6 changes: 4 additions & 2 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.jetbrainsCompose)
id("module.publication")
id("convention.publication")
}

group = "${AppConfig.groupId}.${AppConfig.artifactId}"
version = AppConfig.version

kotlin {
applyDefaultHierarchyTemplate()

Expand All @@ -15,7 +18,6 @@ kotlin {
}
}
}
// binaries.executable()
}

sourceSets {
Expand Down

0 comments on commit 5da9671

Please sign in to comment.