From 6156e9457f48c3b20b8c85c9015959ba3ab6dcd5 Mon Sep 17 00:00:00 2001 From: Gergely Hegedus Date: Tue, 12 Jul 2022 12:58:01 +0300 Subject: [PATCH] Issue#67 Define deployment of libraries to GitHub --- gradle.properties | 3 +- gradlescripts/deploy.aar.gradle | 44 +++++++++++++++++++++++ gradlescripts/versions.gradle | 1 - test-util-android/build.gradle | 5 ++- test-util-junit5-android/build.gradle | 5 ++- test-util-shared-android/build.gradle | 4 ++- test-util-shared-robolectric/build.gradle | 5 ++- 7 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 gradlescripts/deploy.aar.gradle diff --git a/gradle.properties b/gradle.properties index dbc9506..c3dcb2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,5 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=false # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +android.disableAutomaticComponentCreation=true diff --git a/gradlescripts/deploy.aar.gradle b/gradlescripts/deploy.aar.gradle new file mode 100644 index 0000000..6ab3795 --- /dev/null +++ b/gradlescripts/deploy.aar.gradle @@ -0,0 +1,44 @@ +apply plugin: "maven-publish" + +def testUtilVersion = "1.0.0" +if (!extensions.extraProperties.has("artifactId")) { + throw IllegalStateException("ext.artifactId is not set while applying deploy script") +} +def testUtilGroupId = "org.fnives.android.testutil" +def testUtilArtifactId = extensions.extraProperties.get("artifactId") + +task publishToGitHub(dependsOn: "publishMavenAarPublicationToGitHubPackagesRepository") { + group = "Publishing" +} + +task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier "sources" +} + +afterEvaluate { + publishing { + publications { + mavenAar(MavenPublication) { + from components.release + + groupId "$testUtilGroupId" + println("$testUtilArtifactId") + version "$testUtilVersion" + artifactId "$testUtilArtifactId" + artifact sourcesJar + } + } + + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/fknives/AndroidTest-ShowCase") + credentials { + username = System.getenv("GITHUB_USERNAME") + password = System.getenv("GITHUB_TOKEN") + } + } + } + } +} \ No newline at end of file diff --git a/gradlescripts/versions.gradle b/gradlescripts/versions.gradle index 7c1f9da..ff127d6 100644 --- a/gradlescripts/versions.gradle +++ b/gradlescripts/versions.gradle @@ -27,7 +27,6 @@ project.ext { arch_core_version = "2.1.0" testing_livedata_version = "1.2.0" mockito_version = "4.0.0" - println("MYLOG versions set") junit5_version = "5.7.0" json_assert_version = "1.5.0" junit4_version = "4.13.2" diff --git a/test-util-android/build.gradle b/test-util-android/build.gradle index 4f1819a..160e628 100644 --- a/test-util-android/build.gradle +++ b/test-util-android/build.gradle @@ -44,4 +44,7 @@ dependencies { implementation "com.google.android.material:material:$androidx_material_version" implementation "androidx.swiperefreshlayout:swiperefreshlayout:$androidx_swiperefreshlayout_version" implementation "androidx.core:core-ktx:$androidx_core_version" -} \ No newline at end of file +} + +ext.artifactId = "android" +apply from: "../gradlescripts/deploy.aar.gradle" \ No newline at end of file diff --git a/test-util-junit5-android/build.gradle b/test-util-junit5-android/build.gradle index f700de7..6e2f11a 100644 --- a/test-util-junit5-android/build.gradle +++ b/test-util-junit5-android/build.gradle @@ -37,4 +37,7 @@ dependencies { implementation "androidx.arch.core:core-runtime:$arch_core_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" -} \ No newline at end of file +} + +ext.artifactId = "android-unit-junit5" +apply from: "../gradlescripts/deploy.aar.gradle" \ No newline at end of file diff --git a/test-util-shared-android/build.gradle b/test-util-shared-android/build.gradle index 36a2f69..1e4f84f 100644 --- a/test-util-shared-android/build.gradle +++ b/test-util-shared-android/build.gradle @@ -35,5 +35,7 @@ android { dependencies { implementation "androidx.room:room-testing:$room_version" api project(':test-util-shared-robolectric') +} -} \ No newline at end of file +ext.artifactId = "shared-android" +apply from: "../gradlescripts/deploy.aar.gradle" \ No newline at end of file diff --git a/test-util-shared-robolectric/build.gradle b/test-util-shared-robolectric/build.gradle index 8bcb73a..b6cc483 100644 --- a/test-util-shared-robolectric/build.gradle +++ b/test-util-shared-robolectric/build.gradle @@ -35,4 +35,7 @@ android { dependencies { implementation "androidx.room:room-testing:$room_version" implementation "androidx.arch.core:core-testing:$arch_core_version" -} \ No newline at end of file +} + +ext.artifactId = "shared-robolectric" +apply from: "../gradlescripts/deploy.aar.gradle" \ No newline at end of file