Skip to content

Commit

Permalink
Update Android Build Settings (#45)
Browse files Browse the repository at this point in the history
* update gradle

update gradle

* revert back spotless code

revert back spotless code

* Update jacocoVersion bak to 0.8.7

Update jacocoVersion bak to 0.8.7

* update gitignore

update gitignore

* update makefile to show logs

update makefile to show logs

* Update javadoc command in gradle

Update javadoc command in gradle

* add doc debugging to makefile

add doc debugging to makefile

* update spotless version

update spotless version

* update build.gradle for doc

update build.gradle for doc

* update gradle files

update gradle files

* try set to gradle 7.4

try set to gradle 7.4

* update gradle to a lower version

update gradle to a lower version

* Revert "update gradle to a lower version"

This reverts commit 87af7e8.

* Remove linksOffline for javadoc

Remove linksOffline for javadoc

* revert make file

revert make file

* Update Gradle files

Update Gradle files

* Update makefile for debugging

Update makefile for debugging

* update make file to print debug log

update make file to print debug log

* update build gradle

update build gradle

* update build gradle

update build gradle

* update gradle

update gradle

* update build gradle

update build gradle

* Change build gradle

Change build gradle

* Update build gradle

Update build gradle

* revert back make file

revert back make file

* revert files

revert files

* Update javadoc build.gradle

Update javadoc build.gradle

* Add back the test scrDirs

Add back the test scrDirs

* remove the debug log in make file for javadoc

remove the debug log in make file for javadoc

* update code coverage output page

update code coverage output page

* Delete local.properties

* Update test context for internalJavaDoc

Update test context for internalJavaDoc

* update gradle file for tests

update gradle file for tests

* Update with review comments

Update with review comments

* Remove ADB class from excludeRegex and update from review comments

Remove ADB class from excludeRegex and update from review comments

* Add To Do note for removing jetifier

Add To Do note for removing jetifier
  • Loading branch information
cacheung authored Nov 9, 2022
1 parent 2cef8ac commit e20e666
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 125 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@

# Generated files
bin/
gen/
out/

# Built application files
*.apk
*.ap_

# Gradle files
.gradle/
build/
ci/
jacoco.exec

# IntelliJ
*.iml
**/.idea/

# Log Files
*.log

# Local configuration file (sdk path, etc)
local.properties

# .Idea file
code/.idea*
23 changes: 12 additions & 11 deletions code/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: "com.diffplug.spotless"
plugins {
id 'com.android.application'
id 'com.diffplug.spotless'
}

spotless {
java {
Expand All @@ -14,15 +16,15 @@ spotless {
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
namespace "com.adobe.marketing.mobile.consentTestApp"
compileSdk rootProject.ext.compileSdkVersion

defaultConfig {
applicationId "com.adobe.marketing.mobile.consenttestapp"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
minSdk rootProject.ext.minSdkVersion
targetSdk rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName project.property('moduleVersion') as String ?: "1.0.0 (Default)"
}

buildTypes {
Expand All @@ -34,9 +36,8 @@ android {
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation project(':edgeconsent')
implementation 'com.adobe.marketing.mobile:core:1+'
Expand Down
3 changes: 1 addition & 2 deletions code/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adobe.marketing.mobile.consentTestApp">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand Down
54 changes: 17 additions & 37 deletions code/build.gradle
Original file line number Diff line number Diff line change
@@ -1,53 +1,33 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.12.5"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

apply plugin: 'maven-publish'
}

task clean(type: Delete) {
delete rootProject.buildDir
plugins {
// Android Gradle Plugin version
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'com.diffplug.gradle.spotless' version '6.11.0' apply false
}

ext {
// android config
minSdkVersion = 19
targetSdkVersion = 29
compileSdkVersion = 29
targetSdkVersion = 33
compileSdkVersion = 33
versionCode = 1

// java config
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

// dependencies
junitVersion = "1.1.2"
junitVersion = "1.1.3"
mockitoCoreVersion = "2.28.2"
buildToolsVersion = "29.0.3"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
jacocoVersion = "0.8.7"
jacocoVersion = "0.8.8"

// spotless config
prettierVersion = "2.3.0"
prettierPluginJavaVersion = "1.1.0"
prettierVersion = "2.7.1"
prettierPluginJavaVersion = "1.6.2"
}

task clean(type: Delete) {
delete rootProject.buildDir
}
104 changes: 37 additions & 67 deletions code/edgeconsent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
apply plugin: 'com.android.library'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: "com.diffplug.spotless"
plugins {
id 'com.android.library'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'com.diffplug.spotless'
}

jacoco {
toolVersion = rootProject.ext.jacocoVersion
Expand All @@ -23,14 +25,13 @@ spotless {
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
namespace 'com.adobe.marketing.mobile.edge.consent'

compileSdk rootProject.ext.compileSdkVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName rootProject.moduleVersion
minSdk rootProject.ext.minSdkVersion
targetSdk rootProject.ext.targetSdkVersion

testInstrumentationRunner rootProject.ext.testInstrumentationRunner
consumerProguardFiles "consumer-rules.pro"
Expand Down Expand Up @@ -77,16 +78,15 @@ android {
}
}

android.libraryVariants.all { variant ->
afterEvaluate {
tasks.withType(Javadoc) {
source = [android.sourceSets.main.java.sourceFiles, android.sourceSets.phone.java.sourceFiles]
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"

doFirst{classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)}

exclude "**/BuildConfig.java"
exclude "**/R.java"
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += files(android.libraryVariants.collect { variant ->
variant.javaCompileProvider.get().classpath.files
})
options {
source = "8"
links "https://developer.android.com/reference"
}
}
Expand Down Expand Up @@ -117,39 +117,6 @@ publish.dependsOn('assemblePhone')

publishing {
publications {
aar(MavenPublication) {
groupId = 'com.adobe.marketing.mobile'
artifactId = rootProject.moduleName
version = rootProject.moduleVersion
artifact("$buildDir/outputs/aar/${rootProject.moduleAARName}")
artifact javadocPublish
pom.withXml {
asNode().appendNode('name', mavenRepoName)
asNode().appendNode('description', mavenRepoDescription)
asNode().appendNode('url', 'https://aep-sdks.gitbook.io/docs/')
def scmNode = asNode().appendNode('scm')
scmNode.appendNode('url', 'https://github.com/Adobe-Marketing-Cloud/acp-sdks/')


def developersNode = asNode().appendNode('developers')
def developerNode = developersNode.appendNode('developer')
developerNode.appendNode('id', 'adobe')
developerNode.appendNode('name', 'adobe')

def licensesNode = asNode().appendNode('licenses')
def licenseNode = licensesNode.appendNode('license')
licenseNode.appendNode('name', 'Adobe Proprietary')

def dependenciesNode = asNode().appendNode('dependencies')

//Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each

def coreDependencyNode = dependenciesNode.appendNode('dependency')
coreDependencyNode.appendNode('groupId', 'com.adobe.marketing.mobile')
coreDependencyNode.appendNode('artifactId', 'core')
coreDependencyNode.appendNode('version', mavenCoreVersion)
}
}
release(MavenPublication) {
groupId = 'com.adobe.marketing.mobile'
artifactId = rootProject.moduleName
Expand All @@ -174,9 +141,9 @@ publishing {
}
}
scm {
connection = 'scm:git:github.com//Adobe-Marketing-Cloud/acp-sdks.git'
developerConnection = 'scm:git:ssh://github.com//Adobe-Marketing-Cloud/acp-sdks.git'
url = 'https://github.com/Adobe-Marketing-Cloud/acp-sdks'
connection = 'scm:git:github.com//adobe/aepsdk-edgeconsent-android.git'
developerConnection = 'scm:git:ssh://github.com//adobe/aepsdk-edgeconsent-android.git'
url = 'https://github.com/adobe/aepsdk-edgeconsent-android'
}
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
Expand Down Expand Up @@ -216,23 +183,23 @@ signing {
}

task platformUnitTestJacocoReport(type: JacocoReport, dependsOn: "testPhoneDebugUnitTest") {
def excludeRegex = ['**/ADB*.class', '**/BuildConfig.class']
def excludeRegex = ['**/BuildConfig.class']
def debugTree = fileTree(dir: "${project.buildDir}/intermediates/javac/phoneDebug/classes/com/adobe/marketing/mobile", excludes: excludeRegex)

additionalClassDirs.setFrom files([debugTree])
additionalSourceDirs.setFrom files(android.sourceSets.main.java.sourceFiles)
sourceDirectories.setFrom files(android.sourceSets.phone.java.sourceFiles)
executionData "$buildDir/jacoco/testPhoneDebugUnitTest.exec"
executionData "$buildDir/outputs/unit_test_code_coverage/phoneDebugUnitTest/testPhoneDebugUnitTest.exec"

reports {
xml.enabled true
csv.enabled false
html.enabled true
xml.required = true
csv.required = false
html.required = true
}
}

task platformFunctionalTestJacocoReport(type: JacocoReport, dependsOn: "createPhoneDebugCoverageReport") {
def excludeRegex = ['**/ADB*.class', '**/BuildConfig.class']
def excludeRegex = ['**/BuildConfig.class']
def debugTree = fileTree(dir: "${project.buildDir}/intermediates/javac/phoneDebug/classes/com/adobe/marketing/mobile", excludes: excludeRegex)

additionalClassDirs.setFrom files([debugTree])
Expand All @@ -243,31 +210,34 @@ task platformFunctionalTestJacocoReport(type: JacocoReport, dependsOn: "createPh
])

reports {
xml.enabled true
csv.enabled false
html.enabled true
xml.required = true
csv.required = false
html.required = true
}
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
// Adobe Mobile SDK Core
implementation "com.adobe.marketing.mobile:core:${rootProject.mavenCoreVersion}"

testImplementation "androidx.test.ext:junit:${rootProject.ext.junitVersion}"
testImplementation "org.mockito:mockito-core:${rootProject.ext.mockitoCoreVersion}"
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.10.5'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.12.7'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.0'
testImplementation 'org.powermock:powermock-module-junit4:2.0.0'
testImplementation 'org.json:json:20180813'

androidTestImplementation "androidx.test.ext:junit:${rootProject.ext.junitVersion}"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Using older version of PowerMock as it supports minimum Android API < 26
// the root issue appears to be a dependency with Objenesis in Mockito-Core
// where Objenesis 2 requires minimum Android API 26
androidTestImplementation 'org.powermock:powermock-module-junit4:1+'
androidTestImplementation 'com.fasterxml.jackson.core:jackson-databind:2.10.5'
androidTestImplementation 'com.fasterxml.jackson.core:jackson-databind:2.12.7'
}

tasks.withType(Test) {
Expand Down
3 changes: 1 addition & 2 deletions code/edgeconsent/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adobe.marketing.mobile.edge.consent">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ public void error(final ExtensionError extensionError) {
* Helper methods that take the payload from the edge consent preferences response and builds a XDM formatted consentMap.
*
* @param payload a {@link Map} representing a payload from edge consent response
* @return consentMap in XDM formatted Map
*/
private Map<String, Object> prepareConsentXDMMapWithPayload(final Map<String, Object> payload) {
final Map<String, Object> consentMap = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public boolean equals(final Object comparingConsentObject) {

/**
* Compares the current consent instance the with the passed object ignoring the timestamp field in metadata
*
* @param comparingConsent the new consent object to be compared against current consent settings
* @return true, if both the consents are equal ignoring timestamp
*/
boolean equalsIgnoreTimestamp(final Consents comparingConsent) {
Expand Down
2 changes: 2 additions & 0 deletions code/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
org.gradle.jvmargs=-Xmx2048m

android.useAndroidX=true
#TO DO - Remove jetifier
android.enableJetifier=true
android.disableAutomaticComponentCreation=true

moduleProjectName=edgeconsent
moduleName=edgeconsent
Expand Down
6 changes: 3 additions & 3 deletions code/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jan 25 11:55:49 PST 2021
#Wed Nov 02 00:19:36 PDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
Loading

0 comments on commit e20e666

Please sign in to comment.