REM --- build progress reporting -----------------------------------------------
REM This project was generated by the Codename One Initializr. When you run this
REM launcher it tells cloud.codenameone.com that a build started and how Maven
REM exited, so a first build that dies on this machine (no JDK, an old JDK, a
REM Maven download, a compile error, a build that was never submitted) is visible
REM to us instead of silent, and we
REM can fix what trips people up.
REM
REM It sends ONLY: a one-way SHA-256 hash of this project's package name (never
REM the name itself), the target (e.g. javascript_cloud), "windows", the Java
REM major version, the exit code, one word for why the build stopped and how
REM many seconds it took. Never your code, paths, user name or build output.
REM Each report is a single request with a 3 second limit; a failure is ignored
REM and never changes the build's output or exit code.
REM
REM Opt out in Command Prompt:  set CN1_TELEMETRY=0
REM Opt out in PowerShell:      $Env:CN1_TELEMETRY = "0"
set "CN1_PROJECT_ID=__CN1_PROJECT_ID__"
set "CN1_MIN_JAVA=__CN1_MIN_JAVA__"
if not defined CN1_EVENTS_URL set "CN1_EVENTS_URL=https://cloud.codenameone.com/api/v2/funnel/initializr-event"
REM Maven reports IDE builds itself (cn1.telemetry.* in pom.xml); this tells it the
REM launcher is already reporting this one, so it is counted once.
set "CN1_LAUNCHER=1"
set "CN1_TARGET=%CMD%"
set "CN1_JAVA=none"
set "CN1_JAVA_EXE=java"
if defined JAVA_HOME set "CN1_JAVA_EXE=%JAVA_HOME%\bin\java"
for /f "tokens=3" %%v in ('call "%CN1_JAVA_EXE%" -version 2^>^&1 ^| findstr /i "version"') do set "CN1_JAVA=%%~v"
for /f "tokens=1,2 delims=." %%a in ("%CN1_JAVA%") do (
  if "%%a"=="1" (set "CN1_JAVA=%%b") else (set "CN1_JAVA=%%a")
)
REM A copy of Maven's output, read only for the one-word reason at exit (build.sh
REM does the same with tee). .mvn\Cn1Capture.java runs the Maven wrapper and
REM copies its output; it runs as a single source file, which needs Java 11 or
REM newer. With an older Java, no JDK, or reporting off, Maven runs exactly as
REM before and the reason comes from the Java check alone.
set "CN1_LOG="
REM A JRE runs java but has no javac, and Maven then fails with "No compiler is
REM provided". Known here without the output copy, which a Java 8 project's
REM JDK 8 cannot make, so it is reported as no_jdk either way.
set "CN1_JAVAC=yes"
if defined JAVA_HOME if not exist "%JAVA_HOME%\bin\javac.exe" set "CN1_JAVAC=no"
if not defined JAVA_HOME where javac >nul 2>&1 || set "CN1_JAVAC=no"
REM Copies left by builds that were interrupted (cmd cannot trap Ctrl+C, so
REM those never reach the cleanup at the end). A day old, so a build still
REM running in another window keeps its own.
if not "%CN1_TELEMETRY%"=="0" forfiles /p "%TEMP%" /m cn1-build-*.log /d -1 /c "cmd /c del /q @path" >nul 2>&1
set "CN1_JMAJ=0"
set /a CN1_JMAJ=%CN1_JAVA% >nul 2>&1
if not "%CN1_TELEMETRY%"=="0" if %CN1_JMAJ% GEQ 11 if exist "%~dp0.mvn\Cn1Capture.java" set "CN1_LOG=%TEMP%\cn1-build-%RANDOM%%RANDOM%.log"
if defined CN1_LOG set "MVNW=%~dp0.mvn\cn1-capture.cmd"
REM Start time as seconds since midnight, for the duration reported at exit.
REM Plain cmd arithmetic on %TIME%, deliberately not PowerShell: when the
REM launcher runs with redirected input (an IDE run configuration, CI) a
REM PowerShell child can wait on stdin forever and hang the whole build.
set "CN1_START="
if not "%CN1_TELEMETRY%"=="0" call :cn1_now
if not "%CN1_TELEMETRY%"=="0" set "CN1_START=%CN1_NOW%"
if /i not "%CMD%"=="help" call :cn1_event "step=launch" "exit=" "reason=" "secs="

