-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: Add a Java development skill for the monorepo #12797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lqiu96
wants to merge
3
commits into
main
Choose a base branch
from
feat/add-java-dev-skill
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+67
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| name: java-development | ||
| description: General guidance on Java development practices, building, testing, and style in the monorepo. Use this skill when working on Java code across the repository. | ||
| --- | ||
|
|
||
| # Java Development Guide | ||
|
|
||
| This skill provides general guidelines for Java development inside the monorepo. It covers building, formatting, testing, and style conventions to ensure consistency across modules. | ||
|
|
||
| ## Workflow | ||
|
|
||
| ### 1. Building the Project | ||
|
|
||
| The repository uses Maven as its primary build system. | ||
|
|
||
| * **Build All Modules**: To build all modules from the root of the repository, run: | ||
| ```bash | ||
| mvn install -T 1C -P quick-build | ||
lqiu96 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
| > [!TIP] | ||
| > Use `-T 1C` to build modules in parallel (one thread per CPU core) and `-P quick-build` to skip unnecessary plugins for faster builds. | ||
| * **Build a Specific Module**: You can also run Maven commands within a specific module directory (e.g., `java-bigquery`) to build only that module. | ||
|
|
||
| ### 2. Code Formatting | ||
|
|
||
| Code formatting is enforced using the `fmt-maven-plugin`. | ||
|
|
||
| * **Check Formatting**: To check for formatting issues without modifying files, run: | ||
| ```bash | ||
| mvn fmt:check -T 1C | ||
| ``` | ||
| * **Apply Formatting**: To automatically format the code according to the project style, run: | ||
| ```bash | ||
| mvn fmt:format -T 1C | ||
| ``` | ||
| > [!TIP] | ||
| > To save time, run `mvn fmt:format` within the specific module directory you are working on, rather than at the root. | ||
| > [!NOTE] | ||
| > Always run `mvn fmt:format` before committing changes to avoid build failures due to formatting. | ||
|
|
||
| ### 3. Testing Strategy | ||
|
|
||
| * **Unit Tests**: Traditional unit tests should be added for individual classes and methods. Run them using: | ||
| ```bash | ||
| mvn test -T 1C | ||
| ``` | ||
| * **Integration Tests**: Many modules have integration tests that run against live services or emulators. These may require specific profiles or environment variables. Refer to the specific module's README for details. | ||
|
|
||
| ### 4. Style Guide | ||
|
|
||
| Follow these general rules to maintain code quality and consistency: | ||
|
|
||
| 1. **Minimize Visibility**: Default to the most restrictive access level possible. Avoid using `public` unless the class or method is intended to be part of the public API. | ||
| 2. Avoid Fully Qualified Names: Use imports to keep class names short and readable, rather than using fully qualified names in the code. | ||
| 3. **Avoid Obsolete APIs**: Do not call methods marked with `@ObsoleteApi` or `@Deprecated` unless there are no viable alternatives. | ||
| 4. **Clean Diffs**: Avoid unnecessary formatting changes or whitespace modifications to keep diffs clean and easy to review. | ||
lqiu96 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### 5. Dependency Management | ||
|
|
||
| * **Version Bumps**: Try not to bump any external dependency versions unless there is a known security vulnerability (CVE) or a critical bug fix. | ||
| * **New Dependencies**: Avoid introducing new external dependencies. If a new dependency is required, provide a strong justification in the pull request. | ||
| * **Standard Library First**: Prefer to use features from the Java standard library, followed by existing dependencies in the project (preferably Google-managed dependencies). | ||
|
|
||
| ### 6. Contribution Guidelines | ||
|
|
||
| * **Commit Messages**: Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification. Include the module as the scope (e.g., `feat(spanner): ...`, `fix(bigquery): ...`). | ||
| * **Pull Requests**: All code changes must be submitted via a pull request and require review. Ensure you pull the latest changes from `main` and resolve any conflicts before submitting. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel 1/2/3 are proper skills since they are telling the AI exactly how to do things. But 4/5/6 might be more suitable for a repo level gemini.md?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. I think it would be relevant as it tells the agent how to generate code to be used for the features. Shall we try a skill to see how it works?