-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-run-cfml.xml
200 lines (182 loc) · 6.09 KB
/
build-run-cfml.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?xml version="1.0" encoding="UTF-8"?>
<project default="all" basedir="." name="run-cfml">
<macrodef name="echots">
<attribute name="message"/>
<sequential>
<local name="timestamp" />
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<echo message="---------- ${timestamp} - @{message} ----------" />
</sequential>
</macrodef>
<target name="all">
<echots message="Lucee Starting"/>
<script language="CFML">
<![CDATA[
systemOutput( "---------- #DateTimeFormat(now(),'yyyy-mm-dd HH:nn:ss')# - Lucee Started ----------", true);
systemOutput( "#server.lucee.version#", true );
request.adminPassword="admin";
request.errorThrown = false;
try {
// set a password for the admin
try {
admin
action="updatePassword"
type="web"
oldPassword=""
newPassword="#request.adminPassword#";
systemOutput( "Set Web admin password", true );
}
catch(e){
systemOutput( e.message, true ); // may exist from previous execution
}
try {
admin
action="updatePassword"
type="server"
oldPassword=""
newPassword="#request.adminPassword#";
systemOutput( "Set Server admin password", true );
}
catch(e){
systemOutput( e.message, true ); // may exist from previous execution
}
admin
action="updateMapping"
type="web"
password="#request.adminPassword#"
virtual="/"
physical="#webroot#"
toplevel="true"
archive=""
primary="physical"
trusted="no";
admin
action="getMappings"
type="web"
password="#request.adminPassword#"
returnVariable="mappings";
systemOutput( "-------------- Mappings --------------", true );
loop query="mappings" {
systemOutput("#mappings.virtual# #chr( 9 )# #mappings.strPhysical# "
& ( len( mappings.strArchive ) ? "[#mappings.strArchive#] " : "" )
& ( len( mappings.inspect ) ? "(#mappings.inspect#)" : ""), true );
}
param name="extensionDir" default="";
if ( len( extensionDir) ){
function reportExtensions() localmode=true {
systemOutput( "-------------- Extensions --------------", true );
deployExtensions = DirectoryList( path=extensionDir, filter="*.lex" );
loop array="#deployExtensions#" item="lexFile" {
SystemOutput("Manually installing extension [#lexFile#]", true);
FileCopy( lexFile, getTempDirectory() ); // make a copy, so lucee doesn't delete it after installing
admin
action="updateRHExtension"
type="server"
password="#request.adminPassword#"
source="#getTempDirectory()##ListLast( lexFile, "\/")#";
}
if ( ArrayLen( deployExtensions ) eq 0)
SystemOutput( "No *.lex extension files found in directory [#extensionDir#], directory exists: [#DirectoryExists(extensionDir)#]", true );
}
reportExtensions();
}
systemOutput( "-------------- Lucee Initialized --------------", true );
systemOutput( "", true );
systemOutput( "Running [#execute#]", true);
systemOutput( "", true );
param name="executeScriptByInclude" default="false";
function parseAntParams (str) localmode=true {
loopGuard=0;
pos = findNoCase(" -D", str);
params = {};
do {
vStart = findNoCase('"', str, pos+1 );
if (vStart gt 0){
name = mid(str, pos+3, (vStart-pos-4));
vEnd = findNoCase('"', str, vStart+1);
if (vEnd gt 0){
val = mid(str, vStart+1, vEnd-vStart-1);
pos = vEnd+1;
params[ name ]=val;
}
} else {
pos = 0; // bail
}
if (pos gt 0) {
pos = findNoCase(" -D", str, pos );
loopGuard++;
}
if (loopGuard gt 100)
throw "Error Loop protection @ #loopGuard#";
} while ( pos > 0);
return params;
}
function loadPassedVariables() localmode=true {
// TODO this is windows only and doesn't work
var params = parseAntParams( server.system.environment.ANT_CMD_LINE_ARGS?: "" );
// var props = FileRead( server.system.properties[ "lucee.base.dir" ] & "/ant_args.properties" );
StructAppend(params, variables);
var passedVariables = {};
loop collection=#params# key="key" value="value" {
if ( isSimpleValue( value ) )
passedVariables[ key ] = value;
}
if ( structcount( passedVariables ) ) {
systemOutput( "", true );
systemOutput( "Variables", true);
loop collection=passedVariables key="_k" value="_v" {
systemOutput( chr(9) & _k & ": " & _v , true);
}
systemOutput( "", true );
}
return passedVariables;
}
passedVariables = loadPassedVariables();
if ( compile eq "true" ){
systemOutput( "-------------- Start Compiling Webroot --------------", true );
admin
action="compileMapping"
type="web"
password=#request.adminPassword#
virtual="/"
stoponerror="false";
systemOutput( "-------------- Finished Compiling Webroot --------------", true );
}
try {
if ( executeScriptByInclude eq "true"){
include template="#execute#";
} else {
_internalRequest(
template = execute,
url = passedVariables
); // using internal request runs the Application.cfc, pass any simple variables in as URLs
}
} catch (e){
request.errorThrown = true;
systemOutput( cfcatch, true);
rethrow;
}
/*
if ( ! FileExists( execute ) ){
systemOutput( DirectoryList( path="/" ), true);
systemOutput( DirectoryList( path=webroot ), true);
//systemOutput( ExpandPath( execute ) ), true);
throw "Execute: [#execute#] file not found";
} else {
include template="#execute#";
}
*/
systemOutput( "", true );
systemOutput( "-------------- Finished --------------", true );
} catch (e){
if ( !request.errorThrown )
systemOutput( cfcatch, true);
rethrow;
}
]]>
</script>
<echots message="Lucee Stopping"/>
</target>
</project>