|
| 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 | + Write the issue in English to share it with many people. |
| 21 | + |
| 22 | +## Contact |
| 23 | + |
| 24 | +Let's work together to make this project better! |
| 25 | + |
| 26 | +If you have any questions or suggestions, feel free to open an issue or contact the maintainers via GitHub. |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +- Install **IntelliJ IDEA** (2024.3 or later) |
| 31 | + - We recommend using the latest stable version of IntelliJ IDEA. |
| 32 | +- Install **Git** and configure your GitHub access |
| 33 | +- Install **JDK 17** |
| 34 | + |
| 35 | +## Recommended IntelliJ IDEA Plugins |
| 36 | + |
| 37 | +We recommend installing the following plugins in IntelliJ IDEA to improve your development experience: |
| 38 | + |
| 39 | +You can install these plugins from `File > Settings > Plugins` in IntelliJ IDEA. |
| 40 | + |
| 41 | +- **[Plugin DevKit](https://plugins.jetbrains.com/plugin/22851-plugin-devkit)** |
| 42 | +- **[PsiViewer](https://plugins.jetbrains.com/plugin/227-psiviewer)** |
| 43 | +- **[Spotless Gradle](https://plugins.jetbrains.com/plugin/18321-spotless-gradle)** |
| 44 | +- **[Ktlint](https://plugins.jetbrains.com/plugin/15057-ktlint)** |
| 45 | + |
| 46 | +## Setting Up the Development Environment |
| 47 | + |
| 48 | +1. **Clone the Repository** |
| 49 | + |
| 50 | + ```sh |
| 51 | + git clone https://github.com/domaframework/doma-tools-for-intellij.git |
| 52 | + cd doma-tools-for-intellij |
| 53 | + ``` |
| 54 | + |
| 55 | +2. **Open the Project in IntelliJ IDEA** |
| 56 | + - Select `Open` and choose the project root directory. |
| 57 | + - IntelliJ will automatically import the Gradle project. |
| 58 | + |
| 59 | +3. **Generate Custom Language Java Files (Grammar-Kit)** |
| 60 | + - Before building the project, generate the lexer and parser Java files using Grammar-Kit tasks: |
| 61 | + ```sh |
| 62 | + ./gradlew generateLexer |
| 63 | + ./gradlew generateParser |
| 64 | + ``` |
| 65 | + - If you make changes to `Sql.bnf` or `Sql.flex`, be sure to re-run the above tasks to regenerate the Java files. |
| 66 | + - If you encounter build errors related to generated sources, try deleting the generated `gen` directory and re-running the Grammar-Kit tasks. |
| 67 | + |
| 68 | +4. **Build the Project** |
| 69 | + - Use the Gradle tool window or run: |
| 70 | + ```sh |
| 71 | + ./gradlew build |
| 72 | + ``` |
| 73 | + |
| 74 | +5. **Run/Debug the Plugin** |
| 75 | + - Use the Gradle task `runIde` to launch a sandboxed IntelliJ instance: |
| 76 | + ```sh |
| 77 | + ./gradlew runIde |
| 78 | + ``` |
| 79 | + |
| 80 | +## Testing and Doma Dependency Management |
| 81 | + |
| 82 | +When running tests, the plugin creates a virtual project environment with the required Doma dependencies. |
| 83 | + |
| 84 | +- The Doma jar files for each version used in tests are located in the [`src/test/lib`](src/test/lib) directory. |
| 85 | +- The dependencies for the virtual project are managed in the `setUp()` method of [`DomaSqlTest`](src/test/kotlin/org/domaframework/doma/intellij/DomaSqlTest.kt). |
| 86 | +
|
| 87 | +## Code Style |
| 88 | +
|
| 89 | +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. |
| 90 | +
|
| 91 | +- To check or apply formatting, run the following Gradle tasks: |
| 92 | + ```sh |
| 93 | + ./gradlew spotlessCheck # Check code format |
| 94 | + ./gradlew spotlessApply # Apply code format |
| 95 | + ``` |
| 96 | +- Alternatively, formatting will also be applied automatically when you build the project: |
| 97 | + ```sh |
| 98 | + ./gradlew build |
| 99 | + ``` |
| 100 | +
|
| 101 | +Please ensure your code is formatted with Spotless before submitting a pull request. |
| 102 | +
|
| 103 | +### Code Inspection |
| 104 | +
|
| 105 | +For advanced code inspection and static analysis, consider using [Qodana](https://www.jetbrains.com/qodana/). |
| 106 | +
|
| 107 | +- Qodana is a static analysis tool by JetBrains that can automatically check code quality in CI pipelines. |
| 108 | +- This repository includes a [`qodana.yml`](qodana.yml) file as an example configuration for Qodana. |
| 109 | +- For more details, refer to the [Qodana official documentation](https://www.jetbrains.com/help/qodana/). |
| 110 | +
|
| 111 | +## Branch Naming Rules |
| 112 | +
|
| 113 | +When creating a working branch, please follow the naming rules below according to the type of change. |
| 114 | +
|
| 115 | +These branch paths are used to categorize pull requests by label when automatically creating release drafts. |
| 116 | +
|
| 117 | +The mapping between branch paths and label names is configured in [`release-drafter.yml`](.github/release-drafter.yml). |
| 118 | +
|
| 119 | +- Bug fixes: `fix/` |
| 120 | +- Documentation changes: `document/` |
| 121 | +- CI-related changes: `ci/` |
| 122 | +- Dependency updates: `dependencies/` (Note: Version upgrades for dependencies are handled automatically by Renovate) |
| 123 | +- New features: `feature/` |
| 124 | +- Refactoring: `chore/` |
| 125 | +
|
| 126 | +For example, a bug fix branch might be named `fix/typo-in-readme`, and a new feature branch might be `feature/add-user-authentication`. |
| 127 | +
|
| 128 | +## Submitting a Pull Request |
| 129 | +
|
| 130 | +1. Create your branch from `main`. |
| 131 | +2. Make your changes and ensure all tests pass: |
| 132 | + ```sh |
| 133 | + ./gradlew check |
| 134 | + ``` |
| 135 | +3. Submit a pull request with a clear description of your changes. |
| 136 | +4. After creating a pull request, please link any related issues to the PR. |
0 commit comments