Skip to content

Commit f5c0b59

Browse files
authored
feat(gradle): adding support for android studio 3.0 and gradle 4.1 (#112)
* feat(gradle): adding support for android studio 3.0 and gradle 4.1 * fix(tests): upgrading robolectric, fixing failing tests * fix(publish): fixing pom dependencies * fix(build): using wrapper * fix(build): fixing wrong path * fix(build): using correct folder
1 parent 1fe732b commit f5c0b59

25 files changed

+108
-289
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ $RECYCLE.BIN/
7070
.idea/**/workspace.xml
7171
.idea/**/tasks.xml
7272
.idea/dictionaries
73+
.idea/**
7374

7475
# Sensitive or high-churn files:
7576
.idea/**/dataSources/

.idea/compiler.xml

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

.idea/misc.xml

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

.idea/modules.xml

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

.idea/runConfigurations.xml

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

AndroidSDK/build.gradle

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ apply plugin: 'com.jfrog.artifactory'
33
apply plugin: 'maven-publish'
44

55
def COMPILE_SDK_VERSION=26
6-
def BUILD_TOOLS_VERSION='26.0.1'
7-
def SUPPORT_LIBRARY_VERSION='26.1.0'
6+
def BUILD_TOOLS_VERSION='26.0.2'
7+
def SUPPORT_LIBRARY_VERSION='27.0.0'
88

99
allprojects {
1010
gradle.projectsEvaluated {
@@ -16,19 +16,17 @@ allprojects {
1616

1717
dependencies {
1818
// Compile dependencies will be added as dependency in pom file.
19-
//noinspection GradleDynamicVersion
20-
compile "com.android.support:support-v4:[22.0.0,${SUPPORT_LIBRARY_VERSION}]"
21-
//noinspection GradleDynamicVersion
22-
compile "com.android.support:appcompat-v7:[22.0.0,${SUPPORT_LIBRARY_VERSION}]"
19+
api "com.android.support:support-v4:[22.0.0,${SUPPORT_LIBRARY_VERSION}]"
20+
api "com.android.support:appcompat-v7:[22.0.0,${SUPPORT_LIBRARY_VERSION}]"
2321

2422
// Provided dependencies are optional dependencies and will not show up in pom file.
25-
provided('com.google.android.gms:play-services-gcm:[8.3.0,)') {
23+
compileOnly('com.google.android.gms:play-services-gcm:[8.3.0,)') {
2624
exclude module: 'support-v4'
2725
}
28-
provided('com.google.firebase:firebase-messaging:[10.0.0,)') {
26+
compileOnly('com.google.firebase:firebase-messaging:[10.0.0,)') {
2927
exclude module: 'support-v4'
3028
}
31-
provided('com.google.android.gms:play-services-location:[10.0.0,)') {
29+
compileOnly('com.google.android.gms:play-services-location:[10.0.0,)') {
3230
exclude module: 'support-v4'
3331
}
3432
}
@@ -37,7 +35,7 @@ android {
3735
compileSdkVersion COMPILE_SDK_VERSION
3836
buildToolsVersion BUILD_TOOLS_VERSION
3937
useLibrary 'org.apache.http.legacy'
40-
publishNonDefault true
38+
// publishNonDefault true
4139

4240
defaultConfig {
4341
consumerProguardFiles 'consumer-proguard-rules.pro'
@@ -119,7 +117,7 @@ publishing {
119117

120118
// Iterate over the compile dependencies (we don't want the test ones),
121119
// adding a <dependency> node for each.
122-
configurations.compile.allDependencies.each {
120+
configurations.api.allDependencies.each {
123121
if (it.group != null && it.name != null) {
124122
def dependencyNode = dependenciesNode.appendNode('dependency')
125123
dependencyNode.appendNode('groupId', it.group)
@@ -144,7 +142,7 @@ publishing {
144142

145143
// Iterate over the compile dependencies (we don't want the test ones),
146144
// adding a <dependency> node for each.
147-
configurations.compile.allDependencies.each {
145+
configurations.api.allDependencies.each {
148146
if (it.group != null && it.name != null) {
149147
def dependencyNode = dependenciesNode.appendNode('dependency')
150148
dependencyNode.appendNode('groupId', it.group)

AndroidSDKTests/build.gradle

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
def COMPILE_SDK_VERSION=26
4-
def BUILD_TOOLS_VERSION='26.0.1'
5-
def SUPPORT_LIBRARY_VERSION='26.0.2'
4+
def BUILD_TOOLS_VERSION='26.0.2'
5+
def SUPPORT_LIBRARY_VERSION='27.0.0'
66

77
android {
88
compileSdkVersion COMPILE_SDK_VERSION
9-
buildToolsVersion "${BUILD_TOOLS_VERSION}"
9+
buildToolsVersion BUILD_TOOLS_VERSION
1010

1111
defaultConfig {
1212
applicationId "com.leanplum.tests"
@@ -21,27 +21,32 @@ android {
2121
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2222
}
2323
}
24+
testOptions {
25+
unitTests {
26+
includeAndroidResources = true
27+
}
28+
}
2429
}
2530

2631
dependencies {
27-
compile project(path: ':AndroidSDK', configuration: 'debug')
28-
compile "com.android.support:appcompat-v7:${SUPPORT_LIBRARY_VERSION}"
29-
compile 'com.google.android.gms:play-services-gcm:11.0.4'
30-
compile 'com.google.android.gms:play-services-location:11.0.4'
32+
implementation project(':AndroidSDK')
33+
implementation "com.android.support:appcompat-v7:${SUPPORT_LIBRARY_VERSION}"
34+
implementation 'com.google.android.gms:play-services-gcm:11.6.0'
35+
implementation 'com.google.android.gms:play-services-location:11.6.0'
3136

3237
// Dependencies used for unit tests.
33-
testCompile 'junit:junit:4.12'
34-
testCompile('org.robolectric:robolectric:3.4.2') {
38+
testImplementation 'junit:junit:4.12'
39+
testImplementation('org.robolectric:robolectric:3.5.1') {
3540
exclude group: 'commons-logging', module: 'commons-logging'
3641
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
3742
}
38-
testCompile 'org.robolectric:shadows-play-services:3.3.2'
39-
testCompile 'org.mockito:mockito-core:1.10.19'
40-
testCompile 'org.powermock:powermock-module-junit4:1.6.6'
41-
testCompile 'org.powermock:powermock-module-junit4-rule:1.6.6'
42-
testCompile 'org.powermock:powermock-api-mockito:1.6.6'
43-
testCompile 'org.powermock:powermock-classloading-xstream:1.6.6'
44-
testCompile 'org.bouncycastle:bcmail-jdk15on:1.54'
43+
testImplementation 'org.robolectric:shadows-play-services:3.3.2'
44+
testImplementation 'org.mockito:mockito-core:1.10.19'
45+
testImplementation 'org.powermock:powermock-module-junit4:1.6.6'
46+
testImplementation 'org.powermock:powermock-module-junit4-rule:1.6.6'
47+
testImplementation 'org.powermock:powermock-api-mockito:1.6.6'
48+
testImplementation 'org.powermock:powermock-classloading-xstream:1.6.6'
49+
testImplementation 'org.bouncycastle:bcmail-jdk15on:1.54'
4550
}
4651

4752
task jarTests(type: Jar, dependsOn: "assembleDebugUnitTest") {

AndroidSDKTests/src/test/java/com/leanplum/LeanplumCloudMessagingProviderTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
package com.leanplum;
2222

2323
import android.app.Application;
24-
import android.os.Build;
2524

2625
import com.leanplum.__setup.LeanplumTestApp;
27-
import com.leanplum.__setup.LeanplumTestRunner;
2826
import com.leanplum.internal.Constants;
2927
import com.leanplum.utils.SharedPreferencesUtil;
3028

@@ -36,6 +34,7 @@
3634
import org.powermock.core.classloader.annotations.PowerMockIgnore;
3735
import org.powermock.core.classloader.annotations.PrepareForTest;
3836
import org.powermock.modules.junit4.rule.PowerMockRule;
37+
import org.robolectric.RobolectricTestRunner;
3938
import org.robolectric.RuntimeEnvironment;
4039
import org.robolectric.annotation.Config;
4140

@@ -53,9 +52,8 @@
5352
*
5453
* @author Anna Orlova
5554
*/
56-
@RunWith(LeanplumTestRunner.class)
55+
@RunWith(RobolectricTestRunner.class)
5756
@Config(
58-
constants = BuildConfig.class,
5957
sdk = 16,
6058
application = LeanplumTestApp.class
6159
)

AndroidSDKTests/src/test/java/com/leanplum/LeanplumPushServiceTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import android.os.Bundle;
2929

3030
import com.leanplum.__setup.LeanplumTestApp;
31-
import com.leanplum.__setup.LeanplumTestRunner;
3231
import com.leanplum.__setup.TestClassUtil;
3332
import com.leanplum.internal.CollectionUtil;
3433
import com.leanplum.internal.Constants;
@@ -45,6 +44,7 @@
4544
import org.powermock.core.classloader.annotations.PowerMockIgnore;
4645
import org.powermock.core.classloader.annotations.PrepareForTest;
4746
import org.powermock.modules.junit4.rule.PowerMockRule;
47+
import org.robolectric.RobolectricTestRunner;
4848
import org.robolectric.RuntimeEnvironment;
4949
import org.robolectric.annotation.Config;
5050

@@ -74,9 +74,8 @@
7474
*
7575
* @author Anna Orlova
7676
*/
77-
@RunWith(LeanplumTestRunner.class)
77+
@RunWith(RobolectricTestRunner.class)
7878
@Config(
79-
constants = BuildConfig.class,
8079
sdk = 16,
8180
application = LeanplumTestApp.class
8281
)

AndroidSDKTests/src/test/java/com/leanplum/__setup/AbstractTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.powermock.core.classloader.annotations.PowerMockIgnore;
5151
import org.powermock.core.classloader.annotations.PrepareForTest;
5252
import org.powermock.modules.junit4.rule.PowerMockRule;
53+
import org.robolectric.RobolectricTestRunner;
5354
import org.robolectric.RuntimeEnvironment;
5455
import org.robolectric.annotation.Config;
5556
import org.robolectric.shadows.ShadowLog;
@@ -75,9 +76,8 @@
7576
import static org.powermock.api.mockito.PowerMockito.when;
7677
import static org.powermock.api.mockito.PowerMockito.whenNew;
7778

78-
@RunWith(LeanplumTestRunner.class)
79+
@RunWith(RobolectricTestRunner.class)
7980
@Config(
80-
constants = BuildConfig.class,
8181
sdk = 16,
8282
application = LeanplumTestApp.class,
8383
packageName = "com.leanplum.tests",

0 commit comments

Comments
 (0)