Skip to content

Commit

Permalink
Switch to package publication on Github Packages. Switch from kap to …
Browse files Browse the repository at this point in the history
…ksp for Room. Use lib dependency from Maven Central in driver demo.

Signed-off-by: ingonoka <ingonoka@icloud.com>
  • Loading branch information
ingonoka committed Mar 6, 2024
1 parent b0eebd8 commit 535748b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
46 changes: 26 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,32 @@ buildscript {

plugins {

// id("maven-publish")
id("org.asciidoctor.jvm.convert")
id("org.jetbrains.dokka")
// id("org.jetbrains.kotlin.android") version "${project.properties["kotlin_version"].toString()}"
// id 'com.android.application' version '7.0.4' apply false
id("com.google.devtools.ksp") version "1.8.10-1.0.9" apply false
}

fun getVersionCode() = try {
/**
* Number of commits from the start of this repository
*/
fun getVersionCode(): Int = try {
val stdout = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-list", "--first-parent", "--count", "master")
commandLine =
listOf("git", "rev-list", "--first-parent", "--count", "master")
standardOutput = stdout
}
Integer.parseInt(stdout.toString().trim())
} catch (e: Exception) {
-1
}

fun getVersionName() = try {
/**
* Get a version name of the form "v0.3-8-g9518e52", which is the tag
* assigned to the commit (v0.3), the number of commits since the
* commit the tag is assigned to and the hash of the latest commit
*/
fun getVersionName(): String = try {
val stdout = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "describe", "--tags") //, '--long'
Expand All @@ -57,19 +64,25 @@ fun getVersionName() = try {
extra.apply {
set("domain", "com.ingonoka")
set("pom_developer", "Ingo Noka")
set("pom_licenseName", "Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)")
set("pom_licenseUrl", "https://creativecommons.org/licenses/by-nc-nd/4.0/")
set("group","com.ingonoka")
set("versionName", getVersionName() ?: "na")
set("versionCode", getVersionCode() ?: 0)
set(
"pom_licenseName",
"Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)"
)
set(
"pom_licenseUrl",
"https://creativecommons.org/licenses/by-nc-nd/4.0/"
)
set("group", "com.ingonoka")
set("versionName", getVersionName())
set("versionCode", getVersionCode())
}

group = "com.ingonoka"


tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(buildDir.resolve("$buildDir/dokka"))
moduleName.set("NFC Adapter for Android")
outputDirectory.set(layout.buildDirectory.file("dokka").get().asFile)
moduleName.set("CBA9 Driver for Android")
includes.from("module.md")
}

Expand All @@ -83,12 +96,5 @@ asciidoctorj {

tasks {
"asciidoctor"(AsciidoctorTask::class) {
// baseDirFollowsSourceDir()
// sourceDir = buildDir.resolve("docs")
// outputDir.set(buildDir.resolve("build/docs"))
//
// attributes["source-highlighter"] = "rouge"
//
// attributes["revnumber"] = getVersionName()
}
}
4 changes: 2 additions & 2 deletions cba9driverdemo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ dependencies {

implementation("org.slf4j:slf4j-api:${providers.gradleProperty("slf4j_version").get()}")
implementation("com.github.tony19:logback-android:${providers.gradleProperty("logback_android_version").get()}")
// implementation "com.ingonoka:cba9-driver:v0.1-0-g1af64e1"
implementation("com.ingonoka:cba9driver:v0.3-8-g9518e52")

implementation(project(":lib"))
// implementation(project(":lib"))
}
20 changes: 15 additions & 5 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("kotlin-kapt")
// id("kotlin-kapt")
id("com.google.devtools.ksp")
id("maven-publish")
id("signing")
id("org.asciidoctor.jvm.convert")
Expand All @@ -33,7 +34,6 @@ android {
defaultConfig {

minSdk = project.properties["android_min_sdk_version"].toString().toInt()
targetSdk = project.properties["android_target_sdk_version"].toString().toInt()
resourceConfigurations.addAll(listOf("en", "de"))

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -82,7 +82,8 @@ dependencies {
implementation("org.slf4j:slf4j-api:${providers.gradleProperty("slf4j_version").get()}")

implementation("androidx.room:room-ktx:${providers.gradleProperty("room_version").get()}")
kapt("androidx.room:room-compiler:${providers.gradleProperty("room_version").get()}")
// kapt("androidx.room:room-compiler:${providers.gradleProperty("room_version").get()}")
ksp("androidx.room:room-compiler:${providers.gradleProperty("room_version").get()}")

}

Expand All @@ -105,7 +106,7 @@ afterEvaluate {

register<MavenPublication>("debug") {
groupId = "com.ingonoka"
artifactId = "cba9driver"
artifactId = "cba9driver-debug"
version = version.toString()

from(components["debug"])
Expand Down Expand Up @@ -148,13 +149,22 @@ afterEvaluate {
password = providers.gradleProperty("sonatype_pw").get()
}
}

maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/ingonoka/cba9-driver")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
}
}
}
}
}
}

tasks.dokkaHtmlPartial.configure {
outputDirectory.set(buildDir.resolve("$buildDir/dokka"))
outputDirectory.set(layout.buildDirectory.file("dokka").get().asFile)
moduleName.set("NFC Adapter for Android")
dokkaSourceSets {
configureEach {
Expand Down

0 comments on commit 535748b

Please sign in to comment.