Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 22 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ plugins {

def envCI = System.getenv("CI")
def isCI = envCI != null && envCI != ""
def envMTDebugDefault = System.getenv("MT_DEBUG_DEFAULT")
def mtDebugDefault = envMTDebugDefault != null ? envMTDebugDefault.toBoolean() : false
def generatedBuildConfigDir = layout.buildDirectory.dir("generated/sources/mt/buildConfig")

tasks.register("generateBuildConfig") {
outputs.dir(generatedBuildConfigDir)
Comment thread
mmathieum marked this conversation as resolved.
Outdated
doLast {
def outputFile = generatedBuildConfigDir.get().file("org/mtransit/commons/BuildConfig.kt").asFile
outputFile.parentFile.mkdirs()
outputFile.text = """package org.mtransit.commons

internal object BuildConfig {
const val DEBUG_DEFAULT = ${mtDebugDefault}
}
"""
}
Comment thread
mmathieum marked this conversation as resolved.
}

tasks.named("compileKotlin") {
dependsOn(tasks.named("generateBuildConfig"))
source(generatedBuildConfigDir)
}
Comment thread
mmathieum marked this conversation as resolved.
Outdated

java {
sourceCompatibility = rootProject.javaVersion
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/mtransit/commons/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object Constants {

@JvmStatic
// val DEBUG = true // DEBUG
val DEBUG = false
val DEBUG = BuildConfig.DEBUG_DEFAULT

const val NEW_LINE = '\n'
const val SPACE = ' '
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/mtransit/commons/ConstantsTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.mtransit.commons

import kotlin.test.Test

class ConstantsTests {

@Test
fun test_DEBUG() {
val expectedDebug = (System.getenv("MT_DEBUG_DEFAULT") ?: "false").toBoolean()
assert(Constants.DEBUG == expectedDebug)
Comment thread
mmathieum marked this conversation as resolved.
Outdated
}
}