Skip to content

Android / Gradle updates (current working build) #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: feature/lcp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions SDKLauncher-Android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
def ndk_experimental = (rootProject.hasProperty("readium_ndk_experimental") && rootProject.readium_ndk_experimental)

println "[[${project.name}]] (APP) Gradle Experimental: ${ndk_experimental}"

if (ndk_experimental) {
println "${project.name}: Using Gradle EXPERIMENTAL to build application"
apply from: 'build_experimental.gradle'
} else {
println "${project.name}: Using Gradle STABLE to build application"
apply from: 'build_stable.gradle'
}


repositories {
if (!ndk_experimental) {
google()
}
maven {
url "https://maven.google.com"
}
mavenCentral()
jcenter()
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs '../libs'
}
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
Expand Down Expand Up @@ -56,18 +61,22 @@ buildAssets.dependsOn "buildCssAssets",
apply from: 'build_epubReadingSystem.gradle'

tasks.whenTaskAdded { task ->
def taskName = task.name
println "[[${project.name}]] (APP) TaskAdded: ${task.name}"

if (task.name.startsWith("compile")) {
def isDebug = task.name.toLowerCase().contains("debug")

if (taskName.startsWith("compile")) {
if (ndk_experimental) {
task.dependsOn "buildAssets",
":lcp:build",
"buildEpubReadingSystem"
isDebug ? ":lcp:assembleDebug" : ":lcp:assembleRelease",
"buildEpubReadingSystem"
} else {
println("Task: ${taskName}")
task.dependsOn "buildAssets",
":epub3:buildMk",
"buildEpubReadingSystem"
isDebug ? ":lcp:assembleDebug" : ":lcp:assembleRelease",
"buildEpubReadingSystem"
}
}
}
}
gradle.buildFinished { buildResult ->
println "[[${project.name}]] (APP) buildFinished"
}
114 changes: 102 additions & 12 deletions SDKLauncher-Android/app/build_experimental.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def store_password = (rootProject.hasProperty("readium_sign_store_password") ?

def lcpDir = project(':lcp').projectDir
def epub3Dir = project(':epub3').projectDir
def rsdkDir = project(':rsdk').projectDir

def _buildTypes = []
def _productFlavors = []
def currentBuildType
model {
android.lintOptions {
checkReleaseBuilds = false
Expand All @@ -35,8 +39,8 @@ model {
}

android {
compileSdkVersion = 26
buildToolsVersion = "27.0.3"
compileSdkVersion = 28
buildToolsVersion = "28.0.3"

defaultConfig {

Expand All @@ -47,7 +51,7 @@ model {
minSdkVersion.apiLevel = 19

// manifest/uses-sdk@android:targetSdkVersion attribute in src/main/AndroidManifest.xml
targetSdkVersion.apiLevel = 26
targetSdkVersion.apiLevel = 28

// manifest@android:versionCode attribute in src/main/AndroidManifest.xml
versionCode 31
Expand Down Expand Up @@ -101,19 +105,105 @@ model {
} //buildTypes

productFlavors {
if (!ndk_skipARM)
create("arm") {
if (!ndk_skipARM && !ndk_skipX86) {
create('armeabi-v7a--arm64-v8a--x86--x86_64') {
ndk.with {
abiFilters.add("armeabi-v7a")
abiFilters.add('armeabi-v7a')
abiFilters.add('arm64-v8a')
abiFilters.add('x86')
abiFilters.add('x86_64')
}
}

if (!ndk_skipX86)
create("x86") {
ndk.with {
abiFilters.add("x86")
} else {
if (!ndk_skipARM) {
create('armeabi-v7a--arm64-v8a') {
ndk.with {
abiFilters.add('armeabi-v7a')
abiFilters.add('arm64-v8a')
}
}
}
if (!ndk_skipX86) {
create('x86--x86_64') {
ndk.with {
abiFilters.add('x86')
abiFilters.add('x86_64')
}
}
}
}
} //productFlavors
} //android
} //model

components.android {
binaries.afterEach { binary ->
println "[[${project.name}]] (APP) components.android.binaries buildType: ${binary.getBuildType().name}"
if (!_buildTypes.contains(binary.getBuildType().name)) {
println "[[${project.name}]] (APP) components.android.binaries buildType ADDED"
_buildTypes += binary.getBuildType().name
}

binary.getProductFlavors().each { flavor ->
println " [[${project.name}]] (APP) components.android.binaries productFlavor: ${flavor.name}"
if (!_productFlavors.contains(flavor)) {
println " [[${project.name}]] (APP) components.android.binaries productFlavor ADDED"
_productFlavors += flavor
}

flavor.ndk.abiFilters.each { abiFilter ->
println " [[${project.name}]] (APP) components.android.binaries abiFilter (${abiFilter})"
}
}
// binary.mergedNdkConfig.cppFlags.add("-DVARIANT=\"" + binary.name + "\"")
}
}
} //model

gradle.taskGraph.whenReady { taskGraph ->
println "[[${project.name}]] (APP) taskGraph ready"

// taskGraph.getAllTasks().last().finalizedBy("copyLibs")
// taskGraph.getAllTasks().last().doLast "copyLibs"
taskGraph.getAllTasks().last().doLast {
println "[[${project.name}]] (APP) last TASK (${currentBuildType})"
} // .dependsOn "copyLibs"

if (taskGraph.hasTask(buildRelease)) {
println "[[${project.name}]] (APP) taskGraph RELEASE (build)"

currentBuildType = "release"
} else if (taskGraph.hasTask(buildDebug)) {
println "[[${project.name}]] (APP) taskGraph DEBUG (build)"

currentBuildType = "debug"
} else {
if (taskGraph.hasTask(assembleRelease)) {
println "[[${project.name}]] (APP) taskGraph RELEASE (assemble)"

currentBuildType = "release"
}
if (taskGraph.hasTask(assembleDebug)) {
println "[[${project.name}]] (APP) taskGraph DEBUG (assemble)"

currentBuildType = "debug"
}
}
}

task buildRelease(type: GradleBuild, dependsOn: build) {
}

task buildDebug(type: GradleBuild, dependsOn: build) {
}

// task assembleRelease(type: GradleBuild, dependsOn: assemble) {
// }

// task assembleDebug(type: GradleBuild, dependsOn: assemble) {
// }

// tasks.all { task ->
// if (task.name.startsWith('compile') && task.name.endsWith('Ndk')) {
// task.enabled = false
// }
// }
Loading