@@ -3,9 +3,6 @@ component {
33" ;
44 public function init (s3Root ) {
55 variables .s3Root = arguments .s3Root ;
6- if ( ! structKeyExists ( application , " expressTemplates" ) ) {
7- application .expressTemplates = new expressTemplates ().getExpressTemplates ( s3Root );
8- }
96 }
107
118 public void function reset () {
@@ -189,6 +186,13 @@ component {
189186 return versions [keys [arrayLen (key s )]].version ;
190187 }
191188
189+ private function getExpressTemplates (){
190+ if ( ! structKeyExists ( application , " expressTemplates" ) ) {
191+ application .expressTemplates = new expressTemplates ().getExpressTemplates ( s3Root );
192+ }
193+ return application .expressTemplates ;
194+ }
195+
192196 public function add (required string type , required string version ) {
193197 setting requesttimeout = " 10000000" ;
194198 var versions = getVersions (true );
@@ -239,6 +243,7 @@ component {
239243 if (resetRequired )
240244 s3List = getVersions (true ); // force reset();
241245 }
246+ getExpressTemplates ();
242247 // create the missing artifacts
243248 loop struct = s3List index = " local.vs" item = " local.el" {
244249 createArtifacts (mr ,el ," " ,includingForgeBox );
@@ -315,34 +320,34 @@ component {
315320 // extract lco and copy to S3
316321 if (type == " lco" ) {
317322 var result = createLCO (lcl ,s3 .version );
318- systemOutput (" lco: " & result & " " & numberFormat (getTickCount ()- s ),1 ,1 );
323+ systemOutput (" lco: " & result & " took " & numberFormat (getTickCount ()- s ) & " ms " ,1 ,1 );
319324 }
320325 else if (type == " fb" ) {
321326 var result = createForgeBox (lcl ,s3 .version ,false );
322- systemOutput (" forgebox: " & result & " " & numberFormat (getTickCount ()- s ),1 ,1 );
327+ systemOutput (" forgebox: " & result & " took " & numberFormat (getTickCount ()- s ) & " ms " ,1 ,1 );
323328 // abort;
324329 }
325330 else if (type == " fbl" ) {
326331 var result = createForgeBox (lcl ,s3 .version ,true );
327- systemOutput (" forgebox-light: " & result & " " & numberFormat (getTickCount ()- s ),1 ,1 );
332+ systemOutput (" forgebox-light: " & result & " took " & numberFormat (getTickCount ()- s ) & " ms " ,1 ,1 );
328333 }
329334 // create war and copy to S3
330335 else if (type == " war" ) {
331336 lock name = " build-lucee-war" timeout = " 10" {
332337 var result = createWar (lcl ,s3 .version );
333338 }
334- systemOutput (" war: " & result & " " & numberFormat (getTickCount ()- s ),1 ,1 );
339+ systemOutput (" war: " & result & " took " & numberFormat (getTickCount ()- s ) & " ms " ,1 ,1 );
335340 }
336341 // create war and copy to S3
337342 else if (type == " light" ) {
338343 var result = createLight (lcl ,s3 .version );
339- systemOutput (" light: " & result & " " & numberFormat (getTickCount ()- s ),1 ,1 );
344+ systemOutput (" light: " & result & " took " & numberFormat (getTickCount ()- s ) & " ms " ,1 ,1 );
340345 }
341346 else if (type == " express" ) {
342347 lock name = " build-lucee-express" timeout = " 10" {
343348 var result = createExpress (lcl ,s3 .version );
344349 }
345- systemOutput (" express: " & result & " " & numberFormat (getTickCount ()- s ),1 ,1 );
350+ systemOutput (" express: " & result & " took " & numberFormat (getTickCount ()- s ) & " ms " ,1 ,1 );
346351 }
347352 else {
348353 systemOutput (" unsupported: " & type & " :" & s3 .version ,1 ,1 );
@@ -354,6 +359,7 @@ component {
354359 catch (e ){
355360 systemOutput (" ----------------------------------------------" ,1 ,1 );
356361 systemOutput (cfcatch .stacktrace ,1 ,1 );
362+ writeLog ( text = e .message , exception = e , type = " error" );
357363 }
358364 finally {
359365 if (! isNull (lcl ) && fileExists (lcl )) fileDelete (lcl );
@@ -364,30 +370,32 @@ component {
364370 }
365371 }
366372
367- private function createLCO (jar ,version ) {
368- var lco = getTempDirectory () & " /lucee-" & version & " .lco" ;
369- var trg = variables .s3Root & version & " .lco" ;
373+ private function createLCO ( jar , version ) {
374+ var trg = variables .s3Root & version & " .lco" ;
370375 if ( fileExists ( trg ) ) {
371376 systemOutput (" --- " & trg & " already built, skipping" , true );
372377 }
373378 try {
374- fileCopy (" zip://" & jar & " !core/core.lco" ,lco ); // now extract
375- fileMove (lco ,trg );
379+ var temp = getTemp ( arguments .version );
380+ var lco = temp & " lucee-" & version & " .lco" ;
381+
382+ fileCopy ( " zip://" & jar & " !core/core.lco" , lco ); // now extract
383+ fileMove ( lco , trg );
376384 }
377385 finally {
378- if (! isNull (lco ) && fileExists ( lco )) fileDelete ( lco );
386+ if (! isNull (temp ) && directoryExists ( temp )) directoryDelete ( temp , true );
379387 }
380388 return trg ;
381389 }
382390
383- private function createWar (jar ,version ) {
384- var temp = getTemp ( arguments .version );
385- local .war = variables .s3Root & " lucee-" & version & " .war" ;
391+ private function createWar ( jar , version ) {
392+ var war = variables .s3Root & " lucee-" & version & " .war" ;
386393 if ( fileExists ( war ) ) {
387394 systemOutput (" --- " & war & " already built, skipping" , true );
388395 }
389- local .warTmp = temp & " lucee-" & version & " -temp-" & createUniqueId ()& " .war" ;
390- var curr = getDirectoryFromPath (getCurrenttemplatePath ());
396+ var temp = getTemp ( arguments .version );
397+ var warTmp = temp & " lucee-" & version & " -temp-" & createUniqueId () & " .war" ;
398+ var curr = getDirectoryFromPath ( getCurrentTemplatePath () );
391399
392400 var noLuceeServlet = checkVersionGTE ( arguments .version , 6 , 2 );
393401 // systemOutput("Has LuceeServlet Version check, gte 6.2: #noLuceeServlet#", true );
@@ -397,9 +405,9 @@ component {
397405 try {
398406 // temp directory
399407 // create paths and dir if necessary
400- local . build = {};
408+ var build = {};
401409 loop list = " extensions,common,website,war" item = " local.name" {
402- local . tmp = curr & " build/" & name & " /" ;
410+ var tmp = curr & " build/" & name & " /" ;
403411 if ( name == " extensions" && ! directoryExists ( tmp ) )
404412 directoryCreate ( tmp , true );
405413 if ( name == " war" ){
@@ -408,8 +416,8 @@ component {
408416 build [ name ] = tmp ;
409417
410418 }
411- systemOutput ( " ---- createWar" , true );
412- systemOutput ( build , true );
419+ // systemOutput( "---- createWar", true );
420+ // systemOutput( build, true );
413421
414422 // let's zip it
415423 zip action = " zip" file = warTmp overwrite = true {
@@ -419,33 +427,29 @@ component {
419427 zipparam source = build [" website" ];
420428 zipparam source = build [" war" ];
421429 }
422- fileMove (warTmp ,war );
430+ fileMove (warTmp , war );
423431 }
424432 finally {
425- if (! isNull (warTmp ) && fileExists ( warTmp )) fileDelete ( warTmp );
433+ if (! isNull (temp ) && directoryExists ( temp )) directoryDelete ( temp , true );
426434 }
427435 return war ;
428436 }
429437
430- private function createLight (jar , version , boolean toS3 = true ) {
438+ private function createLight (jar , version , boolean toS3 = true , tempDir ) {
431439 var sep = server .separator .file ;
432- var temp = getTemp ( arguments .version );
433- if ( directoryExists ( temp ) )
434- directoryDelete ( temp , true );
435- directoryCreate ( temp );
436-
437- local .trg = variables .s3Root & " lucee-light-" & version & " .jar" ;
440+ var trg = variables .s3Root & " lucee-light-" & version & " .jar" ;
438441 if ( fileExists ( trg ) ) {
439442 // avoid double handling for forgebox light builds
440443 systemOutput (" --- " & trg & " already built, skipping" , true );
441- var tempLight = getTempFile (getTempDirectory () , " lucee-light-" & version , " jar" );
444+ var tempLight = getTempFile ( arguments . tempDir , " lucee-light-" & version , " jar" );
442445 fileCopy ( trg , tempLight ); // create a local temp file from s3
443446 return tempLight ;
444447 }
445- local .s = getTickCount ();
448+ var temp = getTemp ( arguments .version );
449+ var s = getTickCount ();
446450 try {
447- local . tmpLoader = temp & " lucee-loader-" & createUniqueId (); // the jar
448- directoryCreate (tmpLoader );
451+ var tmpLoader = temp & " lucee-loader-" & createUniqueId (); // the jar
452+ directoryCreate ( tmpLoader );
449453
450454 // unzip
451455 try {
@@ -456,17 +460,17 @@ component {
456460 return " " ;
457461 }
458462 // rewrite trg
459- var extDir = tmpLoader & sep & " extensions" ;
463+ var extDir = tmpLoader & sep & " extensions" ;
460464 if ( directoryExists ( extDir ) ) directoryDelete (extDir ,true ); // deletes directory with all files inside
461465 directoryCreate ( extDir ); // create empty dir again (maybe Lucee expect this directory to exist)
462466
463467 // unzip core
464- var lcoFile = tmpLoader & sep & " core" & sep & " core.lco" ;
465- local .tmpCore = temp & " lucee-core-" & createUniqueId (); // the jar
468+ var lcoFile = tmpLoader & sep & " core" & sep & " core.lco" ;
469+ local .tmpCore = temp & " lucee-core-" & createUniqueId (); // the jar
466470 directoryCreate (tmpCore );
467471 zip action = " unzip" file = lcoFile destination = tmpCore ;
468472 // rewrite manifest
469- var manifest = tmpCore & sep & " META-INF" & sep & " MANIFEST.MF" ;
473+ var manifest = tmpCore & sep & " META-INF" & sep & " MANIFEST.MF" ;
470474 var content = fileRead (manifest );
471475 var index = find (' Require-Extension' ,content );
472476 if (index > 0 ) content = mid (content ,1 ,index - 1 )& variables .NL ;
@@ -483,44 +487,41 @@ component {
483487 if (toS3 ) fileMove (tmpLoaderFile ,trg );
484488 }
485489 finally {
486- if (toS3 && ! isNull (tmpLoaderFile ) && fileExists (tmpLoaderFile )) fileDelete (tmpLoaderFile );
487- if (! isNull (tmpLoader ) && directoryExists (tmpLoader )) directoryDelete (tmpLoader ,true );
488- if (! isNull (tmpCore ) && directoryExists (tmpCore )) directoryDelete (tmpCore ,true );
490+ if (! isNull (temp ) && directoryExists (temp )) directoryDelete (temp ,true );
489491 }
490492 return toS3 ? trg : tmpLoaderFile ;
491493 }
492494
493495 private string function createExpress (required jar ,required string version ) {
494496 var sep = server .separator .file ;
495- var temp = getTemp ( arguments .version );
496-
497- var trg = variables .s3Root & " lucee-express-" & version & " .zip" ;
497+ var trg = variables .s3Root & " lucee-express-" & version & " .zip" ;
498498 if ( fileExists ( trg ) ) {
499499 systemOutput (" --- " & trg & " already built, skipping" , true );
500500 return trg ;
501501 }
502+ var temp = getTemp ( arguments .version );
502503 // todo this can overlapp?
503- var curr = getDirectoryFromPath (getCurrenttemplatePath ());
504+ var curr = getDirectoryFromPath (getCurrentTemplatePath ());
504505
505506 // website trg
506- var zipTmp = temp & " lucee-express-" & version & " -temp-" & createUniqueId ()& " .zip" ;
507+ var zipTmp = temp & " lucee-express-" & version & " -temp-" & createUniqueId () & " .zip" ;
507508 var tmpTom = " #temp #tomcat" ;
508509 // Create the express zip
509510 try {
510511 // extension directory
511- local . extDir = local . curr & (" build/extensions/" );
512+ var extDir = curr & (" build/extensions/" );
512513 if (! directoryExists (extDir )) directoryCreate (extDir );
513514
514515 // common directory
515- local . commonDir = local . curr & (" build/common/" );
516+ var commonDir = curr & (" build/common/" );
516517 // if (!directoryExists(commonDir)) directoryCreate(commonDir);
517518
518519 // website directory
519- local . webDir = local . curr & (" build/website/" );
520+ var webDir = curr & (" build/website/" );
520521 // if (!directoryExists(webDir)) directoryCreate(webDir);
521522
522- var expressTemplates = application . expressTemplates ;
523- // unpack the servers
523+ var expressTemplates = getExpressTemplates (); // at this point it should be already cached in the application scope
524+ // unpack the lucee tomcat template
524525 var local_tomcat_templates = curr & " build/servers"
525526 if ( checkVersionGTE ( arguments .version , 6 , 2 ) ) {
526527 zip action = " unzip" file = " #local_tomcat_templates #/#expressTemplates [' tomcat-10' ] #" destination = tmpTom ;
@@ -544,40 +545,39 @@ component {
544545 fileMove ( zipTmp , trg );
545546 }
546547 finally {
547- if ( ! isNull ( zipTmp ) && fileExists ( zipTmp ) ) fileDelete ( zipTmp );
548- if ( ! isNull ( tmpTom ) && directoryExists ( tmpTom ) ) directoryDelete ( tmpTom , true );
548+ if (! isNull (temp ) && directoryExists (temp )) directoryDelete (temp ,true );
549549 }
550550 return trg ;
551551 }
552552
553553 private string function createForgeBox (required jar ,required string version , boolean light = false ) {
554- var sep = server .separator .file ;
555- var temp = getTemp ( arguments .version );
556- var curr = getDirectoryFromPath (getCurrenttemplatePath ());
557- var trg = variables .s3Root & " forgebox#( light ? ' -light' : ' ' ) #-" & version & " .zip" ;
554+ var trg = variables .s3Root & " forgebox#( light ? ' -light' : ' ' ) #-" & version & " .zip" ;
558555 if ( fileExists ( trg ) ) {
559556 systemOutput (" --- " & trg & " already built, skipping" , true );
560557 return trg ;
561558 }
559+ var sep = server .separator .file ;
560+ var temp = getTemp ( arguments .version );
561+ var curr = getDirectoryFromPath (getCurrentTemplatePath ());
562562
563- var zipTmp = temp & " forgebox#( light ? ' -light' : ' ' ) #-" & version & " -temp-" & createUniqueId ()& " .zip" ;
563+ var zipTmp = temp & " forgebox#( light ? ' -light' : ' ' ) #-" & version & " -temp-" & createUniqueId () & " .zip" ;
564564 try {
565565 // extension directory
566- local . extDir = curr & " /build/extensions/" ;
566+ var extDir = curr & " /build/extensions/" ;
567567 if (! directoryExists (extDir )) directoryCreate (extDir );
568568
569569 // common directory
570- local . commonDir = curr & " /build/common/" ;
570+ var commonDir = curr & " /build/common/" ;
571571 // if(!directoryExists(commonDir)) directoryCreate(commonDir);
572572
573573 // war directory
574574 var noLuceeServlet = checkVersionGTE ( arguments .version , 6 , 2 );
575575 // systemOutput("Has LuceeServlet Version check, gte 6.2: #noLuceeServlet#", true );
576- local . warDir = curr & " /build/" & (noLuceeServlet ? " war-6.2" : " war" ) & " /" ;
576+ var warDir = curr & " /build/" & (noLuceeServlet ? " war-6.2" : " war" ) & " /" ;
577577
578578 // create the war
579- local . war = temp & " /engine.war" ;
580- if ( light ) local .lightJar = createLight (jar , version , false );
579+ var war = temp & " /engine.war" ;
580+ if ( light ) local .lightJar = createLight (jar , version , false , temp );
581581
582582 zip action = " zip" file = war overwrite = true {
583583 zipparam source = extDir filter = " *.lex" prefix = " WEB-INF/lucee-server/context/deploy" ;
@@ -589,8 +589,8 @@ component {
589589 // create the json
590590 // Turn 1.2.3.4 into 1.2.3+4 and 1.2.3.4-rc into 1.2.3-rc+4
591591 var v = reReplace ( arguments .version , ' ([0-9]*\.[0-9]*\.[0-9]*)(\.)([0-9]*)(-.*)?' , ' \1\4+\3' );
592- local . json = temp & " /box.json" ;
593- fileWrite (json ,
592+ var json = temp & " /box.json" ;
593+ fileWrite ( json ,
594594' {
595595 "name":"Lucee #( light ? ' Light' : ' ' ) # CF Engine",
596596 "version":"#v #",
@@ -609,15 +609,13 @@ component {
609609 fileMove ( zipTmp , trg );
610610 }
611611 finally {
612- if (! isNull (lightJar ) && fileExists (lightJar )) fileDelete (lightJar );
613- if (! isNull (zipTmp ) && fileExists (zipTmp )) fileDelete (zipTmp );
614- if (! isNull (tmpTom ) && directoryExists (tmpTom )) directoryDelete (tmpTom ,true );
612+ if (! isNull (temp ) && directoryExists (temp )) directoryDelete (temp ,true );
615613 }
616614 return trg ;
617615 }
618616
619617 private function getTemp ( string version ){
620- var temp = getTempDirectory () & createUniqueId () & " -# arguments . version # " ;
618+ var temp = getTempDirectory () & " # arguments . version #- " & createUniqueId () & " / " ;
621619 if ( directoryExists ( temp ) )
622620 directoryDelete ( temp , true );
623621 directoryCreate ( temp );
0 commit comments