|
| 1 | +# Contributing to lib2813 |
| 2 | + |
| 3 | +We welcome contributions! |
| 4 | + |
| 5 | +## What to Contribute |
| 6 | + |
| 7 | +- Bug reports |
| 8 | +- Bug fixes (consider filing a bug report first) |
| 9 | +- Feature additions (please create an issue first) |
| 10 | + |
| 11 | +## Pull Request Guidelines |
| 12 | + |
| 13 | +- Code should be well documented. |
| 14 | +- Please consider writing tests. Tests give us assurance that new changes do not break older functionality. |
| 15 | +- We loosely follow the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). Format the code |
| 16 | + using `./gradlew spotlessApply`. |
| 17 | +- Write a [good change description](https://google.github.io/eng-practices/review/developer/cl-descriptions.html) |
| 18 | + |
| 19 | +We may ask you to test locally on your robot code in simulation mode. |
| 20 | + |
| 21 | +## Getting Started |
| 22 | + |
| 23 | +If you need to make changes to lib213, you can either clone the repository directly, or you |
| 24 | +can include it as a submodule for your robot code. |
| 25 | + |
| 26 | +### Option 1: Developing on a Clone |
| 27 | + |
| 28 | +To clone the repository, run: |
| 29 | + |
| 30 | +```shell |
| 31 | +git clone --recurse-submodules https://github.com/Prospect-Robotics/Robot2025.git |
| 32 | +``` |
| 33 | + |
| 34 | +### Option 2: Developing via Submodules |
| 35 | + |
| 36 | +#### 1. Adding the lib2813 repo as a submodule |
| 37 | + |
| 38 | +When making changes to lib2813, it is often helpful to build the code along with your robot code. |
| 39 | +To do that, you can add the lib2813 repo as a submodule. |
| 40 | + |
| 41 | +Before adding the submodule, it is recommended that you set the `submodule.stickyRecursiveClone` |
| 42 | +git config option to `true` to make working with submodule easier (see |
| 43 | +[this StackOverflow answer](https://stackoverflow.com/a/53622660) for details about this option). |
| 44 | +To do this, run the following command from any directory: |
| 45 | +```shell |
| 46 | +git config --global submodule.stickyRecursiveClone true |
| 47 | +``` |
| 48 | + |
| 49 | +To add the lib2813 submodule, go to your robot project directory (where the `vendordeps` directory is), and run |
| 50 | +this command: |
| 51 | +```shell |
| 52 | +git submodule add https://github.com/Prospect-Robotics/lib2813 |
| 53 | +``` |
| 54 | + |
| 55 | +#### 2. Updating Gradle files |
| 56 | + |
| 57 | +Add the following lines needs to be added to your `settings.gradle`: |
| 58 | +``` |
| 59 | +includeBuild('lib2813') { |
| 60 | + dependencySubstitution { |
| 61 | + substitute module('com.team2813.lib2813:lib') using project(':lib') |
| 62 | + } |
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +Next, remove the version numbers for the lib2813 dependencies in your `build.gradle`: |
| 67 | + |
| 68 | +``` |
| 69 | +implementation "com.team2813.lib2813:lib" |
| 70 | +``` |
| 71 | + |
| 72 | +Next, add the following lines to your `build.gradle`: |
| 73 | + |
| 74 | +Finally, in order to guarantee that the library jars are created before GradleRIO referees to them, add the following |
| 75 | +lines to your `build.gradle`: |
| 76 | +```groovy |
| 77 | +downloadDepsPreemptively.dependsOn gradle.includedBuild('lib2813').task(':lib:jar') |
| 78 | +downloadDepsPreemptively.dependsOn gradle.includedBuild('lib2813').task(':testing:jar') |
| 79 | +downloadDepsPreemptively.dependsOn gradle.includedBuild('lib2813').task(':limelight:jar') |
| 80 | +``` |
| 81 | + |
| 82 | +#### 3. Fixing vscode jank |
| 83 | +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 |
| 84 | +to your settings.json |
| 85 | +``` |
| 86 | +"java.gradle.buildServer.enabled": "off", |
| 87 | +``` |
| 88 | +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, |
| 89 | +when gradle builds fine. |
| 90 | + |
| 91 | +## Tips and Tricks |
| 92 | + |
| 93 | +### Publishing to Maven Local |
| 94 | + |
| 95 | +It can often be useful to publish jars locally and test with a real or simulated robot. |
| 96 | + |
| 97 | +To publish to Maven Local, run: |
| 98 | + |
| 99 | +```shell |
| 100 | +./gradlew publishToMavenLocal -Pversion=2.0.0-test-123 |
| 101 | +``` |
| 102 | + |
| 103 | +(replace "test-123" with some unique identifier) |
| 104 | + |
| 105 | +In your robot's `build.gradle` file, be sure to include Maven Local in your repositories: |
| 106 | + |
| 107 | +```groovy |
| 108 | +repositories { |
| 109 | + mavenLocal() |
| 110 | + mavenCentral() |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +Then update your `build.gradle` to reference the version that you published locally. |
| 115 | + |
| 116 | +### Cloning a repository with a git submodule |
| 117 | +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 |
| 118 | +``` |
| 119 | +git submodule update --init --recursive |
| 120 | +``` |
| 121 | +This command will recursively initialize all submodules. |
| 122 | + |
| 123 | +### Getting blame data |
| 124 | + |
| 125 | +To ignore code reformatting when running `git blame` run: |
| 126 | + |
| 127 | +```shell |
| 128 | +git config blame.ignoreRevsFile .git-blame-ignore-revs |
| 129 | +``` |
0 commit comments