2019-02-01 14:26:58 +00:00
include ':app' , ':architecture'
2019-03-21 19:41:41 +00:00
2019-10-04 23:01:12 +00:00
def log ( message ) {
logger . lifecycle ( "[settings] ${message}" )
}
def runCmd ( cmd , workingDir , successMessage ) {
def proc = cmd . execute ( null , new File ( workingDir ) )
def standardOutput = new ByteArrayOutputStream ( )
def standardError = new ByteArrayOutputStream ( )
proc . consumeProcessOutput ( standardOutput , standardError )
proc . waitFor ( )
if ( proc . exitValue ( ) ! = 0 ) {
throw new GradleException ( "Process '${cmd}' finished with non-zero exit value ${proc.exitValue()}:\n\nstdout:\n${standardOutput.toString()}\n\nstderr:\n${standardError.toString()}" )
} else {
log ( successMessage )
}
return standardOutput
}
2019-03-21 19:41:41 +00:00
//////////////////////////////////////////////////////////////////////////
// Local Development overrides
//////////////////////////////////////////////////////////////////////////
2019-10-04 23:01:12 +00:00
Properties localProperties = null
String settingAppServicesPath = "substitutions.application-services.dir"
String settingAndroidComponentsPath = "autoPublish.android-components.dir"
2019-03-21 19:41:41 +00:00
if ( file ( 'local.properties' ) . canRead ( ) ) {
localProperties = new Properties ( )
localProperties . load ( file ( 'local.properties' ) . newDataInputStream ( ) )
2019-10-04 23:01:12 +00:00
log ( 'Loaded local.properties' )
2019-03-21 19:41:41 +00:00
} else {
2019-10-04 23:01:12 +00:00
log ( 'Missing local.properties; see https://github.com/mozilla-mobile/fenix/blob/master/README.md#local-properties-helpers for instructions.' )
2019-03-21 19:41:41 +00:00
}
if ( localProperties ! = null ) {
2019-08-15 21:33:40 +00:00
localProperties . each { prop - >
gradle . ext . set ( "localProperties.${prop.key}" , prop . value )
}
2019-10-04 23:01:12 +00:00
String appServicesLocalPath = localProperties . getProperty ( settingAppServicesPath )
2019-03-21 19:41:41 +00:00
if ( appServicesLocalPath ! = null ) {
2019-10-04 23:01:12 +00:00
log ( "Enabling composite build with application-services modules from: $appServicesLocalPath" )
2019-07-17 22:09:47 +00:00
includeBuild ( appServicesLocalPath )
2019-03-21 19:41:41 +00:00
} else {
2019-10-04 23:01:12 +00:00
log ( "Disabled composite builds with application-services. Enable them by settings '$settingAppServicesPath' in local.properties" )
}
String androidComponentsLocalPath = localProperties . getProperty ( settingAndroidComponentsPath )
if ( androidComponentsLocalPath ! = null ) {
log ( "Enabling automatic publication of android-components from: $androidComponentsLocalPath" )
log ( "Determining if android-components are up-to-date..." )
def compileAcCmd = [ "${androidComponentsLocalPath}/gradlew" , "compileReleaseKotlin" ]
def compileOutput = runCmd ( compileAcCmd , androidComponentsLocalPath , "Compiled android-components." )
// This is somewhat brittle: parse last line of gradle output, to fish out how many tasks were executed.
// One executed task means gradle didn't do any work other than executing the top-level 'compile' task.
def compileTasksExecuted = compileOutput . toString ( ) . split ( '\n' ) . last ( ) . split ( ':' ) [ 1 ] . split ( ' ' ) [ 1 ]
if ( compileTasksExecuted . equals ( "1" ) ) {
log ( "android-components are up-to-date, skipping publication." )
} else {
log ( "android-components changed, publishing locally..." )
def publishAcCmd = [ "${androidComponentsLocalPath}/gradlew" , "publishToMavenLocal" , "-Plocal=true" ]
runCmd ( publishAcCmd , androidComponentsLocalPath , "Published android-components." )
}
} else {
log ( "Disabled auto-publication of android-components. Enable it by settings '$settingAndroidComponentsPath' in local.properties" )
2019-03-21 19:41:41 +00:00
}
2019-10-04 23:01:12 +00:00
}