Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ecb021a

Browse files
committedAug 19, 2022
v1.1.0 update
increment version from 1.0.2 to 1.1.0 updated README.md rewrote dependency collection mechanism support auto-collection of more dependencies from local WebCTRL installations support auto-collection of dependencies from an external website added 'depend [--all]' command for triggering dependency recollection added jar files to default .gitignore removed config.txt from default .gitignore added listener and welcome-file-list to default deployment descriptor added `override` variable which allows extensions to invoke base commands they override (if any) added support for an optional startup script implemented fail-fast compilation
1 parent c60bc00 commit ecb021a

File tree

4 files changed

+244
-120
lines changed

4 files changed

+244
-120
lines changed
 

‎.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
!LICENSE
44
!README.md
55
!Utility.bat
6-
!*.cer
6+
!*.cer
7+
!DEPENDENCIES

‎DEPENDENCIES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
file:tomcat-embed-core:webserver\lib
2+
file:addonsupport-api-addon:modules\addonsupport
3+
file:alarmmanager-api-addon:modules\alarmmanager
4+
file:bacnet-api-addon:bin\lib
5+
file:directaccess-api-addon:modules\directaccess
6+
file:webaccess-api-addon:modules\webaccess
7+
file:xdatabase-api-addon:modules\xdatabase

‎README.md

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,30 @@
22

33
WebCTRL is a trademark of Automated Logic Corporation. Any other trademarks mentioned herein are the property of their respective owners.
44

