Skip to content

Commit

Permalink
Fix #60 add conf file sourcing in shadow rd script
Browse files Browse the repository at this point in the history
* Modify shadow start script as well as normal start script
* Verify changes present in generated scripts during check phase of
  build.
  • Loading branch information
gschueler committed Jan 18, 2017
1 parent 8dc2225 commit 9e691cb
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@ dependencies {
distShadowZip.mustRunAfter distZip
distShadowTar.mustRunAfter distTar

startScripts {
def scriptsClos = {

def addConfigSource = { regexTest, additionalText, line ->
// Looking for the line that starts with either CLASSPATH=
// or set CLASSPATH=, defined by the regexTest closure argument.
line = line.replaceAll(~/${regexTest}/) { original ->
original += "\n${additionalText}"
additionalText + "\n" + original
}
}

def addUnixConfigSource = addConfigSource.curry(
'^CLASSPATH=.*$',
'^# Determine the Java command to use to start the JVM.*',
'''
# Source user's config file
APP_CONFIG=$HOME/.$APP_NAME/$APP_NAME.conf
Expand All @@ -176,6 +176,22 @@ test -f $APP_CONFIG && source $APP_CONFIG
}

}
startScripts scriptsClos
startShadowScripts scriptsClos

task verifyScripts {
group = "Verification"
description = 'Verify the start scripts (normal and shadow) contain the modifications for the APP_CONFIG'
doFirst {
[startScripts.outputDir, startShadowScripts.outputDir].each { dir ->
def f = new File(dir, applicationName)
assert f.exists()
assert f.text ==~ /(?s)^.*APP_CONFIG.*\u0024/
}
}
}
check.dependsOn verifyScripts

/**
* Define rpm/deb details
*/
Expand Down

0 comments on commit 9e691cb

Please sign in to comment.