Skip to content
Merged
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
127 changes: 127 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Contributing to lib2813

We welcome contributions!

## What to Contribute

- Bug reports
- Bug fixes (consider filing a bug report first)
- Feature additions (please create an issue first)

## Pull Request Guidelines

- Code should be well documented.
- Please consider writing tests. Tests give us assurance that new changes do not break older functionality.
- We loosely follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Format the code
using `./gradlew spotlessApply`.
- Write a [good change description](https://google.github.io/eng-practices/review/developer/cl-descriptions.html)

We may ask you to test locally on your robot code in simulation mode.

## Getting Started

If you need to make changes to lib213, you can either clone the repository directly, or you
can include it as a submodule for your robot code.

### Option 1: Developing on a Clone

To clone the repository, run:

```shell
git clone --recurse-submodules https://github.com/Prospect-Robotics/Robot2025.git
```

### Option 2: Developing via Submodules

#### 1. Adding the lib2813 repo as a submodule

When making changes to lib2813, it is often helpful to build the code along with your robot code.
To do that, you can add the lib2813 repo as a submodule.

Before adding the submodule, it is recommended that you set the `submodule.stickyRecursiveClone`
git config option to `true` to make working with submodule easier (see
[this StackOverflow answer](https://stackoverflow.com/a/53622660) for details about this option).
To do this, run the following command from any directory:
```shell
git config --global submodule.stickyRecursiveClone true
```

To add the lib2813 submodule, go to your robot project directory (where the `settings.gradle` file is), and run
this command:
```shell
git submodule add https://github.com/Prospect-Robotics/lib2813
```

#### 2. Updating Gradle files

Add the following lines needs to be added to your `settings.gradle`:
```
includeBuild('lib2813') {
dependencySubstitution {
substitute module('com.team2813.lib2813:lib') using project(':lib')
}
}
```

Next, remove the version numbers for the lib2813 dependencies in your `build.gradle`:

```
implementation "com.team2813.lib2813:lib"
```

Finally, in order to guarantee that the library jars are created before GradleRIO referees to them, add the following
lines to your `build.gradle`:
```groovy
downloadDepsPreemptively.dependsOn gradle.includedBuild('lib2813').task(':lib:jar')
downloadDepsPreemptively.dependsOn gradle.includedBuild('lib2813').task(':testing:jar')
downloadDepsPreemptively.dependsOn gradle.includedBuild('lib2813').task(':limelight:jar')
```

#### 3. Fixing vscode jank
As of version 1.85.1, vscode doesn't work properly with gradle composite builds without the old buildServer. To use the old buildServer, add the following line
to your settings.json
```
"java.gradle.buildServer.enabled": "off",
```
This isn't strictly necessary, but without it vscode will not be able to do code completion from things in the library, and tell the user that there are errors,
when gradle builds fine.

## Tips and Tricks

### Publishing to Maven Local

It can often be useful to publish jars locally and test with a real or simulated robot.

To publish to Maven Local, run:

```shell
./gradlew publishToMavenLocal -Pversion=2.0.0-test-123
```

(replace "test-123" with some unique identifier)

In your robot's `build.gradle` file, be sure to include Maven Local in your repositories:

```groovy
repositories {
mavenLocal()
mavenCentral()
}
```

Then update your `libs.versions.toml` to reference the version that you published locally.

### Cloning a repository with a git submodule
When cloning a repository with a git submodule, git will not automatically get the files in the submodules. in order to do this, run the command
```
git submodule update --init --recursive
```
This command will recursively initialize all submodules.

### Getting blame data

To ignore code reformatting when running `git blame` run:

```shell
git config blame.ignoreRevsFile .git-blame-ignore-revs
```
12 changes: 12 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Maintainer Documentation

## Publishing to Maven Central

Before publishing to Maven Central, consider publishing to Maven Local.

1. Run `./gradlew build` to build the code, run the tests, and verify that there are no formatting
issues
2. Update the version string in `publishing-conventions.gradle`.
3. Make sure all changes are pushed to GitHub
4. ???
Comment thread
kcooney marked this conversation as resolved.
5. Celebrate!
90 changes: 51 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,63 @@
# User Documentation

## adding submodule
In order to use, go to your WPILib project directory (the inner one, where the build.gradle file is), and run the command
```
git submodule add https://github.com/Prospect-Robotics/lib2813
```
## adding submodule to gradle
The following lines needs to be added to your settings.gradle to make the lib usable:
## Using the libraries

### Updating your dependencies

> [!NOTE]
> The lib2813 jars are not yet published to Maven Central. For the time being, you need to publish
> them to Maven Local. See [the Contributing page](CONTRIBUTING.md#publishing-to-maven-local) for details.

In your project's "gradle" directory, create a file named `libs.versions.toml` with the following content:

```toml
[versions]
lib2813 = "2.0.0-rc-1"

[libraries]
lib2813-lib = { module = "com.team2813.lib2813:lib", version.ref="lib2813" }
lib2813-vision = { module = "com.team2813.lib2813:vision", version.ref="lib2813" }
lib2813-limelight = { module = "com.team2813.lib2813:limelight", version.ref="lib2813" }
lib2813-testing = { module = "com.team2813.lib2813:testing", version.ref="lib2813" }
```
includeBuild('lib2813') {
dependencySubstitution {
substitute module('com.team2813:lib2813') using project(':lib')
}

In your `build.gradle`, update the `dependencies` section:

```groovy
dependencies {
// Existing dependencies
implementation libs.lib2813.lib
implementation libs.lib2813.vision
implementation libs.lib2813.limelight
testImplementation libs.lib2813.testing
}
```
Whatever text that is in the module parentheses is the text that will need to be in an `implementation` statement to depend on the library.
So, after adding the lines to the settings.gradle, this line in the dependencies block will refer to the library.
```
implementation "com.team2813:lib2813"
```
Finally, in order to guarantee that the library jars are created before GradleRIO referees to them, add the following line to your build.gradle
```
downloadDepsPreemptively.dependsOn gradle.includedBuild("lib2813").task(":lib:jar")
```

## Fixing vscode jank
As of version 1.85.1, vscode doesn't work properly with gradle composite builds without the old buildServer. To use the old buildServer, add the following line
to your settings.json
```
"java.gradle.buildServer.enabled": "off",
```
This isn't strictly necessary, but without it vscode will not be able to do code completion from things in the library, and tell the user that there are errors,
when gradle builds fine.
Note that you do not need to include all the dependencies. See the [Runtime dependencies](#runtime-dependencies)
section for details.

## Cloning a repository with a git submodule
When cloning a repository with a git submodule, git will not automatically get the files in the submodules. in order to do this, run the command
```
git submodule update --init --recursive
In addition be sure to include Maven Local in the list of repositories in your `build.gradle`
(needed until we publish to Maven Central):

```groovy
repositories {
mavenLocal()
mavenCentral()
}
```
This command will recursively initialize all submodules.

This code is still in development, and apis are still subject to change. The most likely thing to get removed is the swerve api, as ctre recently released their own.
### Upgrading

## Developer Documentation
To upgrade the version of the lib2813 libraries you are using, simply update the version string for "lib2813" in
`libs.versions.toml`.

To ignore code reformatting when running `git blame` run:
### Vendordeps

```shell
git config blame.ignoreRevsFile .git-blame-ignore-revs
```
- `com.team2813.lib2813:lib`:
- `WPILibNewCommands.json`
- `Phoenix6.json` (if using Phoenix motors)
- `REVLib.json` (if using REV Robotics motors)
- `com.team2813.lib2813:vision`:
- `photonlib.json`
- `com.team2813.lib2813:testing`:
- `WPILibNewCommands.json`
19 changes: 19 additions & 0 deletions buildSrc/src/main/groovy/java-common-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id 'com.diffplug.spotless'
id 'idea'
}

java {
Expand Down Expand Up @@ -119,5 +120,23 @@ javadoc {
links += "https://codedocs.revrobotics.com/java/"
// PhotonVision
links += "https://javadocs.photonvision.org/release/"

// Converts `@apiNote` paragraph to "Note: " section in the generated javadoc
tags += 'apiNote:a:Api Note:'

// Converts `@implSpec` paragraph to "Implementation Requirements: " section in the generated javadoc
tags += 'implSpec:a:Implementation Requirements:'
}
}

task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}

idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
32 changes: 32 additions & 0 deletions buildSrc/src/main/groovy/publishing-conventions.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins {
id 'maven-publish'
}

version = '2.0.0-rc-1'

publishing {
publications {
lib2813(MavenPublication) {
groupId = 'com.team2813.lib2813'
from components.java
artifact sourceJar
pom {
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection = 'scm:git:git://github.com/Prospect-Robotics/lib2813.git'
developerConnection = 'scm:git:git://github.com/Prospect-Robotics/lib2813.git'
url = 'https://github.com/Prospect-Robotics/lib2813'
}
organization {
name = 'FRC 2813 Gear Heads'
url = 'https://team2813.com'
}
}
}
}
}
30 changes: 3 additions & 27 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
plugins {
id 'java-common-conventions'
id 'publishing-conventions'
id 'edu.wpi.first.GradleRIO' version '2026.1.1'
id 'maven-publish'
}

version = '2.0.0-alpha.1'

dependencies {
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()
Expand Down Expand Up @@ -39,41 +37,19 @@ tasks.named('test') {
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
}

javadoc {
options.tags = [
// Converts `@apiNote` paragraph to "Note: " section in the generated javadoc
'apiNote:a:Api Note:',
// Converts `@implSpec` paragraph to "Implementation Requirements: " section in the generated javadoc
'implSpec:a:Implementation Requirements:'
]
}

task sourceJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}

publishing {
publications {
lib2813(MavenPublication) {
groupId = 'com.team2813.lib2813'
artifactId = 'lib2813'
from components.java
artifact sourceJar
pom {
name = '2813 Library'
description = 'Frequently reused code written by team 2813'
developers {
developer {
id = 'mango'
name = 'kyle'
id = 'cuttestkittensrule'
name = 'Kyle'
email = 'mangoiscute95@gmail.com'
}
}
organization {
name = '2813 Gear Heads'
url = 'https://team2813.com'
}
}
}
}
Expand Down
Loading
Loading