2020-11-12 23:08:00 -07:00
|
|
|
## paperweight
|
|
|
|
|
2021-09-23 23:34:33 -07:00
|
|
|
`paperweight` consists of three Gradle plugins:
|
|
|
|
- `paperweight-core`: Used to build Paper
|
|
|
|
- `paperweight-patcher`: Used to create forks of Paper or other `paperweight-patcher`-based forks
|
|
|
|
- `paperweight-userdev`: Used to develop internals plugins using Mojang mappings
|
2018-10-12 21:33:26 -07:00
|
|
|
|
2021-09-23 23:34:33 -07:00
|
|
|
### How to use this for testing:
|
2018-10-12 21:33:26 -07:00
|
|
|
|
2021-09-23 23:34:33 -07:00
|
|
|
- Install `paperweight` to Maven Local:
|
2018-10-12 21:33:26 -07:00
|
|
|
```bash
|
2020-12-26 00:48:41 -07:00
|
|
|
./gradlew publishToMavenLocal
|
2018-10-12 21:33:26 -07:00
|
|
|
```
|
2021-09-23 23:34:33 -07:00
|
|
|
- Add `mavenLocal()` for plugin resolution in your test project
|
|
|
|
(see the [Gradle docs](https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories) for more details)
|
|
|
|
- Adjust the `paperweight` version in your test project
|
|
|
|
- Local versions of `paperweight` will use have the `-SNAPSHOT` suffix in the version from `gradle.properties` replaced by `-LOCAL-SNAPSHOT`
|
2018-10-12 21:33:26 -07:00
|
|
|
|
2021-09-23 23:34:33 -07:00
|
|
|
> Most output `paperweight` creates goes into `<project-root>/.gradle/caches/paperweight`
|
2018-10-12 21:33:26 -07:00
|
|
|
|
2020-11-12 23:08:00 -07:00
|
|
|
### Debugging
|
2018-10-12 21:33:26 -07:00
|
|
|
|
2020-11-12 23:08:00 -07:00
|
|
|
Create a remote JVM debug run configuration in IntelliJ which connects to port 5005, then run Gradle in debug mode:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
./gradlew --no-daemon -Dorg.gradle.debug=true <task>
|
2018-10-12 21:33:26 -07:00
|
|
|
```
|
|
|
|
|
2020-11-12 23:08:00 -07:00
|
|
|
Gradle will not start until the debugger is connected so you don't need to worry about missing a breakpoint.
|
2020-12-26 16:56:49 -07:00
|
|
|
|
|
|
|
### Style Guide
|
|
|
|
|
|
|
|
This projects follows the opinionated [`ktlint`](https://ktlint.github.io/) linter and formatter. It uses the
|
|
|
|
[`ktlint-gradle`](https://github.com/jlleitschuh/ktlint-gradle) plugin to automatically check and format the code in
|
|
|
|
this repo.
|
|
|
|
|
|
|
|
Run the `format` task to automatically reformat the project using `ktlint` - which should handle most cases - to
|
|
|
|
maintain a consistent code style. Adjust any errors `ktlint` can't fix itself before committing.
|
|
|
|
|
|
|
|
```
|
|
|
|
./gradlew format
|
|
|
|
```
|
|
|
|
|
|
|
|
### IDE Setup
|
|
|
|
|
2021-07-03 20:45:33 -07:00
|
|
|
It's recommended to run the `ktlintApplyToIdea` and `addKtlintFormatGitPreCommitHook` tasks to configure your IDE
|
|
|
|
with `ktlint` style settings and to automatically format this project's code before committing:
|
2020-12-26 16:56:49 -07:00
|
|
|
|
|
|
|
```
|
|
|
|
./gradlew ktlintApplyToIdea addKtlintFormatGitPreCommitHook
|
|
|
|
```
|
|
|
|
|
|
|
|
> This project uses many new Gradle features to make sure we're ready for Gradle 7.0 and beyond, and we don't find
|
|
|
|
> ourselves stuck in a bad position where it's too hard for us to update. That being said, Gradle always marks new APIs
|
|
|
|
> as unstable for a bit until the next major version, so you should probably disable the "Unstable API Usages" inspection
|
|
|
|
> in IntelliJ as well. The easiest way to do this is just find any place where an "unstable API" is used (tons in
|
|
|
|
> `Paperweight.kt`) and disable the inspection from there.
|