Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated version #17

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.gradle/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# frc-template
[![TravisCI](https://api.travis-ci.org/team5499/frc-template.svg)](https://travis-ci.org/team5499/frc-template)


## Cookiecutter template for our FRC/WPILib projects
Cookiecutter template for our FRC/WPILib projects. The template uses Kotlin but can be adjusted for other languages.


## Usage
```
pip install --user cookiecutter
Expand Down
66 changes: 48 additions & 18 deletions {{cookiecutter.repo_name}}/build.gradle
Original file line number Diff line number Diff line change
@@ -1,52 +1,82 @@
plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.0"
id "edu.wpi.first.GradleRIO" version "2019.0.0-alpha-3"
id "org.jetbrains.kotlin.jvm" version "1.3.20"
id "edu.wpi.first.GradleRIO" version "2019.3.2"
}

def ROBOT_CLASS = "frc.team{{cookiecutter.team_number}}.{{cookiecutter.repo_name}}.Robot"
def ROBOT_MAIN_CLASS = "frc.team{{cookiecutter.team_number}}.{{cookiecutter.repo_name}}.Main"

// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project EmbeddedTools.
deploy {
targets {
target("roborio", edu.wpi.first.gradlerio.frc.RoboRIO) {
// Team can be overridden by command line, for use with VSCode
team = getTeamOrDefault({{cookiecutter.team_number}})
roboRIO("roborio") {
// Team number is loaded either from the .wpilib/wpilib_preferences.json
// or from command line. If not found an exception will be thrown.
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
// want to store a team number in this file.
team = frc.getTeamOrDefault({{cookiecutter.team_number}})
}
}
artifacts {
// We still use FRCJavaArtifact since kotlin does respond as a Java build.
artifact('frcKotlin', edu.wpi.first.gradlerio.frc.FRCJavaArtifact) {
frcJavaArtifact('frcKotlin') {
targets << "roborio"
// Debug can be overridden by command line, for use with VSCode
debug = getDebugOrDefault(false)
debug = frc.getDebugOrDefault(false)
}
// Built in artifact to deploy arbitrary files to the roboRIO.
fileTreeArtifact('frcStaticFileDeploy') {
// The directory below is the local directory to deploy
files = fileTree(dir: 'src/main/deploy')
// Deploy to RoboRIO target, into /home/lvuser/deploy
targets << "roborio"
directory = '/home/lvuser/deploy'
}
}
}

def includeDesktopSupport = true

repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://maven.team5499.org'
}
maven {
url "http://devsite.ctr-electronics.com/maven/release/"
}
maven {
url "https://repo1.maven.org/maven2/"
}
}


// Defining my dependencies. In this case, WPILib (+ friends)
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.1'
// We need to add the Kotlin stdlib in order to use most Kotlin language features.
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.3.20'

compile wpilib()
compile ctre()
compile 'org.tinylog:tinylog-api:2.0.0-M3'
compile 'org.tinylog:tinylog-impl:2.0.0-M3'

// We need to add the Kotlin stdlib in order to use most Kotlin language features.
compile "org.jetbrains.kotlin:kotlin-stdlib"
// wpilib specific
compile wpi.deps.wpilib()
compile wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)

// test framework = JUnit5
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.1'
}

// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_CLASS)
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
}

test {
Expand Down Expand Up @@ -83,7 +113,7 @@ task tox {
task install_hooks(dependsOn: 'tox')

compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 1.11
targetCompatibility = 1.11
options.compilerArgs += '-parameters'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package frc.team{{cookiecutter.team_number}}.{{cookiecutter.repo_name}}

import edu.wpi.first.wpilibj.RobotBase

import java.util.function.Supplier

public class Main {

/**
* Main initialization function. Do not perform any initialization here.
*
* <p>If you change your main robot class, change the parameter type.
*/
companion object {
@JvmStatic
public fun main(args: Array<String>) {
RobotBase.startRobot(Supplier<Robot> { Robot() })
}
}
}