5-
[This script](Utility.bat) may be used to automate certain aspects of *WebCTRL* add-on development on *Windows* operating systems. *WebCTRL SDK* dependencies are automatically collected from a local *WebCTRL* installation. Commands are provided for add-on compilation and packaging. Keystore management is automatic, so you don't have to worry about manually signing your *.addon* file.
5+
- [Add-On Development Script for WebCTRL](#add-on-development-script-for-webctrl)
6+
- [About](#about)
7+
- [Setup Instructions](#setup-instructions)
8+
- [Command Reference](#command-reference)
9+
- [Extensions](#extensions)
10+
- [Generated Project Structure](#generated-project-structure)
11+
- [Manual Deployment](#manual-deployment)
12+
- [Dependencies](#dependencies)
13+
- [Automated Collection](#automated-collection)
14+
- [Keystore Management](#keystore-management)
15+
- [Compatibility Notes](#compatibility-notes)
16+
- [Known Issues](#known-issues)
17+
- [Recursive Dependency Collection](#recursive-dependency-collection)
18+
- [Lazy Inline Constants](#lazy-inline-constants)
19+
20+
## About
21+
22+
[This script](Utility.bat) may be used to automate certain aspects of *WebCTRL* add-on development on *Windows* operating systems. *Windows* version 10 or greater is required. *WebCTRL SDK* dependencies are automatically collected from a local *WebCTRL* installation. Other dependencies may be automatically downloaded from URLs. Commands are provided for add-on compilation and packaging. Keystore management is automatic, so you don't have to worry about manually signing your *.addon* file. Newly created projects are scaffolded by the script to contain all required files.
623

724
## Setup Instructions
825

9-
1. Install *WebCTRL7.0* or later.
26+
1. Install *WebCTRL8.0* or later.
1027

11-
1. Install [*JDK 16*](https://jdk.java.net/) or later.
28+
1. Install the most recent [*JDK*](https://jdk.java.net/) release.
1229

1330
1. Install [*Visual Studio Code*](https://code.visualstudio.com/) and the following extensions:
1431

@@ -28,7 +45,7 @@ WebCTRL is a trademark of Automated Logic Corporation. Any other trademarks men
2845

2946
- If the script cannot locate a *WebCTRL* installation folder under *%SystemDrive%*, you will be prompted to specify an installation path.
3047

31-
- The script will automatically retrieve all [runtime dependencies](#dependency-collection) from this *WebCTRL* installation.
48+
- The script will automatically retrieve all [runtime dependencies](#dependencies) from this *WebCTRL* installation.
3249

3350
- You will be prompted to enter a keystore password and a few other parameters for creating a new keystore. Refer to [Keystore Management](#keystore-management) for more details.
3451

@@ -52,6 +69,7 @@ The following commands may be used to automate add-on compilation and packaging.
5269
| - | - |
5370
| `help` | Displays a help message listing these commands with brief descriptions. |
5471
| `cls` | Clears the terminal. |
72+
| `depend [--all]` | Attempts to collect missing dependencies. Recollects all dependencies if the `--all` flag is given. |
5573
| `init [--new]` | Reinitializes the current project if no parameters are given. Prompts you to initialize a new project if the `--new` flag is given. |
5674
| `build [args]` | Compiles source code. The last modified timestamp for each *.java* file is recorded to avoid unnecessary recompilation. Arguments are passed to the `javac` compilation command. Arguments are stored for future invokation, so you only have to type them once. The default compilation flag is `--release 11`. |
5775
| `pack` | Packages all relevant files into a newly created *.addon* archive. |
@@ -64,7 +82,11 @@ The following commands may be used to automate add-on compilation and packaging.
6482

6583
## Extensions
6684

67-
Custom project-specific commands can be created to extend the functionality of this script. For examples, refer to <https://github.com/automatic-controls/centralizer-for-webctrl/tree/main/ext>. Any batch file placed in *./ext* is treated as an extension. The name of each batch file is used as the command name (case-insensitive). It is expected that each extension prints help information to the terminal when passed the `--help` parameter. Help information is appended to the help menu shown in the terminal. The default commands shown in the previous section can be overridden by extensions. For instance, <https://github.com/automatic-controls/centralizer-for-webctrl/blob/main/ext/pack.bat> overrides the default `pack` command.
85+
Custom project-specific commands can be created to extend the functionality of this script. For examples, refer to <https://github.com/automatic-controls/centralizer-for-webctrl/tree/main/ext>. Any batch file placed in *./ext* is treated as an extension. The name of each batch file is used as the command name (case-insensitive). It is expected that each extension prints help information to the terminal when passed the `--help` parameter. Help information is appended to the help menu shown in the terminal.
86+
87+
The default commands shown in the previous section can be overridden by extensions. For instance, <https://github.com/automatic-controls/commissioning-scripts/blob/main/ext/pack.bat> overrides the default `pack` command. This example also shows how to invoke the overridden packing command (akin to the `super` keyword in Java).
88+
89+
An optional script, `./startup.bat`, is invoked whenever a project folder is loaded. This may be used for any additional setup required for project files after cloning a remote repository to your local device.
6890

6991
## Generated Project Structure
7092

@@ -74,28 +96,32 @@ Custom project-specific commands can be created to extend the functionality of t
7496
| *./.gitignore* | Tells *Git* what to ignore when committing files. |
7597
| *./Utility.bat* | Script to automate builds. |
7698
| *./README.md* | User-friendly information about the project. |
77-
| *./DEPENDENCIES* | Record all compile-time dependencies. |
7899
| *./LICENSE* | License file for the project. |
79-
| *./config.txt* | Specifies additional compilation flags. |
100+
| *./config* | Contains various configuration files for this script. |
101+
| *./config/BUILD_DETAILS* | Record basic information about the latest build. |
102+
| *./config/COMPILE_FLAGS* | Specifies additional compilation flags. |
103+
| *./config/EXTERNAL_DEPS* | File specifying external dependencies for [automatic collection](#automated-collection). |
104+
| *./config/RUNTIME_DEPS* | File specifying runtime dependencies for [automatic collection](#automated-collection). |
80105
| *./src* | Contains all source code. |
81106
| *./classes* | Contains and indexes compiled *.class* files. |
82107
| *./classes/index.txt* | Records last modified timestamps for source code to avoid unnecessary recompilation. |
83108
| *./root* | Root directory packaged into the *.addon* archive. |
84-
| *./root/info.xml* | Contains basic information. |
109+
| *./root/info.xml* | Contains basic information about the add-on. |
85110
| *./root/webapp* | Static resources (e.g, files and folders including *html*, *css*, *js*, *jsp*, and *png*). |
86111
| *./root/webapp/WEB-INF/web.xml* | Deployment descriptor (e.g, servlet, filter, and listener mappings). |
87112
| *./root/webapp/WEB-INF/classes* | Contains compiled *.class* files. |
88113
| *./root/webapp/WEB-INF/lib* | Contains dependencies **not** provided by *WebCTRL* at runtime. |
89114
| *./lib* | Contains project-specific dependencies provided by *WebCTRL* at runtime. |
90115
| *./ext* | Contains [extensions](#extensions) that provide additional commands. |
116+
| *./startup.bat* | Batch script which is executed whenever the project folder is loaded. |
91117

92118
## Manual Deployment
93119

94120
1. Place the authentication certificate (look for a file with the *.cer* extension in your local clone of this repository) into the *./addons* directory of the target *WebCTRL* installation.
95121

96122
1. Use the *WebCTRL* interface to install the *.addon* archive of your project.
97123

98-
## Dependency Collection
124+
## Dependencies
99125

100126
Runtime dependencies are located in *./lib* relative to your local clone of this repository. These dependencies do not need to be packaged into your *.addon* file because they are provided by *WebCTRL* at runtime. Other external dependencies should be placed in *./root/webapp/WEB-INF/lib* relative to your project folder. The following runtime dependencies are collected from your *WebCTRL* installation:
101127

@@ -109,7 +135,25 @@ Runtime dependencies are located in *./lib* relative to your local clone of this
109135
| [*webaccess-api-addon*](http://repo.alcshare.com/com/controlj/green/webaccess-api-addon/) | *./modules/webaccess* |
110136
| [*xdatabase-api-addon*](http://repo.alcshare.com/com/controlj/green/xdatabase-api-addon/) | *./modules/xdatabase* |
111137

112-
If you change the *WebCTRL* installation by manually editing *./config.txt* (relative to your local clone of this repository), then you should delete *./lib* to force dependency recollection. Feel free to browse your *WebCTRL* installation for dependencies that give access to other internal APIs if these defaults are insufficient. If you would like to add a *WebCTRL* API to one project folder without affecting any other projects, the *.jar* file should be placed in *./lib* relative to your project folder.
138+
Feel free to browse your *WebCTRL* installation for dependencies that give access to other internal APIs if these defaults are insufficient. If you would like to add a *WebCTRL* API to one project folder without affecting any other projects, the *.jar* file should be placed in *./lib* relative to your project folder. This is also the folder where source jars should be placed for external dependencies (source jars do not need to be packaged into the add-on; however, they are useful for intellisense and documentation).
139+
140+
### Automated Collection
141+
142+
There are three files which define automatic dependency collection. The first is [*./DEPENDENCIES*](./DEPENDENCIES) relative to your local clone of this repository. This file defines global runtime dependencies used by every project (e.g, the *WebCTRL SDK*). The other two files are [*./config/EXTERNAL_DEPS*](https://github.com/automatic-controls/commissioning-scripts/blob/main/config/EXTERNAL_DEPS) and [*./config/RUNTIME_DEPS*](https://github.com/automatic-controls/commissioning-scripts/blob/main/config/RUNTIME_DEPS) relative to each project folder (click the links for an example).
143+
144+
Dependencies specified by *EXTERNAL_DEPS* are placed in *./root/webapp/WEB-INF/lib*. Dependencies specified by *RUNTIME_DEPS* are placed in *./lib*. Dependency collection automatically occurs whenever a project folder is loaded, or it can be manually triggered with the [`depend`](#command-reference) command.
145+
146+
Each dependency list adheres to the same file format. Two schemes currently exist for collecting dependencies. The `file` scheme searches for a dependency located in your *WebCTRL* installation. The `url` scheme downloads a dependency from a website (using [`curl`](https://curl.se/windows/microsoft.html)). See the example:
147+
148+
```
149+
url:janino:https://repo1.maven.org/maven2/org/codehaus/janino/janino/3.1.7/janino-3.1.7-sources.jar
150+
url:commons-compiler:https://repo1.maven.org/maven2/org/codehaus/janino/commons-compiler/3.1.7/commons-compiler-3.1.7-sources.jar
151+
file:spring-context:bin\lib
152+
file:javax.activation:bin\lib
153+
file:core-api:modules\core
154+
```
155+
156+
The general format is `scheme:identifier:location`. For files, the location is a relative path to the folder in your *WebCTRL* installation which contains the dependency. For urls, the location is a direct download link. The identifier should be the first part of the dependency's filename (excluding the version). Dependency filenames are generally expected to match the regular expression `^identifier-\d.*\.jar$`.
113157

114158
## Keystore Management
115159

@@ -123,9 +167,9 @@ The generated 2048-bit RSA key-pair is valid for 100 years, uses SHA512 as the s
123167

124168
## Known Issues
125169

126-
### Automatic Collection of External Dependencies
170+
### Recursive Dependency Collection
127171

128-
Recursive dependency collection from *Maven* repositories is not supported. *POM* files are commonly used by other compilation scripts for such purposes.
172+
Recursive dependency collection from *Maven* repositories is not supported. *POM* files are commonly used by other compilation scripts for such purposes. For this development tool, you must manually specify the URL to download each required dependency individually.
129173

130174
### Lazy Inline Constants
131175

‎Utility.bat

Lines changed: 179 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if "%1" EQU "--goto" (
4646
setlocal EnableDelayedExpansion
4747

4848
:: Version control
49-
set "version=1.0.2"
49+
set "version=1.1.0"
5050
if "%1" EQU "--version" (
5151
echo %version%
5252
exit /b
@@ -55,6 +55,9 @@ if "%1" EQU "--version" (
5555
title Add-On Development Utility for WebCTRL
5656
echo Initializing...
5757

58+
:: Whether to let extensions override commands of the same name
59+
set "override=1"
60+
5861
:: This script's location for extension callback usage
5962
set "callback=%~f0"
6063

@@ -125,61 +128,8 @@ if "%WebCTRL%" EQU "" (
125128
goto :webctrlFinder
126129
)
127130

128-
:: Collect runtime dependencies from the WebCTRL installation
129-
setlocal
130-
set "depFolders[1]=%WebCTRL%\webserver\lib"
131-
set "depFiles[1]=tomcat-embed-core"
132-
set "depFolders[2]=%WebCTRL%\modules\addonsupport"
133-
set "depFiles[2]=addonsupport-api-addon"
134-
set "depFolders[3]=%WebCTRL%\modules\alarmmanager"
135-
set "depFiles[3]=alarmmanager-api-addon"
136-
set "depFolders[4]=%WebCTRL%\bin\lib"
137-
set "depFolders2[4]=%WebCTRL%\modules\bacnet"
138-
set "depFiles[4]=bacnet-api-addon"
139-
set "depFolders[5]=%WebCTRL%\modules\directaccess"
140-
set "depFiles[5]=directaccess-api-addon"
141-
set "depFolders[6]=%WebCTRL%\modules\webaccess"
142-
set "depFiles[6]=webaccess-api-addon"
143-
set "depFolders[7]=%WebCTRL%\modules\xdatabase"
144-
set "depFiles[7]=xdatabase-api-addon"
145-
set "msg=0"
146-
for /L %%i in (1,1,7) do (
147-
set "exists=0"
148-
for /F %%j in ('dir "%globalLib%" /B ^| findstr /C:"!depFiles[%%i]!"') do (
149-
set "exists=1"
150-
)
151-
if "!exists!" EQU "0" (
152-
set "msg=1"
153-
set "file="
154-
for /F %%j in ('dir "!depFolders[%%i]!" /B ^| findstr /C:"!depFiles[%%i]!"') do (
155-
set "file=%%j"
156-
)
157-
if "!file!" EQU "" (
158-
for /F %%j in ('dir "!depFolders2[%%i]!" /B ^| findstr /C:"!depFiles[%%i]!"') do (
159-
set "file=%%j"
160-
)
161-
if "!file!" EQU "" (
162-
echo Failed to collect dependency: !depFiles[%%i]!
163-
) else (
164-
copy /Y "!depFolders2[%%i]!\!file!" "%globalLib%\!file!" >nul
165-
if !ErrorLevel!==0 (
166-
echo Collected dependency: !depFiles[%%i]!
167-
) else (
168-
echo Failed to collect dependency: !depFiles[%%i]!
169-
)
170-
)
171-
) else (
172-
copy /Y "!depFolders[%%i]!\!file!" "%globalLib%\!file!" >nul
173-
if !ErrorLevel!==0 (
174-
echo Collected dependency: !depFiles[%%i]!
175-
) else (
176-
echo Failed to collect dependency: !depFiles[%%i]!
177-
)
178-
)
179-
)
180-
)
181-
if "%msg%" EQU "1" echo.
182-
endlocal
131+
:: Collect dependencies
132+
if exist "%settings%\DEPENDENCIES" call :collect "%settings%\DEPENDENCIES" "%globalLib%"
183133

184134
:: Keystore used for signing the addon
185135
set "keystore=%settings%\keystore.jks"
@@ -189,7 +139,7 @@ set "alias=addon_dev"
189139

190140
:: Certificate file
191141
set "certFileName=Authenticator.cer"
192-
for /f "tokens=* delims=" %%i in ('dir /A-D /B "%settings%" ^| findstr /C:.cer') do set "certFileName=%%i"
142+
for /f "tokens=* delims=" %%i in ('dir /A-D /B "%settings%\*.cer"') do set "certFileName=%%i"
193143
set "certFile=%settings%\%certFileName%"
194144

195145
:: Retrieve the keystore password
@@ -236,14 +186,15 @@ if not exist "%certFile%" (
236186

237187
:: List of valid workspace commands
238188
set "commands[1]=help"
239-
set "commands[2]=build"
240-
set "commands[3]=pack"
241-
set "commands[4]=make"
242-
set "commands[5]=sign"
243-
set "commands[6]=forge"
244-
set "commands[7]=deploy"
245-
set "commands[8]=exec"
246-
set "commands=8"
189+
set "commands[2]=depend"
190+
set "commands[3]=build"
191+
set "commands[4]=pack"
192+
set "commands[5]=make"
193+
set "commands[6]=sign"
194+
set "commands[7]=forge"
195+
set "commands[8]=deploy"
196+
set "commands[9]=exec"
197+
set "commands=9"
247198

248199
:: Retrieve workspace from parameter
249200
if "%*" NEQ "" (
@@ -275,7 +226,7 @@ exit /b
275226
exit /b
276227

277228
:help
278-
if exist "%ext%\help.bat" (
229+
if "%override%" EQU "1" if exist "%ext%\help.bat" (
279230
call "%ext%\help.bat" %*
280231
exit /b
281232
)
@@ -310,8 +261,50 @@ exit /b
310261
echo.
311262
exit /b
312263

264+
:depend
265+
if "%override%" EQU "1" if exist "%ext%\depend.bat" (
266+
call "%ext%\depend.bat" %*
267+
exit /b
268+
)
269+
if /i "%*" EQU "--help" (
270+
echo DEPEND [--all] Attempts to collect missing dependencies.
271+
echo Recollects all dependencies if the '--all' flag is given.
272+
exit /b
273+
) else if /i "%*" EQU "--all" (
274+
rmdir /S /Q "%globalLib%" >nul 2>nul
275+
rmdir /S /Q "%lib%" >nul 2>nul
276+
rmdir /S /Q "%localLib%" >nul 2>nul
277+
mkdir "%globalLib%" >nul 2>nul
278+
mkdir "%lib%" >nul 2>nul
279+
mkdir "%localLib%" >nul 2>nul
280+
)
281+
setlocal
282+
set "err=0"
283+
if exist "%settings%\DEPENDENCIES" (
284+
call :collect "%settings%\DEPENDENCIES" "%globalLib%"
285+
if !ErrorLevel! NEQ 0 set "err=1"
286+
) else (
287+
echo No global dependencies detected: "%settings%\DEPENDENCIES"
288+
echo.
289+
)
290+
if exist "%libCollector%" (
291+
call :collect "%libCollector%" "%lib%"
292+
if !ErrorLevel! NEQ 0 set "err=1"
293+
) else (
294+
echo No external dependencies detected: "%libCollector%"
295+
echo.
296+
)
297+
if exist "%localLibCollector%" (
298+
call :collect "%localLibCollector%" "%localLib%"
299+
if !ErrorLevel! NEQ 0 set "err=1"
300+
) else (
301+
echo No runtime dependencies detected: "%localLibCollector%"
302+
echo.
303+
)
304+
endlocal & exit /b %err%
305+
313306
:exec
314-
if exist "%ext%\exec.bat" (
307+
if "%override%" EQU "1" if exist "%ext%\exec.bat" (
315308
call "%ext%\exec.bat" %*
316309
exit /b
317310
)
@@ -323,7 +316,7 @@ exit /b
323316
exit /b
324317

325318
:forge
326-
if exist "%ext%\forge.bat" (
319+
if "%override%" EQU "1" if exist "%ext%\forge.bat" (
327320
call "%ext%\forge.bat" %*
328321
exit /b
329322
)
@@ -335,7 +328,7 @@ exit /b
335328
exit /b
336329

337330
:make
338-
if exist "%ext%\make.bat" (
331+
if "%override%" EQU "1" if exist "%ext%\make.bat" (
339332
call "%ext%\make.bat" %*
340333
exit /b
341334
)
@@ -347,7 +340,7 @@ exit /b
347340
exit /b
348341

349342
:deploy
350-
if exist "%ext%\deploy.bat" (
343+
if "%override%" EQU "1" if exist "%ext%\deploy.bat" (
351344
call "%ext%\deploy.bat" %*
352345
exit /b
353346
)
@@ -382,7 +375,7 @@ exit /b
382375
)
383376

384377
:sign
385-
if exist "%ext%\sign.bat" (
378+
if "%override%" EQU "1" if exist "%ext%\sign.bat" (
386379
call "%ext%\sign.bat" %*
387380
exit /b
388381
)
@@ -410,7 +403,7 @@ exit /b
410403
)
411404

412405
:pack
413-
if exist "%ext%\pack.bat" (
406+
if "%override%" EQU "1" if exist "%ext%\pack.bat" (
414407
call "%ext%\pack.bat" %*
415408
exit /b
416409
)
@@ -437,7 +430,7 @@ exit /b
437430
)
438431

439432
:build
440-
if exist "%ext%\build.bat" (
433+
if "%override%" EQU "1" if exist "%ext%\build.bat" (
441434
call "%ext%\build.bat" %*
442435
exit /b
443436
)
@@ -467,7 +460,7 @@ exit /b
467460
echo.
468461
echo Packaged Dependencies:
469462
for /r "%lib%" %%i in (*.jar) do echo %%~ni
470-
) > "%depRecord%"
463+
) > "%buildDetails%"
471464
setlocal
472465
set err=0
473466
set "changes=0"
@@ -485,23 +478,28 @@ exit /b
485478
for /l %%a in (1,1,%index%) do (
486479
if !exists! EQU 0 if "!file[%%a]!" EQU "%%k" (
487480
set exists=1
488-
set "process[%%a]=1"
489481
set /a newIndex+=1
490-
set "newTime[!newIndex!]=!time[%%a]!"
482+
set "process[%%a]=1"
491483
set "newFile[!newIndex!]=%%k"
492-
if "%%j" EQU "!time[%%a]!" (
493-
if "%%i" NEQ "!newIndex!" rename "%trackingClasses%\%%i" !newIndex!
494-
) else (
495-
echo Compiling: %%k
496-
set "changes=1"
497-
rmdir /S /Q "%trackingClasses%\%%i" >nul 2>nul
498-
mkdir "%trackingClasses%\!newIndex!"
499-
"%JDKBin%\javac.exe" !compileArgs! -implicit:none -d "%trackingClasses%\!newIndex!" -cp "%src%;%globalLib%\*;%lib%\*;%localLib%\*" "%%k"
500-
if !ERRORLEVEL! NEQ 0 (
501-
rmdir /S /Q "%trackingClasses%\!newIndex!" >nul 2>nul
502-
set /a newIndex-=1
503-
set err=1
484+
if !err! EQU 0 (
485+
set "newTime[!newIndex!]=!time[%%a]!"
486+
if "%%j" EQU "!time[%%a]!" (
487+
if "%%i" NEQ "!newIndex!" rename "%trackingClasses%\%%i" !newIndex!
488+
) else (
489+
echo Compiling: %%k
490+
set "changes=1"
491+
rmdir /S /Q "%trackingClasses%\%%i" >nul 2>nul
492+
mkdir "%trackingClasses%\!newIndex!"
493+
"%JDKBin%\javac.exe" !compileArgs! -implicit:none -d "%trackingClasses%\!newIndex!" -cp "%src%;%globalLib%\*;%lib%\*;%localLib%\*" "%%k"
494+
if !ERRORLEVEL! NEQ 0 (
495+
rmdir /S /Q "%trackingClasses%\!newIndex!" >nul 2>nul
496+
set /a newIndex-=1
497+
set err=1
498+
)
504499
)
500+
) else (
501+
set "newTime[!newIndex!]=%%j"
502+
if "%%i" NEQ "!newIndex!" rename "%trackingClasses%\%%i" !newIndex!
505503
)
506504
)
507505
)
@@ -515,20 +513,22 @@ exit /b
515513
rmdir /S /Q "%trackingClasses%" >nul 2>nul
516514
mkdir "%trackingClasses%"
517515
)
518-
for /l %%i in (1,1,%index%) do (
519-
if "!process[%%i]!" EQU "0" (
520-
echo Compiling: !file[%%i]!
521-
set "changes=1"
522-
set /a newIndex+=1
523-
set "newTime[!newIndex!]=!time[%%i]!"
524-
set "newFile[!newIndex!]=!file[%%i]!"
525-
if exist "%trackingClasses%\!newIndex!" rmdir /S /Q "%trackingClasses%\!newIndex!" >nul 2>nul
526-
mkdir "%trackingClasses%\!newIndex!"
527-
"%JDKBin%\javac.exe" !compileArgs! -implicit:none -d "%trackingClasses%\!newIndex!" -cp "%src%;%globalLib%\*;%lib%\*;%localLib%\*" "!file[%%i]!"
528-
if !ERRORLEVEL! NEQ 0 (
529-
rmdir /S /Q "%trackingClasses%\!newIndex!" >nul 2>nul
530-
set /a newIndex-=1
531-
set err=1
516+
if %err% EQU 0 (
517+
for /l %%i in (1,1,%index%) do (
518+
if !err! EQU 0 if "!process[%%i]!" EQU "0" (
519+
echo Compiling: !file[%%i]!
520+
set "changes=1"
521+
set /a newIndex+=1
522+
set "newTime[!newIndex!]=!time[%%i]!"
523+
set "newFile[!newIndex!]=!file[%%i]!"
524+
if exist "%trackingClasses%\!newIndex!" rmdir /S /Q "%trackingClasses%\!newIndex!" >nul 2>nul
525+
mkdir "%trackingClasses%\!newIndex!"
526+
"%JDKBin%\javac.exe" !compileArgs! -implicit:none -d "%trackingClasses%\!newIndex!" -cp "%src%;%globalLib%\*;%lib%\*;%localLib%\*" "!file[%%i]!"
527+
if !ERRORLEVEL! NEQ 0 (
528+
rmdir /S /Q "%trackingClasses%\!newIndex!" >nul 2>nul
529+
set /a newIndex-=1
530+
set err=1
531+
)
532532
)
533533
)
534534
)
@@ -595,6 +595,59 @@ exit /b
595595
set "%~1=%~f2"
596596
exit /b
597597

598+
:: Collect dependencies from the WebCTRL installation or from external websites
599+
:: Parameters: <dependency-file> <output-folder>
600+
:collect
601+
setlocal
602+
set "tmp1=%settings%\tmp1"
603+
set "tmp2=%settings%\tmp2"
604+
set "err=0"
605+
set "msg=0"
606+
dir "%~f2\*.jar" /B /A-D 2>nul >"%tmp1%"
607+
for /F "usebackq tokens=1,2,* delims=:" %%i in ("%~f1") do (
608+
set "exists=0"
609+
for /F %%a in ('findstr /R /X "%%j-[0-9].*" "%tmp1%"') do (
610+
set "exists=1"
611+
)
612+
if "!exists!" EQU "0" (
613+
set "msg=1"
614+
if /I "%%i" EQU "url" (
615+
curl --fail --silent --output-dir "%~f2" --remote-name %%k
616+
if !ErrorLevel! EQU 0 (
617+
echo Collected: %%j
618+
) else (
619+
set "err=1"
620+
echo Failed to collect: %%j
621+
)
622+
) else if /I "%%i" EQU "file" (
623+
set "file="
624+
dir "%WebCTRL%\%%k\*.jar" /B /A-D 2>nul >"%tmp2%"
625+
for /F %%a in ('findstr /R /X "%%j-[0-9].*" "%tmp2%"') do (
626+
set "file=%%a"
627+
)
628+
if "!file!" EQU "" (
629+
set "err=1"
630+
echo Failed to collect: %%j
631+
) else (
632+
copy /Y "%WebCTRL%\%%k\!file!" "%~f2\!file!" >nul
633+
if !ErrorLevel!==0 (
634+
echo Collected: %%j
635+
) else (
636+
set "err=1"
637+
echo Failed to collect: %%j
638+
)
639+
)
640+
) else (
641+
set "err=1"
642+
echo Failed to collect: %%j
643+
)
644+
)
645+
)
646+
if "%msg%" EQU "1" echo.
647+
if exist "%tmp1%" del /F "%tmp1%" >nul 2>nul
648+
if exist "%tmp2%" del /F "%tmp2%" >nul 2>nul
649+
endlocal & exit /b %err%
650+
598651
:initWorkspace
599652
echo.
600653
if not exist "%workspace%" mkdir "%workspace%"
@@ -636,16 +689,24 @@ exit /b
636689
set "classes=%root%\webapp\WEB-INF\classes"
637690
if not exist "%classes%" mkdir "%classes%"
638691

692+
:: Configuration file folder
693+
set "configFolder=%workspace%\config"
694+
if not exist "%configFolder%" mkdir "%configFolder%"
695+
639696
:: External dependencies (packaged into the addon)
640697
set "lib=%root%\webapp\WEB-INF\lib"
641698
if not exist "%lib%" mkdir "%lib%"
699+
set "libCollector=%configFolder%\EXTERNAL_DEPS"
700+
if exist "%libCollector%" call :collect "%libCollector%" "%lib%"
642701

643702
:: Local runtime dependencies (not packaged into the addon)
644703
set "localLib=%workspace%\lib"
645704
if not exist "%localLib%" mkdir "%localLib%"
705+
set "localLibCollector=%configFolder%\RUNTIME_DEPS"
706+
if exist "%localLibCollector%" call :collect "%localLibCollector%" "%localLib%"
646707

647-
:: Dependency record
648-
set "depRecord=%workspace%\DEPENDENCIES"
708+
:: Recent build details
709+
set "buildDetails=%configFolder%\BUILD_DETAILS"
649710

650711
:: Visual Studio Code Settings
651712
set "vscode=%workspace%\.vscode"
@@ -702,6 +763,14 @@ exit /b
702763
echo.
703764
echo ^<web-app^>
704765
echo.
766+
echo ^<listener^>
767+
echo ^<listener-class^>^</listener-class^>
768+
echo ^</listener^>
769+
echo.
770+
echo ^<welcome-file-list^>
771+
echo ^<welcome-file^>^</welcome-file^>
772+
echo ^</welcome-file-list^>
773+
echo.
705774
echo ^<servlet^>
706775
echo ^<servlet-name^>^</servlet-name^>
707776
echo ^<servlet-class^>^</servlet-class^>
@@ -740,11 +809,11 @@ exit /b
740809
echo .vscode
741810
echo Utility.bat
742811
echo classes
743-
echo config.txt
744812
echo root/LICENSE
745813
echo root/webapp/WEB-INF/classes
746814
echo root/webapp/WEB-INF/lib
747815
echo lib
816+
echo **/*.jar
748817
echo **/*.addon
749818
) > "%workspace%\.gitignore"
750819

@@ -759,14 +828,17 @@ exit /b
759828
) > "%workspace%\README.md"
760829

761830
:: Workspace configuration properties
762-
set "workspaceConfig=%workspace%\config.txt"
831+
set "workspaceConfig=%configFolder%\COMPILE_FLAGS"
763832
if exist "%workspaceConfig%" (
764833
for /f "usebackq tokens=* delims=" %%i in ("%workspaceConfig%") do set "compileArgs=%%i"
765834
)
766835
(
767836
echo !compileArgs!
768837
) > "%workspaceConfig%"
769838

839+
:: Execute an optional startup script
840+
if exist "%workspace%\startup.bat" call "%workspace%\startup.bat"
841+
770842
:: Main workspace command processing loop
771843
:main
772844
cls
@@ -814,4 +886,4 @@ exit /b
814886
)
815887
)
816888
)
817-
goto loop
889+
goto loop

0 commit comments

Comments
 (0)
Please sign in to comment.