Added spotless and CONTRIBUTING.md (#172)

This commit is contained in:
Ryan Butler
2022-05-19 15:51:46 +01:00
committed by GitHub
parent 1e4013be98
commit dedec668e1
12 changed files with 541 additions and 1688 deletions

73
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,73 @@
# Contributing to SlimeVR
This document describes essential knowledge for contributors to SlimeVR.
## How to get started
### Getting the code
First, clone the codebase using `git`. If you don't have `git` installed, go install it.
```bash
# Clone repositories
git clone --recursive https://github.com/SlimeVR/SlimeVR-Server.git
# Enter the directory of the codebase
cd SlimeVR-Server
```
Now you can open the codebase in your favorite IDE or text editor.
### Building the code
The code is built with `gradle`, a cli tool that manages java projects and their
dependencies. You can build the code with `./gradlew build` and run it with
`./gradlew run`.
## Code Style
Code is autoformatted with [spotless](https://github.com/diffplug/spotless/tree/main/plugin-gradle).
Code is checked for autoformatting whenever you build, but you can also run
`./gradlew spotlessCheck` if you prefer.
To autoformat your code from the command line, you can run `./gradlew spotlessApply`.
We recommend installing support for spotless in your IDE of choice, and formatting
whenever you save a file, to make things easy.
If you need to prevent autoformatting for a particular region of code, use
`// @formatter:off` and `// @formatter:on`
### Setting up spotless in VSCode
* Install the `richardwillis.vscode-spotless-gradle` extension
* Add the following to your workspace settings, at `.vscode/settings.json`:
```json
"spotlessGradle.format.enable": true,
"editor.formatOnSave": true,
"[java]": {
"editor.defaultFormatter": "richardwillis.vscode-spotless-gradle"
}
```
### Setting up spotless for IntelliJ
* Install https://plugins.jetbrains.com/plugin/18321-spotless-gradle.
* Turn on [formatting on save](https://www.jetbrains.com/help/idea/reformat-and-rearrange-code.html#reformat-on-save).
### Setting up Eclipse autoformatting
Import the formatting settings defined in `spotless.xml`, like this:
* Go to `File > Properties`, then `Java Code Style > Formatter`
* Check `Enable project specific settings`
* Click `Import`, then open `spotless.xml`, then `Apply`
* Go to `Java Editor > Save Actions`
* Select `Enable project specific settings`, `Perform the selected actions on save`,
`Format source code`, `Format all lines`
Eclipse will only do a subset of the checks in `spotless`, so you may still want to do
`./gradlew spotlessApply` if you ever see an error from spotless.
## Code Licensing
SlimeVR uses an MIT license, and some parts of the project use a dual MIT/Apache 2.0
license. Be sure that any code that you reference, or dependencies you add, are
compatible with these licenses. `GPL-v3` for example is not compatible because it
requires any and all code that depends on it to *also* be licensed under `GPL-v3`.
## Discord
We use discord *a lot* to coordinate and discuss development. Come join us at
https://discord.gg/SlimeVR!