Skip to content

Commit 4170f01

Browse files
committed
improve JDK detection logic
Update README
1 parent dcc1e0d commit 4170f01

File tree

2 files changed

+50
-25
lines changed

2 files changed

+50
-25
lines changed

README.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,31 @@ WebCTRL is a trademark of Automated Logic Corporation. Any other trademarks men
1919

2020
## About
2121

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.
22+
[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. 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.
2323

2424
## Setup Instructions
2525

26-
1. Install *WebCTRL8.0* or later.
26+
1. Install *WebCTRL8.5* or later.
2727

28-
1. Install the most recent [*JDK*](https://jdk.java.net/) release.
28+
2. Install the most recent [*JDK*](https://jdk.java.net/) release.
29+
- Download the *.zip* file, unpack it, and move the contents to your program files.
30+
- Set the `JAVA_HOME` environment variable to the JDK installation directory (e.g, *C:\Program Files\Java\jdk-22.0.1*).
2931

30-
1. Install [*Visual Studio Code*](https://code.visualstudio.com/) and the following extensions:
32+
3. Install [*Visual Studio Code*](https://code.visualstudio.com/) and the following extensions:
3133

3234
- [Visual Studio IntelliCode](https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.vscodeintellicode)
3335

3436
- [Project Manager for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-dependency)
3537

3638
- [Lanauge Support for Java(TM) by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java)
3739

38-
1. Clone this repository to your local machine.
40+
4. Clone this repository to your local machine.
3941

4042
- Edit [*LICENSE*](LICENSE) to match your specifications. This license file is copied to the new projects created by the script.
4143

42-
1. Launch [Utility.bat](Utility.bat)
44+
5. Launch [Utility.bat](Utility.bat)
4345

44-
- You will be prompted to enter the location of the *JDK* bin.
46+
- You may be prompted to enter the location of the *JDK* bin if *%JAVA_HOME%* is not set.
4547

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

@@ -59,30 +61,30 @@ WebCTRL is a trademark of Automated Logic Corporation. Any other trademarks men
5961

6062
- You can initialize preexisting project folders. For example, you could clone a remote repository to your local machine, and then initialize it with the script to generate missing files.
6163

62-
1. Review documentation at [*ALCshare*](http://alcshare.com/content/add-ons).
64+
6. Review documentation at [*ALCshare*](http://alcshare.com/content/add-ons).
6365

6466
## Command Reference
6567

6668
The following commands may be used to automate add-on compilation and packaging.
6769

6870
| Command | Description |
6971
| - | - |
70-
| `help` | Displays a help message listing these commands with brief descriptions. |
71-
| `cls` | Clears the terminal. |
72-
| `depend [--all]` | Attempts to collect missing dependencies. Recollects all dependencies if the `--all` flag is given. |
73-
| `init [--new]` | Reinitializes the current project if no parameters are given. Prompts you to initialize a new project if the `--new` flag is given. |
74-
| `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`. |
75-
| `pack` | Packages all relevant files into a newly created *.addon* archive. |
76-
| `make [args]` | Calls `build` and `pack`. Arguments are passed to `build`. |
77-
| `sign` | Signs the *.addon* archive. |
78-
| `forge [args]` | Calls `build`, `pack`, and `sign`. Arguments are passed to `build`. |
79-
| `deploy` | Copies the *.addon* archive and authenticator certificate to the bound *WebCTRL* installation. |
80-
| `exec [args]` | Calls `build`, `pack`, `sign`, and `deploy`. Arguments are passed to `build`. |
81-
| `git [args]` | All [*Git*](https://git-scm.com/) commands are executed literally. |
72+
| **help** | Displays a help message listing these commands with brief descriptions. |
73+
| **cls** | Clears the terminal. |
74+
| **depend [‑‑all]** | Attempts to collect missing dependencies. Recollects all dependencies if the `--all` flag is given. |
75+
| **init [‑‑new]** | Reinitializes the current project if no parameters are given. Prompts you to initialize a new project if the `--new` flag is given. |
76+
| **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`. |
77+
| **pack** | Packages all relevant files into a newly created *.addon* archive. |
78+
| **make [args]** | Calls `build` and `pack`. Arguments are passed to `build`. |
79+
| **sign** | Signs the *.addon* archive. |
80+
| **forge [args]** | Calls `build`, `pack`, and `sign`. Arguments are passed to `build`. |
81+
| **deploy** | Copies the *.addon* archive and authenticator certificate to the bound *WebCTRL* installation. |
82+
| **exec [args]** | Calls `build`, `pack`, `sign`, and `deploy`. Arguments are passed to `build`. |
83+
| **git [args]** | All [*Git*](https://git-scm.com/) commands are executed literally. |
8284

8385
## Extensions
8486

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.
87+
Custom project-specific commands can be created to extend the functionality of this script. 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.
8688

8789
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). For an improved `deploy` command, see <https://github.com/automatic-controls/addon-dev-refresh>.
8890

@@ -125,7 +127,7 @@ An optional script, `./startup.bat`, is invoked whenever a project folder is loa
125127

126128
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:
127129

128-
| Dependency | Location Relative to *WebCTRL8.0* |
130+
| Dependency | Location Relative to *WebCTRL9.0* |
129131
| - | - |
130132
| [*tomcat-embed-core*](https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api) | *./webserver/lib* |
131133
| [*addonsupport-api-addon*](http://repo.alcshare.com/com/controlj/green/addonsupport-api-addon/) | *./modules/addonsupport* |
@@ -167,7 +169,14 @@ The generated 2048-bit RSA key-pair is valid for 100 years, uses SHA512 as the s
167169

168170
## Compatibility Notes
169171

170-
*WebCTRL* may complain if your add-on name includes spaces. You should use the build flag `--release 11` for *WebCTRL8.0* and `--release 8` for *WebCTRL7.0*. These flags indicate the *JVM* version to use for compilation. You can determine the appropriate *JVM* version by invoking `"[WebCTRL]\bin\java\jre\bin\java.exe" -version` from command prompt (after replacing `[WebCTRL]` with the path to your *WebCTRL* installation directory).
172+
*WebCTRL* may complain if your add-on name includes spaces. You may use the build flag `--release 11` for *WebCTRL8.0* and `--release 8` for *WebCTRL7.0*. These flags indicate the *JVM* version to use for compilation. You can determine the appropriate *JVM* version by invoking `"[WebCTRL]\bin\java\jre\bin\java.exe" -version` from command prompt (after replacing `[WebCTRL]` with the path to your *WebCTRL* installation directory).
173+
174+
| WebCTRL | JVM |
175+
| - | - |
176+
| 7.0 | 8 |
177+
| 8.0 | 11 |
178+
| 8.5 | 11 |
179+
| 9.0 | 17 |
171180

172181
## Known Issues
173182

Utility.bat

Lines changed: 18 additions & 2 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.1.3"
49+
set "version=1.1.4"
5050
if "%1" EQU "--version" (
5151
echo %version%
5252
exit /b
@@ -82,6 +82,21 @@ set "config=%settings%\config.txt"
8282
if exist "%config%" call :loadConfig
8383

8484
:: Determine location of JDK bin
85+
if "%JDKBin%" NEQ "" (
86+
"%JDKBin%\java.exe" --version >nul 2>nul
87+
if !ERRORLEVEL! NEQ 0 (
88+
set "JDKBin="
89+
)
90+
)
91+
if "%JDKBin%" EQU "" if "%JAVA_HOME%" NEQ "" (
92+
set "JDKBin=%JAVA_HOME%\bin"
93+
"!JDKBin!\java.exe" --version >nul 2>nul
94+
if !ERRORLEVEL! EQU 0 (
95+
call :saveConfig
96+
) else (
97+
set "JDKBin="
98+
)
99+
)
85100
:jdkFinder
86101
set "jdkFound=0"
87102
if "%JDKBin%" NEQ "" (
@@ -111,6 +126,7 @@ if "%WebCTRL%" EQU "" (
111126
if exist "!WebCTRL!\webserver\*" (
112127
echo Bound to installation !WebCTRL!
113128
echo.
129+
call :saveConfig
114130
) else (
115131
set "WebCTRL="
116132
)
@@ -119,7 +135,7 @@ if "%WebCTRL%" EQU "" (
119135
:webctrlFinder
120136
if "%WebCTRL%" EQU "" (
121137
echo Could not locate WebCTRL installation.
122-
echo Please enter the installation path ^(e.g, %SystemDrive%\WebCTRL8.0^).
138+
echo Please enter the installation path ^(e.g, %SystemDrive%\WebCTRL9.0^).
123139
set /p "WebCTRL=>"
124140
echo.
125141
call :saveConfig

0 commit comments

Comments
 (0)