From 1bd15989db6bd4b9d6edf048a375ae87dbc327c5 Mon Sep 17 00:00:00 2001 From: toxicbakery Date: Tue, 22 Jan 2019 00:35:58 -0500 Subject: [PATCH] Moved Android to its own module in attempt to fix deps --- .circleci/config.yml | 24 ++-- build.gradle | 4 + common/android/.gitignore | 6 + common/android/build.gradle | 81 ++++++++++++ common/android/gradle.properties | 1 + .../com/toxicbakery/logging/LogCatSeedling.kt | 0 .../toxicbakery/logging/LogCatSeedlingTest.kt | 0 .../src/main/AndroidManifest.xml | 0 common/build.gradle | 116 +++++++----------- examples/android/.gitignore | 2 + examples/android/build.gradle | 2 +- examples/build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 2 +- 14 files changed, 153 insertions(+), 89 deletions(-) create mode 100644 common/android/.gitignore create mode 100644 common/android/build.gradle create mode 100644 common/android/gradle.properties rename common/{ => android}/src/androidMain/kotlin/com/toxicbakery/logging/LogCatSeedling.kt (100%) rename common/{ => android}/src/androidTest/kotlin/com/toxicbakery/logging/LogCatSeedlingTest.kt (100%) rename common/{ => android}/src/main/AndroidManifest.xml (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 16c1f3e..41cc803 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,26 +20,26 @@ jobs: command: | echo "org.gradle.parallel=false" >> gradle.properties echo "kotlin.incremental=false" >> gradle.properties - if [ "master" = "$CIRCLE_BRANCH" ] || [ ! -z "$CIRCLE_TAG" ]; then + if [ -z "$CIRCLE_PR_REPONAME" ]; then echo "signing.keyId=${SIGNING_KEY}" >> "gradle.properties" echo "signing.password=${SIGNING_PASSWORD}" >> "gradle.properties" echo "signing.secretKeyRingFile=../maven.keystore" >> "gradle.properties" gpg --cipher-algo AES256 --yes --batch --passphrase=$ENC_FILE_KEY maven.keystore.gpg ./gradlew build dokkaGhPages publish --no-daemon - if [ "master" = "$CIRCLE_BRANCH" ]; then - git config --global user.email $GH_EMAIL - git config --global user.name $GH_NAME - cp -r .circleci common/gh-pages/.circleci - cd common/gh-pages - git init - git checkout --orphan gh-pages - git add -A - git commit -m "Automated deployment of ${CIRCLE_BRANCH} ${CIRCLE_SHA1}" --allow-empty - git push -q https://${GH_PERSONAL_TOKEN}@github.com/ToxicBakery/${CIRCLE_PROJECT_REPONAME}.git gh-pages --force - fi else ./gradlew build --no-daemon fi + if [ -z "$CIRCLE_PR_REPONAME" ] && [ "master" = "$CIRCLE_BRANCH" ]; then + git config --global user.email $GH_EMAIL + git config --global user.name $GH_NAME + cp -r .circleci common/gh-pages/.circleci + cd common/gh-pages + git init + git checkout --orphan gh-pages + git add -A + git commit -m "Automated deployment of ${CIRCLE_BRANCH} ${CIRCLE_SHA1}" --allow-empty + git push -q https://${GH_PERSONAL_TOKEN}@github.com/ToxicBakery/${CIRCLE_PROJECT_REPONAME}.git gh-pages --force + fi bash <(curl -s https://codecov.io/bash) workflows: version: 2 diff --git a/build.gradle b/build.gradle index b6dd080..854c8d6 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,10 @@ buildscript { } } +plugins { + id "io.gitlab.arturbosch.detekt" version "1.0.0-RC12" +} + subprojects { String tagName = System.getenv('CIRCLE_TAG') boolean isTag = tagName != null && !tagName.isEmpty() diff --git a/common/android/.gitignore b/common/android/.gitignore new file mode 100644 index 0000000..a751ee3 --- /dev/null +++ b/common/android/.gitignore @@ -0,0 +1,6 @@ +/.idea +/build +/out +/*.iml +/.gradle +local.properties diff --git a/common/android/build.gradle b/common/android/build.gradle new file mode 100644 index 0000000..80f53ca --- /dev/null +++ b/common/android/build.gradle @@ -0,0 +1,81 @@ +plugins { + id 'com.android.library' + id 'kotlin-multiplatform' + id 'io.gitlab.arturbosch.detekt' + id 'org.jetbrains.dokka' +} + +android { + compileSdkVersion 28 + defaultConfig { + minSdkVersion 15 + } + buildTypes { + release { + minifyEnabled false + } + } + testOptions { + unitTests.returnDefaultValues = true + } +} + +kotlin { + targets { + fromPreset(presets.android, 'android') { + mavenPublication { + artifactId = 'arbor-android' + } + } + } + + sourceSets { + androidMain { + dependencies { + implementation 'org.jetbrains.kotlin:kotlin-stdlib' + implementation project(':common') + } + } + androidTest { + dependencies { + implementation project(':common') + implementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" + } + } + } +} + +detekt { + input = files("src/androidMain/kotlin") + filters = ".*/resources/.*,.*/build/.*" + config = files("../detekt.yml") + reports.xml.enabled = false +} + +task dokkaAndroid(type: org.jetbrains.dokka.gradle.DokkaTask) { + impliedPlatforms = ["Android"] + kotlinTasks { [] } + outputFormat = 'html' + outputDirectory = "$buildDir/javadoc/android" + sourceRoot { + path = kotlin.sourceSets.commonMain.kotlin.srcDirs[0] + platforms = ["Common"] + } + sourceRoot { + path = kotlin.sourceSets.androidMain.kotlin.srcDirs[0] + platforms = ["Android"] + } +} + +task dokkaJavadocAndroidJar(type: Jar, dependsOn: dokkaAndroid) { + classifier = 'javadoc' + from "$buildDir/javadoc/android" +} + +task androidSourcesJar(type: Jar) { + classifier = 'sources' + from kotlin.sourceSets.androidMain.kotlin.srcDirs +} + +build.dependsOn("dokkaJavadocAndroidJar") +build.dependsOn("androidSourcesJar") diff --git a/common/android/gradle.properties b/common/android/gradle.properties new file mode 100644 index 0000000..c9f2940 --- /dev/null +++ b/common/android/gradle.properties @@ -0,0 +1 @@ +POM_ARTIFACT_ID=arbor diff --git a/common/src/androidMain/kotlin/com/toxicbakery/logging/LogCatSeedling.kt b/common/android/src/androidMain/kotlin/com/toxicbakery/logging/LogCatSeedling.kt similarity index 100% rename from common/src/androidMain/kotlin/com/toxicbakery/logging/LogCatSeedling.kt rename to common/android/src/androidMain/kotlin/com/toxicbakery/logging/LogCatSeedling.kt diff --git a/common/src/androidTest/kotlin/com/toxicbakery/logging/LogCatSeedlingTest.kt b/common/android/src/androidTest/kotlin/com/toxicbakery/logging/LogCatSeedlingTest.kt similarity index 100% rename from common/src/androidTest/kotlin/com/toxicbakery/logging/LogCatSeedlingTest.kt rename to common/android/src/androidTest/kotlin/com/toxicbakery/logging/LogCatSeedlingTest.kt diff --git a/common/src/main/AndroidManifest.xml b/common/android/src/main/AndroidManifest.xml similarity index 100% rename from common/src/main/AndroidManifest.xml rename to common/android/src/main/AndroidManifest.xml diff --git a/common/build.gradle b/common/build.gradle index 5cb45a0..64070ce 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,38 +1,19 @@ plugins { - id 'com.android.library' id 'kotlin-multiplatform' id 'maven-publish' id 'com.github.salomonbrys.gradle.kotlin.js.mpp-tests.node' -// id 'maven' id 'signing' id 'org.jetbrains.dokka' - id("io.gitlab.arturbosch.detekt").version("1.0.0-RC12") + id 'io.gitlab.arturbosch.detekt' } archivesBaseName = 'arbor' -android { - compileSdkVersion 28 - defaultConfig { - minSdkVersion 15 - } - buildTypes { - release { - minifyEnabled false - } - } - testOptions { - unitTests.returnDefaultValues = true - } -} +// workaround for https://youtrack.jetbrains.com/issue/KT-27170 +configurations.create("compileClasspath") kotlin { targets { - fromPreset(presets.android, 'android') { - mavenPublication { - artifactId = 'arbor-android' - } - } fromPreset(presets.jvm, 'jvm') { mavenPublication { artifactId = 'arbor-jvm' @@ -81,24 +62,11 @@ kotlin { implementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" } } - androidMain { - dependsOn jvmMain - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-stdlib' - } - } - androidTest { - dependsOn jvmTest - dependencies { - implementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" - } - } } } detekt { input = files( - "src/androidMain/kotlin", "src/commonMain/kotlin", "src/jsMain/kotlin", "src/jvmMain/kotlin", @@ -109,7 +77,7 @@ detekt { } task dokkaGhPages(type: org.jetbrains.dokka.gradle.DokkaTask) { - impliedPlatforms = ["Android", "Common", "JS", "JVM"] + impliedPlatforms = ["Common", "JS", "JVM"] kotlinTasks { [] } outputFormat = 'html' outputDirectory = "${project.projectDir}/gh-pages" @@ -118,7 +86,7 @@ task dokkaGhPages(type: org.jetbrains.dokka.gradle.DokkaTask) { platforms = ["Common"] } sourceRoot { - path = kotlin.sourceSets.androidMain.kotlin.srcDirs[0] + path = "common/android/src/androidMain/kotlin" platforms = ["Android"] } sourceRoot { @@ -131,21 +99,6 @@ task dokkaGhPages(type: org.jetbrains.dokka.gradle.DokkaTask) { } } -task dokkaAndroid(type: org.jetbrains.dokka.gradle.DokkaTask) { - impliedPlatforms = ["Android", "Common"] - kotlinTasks { [] } - outputFormat = 'html' - outputDirectory = "$buildDir/javadoc/android" - sourceRoot { - path = kotlin.sourceSets.commonMain.kotlin.srcDirs[0] - platforms = ["Common"] - } - sourceRoot { - path = kotlin.sourceSets.androidMain.kotlin.srcDirs[0] - platforms = ["Android"] - } -} - task dokkaCommon(type: org.jetbrains.dokka.gradle.DokkaTask) { impliedPlatforms = ["Common"] kotlinTasks { [] } @@ -194,11 +147,6 @@ task emptyJavadocJar(type: Jar) { classifier = 'javadoc' } -task dokkaJavadocAndroidJar(type: Jar, dependsOn: dokkaAndroid) { - classifier = 'javadoc' - from "$buildDir/javadoc/android" -} - task dokkaJavadocCommonJar(type: Jar, dependsOn: dokkaCommon) { classifier = 'javadoc' from "$buildDir/javadoc/common" @@ -215,7 +163,7 @@ task dokkaJavadocJvmJar(type: Jar, dependsOn: dokkaJvm) { } publishing { - publications.all { + publications.all { pub -> pom.withXml { def root = asNode() @@ -247,23 +195,36 @@ publishing { } } } - } - } - afterEvaluate { project -> - if (project.getPlugins().hasPlugin('com.android.library')) { - task androidSourcesJar(type: Jar) { - classifier = 'sources' - // Android source are missing the common sources so they need to be mashed together - from kotlin.sourceSets.androidMain.kotlin.srcDirs.plus(kotlin.sourceSets.commonMain.kotlin.srcDirs) + if (pub.artifactId == "arbor-android") { + def dependenciesNode = asNode().appendNode('dependencies') + appendDepNode(dependenciesNode, 'org.jetbrains.kotlin', 'kotlin-stdlib', kotlin_version, 'runtime') + appendDepNode(dependenciesNode, 'com.ToxicBakery.logging', 'arbor-jvm', version, 'runtime') } } + } + + task dokkaJavadocAndroidJar(type: Jar, dependsOn: project("android").tasks.find { it.name == 'build' }) { + classifier = 'javadoc' + from "android/build/libs/android-$version-javadoc.jar" + } + + task androidSourcesJar(type: Jar) { + classifier = 'sources' + from "android/build/libs/android-$version-sources.jar" + } + + publish.dependsOn ':common:android:build' + publishToMavenLocal.dependsOn ':common:android:build' - publications.getByName('android') { - artifacts.clear() - artifact("$buildDir/outputs/aar/arbor-release.aar") - artifact dokkaJavadocAndroidJar - artifact androidSourcesJar + afterEvaluate { + publications { + maven(MavenPublication) { + artifactId "arbor-android" + artifact 'android/build/outputs/aar/android-release.aar' + artifact dokkaJavadocAndroidJar + artifact androidSourcesJar + } } publications.getByName('js') { artifact dokkaJavadocJsJar @@ -298,10 +259,19 @@ publishing { } } +def appendDepNode(Node node, String groupId, String artifactId, String ver, String scope) { + def newNode = node.appendNode('dependency') + newNode.appendNode('groupId', groupId) + newNode.appendNode('artifactId', artifactId) + newNode.appendNode('version', ver) + newNode.appendNode('scope', scope) +} + signing { required false sign publishing.publications } -publish.dependsOn assemble -publishToMavenLocal.dependsOn assemble +build.dependsOn ':common:android:assemble' +publish.dependsOn build +publishToMavenLocal.dependsOn build diff --git a/examples/android/.gitignore b/examples/android/.gitignore index 796b96d..4d7148e 100644 --- a/examples/android/.gitignore +++ b/examples/android/.gitignore @@ -1 +1,3 @@ /build +/.gradle +/*.iml \ No newline at end of file diff --git a/examples/android/build.gradle b/examples/android/build.gradle index 4555dd4..465e8f8 100644 --- a/examples/android/build.gradle +++ b/examples/android/build.gradle @@ -30,7 +30,7 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.ToxicBakery.logging:arbor-android:1.26.0-SNAPSHOT' + implementation 'com.ToxicBakery.logging:arbor-android:1.27.52-SNAPSHOT' implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' diff --git a/examples/build.gradle b/examples/build.gradle index a8565f6..09489bc 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -7,7 +7,7 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5c1b6c9..290541c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 025bbf8..d468f42 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,3 @@ enableFeaturePreview('GRADLE_METADATA') -include ':common' +include ':common:android', ':common'