Skip to content

Commit

Permalink
Merge pull request #7 from ToxicBakery/feature/correct-android-deps
Browse files Browse the repository at this point in the history
Moved Android to its own module in attempt to fix deps
  • Loading branch information
ToxicBakery authored Jan 22, 2019
2 parents 2e64cfd + 1bd1598 commit 10491e2
Show file tree
Hide file tree
Showing 14 changed files with 153 additions and 89 deletions.
24 changes: 12 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions common/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.idea
/build
/out
/*.iml
/.gradle
local.properties
81 changes: 81 additions & 0 deletions common/android/build.gradle
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions common/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
POM_ARTIFACT_ID=arbor
File renamed without changes.
116 changes: 43 additions & 73 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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 {
Expand All @@ -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 { [] }
Expand Down Expand Up @@ -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"
Expand All @@ -215,7 +163,7 @@ task dokkaJavadocJvmJar(type: Jar, dependsOn: dokkaJvm) {
}

publishing {
publications.all {
publications.all { pub ->
pom.withXml {
def root = asNode()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions examples/android/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/build
/.gradle
/*.iml
2 changes: 1 addition & 1 deletion examples/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
enableFeaturePreview('GRADLE_METADATA')

include ':common'
include ':common:android', ':common'

0 comments on commit 10491e2

Please sign in to comment.