Implements template-based project creation allowing teams to start with
professional example code instead of empty projects.
Features:
- Two templates: 'basic' (minimal) and 'testing' (45-test showcase)
- Template variable substitution ({{PROJECT_NAME}}, etc.)
- Template validation with helpful error messages
- `weevil new --list-templates` command
- Template files embedded in binary at compile time
Technical details:
- Templates stored in templates/basic/ and templates/testing/
- Files ending in .template have variables replaced
- Uses include_dir! macro to embed templates in binary
- Returns file count for user feedback
Testing template includes:
- 3 complete subsystems (MotorCycler, WallApproach, TurnController)
- Hardware abstraction layer with mock implementations
- 45 comprehensive tests (unit, integration, system)
- Professional documentation (DESIGN_AND_TEST_PLAN.md, etc.)
Usage:
weevil new my-robot # basic template
weevil new my-robot --template testing # testing showcase
weevil new --list-templates # show available templates
This enables FTC teams to learn from working code and best practices
rather than starting from scratch.
85 lines
2.1 KiB
Plaintext
85 lines
2.1 KiB
Plaintext
plugins {
|
|
java
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
google()
|
|
}
|
|
|
|
dependencies {
|
|
// Testing (runs on PC without SDK)
|
|
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
testImplementation("org.mockito:mockito-core:5.5.0")
|
|
}
|
|
|
|
java {
|
|
sourceCompatibility = JavaVersion.VERSION_11
|
|
targetCompatibility = JavaVersion.VERSION_11
|
|
}
|
|
|
|
// Configure source sets to exclude FTC-dependent code from test compilation
|
|
sourceSets {
|
|
main {
|
|
java {
|
|
// Exclude FTC-dependent files from test compilation
|
|
// These files use FTC SDK classes that don't exist on Windows
|
|
exclude(
|
|
"robot/hardware/FtcMotorController.java",
|
|
"robot/hardware/FtcDistanceSensor.java",
|
|
"robot/hardware/FtcGyroSensor.java",
|
|
"robot/opmodes/**/*.java"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnitPlatform()
|
|
testLogging {
|
|
events("passed", "skipped", "failed")
|
|
showStandardStreams = false
|
|
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
|
|
}
|
|
}
|
|
|
|
// Task to deploy code to FTC SDK
|
|
tasks.register<Copy>("deployToSDK") {
|
|
group = "ftc"
|
|
description = "Copy code to FTC SDK TeamCode for deployment"
|
|
|
|
val sdkDir = "C:\\Users\\Eric\\.weevil\\ftc-sdk"
|
|
|
|
from("src/main/java") {
|
|
include("robot/**/*.java")
|
|
}
|
|
|
|
into(layout.projectDirectory.dir("$sdkDir/TeamCode/src/main/java"))
|
|
|
|
doLast {
|
|
println("✓ Code deployed to TeamCode")
|
|
}
|
|
}
|
|
|
|
// Task to build APK
|
|
tasks.register<Exec>("buildApk") {
|
|
group = "ftc"
|
|
description = "Build APK using FTC SDK"
|
|
|
|
dependsOn("deployToSDK")
|
|
|
|
val sdkDir = "C:\\Users\\Eric\\.weevil\\ftc-sdk"
|
|
workingDir = file(sdkDir)
|
|
|
|
commandLine = if (System.getProperty("os.name").lowercase().contains("windows")) {
|
|
listOf("cmd", "/c", "gradlew.bat", "assembleDebug")
|
|
} else {
|
|
listOf("./gradlew", "assembleDebug")
|
|
}
|
|
|
|
doLast {
|
|
println("✓ APK built successfully")
|
|
}
|
|
}
|