Skip to content

Commit

Permalink
feat(gradle): adding support for android studio 3.0 and gradle 4.1 (#112
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
milos1290 committed Nov 21, 2017
1 parent 1fe732b commit f5c0b59
Show file tree
Hide file tree
Showing 25 changed files with 108 additions and 289 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -70,6 +70,7 @@ $RECYCLE.BIN/
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
.idea/**

# Sensitive or high-churn files:
.idea/**/dataSources/
Expand Down
22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

36 changes: 0 additions & 36 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

22 changes: 10 additions & 12 deletions AndroidSDK/build.gradle
Expand Up @@ -3,8 +3,8 @@ apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

def COMPILE_SDK_VERSION=26
def BUILD_TOOLS_VERSION='26.0.1'
def SUPPORT_LIBRARY_VERSION='26.1.0'
def BUILD_TOOLS_VERSION='26.0.2'
def SUPPORT_LIBRARY_VERSION='27.0.0'

allprojects {
gradle.projectsEvaluated {
Expand All @@ -16,19 +16,17 @@ allprojects {

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

// Provided dependencies are optional dependencies and will not show up in pom file.
provided('com.google.android.gms:play-services-gcm:[8.3.0,)') {
compileOnly('com.google.android.gms:play-services-gcm:[8.3.0,)') {
exclude module: 'support-v4'
}
provided('com.google.firebase:firebase-messaging:[10.0.0,)') {
compileOnly('com.google.firebase:firebase-messaging:[10.0.0,)') {
exclude module: 'support-v4'
}
provided('com.google.android.gms:play-services-location:[10.0.0,)') {
compileOnly('com.google.android.gms:play-services-location:[10.0.0,)') {
exclude module: 'support-v4'
}
}
Expand All @@ -37,7 +35,7 @@ android {
compileSdkVersion COMPILE_SDK_VERSION
buildToolsVersion BUILD_TOOLS_VERSION
useLibrary 'org.apache.http.legacy'
publishNonDefault true
// publishNonDefault true

defaultConfig {
consumerProguardFiles 'consumer-proguard-rules.pro'
Expand Down Expand Up @@ -119,7 +117,7 @@ publishing {

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

// Iterate over the compile dependencies (we don't want the test ones),
// adding a <dependency> node for each.
configurations.compile.allDependencies.each {
configurations.api.allDependencies.each {
if (it.group != null && it.name != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
Expand Down
37 changes: 21 additions & 16 deletions AndroidSDKTests/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

def COMPILE_SDK_VERSION=26
def BUILD_TOOLS_VERSION='26.0.1'
def SUPPORT_LIBRARY_VERSION='26.0.2'
def BUILD_TOOLS_VERSION='26.0.2'
def SUPPORT_LIBRARY_VERSION='27.0.0'

android {
compileSdkVersion COMPILE_SDK_VERSION
buildToolsVersion "${BUILD_TOOLS_VERSION}"
buildToolsVersion BUILD_TOOLS_VERSION

defaultConfig {
applicationId "com.leanplum.tests"
Expand All @@ -21,27 +21,32 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}

dependencies {
compile project(path: ':AndroidSDK', configuration: 'debug')
compile "com.android.support:appcompat-v7:${SUPPORT_LIBRARY_VERSION}"
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
implementation project(':AndroidSDK')
implementation "com.android.support:appcompat-v7:${SUPPORT_LIBRARY_VERSION}"
implementation 'com.google.android.gms:play-services-gcm:11.6.0'
implementation 'com.google.android.gms:play-services-location:11.6.0'

// Dependencies used for unit tests.
testCompile 'junit:junit:4.12'
testCompile('org.robolectric:robolectric:3.4.2') {
testImplementation 'junit:junit:4.12'
testImplementation('org.robolectric:robolectric:3.5.1') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
testCompile 'org.robolectric:shadows-play-services:3.3.2'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.powermock:powermock-module-junit4:1.6.6'
testCompile 'org.powermock:powermock-module-junit4-rule:1.6.6'
testCompile 'org.powermock:powermock-api-mockito:1.6.6'
testCompile 'org.powermock:powermock-classloading-xstream:1.6.6'
testCompile 'org.bouncycastle:bcmail-jdk15on:1.54'
testImplementation 'org.robolectric:shadows-play-services:3.3.2'
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation 'org.powermock:powermock-module-junit4:1.6.6'
testImplementation 'org.powermock:powermock-module-junit4-rule:1.6.6'
testImplementation 'org.powermock:powermock-api-mockito:1.6.6'
testImplementation 'org.powermock:powermock-classloading-xstream:1.6.6'
testImplementation 'org.bouncycastle:bcmail-jdk15on:1.54'
}

task jarTests(type: Jar, dependsOn: "assembleDebugUnitTest") {
Expand Down
Expand Up @@ -21,10 +21,8 @@
package com.leanplum;

import android.app.Application;
import android.os.Build;

import com.leanplum.__setup.LeanplumTestApp;
import com.leanplum.__setup.LeanplumTestRunner;
import com.leanplum.internal.Constants;
import com.leanplum.utils.SharedPreferencesUtil;

Expand All @@ -36,6 +34,7 @@
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

Expand All @@ -53,9 +52,8 @@
*
* @author Anna Orlova
*/
@RunWith(LeanplumTestRunner.class)
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
sdk = 16,
application = LeanplumTestApp.class
)
Expand Down
Expand Up @@ -28,7 +28,6 @@
import android.os.Bundle;

import com.leanplum.__setup.LeanplumTestApp;
import com.leanplum.__setup.LeanplumTestRunner;
import com.leanplum.__setup.TestClassUtil;
import com.leanplum.internal.CollectionUtil;
import com.leanplum.internal.Constants;
Expand All @@ -45,6 +44,7 @@
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

Expand Down Expand Up @@ -74,9 +74,8 @@
*
* @author Anna Orlova
*/
@RunWith(LeanplumTestRunner.class)
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
sdk = 16,
application = LeanplumTestApp.class
)
Expand Down
Expand Up @@ -50,6 +50,7 @@
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
Expand All @@ -75,9 +76,8 @@
import static org.powermock.api.mockito.PowerMockito.when;
import static org.powermock.api.mockito.PowerMockito.whenNew;

@RunWith(LeanplumTestRunner.class)
@RunWith(RobolectricTestRunner.class)
@Config(
constants = BuildConfig.class,
sdk = 16,
application = LeanplumTestApp.class,
packageName = "com.leanplum.tests",
Expand Down

This file was deleted.

0 comments on commit f5c0b59

Please sign in to comment.