Skip to content

Commit dfcdc6e

Browse files
authored
Update to Kotlin 1.2.60 and androidx (#16)
1 parent 03dc92b commit dfcdc6e

File tree

32 files changed

+418
-185
lines changed

32 files changed

+418
-185
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ android:
55
- platform-tools
66
- tools
77

8-
- build-tools-26.0.2
8+
- build-tools-28.0.2
99
- android-26
1010

1111
script:

bintray.gradle

Lines changed: 215 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import com.novoda.gradle.release.Artifacts
2+
import com.novoda.gradle.release.JavaArtifacts
3+
import org.gradle.api.capabilities.Capability
4+
import org.gradle.api.internal.DefaultDomainObjectSet
5+
import org.gradle.api.internal.component.SoftwareComponentInternal
6+
import org.gradle.api.internal.component.UsageContext
7+
18
/*
29
* Copyright 2017 Appmattus Limited
310
*
@@ -14,19 +21,216 @@
1421
* limitations under the License.
1522
*/
1623

17-
apply plugin: 'com.novoda.bintray-release'
24+
buildscript {
25+
repositories {
26+
google()
27+
jcenter()
28+
maven { url "https://plugins.gradle.org/m2/" }
29+
maven { url "https://kotlin.bintray.com/kotlinx" }
30+
}
31+
32+
dependencies {
33+
classpath 'com.novoda:bintray-release:0.8.1'
34+
}
35+
}
36+
1837

19-
publish {
20-
bintrayUser = System.getenv('BINTRAY_USER') ?: System.getProperty('BINTRAY_USER') ?: "unknown"
21-
bintrayKey = System.getenv('BINTRAY_KEY') ?: System.getProperty('BINTRAY_KEY') ?: "unknown"
38+
apply plugin: 'com.jfrog.bintray'
39+
apply plugin: 'maven-publish'
2240

23-
userOrg = 'appmattus'
24-
groupId = 'com.appmattus'
25-
artifactId = project.name
26-
publishVersion = System.getenv('CIRCLE_TAG') ?: System.getProperty('CIRCLE_TAG') ?: System.getenv('TRAVIS_TAG') ?:
27-
System.getProperty('TRAVIS_TAG') ?: "unknown"
28-
desc = 'Caching made simple for Android and Java'
29-
website = 'https://github.com/appmattus/layercache'
41+
ext.publishVersion = System.getenv('CIRCLE_TAG') ?: System.getProperty('CIRCLE_TAG') ?: System.getenv('TRAVIS_TAG') ?:
42+
System.getProperty('TRAVIS_TAG') ?: "unknown"
43+
ext.projectGroupId = 'com.appmattus'
3044

45+
bintray {
46+
user = System.getenv('BINTRAY_USER') ?: System.getProperty('BINTRAY_USER') ?: "unknown"
47+
key = System.getenv('BINTRAY_KEY') ?: System.getProperty('BINTRAY_KEY') ?: "unknown"
48+
publish = true
3149
dryRun = false
50+
override = false
51+
52+
publications = project.plugins.hasPlugin('com.android.library') ? ['release'] : ['maven']
53+
54+
pkg {
55+
repo = 'maven'
56+
userOrg = 'appmattus'
57+
name = project.name
58+
desc = 'Caching made simple for Android and Java'
59+
websiteUrl = 'https://github.com/appmattus/layercache'
60+
issueTrackerUrl = 'https://github.com/appmattus/layercache/issues'
61+
vcsUrl = 'https://github.com/appmattus/layercache.git'
62+
63+
licenses = ['Apache-2.0']
64+
version {
65+
name = publishVersion
66+
attributes = [:]
67+
}
68+
}
69+
}
70+
71+
// Portions below modified from https://github.com/novoda/bintray-release
72+
// Copyright 2014 Novoda Ltd
73+
// Apache 2.0 Licence
74+
75+
if (project.plugins.hasPlugin('com.android.library')) {
76+
project.android.libraryVariants.all { variant ->
77+
def artifactId = project.name;
78+
addArtifact(project, variant.name, artifactId, new AndroidArtifactsAppmattus(variant))
79+
}
80+
} else {
81+
addArtifact(project, 'maven', project.name, new JavaArtifacts())
82+
}
83+
84+
void addArtifact(Project project, String name, String artifact, Artifacts artifacts) {
85+
project.publishing.publications.create(name, MavenPublication) {
86+
groupId projectGroupId
87+
artifactId artifact
88+
version = publishVersion
89+
90+
artifacts.all(it.name, project).each {
91+
delegate.artifact it
92+
}
93+
from artifacts.from(project)
94+
}
95+
}
96+
97+
class AndroidArtifactsAppmattus implements Artifacts {
98+
99+
def variant
100+
101+
AndroidArtifactsAppmattus(variant) {
102+
this.variant = variant
103+
}
104+
105+
def all(String publicationName, Project project) {
106+
[sourcesJar(project), javadocJar(project), mainJar(project)]
107+
}
108+
109+
def sourcesJar(Project project) {
110+
project.task(variant.name + 'AndroidSourcesJar', type: Jar) {
111+
classifier = 'sources'
112+
variant.sourceSets.each {
113+
from it.java.srcDirs
114+
}
115+
}
116+
}
117+
118+
def javadocJar(Project project) {
119+
def androidJavadocs = project.task(variant.name + 'AndroidJavadocs', type: Javadoc) {
120+
variant.sourceSets.each {
121+
delegate.source it.java.srcDirs
122+
}
123+
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
124+
classpath += variant.javaCompile.classpath
125+
classpath += variant.javaCompile.outputs.files
126+
}
127+
128+
project.task(variant.name + 'AndroidJavadocsJar', type: Jar, dependsOn: androidJavadocs) {
129+
classifier = 'javadoc'
130+
from androidJavadocs.destinationDir
131+
}
132+
}
133+
134+
def mainJar(Project project) {
135+
def archiveBaseName = project.hasProperty("archivesBaseName") ? project.getProperty("archivesBaseName") : project.name
136+
"$project.buildDir/outputs/aar/$archiveBaseName-${variant.baseName}.aar"
137+
}
138+
139+
def from(Project project) {
140+
project.components.add(new AndroidLibraryAppmattus(project))
141+
project.components.android
142+
}
143+
}
144+
145+
146+
class AndroidLibraryAppmattus implements SoftwareComponentInternal {
147+
148+
private final String CONF_COMPILE = "compile"
149+
private final String CONF_API = "api"
150+
private final String CONF_IMPLEMENTATION = "implementation"
151+
152+
private final Set<UsageContext> usages = new DefaultDomainObjectSet<UsageContext>(UsageContext)
153+
154+
AndroidLibraryAppmattus(Project project) {
155+
ObjectFactory objectFactory = project.getObjects()
156+
157+
Usage api = objectFactory.named(Usage.class, Usage.JAVA_API)
158+
Usage runtime = objectFactory.named(Usage.class, Usage.JAVA_RUNTIME)
159+
160+
addUsageContextFromConfiguration(project, CONF_COMPILE, api)
161+
addUsageContextFromConfiguration(project, CONF_API, api)
162+
addUsageContextFromConfiguration(project, CONF_IMPLEMENTATION, runtime)
163+
}
164+
165+
String getName() {
166+
return "android"
167+
}
168+
169+
Set<UsageContext> getUsages() {
170+
return usages
171+
}
172+
173+
private addUsageContextFromConfiguration(Project project, String configuration, Usage usage) {
174+
try {
175+
def configurationObj = project.configurations.getByName(configuration)
176+
def dependency = configurationObj.dependencies
177+
if (!dependency.isEmpty()) {
178+
def libraryUsage = new LibraryUsage(dependency, usage)
179+
usages.add(libraryUsage)
180+
}
181+
} catch (UnknownDomainObjectException ignore) {
182+
// cannot find configuration
183+
}
184+
}
185+
186+
private static class LibraryUsage implements UsageContext {
187+
188+
private final DomainObjectSet<Dependency> dependencies
189+
private final Usage usage
190+
191+
LibraryUsage(DomainObjectSet<Dependency> dependencies, Usage usage) {
192+
this.usage = usage
193+
this.dependencies = dependencies
194+
}
195+
196+
@Override
197+
Usage getUsage() {
198+
return usage
199+
}
200+
201+
@Override
202+
Set<? extends PublishArtifact> getArtifacts() {
203+
new LinkedHashSet<PublishArtifact>()
204+
}
205+
206+
@Override
207+
Set<? extends ModuleDependency> getDependencies() {
208+
dependencies.withType(ModuleDependency)
209+
}
210+
211+
@Override
212+
Set<? extends DependencyConstraint> getDependencyConstraints() {
213+
return []
214+
}
215+
216+
@Override
217+
Set<? extends Capability> getCapabilities() {
218+
return []
219+
}
220+
221+
@Override
222+
Set<ExcludeRule> getGlobalExcludes() {
223+
return []
224+
}
225+
226+
@Override
227+
String getName() {
228+
return "runtime"
229+
}
230+
231+
@Override
232+
AttributeContainer getAttributes() {
233+
return null
234+
}
235+
}
32236
}

build.gradle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
*/
1616

1717
buildscript {
18-
ext.kotlin_version = '1.1.51'
19-
ext.serialization_version = '0.2'
20-
ext.detekt_version = '1.0.0.RC5-3'
21-
ext.dokka_version = '0.9.15'
18+
ext.kotlin_version = '1.2.60'
19+
ext.coroutines_version = '0.24.0'
20+
ext.serialization_version = '0.6.1'
21+
ext.detekt_version = '1.0.0.RC6'
22+
ext.dokka_version = '0.9.17'
2223

2324
repositories {
2425
google()
@@ -27,12 +28,13 @@ buildscript {
2728
maven { url "https://kotlin.bintray.com/kotlinx" }
2829
}
2930
dependencies {
30-
classpath 'com.android.tools.build:gradle:3.0.0'
31+
classpath 'com.android.tools.build:gradle:3.3.0-alpha05'
3132
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
3233
classpath "org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:$serialization_version"
3334
classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detekt_version"
34-
classpath 'com.novoda:bintray-release:0.7.0'
35-
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
35+
classpath 'com.novoda:bintray-release:0.8.1'
36+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
37+
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.3'
3638
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
3739
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}"
3840
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:${dokka_version}"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

layercache-android-encryption/build.gradle

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,16 @@ apply from: "$rootDir/bintray.gradle"
2121
apply from: "$rootDir/dokka-android.gradle"
2222

2323
android {
24-
compileSdkVersion 26
25-
buildToolsVersion "26.0.2"
26-
27-
publishNonDefault true
24+
compileSdkVersion 28
25+
buildToolsVersion "28.0.2"
2826

2927
defaultConfig {
3028
minSdkVersion 17
31-
targetSdkVersion 26
29+
targetSdkVersion 28
3230
versionCode 1
3331
versionName "1.0"
3432

35-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
33+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3634
}
3735

3836
buildTypes {
@@ -43,7 +41,7 @@ android {
4341

4442
release {
4543
minifyEnabled false
46-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
44+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), "$rootDir/proguard-rules.pro"
4745
}
4846
}
4947

@@ -56,18 +54,22 @@ android {
5654
testBuildType "debug"
5755
}
5856

57+
tasks.withType(Test) {
58+
systemProperty "kotlinx.coroutines.blocking.checker", "disable"
59+
}
60+
5961
dependencies {
60-
compile project(':layercache-android')
61-
compileOnly "com.android.support:support-annotations:27.0.0"
62+
implementation project(':layercache-android')
63+
compileOnly "androidx.annotation:annotation:1.0.0-rc01"
6264

6365
testImplementation project(':testutils')
64-
testImplementation "org.robolectric:robolectric:3.5.1"
66+
testImplementation "org.robolectric:robolectric:3.8"
6567

6668
androidTestImplementation project(':testutils')
6769
androidTestImplementation files('testlibs/JUnitParams-1.1.0-custom.jar')
68-
androidTestImplementation('com.android.support.test:runner:1.0.1')
69-
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
70-
exclude group: 'com.android.support', module: 'support-annotations'
70+
androidTestImplementation('androidx.test:runner:1.1.0-alpha4')
71+
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
72+
exclude group: 'androidx.annotation', module: 'annotation'
7173
})
7274
}
7375

layercache-android-encryption/proguard-rules.pro

Lines changed: 0 additions & 25 deletions
This file was deleted.

layercache-android-encryption/src/androidTest/kotlin/com/appmattus/layercache/StringEncryptionShould.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package com.appmattus.layercache
1919
import android.annotation.SuppressLint
2020
import android.os.Build
2121
import android.preference.PreferenceManager
22-
import android.support.annotation.RequiresApi
23-
import android.support.test.InstrumentationRegistry
22+
import androidx.annotation.RequiresApi
23+
import androidx.test.InstrumentationRegistry
2424
import com.appmattus.layercache.encryption.EncryptionFactory
2525
import junitparams.JUnitParamsRunner
2626
import junitparams.Parameters

layercache-android-encryption/src/androidTest/kotlin/com/appmattus/layercache/encryption/AesKeyCompatShould.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package com.appmattus.layercache.encryption
1919
import android.annotation.SuppressLint
2020
import android.os.Build
2121
import android.preference.PreferenceManager
22-
import android.support.test.InstrumentationRegistry
22+
import androidx.test.InstrumentationRegistry
2323
import org.junit.Assert.assertEquals
2424
import org.junit.Assert.assertFalse
2525
import org.junit.Assert.assertTrue

0 commit comments

Comments
 (0)