PageRenderTime 57ms CodeModel.GetById 50ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/build-support/trunk/ci/copy_properties.groovy

#
Groovy | 53 lines | 43 code | 4 blank | 6 comment | 3 complexity | b3deed8fac0f9a95d6390a87caec3837 MD5 | raw file
 1#!/usr/bin/env groovy
 2/* This script copies properties provided as System properties in Hudson into actual properties files used by jEdit's
 3 * Build process.
 4 */
 5 
 6def props = System.properties
 7def env = System.env
 8
 9String workspace = props.get("user.dir")
10String storeComment = "## THIS FILE IS GENERATED BASED ON SYSTEM PROPERTIES SUPPLIED TO HUDSON, AND IS USUALLY REPLACED ON EACH BUILD."
11
12println "Copying properties over to appropriate directories"
13def coreProps = new Properties() 
14def pluginProps = new Properties()
15props.each { key, value ->
16   if(key.startsWith("je.ci.")) {
17      println "jEdit CI prop found - ${key}: ${value}"
18      if(key.startsWith("je.ci.pl.")) {
19         def cleanKey = key - 'je.ci.pl.'
20         println "   clean key: ${cleanKey}"
21         pluginProps.setProperty(cleanKey, value)
22      } else {
23         def cleanKey = key - 'je.ci.'
24         println "   clean key: ${cleanKey}"
25         coreProps.setProperty(cleanKey, value)
26      }
27   }
28}
29File corePropsFile = new File(workspace, "jedit/build.properties")
30// make sure stuff exists.
31corePropsFile.parentFile.exists() ?: corePropsFile.parentFile.mkdirs() ?: {
32   System.err.println("'${corePropsFile.parentFile}' did not exist, and could not be created. Exiting.")
33   System.exit(1)
34}()
35corePropsFile.exists() ?: corePropsFile.createNewFile() ?: {
36   System.err.println("'${corePropsFile}' did not exist, and could not be created. Exiting.")
37   System.exit(1)
38}()
39coreProps.store(corePropsFile.newWriter(), storeComment)
40
41File pluginPropsFile = new File(workspace, "jedit/jars/build.properties")
42// make sure stuff exists.
43pluginPropsFile.parentFile.exists() ?: pluginPropsFile.parentFile.mkdirs() ?: {
44   System.err.println("'${pluginPropsFile.parentFile}' did not exist, and could not be created. Exiting.")
45   System.exit(1)
46}()
47pluginPropsFile.exists() ?: pluginPropsFile.createNewFile() ?: {
48   System.err.println("'${pluginPropsFile}' did not exist, and could not be created. Exiting.")
49   System.exit(1)
50}()
51pluginProps.putAll(coreProps)
52pluginProps.store(pluginPropsFile.newWriter(), storeComment)
53/* ::mode=groovy:noTabs=true:maxLineLen=120:wrap=soft:: */