Fixed more bugs

This commit is contained in:
Eric Ratliff
2026-01-21 08:58:23 -06:00
parent e0c5884fff
commit b1593a4f87
2 changed files with 182 additions and 102 deletions

View File

@@ -47,10 +47,120 @@ if "%PROJECT_NAME%"=="" (
exit /b 1 exit /b 1
) )
echo ============================================
echo FTC Project Generator
echo ============================================
echo.
echo Checking prerequisites...
echo.
REM Check for git
where git >nul 2>&1
if errorlevel 1 (
echo ================================================================
echo ERROR: Git not found
echo ================================================================
echo.
echo Git is required to clone the FTC SDK and manage your project.
echo.
echo TO INSTALL:
echo Download: https://git-scm.com/download/win
echo Run installer with default options
echo Restart command prompt after installation
echo.
echo ================================================================
exit /b 1
)
echo + Git found
REM Check for Java
where java >nul 2>&1
if errorlevel 1 (
echo ================================================================
echo ERROR: Java not found
echo ================================================================
echo.
echo Java 11+ is required to build FTC projects.
echo.
echo TO INSTALL:
echo Download: https://adoptium.net/temurin/releases/
echo Choose: Java 17 LTS ^(recommended^) or Java 11 LTS
echo Run installer with default options
echo Restart command prompt after installation
echo.
echo ================================================================
exit /b 1
)
REM Check Java version
for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do set JAVA_VERSION=%%g
set JAVA_VERSION=%JAVA_VERSION:"=%
for /f "tokens=1,2 delims=." %%a in ("%JAVA_VERSION%") do (
set JAVA_MAJOR=%%a
if "%%a"=="1" set JAVA_MAJOR=%%b
)
if %JAVA_MAJOR% LSS 11 (
echo ================================================================
echo ERROR: Java version too old
echo ================================================================
echo.
echo Current: Java %JAVA_VERSION%
echo Required: Java 11 or later
echo.
echo TO UPGRADE:
echo Download: https://adoptium.net/temurin/releases/
echo Choose: Java 17 LTS ^(recommended^)
echo.
echo ================================================================
exit /b 1
)
echo + Java %JAVA_VERSION% found
REM Check for Gradle
where gradle >nul 2>&1
if errorlevel 1 (
echo ================================================================
echo ERROR: Gradle not found
echo ================================================================
echo.
echo Gradle is required to generate the wrapper for your project.
echo.
echo TO INSTALL ^(choose one method^):
echo.
echo Option 1 - Chocolatey ^(recommended^):
echo choco install gradle
echo.
echo Option 2 - Scoop:
echo scoop install gradle
echo.
echo Option 3 - Manual install:
echo 1. Download: https://gradle.org/releases/
echo 2. Extract to C:\Gradle
echo 3. Add C:\Gradle\bin to PATH
echo.
echo Option 4 - SDKMAN ^(if you use it^):
echo sdk install gradle
echo.
echo After installation:
echo 1. Restart command prompt
echo 2. Run: gradle --version
echo 3. Re-run this script
echo.
echo ================================================================
exit /b 1
)
for /f "tokens=3" %%v in ('gradle --version 2^>^&1 ^| findstr /C:"Gradle"') do set GRADLE_VERSION=%%v
echo + Gradle %GRADLE_VERSION% found
echo.
echo All prerequisites satisfied!
echo.
set "PROJECT_DIR=%CD%\%PROJECT_NAME%" set "PROJECT_DIR=%CD%\%PROJECT_NAME%"
echo ============================================ echo ============================================
echo FTC Project Generator echo Project Configuration
echo ============================================ echo ============================================
echo Project: %PROJECT_NAME% echo Project: %PROJECT_NAME%
echo SDK Dir: %FTC_SDK_DIR% echo SDK Dir: %FTC_SDK_DIR%
@@ -79,7 +189,7 @@ if exist "%FTC_SDK_DIR%" (
git fetch --tags git fetch --tags
git checkout "%FTC_VERSION%" git checkout "%FTC_VERSION%"
if errorlevel 1 ( if errorlevel 1 (
echo Error: Failed to checkout version %FTC_VERSION% echo ERROR: Failed to checkout version %FTC_VERSION%
exit /b 1 exit /b 1
) )
echo + Updated to %FTC_VERSION% echo + Updated to %FTC_VERSION%
@@ -93,19 +203,23 @@ if exist "%FTC_SDK_DIR%" (
echo This will take a minute ^(SDK is about 200MB^)... echo This will take a minute ^(SDK is about 200MB^)...
git clone --depth 1 --branch "%FTC_VERSION%" https://github.com/FIRST-Tech-Challenge/FtcRobotController.git "%FTC_SDK_DIR%" git clone --depth 1 --branch "%FTC_VERSION%" https://github.com/FIRST-Tech-Challenge/FtcRobotController.git "%FTC_SDK_DIR%"
if errorlevel 1 ( if errorlevel 1 (
echo Error: Failed to clone FTC SDK echo ERROR: Failed to clone FTC SDK
echo Check your internet connection or try a different version tag echo Check your internet connection
exit /b 1 exit /b 1
) )
echo + Cloned FTC SDK %FTC_VERSION% to %FTC_SDK_DIR% echo + Cloned FTC SDK %FTC_VERSION% to %FTC_SDK_DIR%
) )
REM Return to starting directory
cd /d "%~dp0"
REM Step 2: Create project structure REM Step 2: Create project structure
echo. echo.
echo ^>^>^> Creating project: %PROJECT_NAME% echo ^>^>^> Creating project: %PROJECT_NAME%
if exist "%PROJECT_DIR%" ( if exist "%PROJECT_DIR%" (
echo Error: Project directory already exists: %PROJECT_DIR% echo ERROR: Project directory already exists: %PROJECT_DIR%
echo Choose a different name or remove the existing directory
exit /b 1 exit /b 1
) )
@@ -124,9 +238,17 @@ echo Generating build configuration...
call "%WINDOWS_DIR%\generate-build-gradle.bat" "%PROJECT_DIR%" call "%WINDOWS_DIR%\generate-build-gradle.bat" "%PROJECT_DIR%"
call "%WINDOWS_DIR%\generate-settings-gradle.bat" "%PROJECT_DIR%" "%FTC_SDK_DIR%" call "%WINDOWS_DIR%\generate-settings-gradle.bat" "%PROJECT_DIR%" "%FTC_SDK_DIR%"
REM Step 4: Create Gradle wrapper files REM Step 4: Create Gradle wrapper using installed Gradle
echo Setting up Gradle wrapper... echo Setting up Gradle wrapper...
call "%WINDOWS_DIR%\create-gradle-wrapper.bat" "%PROJECT_DIR%" call "%WINDOWS_DIR%\create-gradle-wrapper.bat" "%PROJECT_DIR%"
if errorlevel 1 (
echo.
echo ERROR: Failed to setup Gradle wrapper
echo Cleaning up partial project...
cd ..
rmdir /s /q "%PROJECT_DIR%" 2>nul
exit /b 1
)
REM Step 5: Generate source files REM Step 5: Generate source files
echo Generating example source files... echo Generating example source files...

