|
| 1 | +# Cloud Command Framework fork |
| 2 | + |
| 3 | +A fork of the well known [cloud command framework](https://github.com/Incendo/cloud) which fixes some inconsistencies |
| 4 | +and makes it easier to integrate it into standalone applications. |
| 5 | + |
| 6 | +## Dependencies |
| 7 | + |
| 8 | +This project is available via [jitpack](https://jitpack.io): |
| 9 | + |
| 10 | +```groovy |
| 11 | +repositories { |
| 12 | + maven { |
| 13 | + name = 'jitpack' |
| 14 | + url = 'https://jitpack.io/' |
| 15 | + } |
| 16 | +} |
| 17 | +
|
| 18 | +dependencies { |
| 19 | + implementation('com.github.cloudnetservice.cloud-command-framework', '<submodule>', 'main-SNAPSHOT') |
| 20 | +} |
| 21 | +``` |
| 22 | + |
| 23 | +## Building from source |
| 24 | + |
| 25 | +After cloning the project you need to init the submodules and apply the patches using: |
| 26 | + |
| 27 | +``` |
| 28 | +git submodule update --init && ./gradlew applyPatches |
| 29 | +``` |
| 30 | + |
| 31 | +You can then publish cloud into your local maven repository for testing: |
| 32 | + |
| 33 | +* Navigate into the `patched-cloud` folder using the command line |
| 34 | +* Build & publish the project using `./gradlew publishToMavenLocal` |
| 35 | + |
| 36 | +**Java 17 is required to build the project!** |
| 37 | + |
| 38 | +## Making changes |
| 39 | + |
| 40 | +After applying the patches a new folder should appear named `patched-cloud`. You can make changes to the cloud sources |
| 41 | +in that folder. When you are done modifying them: |
| 42 | + |
| 43 | +* Navigate into the `patched-cloud` folder using the command line |
| 44 | +* Commit your changes using a meaningful commit message |
| 45 | +* Move into the root project folder and build a patch from the created commit using `./gradlew rebuildPatches` |
| 46 | + |
| 47 | +## Modifying an existing patch |
| 48 | + |
| 49 | +To modify an existing patch: |
| 50 | + |
| 51 | +* First make your changes in the `patched-cloud` folder as always |
| 52 | +* Find the commit hash of the commit you want to edit by for example using `git log`, `git blame` or the git history |
| 53 | + provided by your IDE or GitHub |
| 54 | +* Make a fixup commit: `git commit -a --fixup <commit hash of the patch to edit>` |
| 55 | + * You can also use `--squash` instead of `--fixup` to change the commit message of the patch as well |
| 56 | +* Rebase the changes: `git rebase -i --autosquash origin`. This will automatically move the fixup to the right place, |
| 57 | + you just need to confirm the action by "saving" the changes in the text editor that will open. |
| 58 | +* Move into the root project folder and rebuild the patch from the created commit using `./gradlew rebuildPatches` |
| 59 | + |
| 60 | +## Patch formatting |
| 61 | + |
| 62 | +In general, it is preferred to keep the patches as small as possible to make it easier to pull in changes made in the |
| 63 | +forked repository. Some general notes: |
| 64 | + |
| 65 | +* Single line changes always have a `// cloudnet` suffix, optionally providing a description of the change |
| 66 | + like: `// cloudnet - private -> protected` |
| 67 | +* Multi line changes start with `// cloudnet start` and end with `// cloudnet end`, the start message can optionally |
| 68 | + contain a reason like: `// cloudnet start - easier access to caption registry` |
| 69 | + |
| 70 | +Don't comment lines out unless necessary, you can make the diff smaller by (for example) inserting an `if (true)` |
| 71 | +before the code you want to prevent from happening like: |
| 72 | + |
| 73 | +```java |
| 74 | +public @NonNull String getMessage() { |
| 75 | + // cloudnet start - no more heavy operations |
| 76 | + if (true) return "hello world"; |
| 77 | + // cloudnet end |
| 78 | + return "hello" + " " + "world"; |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +This is how a full change might look like: |
| 83 | +```java |
| 84 | +public @NonNull String getMessage(final @NonNull String input) { // cloudnet - private -> public |
| 85 | + final String partiallyFixed = input.replace('.', '-'); |
| 86 | + final boolean empty = partiallyFixed.isBlank(); // cloudnet - was isEmpty but isBlank is better |
| 87 | + final Integer parsedValue = Ints.tryParse(partiallyFixed); |
| 88 | + // cloudnet start - no more heavy operations |
| 89 | + if (true) return "hello world " + partiallyFixed; |
| 90 | + // cloudnet end |
| 91 | + return "hello" + " " + partiallyFixed + " " + parsedValue + " " + "world"; |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +## Contributing |
| 96 | + |
| 97 | +If you think that something else should be changed in order to easier integrate this fork into your project, fell free |
| 98 | +to open a pull request. Contributions are always welcome. |
| 99 | + |
| 100 | +## License |
| 101 | + |
| 102 | +This project is based on [cloud](https://github.com/Incendo/cloud) which is licensed under the terms of |
| 103 | +the [MIT license](https://github.com/Incendo/cloud/blob/master/LICENSE) to Alexander Söderberg & Contributors. This |
| 104 | +includes all files pulled in from the `cloud` git submodule as well as the patched code in `patched-cloud`. The patches |
| 105 | +and all other files in this repository are licensed under the terms of the [Apache 2 license](license.txt) to the |
| 106 | +CloudNetService team & contributors. |
0 commit comments