Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #144 from SURFnet/feature/TIQR-211_maven_accessibl…
Browse files Browse the repository at this point in the history
…e_core

Tiqr 211: Make core and data accessible through maven central
  • Loading branch information
sarahachem authored Nov 11, 2021
2 parents 4e5b925 + 124e9a9 commit 0db7b22
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 6 deletions.
32 changes: 28 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
name: Publish

on:
workflow_dispatch:
workflow_dispatch: # Allow manually triggering this workflow
release:
# We'll run this workflow when a new GitHub release is created
types: [released]

jobs:
my-job:
publish:
name: Release build and publish
runs-on: ubuntu-latest
steps:
- name: my-step
run: echo "Hello World!"
- name: Check out code
uses: actions/checkout@v2

# Builds the release artifacts of the library
- name: Release build
run: ./gradlew :tiqr-client-android:assembleRelease

# Generates other artifacts
- name: Source jar
run: ./gradlew androidSourcesJar

# Runs upload, and then closes & releases the repository
- name: Publish to MavenCentral
run: ./gradlew publishMavenAndroidPublicationToSonatypeRepository --max-workers 1
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
105 changes: 103 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import java.util.Properties

plugins {
id("com.android.library")
kotlin("android")
kotlin("kapt")
id("kotlin-parcelize")
id("dagger.hilt.android.plugin")
id("androidx.navigation.safeargs.kotlin")
`maven-publish`
signing
}

android {
Expand Down Expand Up @@ -47,6 +51,17 @@ android {
jvmTarget = "1.8"
}
}
}

fun loadCustomProperties(file: File): java.util.Properties {
val properties = Properties()
if (file.isFile) {
properties.load(file.inputStream())
}
return properties
}

val secureProperties = loadCustomProperties(file("../local.properties"))

dependencies {
implementation(libs.kotlin.stdlib)
Expand Down Expand Up @@ -96,7 +111,93 @@ android {
androidTestImplementation(libs.androidx.testing.uiautomator)
androidTestImplementation(libs.kotlinx.coroutines.test)

androidTestImplementation(libs.dagger.hilt.testing)
kaptAndroidTest(libs.dagger.hilt.compiler)
androidTestImplementation(libs.dagger.hilt.testing)
kaptAndroidTest(libs.dagger.hilt.compiler)
}

group = "org.tiqr"
version = "0.0.7-SNAPSHOT"

tasks {
register("sourcesJar", Jar::class) {
archiveClassifier.set("sources")
from(android.sourceSets.getByName("main").java.srcDirs)
}
}
publishing {
publications {
register<MavenPublication>("mavenAndroid") {
artifactId = "core"

afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) }
artifact(tasks.getByName("sourcesJar"))

pom {
name.set("core")
url.set("https://github.com/SURFnet/tiqr-app-core-android")
description.set("refactoring original tiqr project")
developers {
developer {
name.set("sara hachem")
email.set("[email protected]")
}
developer {
name.set("Dmitry Kovalenko")
email.set("[email protected]")
}
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("https://github.com/SURFnet/tiqr-app-core-android.git")
url.set("https://github.com/SURFnet/tiqr-app-core-android")
}

withXml {
fun groovy.util.Node.addDependency(dependency: Dependency, scope: String) {
appendNode("dependency").apply {
appendNode("groupId", dependency.group)
appendNode("artifactId", dependency.name)
appendNode("version", dependency.version)
appendNode("scope", scope)
}
}

asNode().appendNode("dependencies").let { dependencies ->
// List all "api" dependencies as "compile" dependencies
configurations.api.get().allDependencies.forEach {
dependencies.addDependency(it, "compile")
}
// List all "implementation" dependencies as "runtime" dependencies
configurations.implementation.get().allDependencies.forEach {
dependencies.addDependency(it, "runtime")
}
}
}
}
}
}

repositories {
maven {
name = "sonatype"
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotRepo = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotRepo else releasesRepoUrl)
credentials {
username = secureProperties.getProperty("USERNAME")
password =secureProperties.getProperty("PASSWORD")
}
}
}


signing {
useGpgCmd()
sign(publishing.publications["mavenAndroid"])
}
}
101 changes: 101 additions & 0 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import java.util.Properties

plugins {
id("com.android.library")
kotlin("android")
kotlin("kapt")
id("kotlin-parcelize")
id("dagger.hilt.android.plugin")
`maven-publish`
signing
}

val secureProperties = loadCustomProperties(file("../local.properties"))

fun loadCustomProperties(file: File): java.util.Properties {
val properties = Properties()
if (file.isFile) {
properties.load(file.inputStream())
}
return properties
}

android {
Expand Down Expand Up @@ -96,3 +110,90 @@ android {
androidTestImplementation(libs.kotlinx.coroutines.test)
}
}

group = "org.tiqr"
version = "0.0.3-SNAPSHOT"

tasks {
register("sourcesJar", Jar::class) {
archiveClassifier.set("sources")
from(android.sourceSets.getByName("main").java.srcDirs)
}
}
publishing {
publications {
register<MavenPublication>("mavenAndroid") {
artifactId = "data"

afterEvaluate { artifact(tasks.getByName("bundleReleaseAar")) }
artifact(tasks.getByName("sourcesJar"))

pom {
name.set("data")
url.set("https://github.com/SURFnet/tiqr-app-core-android")
description.set("refactoring original tiqr project")
developers {
developer {
name.set("sara hachem")
email.set("[email protected]")
}
developer {
name.set("Dmitry Kovalenko")
email.set("[email protected]")
}
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("https://github.com/SURFnet/tiqr-app-core-android.git")
url.set("https://github.com/SURFnet/tiqr-app-core-android")
}

withXml {
fun groovy.util.Node.addDependency(dependency: Dependency, scope: String) {
appendNode("dependency").apply {
appendNode("groupId", dependency.group)
appendNode("artifactId", dependency.name)
appendNode("version", dependency.version)
appendNode("scope", scope)
}
}

asNode().appendNode("dependencies").let { dependencies ->
// List all "api" dependencies as "compile" dependencies
configurations.api.get().allDependencies.forEach {
dependencies.addDependency(it, "compile")
}
// List all "implementation" dependencies as "runtime" dependencies
configurations.implementation.get().allDependencies.forEach {
dependencies.addDependency(it, "runtime")
}
}
}
}
}
}

repositories {
maven {
name = "sonatype"
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotRepo = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotRepo else releasesRepoUrl)
credentials {
username = secureProperties.getProperty("USERNAME")
password =secureProperties.getProperty("PASSWORD")
}
}
}


signing {
useGpgCmd()
sign(publishing.publications["mavenAndroid"])
}
}

0 comments on commit 0db7b22

Please sign in to comment.