Skip to content
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
10 changes: 6 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ apply from: "$rootDir/versioning.gradle"

def apikeyPropertiesFile = rootProject.file("apikeys.properties")
def apikeyProperties = new Properties()
apikeyProperties.load(new FileInputStream(apikeyPropertiesFile))
if (apikeyPropertiesFile.exists()) {
apikeyProperties.load(new FileInputStream(apikeyPropertiesFile))
}

def useReleaseKeystore = rootProject.file("scripts/release/app-release.jks").exists()

Expand Down Expand Up @@ -97,7 +99,7 @@ android {
shrinkResources true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField("String", "AMPLITUDE_KEY", apikeyProperties['amplitude.release'])
buildConfigField("String", "AMPLITUDE_KEY", apikeyProperties['amplitude.release'] ?: "MISSING_AMPLITUDE_RELEASE_KEY")
if (useReleaseKeystore) {
signingConfig signingConfigs.release
} else {
Expand All @@ -108,7 +110,7 @@ android {
debug {
applicationIdSuffix ".dev"
debuggable true
buildConfigField("String", "AMPLITUDE_KEY", apikeyProperties['amplitude.debug'])
buildConfigField("String", "AMPLITUDE_KEY", apikeyProperties['amplitude.debug'] ?: "MISSING_AMPLITUDE_DEBUG_KEY")
//signingConfig signingConfigs.debug
firebaseAppDistribution {
artifactType = "AAB"
Expand Down Expand Up @@ -142,7 +144,7 @@ android {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable project.hasProperty("enableAbiSplits") && project.getProperty("enableAbiSplits").toBoolean()
enable true
reset()
include "armeabi-v7a", "arm64-v8a"
universalApk true
Expand Down
79 changes: 71 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import javax.inject.Inject
import com.android.build.gradle.LibraryPlugin
import org.gradle.api.tasks.*
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper

buildscript {
Expand All @@ -14,13 +16,17 @@ buildscript {

def githubProperties = new Properties()
def githubPropertiesFile = file("$rootDir${File.separator}github.properties")
githubProperties.load(new FileInputStream(githubPropertiesFile))
if (githubPropertiesFile.exists()) {
githubProperties.load(new FileInputStream(githubPropertiesFile))
}

def apiKeysProperties = new Properties()
def apiKeysPropertiesFile = file("$rootDir${File.separator}apikeys.properties")
apiKeysProperties.load(new FileInputStream(apiKeysPropertiesFile))
if (apiKeysPropertiesFile.exists()) {
apiKeysProperties.load(new FileInputStream(apiKeysPropertiesFile))
}

ext.sentryApiKey = apiKeysProperties["sentry_dsn"]
ext.sentryApiKey = apiKeysProperties["sentry_dsn"] ?: "MISSING_SENTRY_DSN_KEY"

repositories {
mavenLocal()
Expand Down Expand Up @@ -108,14 +114,71 @@ task clean(type: Delete) {
delete rootProject.buildDir
}

tasks.register("installGitHooks") {
setGroup("Build Setup")
setDescription("Install local repository git hooks")
exec {
commandLine 'sh', '-c', 'git config core.hooksPath .githooks'
abstract class InstallGitHooksTask extends DefaultTask {

private ExecOperations execOps

@Inject
InstallGitHooksTask(ExecOperations execOperations) {
this.execOps = execOperations
}

java.lang.String getGroup() {
return "Build Setup";
}

java.lang.String getDescription() {
return "Install local repository git hooks";
}

@Internal
boolean isPosh7Available() {
try {
logger.debug('checking posh7');
ByteArrayOutputStream stdout = new ByteArrayOutputStream()
ExecResult result = execOps.exec {
commandLine 'cmd', '/c', 'where', 'pwsh.exe'
standardOutput = stdout
}
logger.info('where stdout = ' + stdout.toString() );
logger.info('where exit = ' + result.exitValue);
return result.exitValue == 0;
} catch (Exception e) {
logger.error('checking posh7 error ' + e.getMessage());
return false
}
}

@TaskAction
void action() {
OperatingSystem os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;
String shell = 'sh'
String commandFlag = '-c'

if (os.isWindows()) {
logger.lifecycle('Running on Windows.')

if (isPosh7Available()) {
shell = 'pwsh.exe'
logger.lifecycle('Using pwsh.exe')
} else {
shell = 'powershell.exe'
commandFlag = '-Command'
logger.lifecycle('pwsh.exe not found. Falling back to powershell.exe')
}
}

ByteArrayOutputStream stdout = new ByteArrayOutputStream()
ExecResult result = execOps.exec {
commandLine shell, commandFlag, 'git config core.hooksPath .githooks'
standardOutput = stdout
}
logger.info('githooks stdout = ' + stdout.toString() );
}
}

tasks.register("installGitHooks", InstallGitHooksTask)

var initialTaskNames = getProject().getGradle().getStartParameter().getTaskNames()
getProject().getGradle().getStartParameter().setTaskNames(
initialTaskNames + Collections.singletonList("installGitHooks"))
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ dependencyResolutionManagement {
*/
def githubProperties = new Properties()
def githubPropertiesFile = file("$rootDir${File.separator}github.properties")
githubProperties.load(new FileInputStream(githubPropertiesFile))
if (githubPropertiesFile.exists()) {
githubProperties.load(new FileInputStream(githubPropertiesFile))
}

repositories {
mavenLocal()
Expand Down