View File

@@ -1,8 +1,9 @@
@echo off @echo off
REM Create Gradle wrapper files REM Create Gradle wrapper files
setlocal setlocal enabledelayedexpansion
set "PROJECT_DIR=%~1" set "PROJECT_DIR=%~1"
set "GRADLE_VERSION=8.9"
REM Create gradle wrapper directory REM Create gradle wrapper directory
mkdir "%PROJECT_DIR%\gradle\wrapper" 2>nul mkdir "%PROJECT_DIR%\gradle\wrapper" 2>nul
@@ -11,107 +12,64 @@ REM Create gradle-wrapper.properties
( (
echo distributionBase=GRADLE_USER_HOME echo distributionBase=GRADLE_USER_HOME
echo distributionPath=wrapper/dists echo distributionPath=wrapper/dists
echo distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip echo distributionUrl=https\://services.gradle.org/distributions/gradle-%GRADLE_VERSION%-bin.zip
echo networkTimeout=10000 echo networkTimeout=10000
echo validateDistributionUrl=true
echo zipStoreBase=GRADLE_USER_HOME echo zipStoreBase=GRADLE_USER_HOME
echo zipStorePath=wrapper/dists echo zipStorePath=wrapper/dists
) > "%PROJECT_DIR%\gradle\wrapper\gradle-wrapper.properties" ) > "%PROJECT_DIR%\gradle\wrapper\gradle-wrapper.properties"
REM Create gradlew.bat REM Check if gradle is installed globally
( where gradle >nul 2>&1
echo @rem if errorlevel 1 (
echo @rem Copyright 2015 the original author or authors. echo.
echo @rem echo ================================================================
echo @rem Licensed under the Apache License, Version 2.0 ^(the "License"^); echo ERROR: Gradle not found
echo @rem you may not use this file except in compliance with the License. echo ================================================================
echo @rem You may obtain a copy of the License at echo.
echo @rem echo The Gradle wrapper requires either:
echo @rem https://www.apache.org/licenses/LICENSE-2.0 echo 1. Gradle installed globally to generate wrapper files, OR
echo @rem echo 2. Pre-bundled gradle-wrapper.jar file
echo @rem Unless required by applicable law or agreed to in writing, software echo.
echo @rem distributed under the License is distributed on an "AS IS" BASIS, echo TO FIX - Install Gradle:
echo @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. echo Windows ^(Chocolatey^): choco install gradle
echo @rem See the License for the specific language governing permissions and echo Windows ^(Scoop^): scoop install gradle
echo @rem limitations under the License. echo Manual download: https://gradle.org/install/
echo @rem echo.
echo. echo After installing Gradle:
echo @if "%%DEBUG%%"=="" @echo off echo 1. Restart your command prompt
echo @rem ########################################################################## echo 2. Run: gradle --version ^(to verify^)
echo @rem echo 3. Re-run the project generator
echo @rem Gradle startup script for Windows echo.
echo @rem echo ================================================================
echo @rem ########################################################################## echo.
echo. exit /b 1
echo @rem Set local scope for the variables with windows NT shell )
echo if "%%OS%%"=="Windows_NT" setlocal
echo.
echo set DIRNAME=%%~dp0
echo if "%%DIRNAME%%"=="" set DIRNAME=.
echo set APP_BASE_NAME=%%~n0
echo set APP_HOME=%%DIRNAME%%
echo.
echo @rem Resolve any "." and ".." in APP_HOME to make it shorter.
echo for %%%%i in ^("%%APP_HOME%%"^) do set APP_HOME=%%%%~fi
echo.
echo @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
echo set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
echo.
echo @rem Find java.exe
echo if defined JAVA_HOME goto findJavaFromJavaHome
echo.
echo set JAVA_EXE=java.exe
echo %%JAVA_EXE%% -version ^>NUL 2^>^&1
echo if "%%ERRORLEVEL%%"=="0" goto execute
echo.
echo echo.
echo echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo echo.
echo echo Please set the JAVA_HOME variable in your environment to match the
echo echo location of your Java installation.
echo.
echo goto fail
echo.
echo :findJavaFromJavaHome
echo set JAVA_HOME=%%JAVA_HOME:"=%%
echo set JAVA_EXE=%%JAVA_HOME%%/bin/java.exe
echo.
echo if exist "%%JAVA_EXE%%" goto execute
echo.
echo echo.
echo echo ERROR: JAVA_HOME is set to an invalid directory: %%JAVA_HOME%%
echo echo.
echo echo Please set the JAVA_HOME variable in your environment to match the
echo echo location of your Java installation.
echo.
echo goto fail
echo.
echo :execute
echo @rem Setup the command line
echo.
echo set CLASSPATH=%%APP_HOME%%\gradle\wrapper\gradle-wrapper.jar
echo.
echo @rem Execute Gradle
echo "%%JAVA_EXE%%" %%DEFAULT_JVM_OPTS%% %%JAVA_OPTS%% %%GRADLE_OPTS%% "-Dorg.gradle.appname=%%APP_BASE_NAME%%" -classpath "%%CLASSPATH%%" org.gradle.wrapper.GradleWrapperMain %%*
echo.
echo :end
echo @rem End local scope for the variables with windows NT shell
echo if "%%ERRORLEVEL%%"=="0" goto mainEnd
echo.
echo :fail
echo rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
echo rem the _cmd.exe /c_ return code!
echo if not "" == "%%GRADLE_EXIT_CONSOLE%%" exit 1
echo exit /b 1
echo.
echo :mainEnd
echo if "%%OS%%"=="Windows_NT" endlocal
echo.
echo :omega
) > "%PROJECT_DIR%\gradlew.bat"
REM Create minimal gradle-wrapper.jar placeholder message REM Verify gradle version
echo Note: Download gradle-wrapper.jar from https://services.gradle.org/distributions/ > "%PROJECT_DIR%\gradle\wrapper\gradle-wrapper.jar.txt" for /f "tokens=3" %%v in ('gradle --version 2^>^&1 ^| findstr /C:"Gradle"') do set INSTALLED_GRADLE=%%v
echo Or run: gradlew wrapper to generate the complete wrapper >> "%PROJECT_DIR%\gradle\wrapper\gradle-wrapper.jar.txt" echo Found Gradle %INSTALLED_GRADLE%
REM Now use gradle to generate the wrapper
echo Generating wrapper using installed Gradle...
cd /d "%PROJECT_DIR%"
gradle wrapper --gradle-version %GRADLE_VERSION% --no-daemon >nul 2>&1
if not exist "%PROJECT_DIR%\gradle\wrapper\gradle-wrapper.jar" (
echo.
echo ERROR: Gradle wrapper generation failed
echo.
echo The 'gradle wrapper' command did not create gradle-wrapper.jar
echo This should not happen with a working Gradle installation.
echo.
echo Try manually:
echo cd %PROJECT_DIR%
echo gradle wrapper --gradle-version %GRADLE_VERSION%
echo.
exit /b 1
)
echo + Gradle wrapper generated successfully
endlocal endlocal
exit /b 0 exit /b 0