Skip to content

Commit

Permalink
Migrate from jetpack compose to compose multiplatform
Browse files Browse the repository at this point in the history
dependencies update
  • Loading branch information
tahaak67 committed Sep 7, 2023
1 parent ba2f192 commit d19df6e
Show file tree
Hide file tree
Showing 22 changed files with 203 additions and 278 deletions.
19 changes: 3 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

name: Release build and publish

runs-on: ubuntu-latest
runs-on: macos-latest

steps:

Expand All @@ -35,25 +35,12 @@ jobs:
java-version: 17


# Builds the release artifacts of the library

- name: Release build

run: ./gradlew :showcase-layout-compose:assembleRelease


# Generates other artifacts

- name: Source jar and dokka

run: ./gradlew androidSourcesJar


# Runs upload, and then closes & releases the repository

- name: Publish to MavenCentral

run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
run: ./gradlew publishToSonatype --max-workers 1 closeAndReleaseSonatypeStagingRepository


env:

Expand Down
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ buildscript {
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
//id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '8.1.1' apply false
id 'org.jetbrains.kotlin.android' version '1.9.0' apply false
id 'org.jetbrains.kotlin.multiplatform' version '1.9.0' apply false
id 'org.jetbrains.compose' version '1.5.0' apply false
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}

Expand Down
7 changes: 7 additions & 0 deletions convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl` // Is needed to turn our build logic written in Kotlin into the Gradle Plugin
}

repositories {
gradlePluginPortal() // To use 'maven-publish' and 'signing' plugins in our own plugin
}
119 changes: 119 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,119 @@
import java.util.Properties

plugins {
`maven-publish`
signing
}

// Stub secrets to let the project sync and build without the publication values set up

ext["signingKeyId"] = null
ext["signingPassword"] = null
ext["signingKey"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null

val publishGroupId: String = "ly.com.tahaben"
val publishVersion: String = "1.0.5-beta"
val publishArtifactId: String = "showcase-layout-compose"


// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
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["signingKeyId"] = System.getenv("SIGNING_KEY_ID")
ext["signingPassword"] = System.getenv("SIGNING_PASSWORD")
ext["signingKey"] = System.getenv("SIGNING_KEY")
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}

fun getExtraString(name: String) = ext[name]?.toString()


group = publishGroupId
version = publishVersion

println("group: $group ,version: $version")

publishing {
// Configure maven central repository
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}

// Configure all publications
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(javadocJar.get())

groupId = publishGroupId
artifactId = publishArtifactId
version = publishVersion

println("publish group id $groupId")
println("publish artifact id $artifactId")
println("publish version $version")

// Provide artifacts information requited by Maven Central
pom {
name.set(getExtraString("signingKeyId"))
description.set("Showcase Layout allows you to easily showcase and explain compose UI elements to users in a beautiful and attractive way.")
url.set("https://github.com/tahaak67/ShowcaseLayoutCompose")

licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("tahaak67")
name.set("Taha Ben Ashur")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/tahaak67/ShowcaseLayoutCompose/tree/main")
developerConnection.set("scm:git:ssh://github.com/tahaak67/ShowcaseLayoutCompose.git")
connection.set("scm:git:github.com/tahaak67/ShowcaseLayoutCompose.git")
}
}
}
}

// Signing artifacts. Signing extra properties values will be used

signing {
useInMemoryPgpKeys(
getExtraString("signingKeyId"),
getExtraString("signingKey"),
getExtraString("signingPassword"),
)
sign(publishing.publications)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

#Compose
org.jetbrains.compose.experimental.uikit.enabled=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Sep 03 12:32:11 EET 2023
#Tue Sep 05 13:36:22 EET 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
155 changes: 0 additions & 155 deletions scripts/publish-module.gradle

This file was deleted.

6 changes: 5 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ pluginManagement {
mavenCentral()
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
Expand All @@ -15,3 +18,4 @@ dependencyResolutionManagement {
rootProject.name = "Showcase Layout Compose"
include ':app'
include ':showcase-layout-compose'
includeBuild("convention-plugins")
Loading

0 comments on commit d19df6e

Please sign in to comment.