2 def properties
= [:] as Properties
4 def profiles
= [] as Set
7 def
static defaultProps
= [
9 name
: 'bubba-' + System
.currentTimeMillis(),
11 pastry_port_start
: '3993',
12 pastry_port_end
: '3999',
13 pastry_port_rotate
: '',
14 pastry_boot_host
: 'plubble.com',
15 pastry_boot_start
: '3993',
16 pastry_boot_end
: '3994',
18 external_port
: '3993',
22 past_storage
:'/tmp/storage-9090'
27 println
"going to initprops()"
28 for (e in defaultProps
) {
29 if (!this[e
.key
]) this[e
.key
] = e
.value
31 if (!this['sauer_cmd']) {
32 if (System
.getProperty('os.name').equalsIgnoreCase('linux')) {
33 this.sauer_cmd
= 'packages/plexus/dist/sauerbraten_plexus_linux -t'
35 this.sauer_cmd
= 'packages/plexus/dist/sauerbraten_plexus_windows.exe -t'
40 def
setProfile(prof
) {
41 profile
= prof ?
"$prof-" : ""
44 def
getAt(String key
) {
45 properties
["$profile$key" as String
]
47 def
putAt(String key
, value
) {
48 key
= "$profile$key" as String
49 def old
= properties
[key
]
51 properties
[key
] = value as String
54 def
propertyMissing(String name
) {
57 def
propertyMissing(String name
, value
) {
61 def output
= file
.newOutputStream()
63 properties
.store(output
, "Plexus Properties")
67 def dir
= new File('').getAbsoluteFile()
68 def plexusdir
= new File(dir
, 'packages/plexus')
69 this.file
= new File(plexusdir
, 'plexus.properties')
71 properties
= [:] as Properties
73 def input
= new FileInputStream(file
)
75 properties
.load(input
)
77 profiles
= [*(properties?
.profiles ? properties
.profiles
.split(',') : [])] as Set
78 if (properties
.last_profile
== null) properties
.last_profile
= ""
79 last_profile
= properties
.last_profile
83 def
setLastProfile(prof
) {
84 if (prof
!= last_profile
) {
85 last_profile
= properties
.last_profile
= prof
88 def
containsProfile(prof
) {
89 return profiles
.contains(prof
);
91 def
addProfile(prof
) {
92 if (!profiles
.contains(prof
)) {
94 properties
.profiles
= profiles
.join(',')
101 def
removeProfile() {
105 k
.addAll(properties
.keySet())
107 if (it
==~
"$profile.*") {
108 properties
.remove(it
)
111 profiles
.remove(profile
.substring(0, profile
.length() - 1))
112 properties
.profiles
= profiles
.join(',')