Skip to content

Commit

Permalink
Update to Kotlin 1.2.60 and androidx (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmook committed Aug 16, 2018
1 parent 03dc92b commit dfcdc6e
Show file tree
Hide file tree
Showing 32 changed files with 418 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -5,7 +5,7 @@ android:
- platform-tools
- tools

- build-tools-26.0.2
- build-tools-28.0.2
- android-26

script:
Expand Down
226 changes: 215 additions & 11 deletions bintray.gradle
@@ -1,3 +1,10 @@
import com.novoda.gradle.release.Artifacts
import com.novoda.gradle.release.JavaArtifacts
import org.gradle.api.capabilities.Capability
import org.gradle.api.internal.DefaultDomainObjectSet
import org.gradle.api.internal.component.SoftwareComponentInternal
import org.gradle.api.internal.component.UsageContext

/*
* Copyright 2017 Appmattus Limited
*
Expand All @@ -14,19 +21,216 @@
* limitations under the License.
*/

apply plugin: 'com.novoda.bintray-release'
buildscript {
repositories {
google()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://kotlin.bintray.com/kotlinx" }
}

dependencies {
classpath 'com.novoda:bintray-release:0.8.1'
}
}


publish {
bintrayUser = System.getenv('BINTRAY_USER') ?: System.getProperty('BINTRAY_USER') ?: "unknown"
bintrayKey = System.getenv('BINTRAY_KEY') ?: System.getProperty('BINTRAY_KEY') ?: "unknown"
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

userOrg = 'appmattus'
groupId = 'com.appmattus'
artifactId = project.name
publishVersion = System.getenv('CIRCLE_TAG') ?: System.getProperty('CIRCLE_TAG') ?: System.getenv('TRAVIS_TAG') ?:
System.getProperty('TRAVIS_TAG') ?: "unknown"
desc = 'Caching made simple for Android and Java'
website = 'https://github.com/appmattus/layercache'
ext.publishVersion = System.getenv('CIRCLE_TAG') ?: System.getProperty('CIRCLE_TAG') ?: System.getenv('TRAVIS_TAG') ?:
System.getProperty('TRAVIS_TAG') ?: "unknown"
ext.projectGroupId = 'com.appmattus'

bintray {
user = System.getenv('BINTRAY_USER') ?: System.getProperty('BINTRAY_USER') ?: "unknown"
key = System.getenv('BINTRAY_KEY') ?: System.getProperty('BINTRAY_KEY') ?: "unknown"
publish = true
dryRun = false
override = false

publications = project.plugins.hasPlugin('com.android.library') ? ['release'] : ['maven']

pkg {
repo = 'maven'
userOrg = 'appmattus'
name = project.name
desc = 'Caching made simple for Android and Java'
websiteUrl = 'https://github.com/appmattus/layercache'
issueTrackerUrl = 'https://github.com/appmattus/layercache/issues'
vcsUrl = 'https://github.com/appmattus/layercache.git'

licenses = ['Apache-2.0']
version {
name = publishVersion
attributes = [:]
}
}
}

// Portions below modified from https://github.com/novoda/bintray-release
// Copyright 2014 Novoda Ltd
// Apache 2.0 Licence

if (project.plugins.hasPlugin('com.android.library')) {
project.android.libraryVariants.all { variant ->
def artifactId = project.name;
addArtifact(project, variant.name, artifactId, new AndroidArtifactsAppmattus(variant))
}
} else {
addArtifact(project, 'maven', project.name, new JavaArtifacts())
}

void addArtifact(Project project, String name, String artifact, Artifacts artifacts) {
project.publishing.publications.create(name, MavenPublication) {
groupId projectGroupId
artifactId artifact
version = publishVersion

artifacts.all(it.name, project).each {
delegate.artifact it
}
from artifacts.from(project)
}
}

class AndroidArtifactsAppmattus implements Artifacts {

def variant

AndroidArtifactsAppmattus(variant) {
this.variant = variant
}

def all(String publicationName, Project project) {
[sourcesJar(project), javadocJar(project), mainJar(project)]
}

def sourcesJar(Project project) {
project.task(variant.name + 'AndroidSourcesJar', type: Jar) {
classifier = 'sources'
variant.sourceSets.each {
from it.java.srcDirs
}
}
}

def javadocJar(Project project) {
def androidJavadocs = project.task(variant.name + 'AndroidJavadocs', type: Javadoc) {
variant.sourceSets.each {
delegate.source it.java.srcDirs
}
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
classpath += variant.javaCompile.classpath
classpath += variant.javaCompile.outputs.files
}

project.task(variant.name + 'AndroidJavadocsJar', type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
}

def mainJar(Project project) {
def archiveBaseName = project.hasProperty("archivesBaseName") ? project.getProperty("archivesBaseName") : project.name
"$project.buildDir/outputs/aar/$archiveBaseName-${variant.baseName}.aar"
}

def from(Project project) {
project.components.add(new AndroidLibraryAppmattus(project))
project.components.android
}
}


class AndroidLibraryAppmattus implements SoftwareComponentInternal {

private final String CONF_COMPILE = "compile"
private final String CONF_API = "api"
private final String CONF_IMPLEMENTATION = "implementation"

private final Set<UsageContext> usages = new DefaultDomainObjectSet<UsageContext>(UsageContext)

AndroidLibraryAppmattus(Project project) {
ObjectFactory objectFactory = project.getObjects()

Usage api = objectFactory.named(Usage.class, Usage.JAVA_API)
Usage runtime = objectFactory.named(Usage.class, Usage.JAVA_RUNTIME)

addUsageContextFromConfiguration(project, CONF_COMPILE, api)
addUsageContextFromConfiguration(project, CONF_API, api)
addUsageContextFromConfiguration(project, CONF_IMPLEMENTATION, runtime)
}

String getName() {
return "android"
}

Set<UsageContext> getUsages() {
return usages
}

private addUsageContextFromConfiguration(Project project, String configuration, Usage usage) {
try {
def configurationObj = project.configurations.getByName(configuration)
def dependency = configurationObj.dependencies
if (!dependency.isEmpty()) {
def libraryUsage = new LibraryUsage(dependency, usage)
usages.add(libraryUsage)
}
} catch (UnknownDomainObjectException ignore) {
// cannot find configuration
}
}

private static class LibraryUsage implements UsageContext {

private final DomainObjectSet<Dependency> dependencies
private final Usage usage

LibraryUsage(DomainObjectSet<Dependency> dependencies, Usage usage) {
this.usage = usage
this.dependencies = dependencies
}

@Override
Usage getUsage() {
return usage
}

@Override
Set<? extends PublishArtifact> getArtifacts() {
new LinkedHashSet<PublishArtifact>()
}

@Override
Set<? extends ModuleDependency> getDependencies() {
dependencies.withType(ModuleDependency)
}

@Override
Set<? extends DependencyConstraint> getDependencyConstraints() {
return []
}

@Override
Set<? extends Capability> getCapabilities() {
return []
}

@Override
Set<ExcludeRule> getGlobalExcludes() {
return []
}

@Override
String getName() {
return "runtime"
}

@Override
AttributeContainer getAttributes() {
return null
}
}
}
16 changes: 9 additions & 7 deletions build.gradle
Expand Up @@ -15,10 +15,11 @@
*/

buildscript {
ext.kotlin_version = '1.1.51'
ext.serialization_version = '0.2'
ext.detekt_version = '1.0.0.RC5-3'
ext.dokka_version = '0.9.15'
ext.kotlin_version = '1.2.60'
ext.coroutines_version = '0.24.0'
ext.serialization_version = '0.6.1'
ext.detekt_version = '1.0.0.RC6'
ext.dokka_version = '0.9.17'

repositories {
google()
Expand All @@ -27,12 +28,13 @@ buildscript {
maven { url "https://kotlin.bintray.com/kotlinx" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.3.0-alpha05'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:$serialization_version"
classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detekt_version"
classpath 'com.novoda:bintray-release:0.7.0'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
classpath 'com.novoda:bintray-release:0.8.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.3'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}"
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${dokka_version}"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
28 changes: 15 additions & 13 deletions layercache-android-encryption/build.gradle
Expand Up @@ -21,18 +21,16 @@ apply from: "$rootDir/bintray.gradle"
apply from: "$rootDir/dokka-android.gradle"

android {
compileSdkVersion 26
buildToolsVersion "26.0.2"

publishNonDefault true
compileSdkVersion 28
buildToolsVersion "28.0.2"

defaultConfig {
minSdkVersion 17
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand All @@ -43,7 +41,7 @@ android {

release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), "$rootDir/proguard-rules.pro"
}
}

Expand All @@ -56,18 +54,22 @@ android {
testBuildType "debug"
}

tasks.withType(Test) {
systemProperty "kotlinx.coroutines.blocking.checker", "disable"
}

dependencies {
compile project(':layercache-android')
compileOnly "com.android.support:support-annotations:27.0.0"
implementation project(':layercache-android')
compileOnly "androidx.annotation:annotation:1.0.0-rc01"

testImplementation project(':testutils')
testImplementation "org.robolectric:robolectric:3.5.1"
testImplementation "org.robolectric:robolectric:3.8"

androidTestImplementation project(':testutils')
androidTestImplementation files('testlibs/JUnitParams-1.1.0-custom.jar')
androidTestImplementation('com.android.support.test:runner:1.0.1')
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
exclude group: 'com.android.support', module: 'support-annotations'
androidTestImplementation('androidx.test:runner:1.1.0-alpha4')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
exclude group: 'androidx.annotation', module: 'annotation'
})
}

Expand Down
25 changes: 0 additions & 25 deletions layercache-android-encryption/proguard-rules.pro

This file was deleted.

Expand Up @@ -19,8 +19,8 @@ package com.appmattus.layercache
import android.annotation.SuppressLint
import android.os.Build
import android.preference.PreferenceManager
import android.support.annotation.RequiresApi
import android.support.test.InstrumentationRegistry
import androidx.annotation.RequiresApi
import androidx.test.InstrumentationRegistry
import com.appmattus.layercache.encryption.EncryptionFactory
import junitparams.JUnitParamsRunner
import junitparams.Parameters
Expand Down
Expand Up @@ -19,7 +19,7 @@ package com.appmattus.layercache.encryption
import android.annotation.SuppressLint
import android.os.Build
import android.preference.PreferenceManager
import android.support.test.InstrumentationRegistry
import androidx.test.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
Expand Down

0 comments on commit dfcdc6e

Please sign in to comment.