|
| 1 | +# Contributing to Doma Tools for IntelliJ |
| 2 | + |
| 3 | +Thank you for your interest in contributing to this project! |
| 4 | + |
| 5 | +Please follow the guidelines below to set up your environment and submit contributions. |
| 6 | + |
| 7 | +## License |
| 8 | + |
| 9 | +All original contributions to Doma Tools are licensed under ASL - [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0) or later. |
| 10 | + |
| 11 | +## About This Project |
| 12 | + |
| 13 | +This plugin project is based on the [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template). |
| 14 | + |
| 15 | +For other basic project information and best practices, please refer to the template repository. |
| 16 | + |
| 17 | +## Reporting Issues |
| 18 | + |
| 19 | +- Use the [GitHub Issues page](https://github.com/domaframework/doma-tools-for-intellij/issues) to report bugs or request features. |
| 20 | + |
| 21 | +## Contact |
| 22 | + |
| 23 | +Let's work together to make this project better! |
| 24 | + |
| 25 | +If you have any questions or suggestions, feel free to open an issue or contact the maintainers via GitHub. |
| 26 | +Write the issue in English to share it with many people. |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +- **JDK 17** |
| 31 | +- **Git** (Install Git and configure your GitHub access) |
| 32 | + |
| 33 | +## Recommended IntelliJ IDEA Plugins |
| 34 | + |
| 35 | +We recommend installing the following plugins in IntelliJ IDEA to improve your development experience: |
| 36 | + |
| 37 | +You can install these plugins from `File > Settings > Plugins` in IntelliJ IDEA. |
| 38 | + |
| 39 | +- **[Plugin DevKit](https://plugins.jetbrains.com/plugin/22851-plugin-devkit)** |
| 40 | +- **[PsiViewer](https://plugins.jetbrains.com/plugin/227-psiviewer)** |
| 41 | +- **[Spotless Gradle](https://plugins.jetbrains.com/plugin/18321-spotless-gradle)** |
| 42 | + |
| 43 | +## Setting Up the Development Environment |
| 44 | + |
| 45 | +1. **Clone the Repository** |
| 46 | + |
| 47 | + ```sh |
| 48 | + git clone https://github.com/domaframework/doma-tools-for-intellij.git |
| 49 | + cd doma-tools-for-intellij |
| 50 | + ``` |
| 51 | + |
| 52 | +2. **Open the Project in IntelliJ IDEA** |
| 53 | + - Select `Open` and choose the project root directory. |
| 54 | + - IntelliJ will automatically import the Gradle project. |
| 55 | + |
| 56 | +3. **Generate Custom Language Java Files (Grammar-Kit)** |
| 57 | + - Before building the project, generate the lexer and parser Java files using Grammar-Kit tasks: |
| 58 | + ```sh |
| 59 | + ./gradlew generateLexer |
| 60 | + ./gradlew generateParser |
| 61 | + ``` |
| 62 | + - If you make changes to `Sql.bnf` or `Sql.flex`, be sure to re-run the above tasks to regenerate the Java files. |
| 63 | + - If you encounter build errors related to generated sources, try deleting the generated `gen` directory and re-running the Grammar-Kit tasks. |
| 64 | + |
| 65 | +4. **Build the Project** |
| 66 | + - Use the Gradle tool window or run: |
| 67 | + ```sh |
| 68 | + ./gradlew build |
| 69 | + ``` |
| 70 | + - To generate a plugin zip file for local installation, run: |
| 71 | + ```sh |
| 72 | + ./gradlew buildPlugin |
| 73 | + ``` |
| 74 | + The zip file will be created in the `build/distributions` directory and can be installed locally in IntelliJ IDEA. |
| 75 | + |
| 76 | +5. **Run/Debug the Plugin** |
| 77 | + - Use the Gradle task `runIde` to launch a sandboxed IntelliJ instance: |
| 78 | + ```sh |
| 79 | + ./gradlew runIde |
| 80 | + ``` |
| 81 | +## Code Style |
| 82 | + |
| 83 | +We use [Spotless](https://github.com/diffplug/spotless) and [google-java-format](https://github.com/google/google-java-format) for code formatting and style checking. |
| 84 | + |
| 85 | +- To check or apply formatting, run the following Gradle tasks: |
| 86 | + ```sh |
| 87 | + ./gradlew spotlessCheck # Check code format |
| 88 | + ./gradlew spotlessApply # Apply code format |
| 89 | + ``` |
| 90 | +- Alternatively, formatting will also be applied automatically when you build the project: |
| 91 | + ```sh |
| 92 | + ./gradlew build |
| 93 | + ``` |
| 94 | + |
| 95 | +Please ensure your code is formatted with Spotless before submitting a pull request. |
| 96 | + |
| 97 | +## Branch Naming Rules |
| 98 | + |
| 99 | +When creating a working branch, please follow the naming rules below according to the type of change: |
| 100 | + |
| 101 | +- Bug fixes: `fix/` |
| 102 | +- Documentation changes: `document/` |
| 103 | +- CI-related changes: `ci/` |
| 104 | +- Dependency updates: `dependencies/` (Note: Version upgrades for dependencies are handled automatically by Renovate) |
| 105 | +- New features: `feature/` |
| 106 | +- Refactoring: `chore/` |
| 107 | + |
| 108 | +For example, a bug fix branch might be named `fix/typo-in-readme`, and a new feature branch might be `feature/add-user-authentication`. |
| 109 | + |
| 110 | +## Submitting a Pull Request |
| 111 | + |
| 112 | +1. Fork the repository and create your branch from `main`. |
| 113 | +2. Make your changes and ensure all tests pass: |
| 114 | + ```sh |
| 115 | + ./gradlew check |
| 116 | + ``` |
| 117 | +3. Submit a pull request with a clear description of your changes. |
0 commit comments