A gradle plugin that will verify ownership files are in place in projects and have required information.
plugins {
id("se.premex.ownership") version "LATEST_VERSION"
}ownership {
validateOwnership = true
generateGithubOwners = true
generateBitbucketOwners = true
}./gradlew ownershipThis combined task validates OWNERSHIP.toml files and generates VCS CODEOWNERS files (both validation and generation in a single command).
./gradlew validateOwnershipOutputs from validation is available in build/reports/ownershipValidation/
./gradlew generateOwnershipThis task generates CODEOWNERS files for GitHub and/or Bitbucket based on your OWNERSHIP.toml files:
- When
generateGithubOwners = true: Creates.github/CODEOWNERS - When
generateBitbucketOwners = true: Creates.bitbucket/CODEOWNERS
The generated files map directory paths to owners defined in your OWNERSHIP.toml files.
./gradlew checkversion = 1
[owner]
user = "@team-name"The user field supports:
- GitHub teams:
@org/team-nameor@team-name - GitHub usernames:
@username - Email addresses:
[email protected]
version = 1
[owner]
user = "@platform-team"
[custom]
owners = [
["*.js", "@frontend-team"],
["*.ts", "@frontend-team"],
["*.java", "@backend-team"],
["*.kt", "@backend-team"],
["docs/*", "[email protected]"]
]The [custom] section allows you to specify different owners for specific file patterns or paths within the directory containing the OWNERSHIP.toml file.
You can place OWNERSHIP.toml files in multiple directories:
root/
├── OWNERSHIP.toml # Root ownership (applies to * path)
├── frontend/
│ └── OWNERSHIP.toml # Applies to frontend/ path
└── backend/
└── OWNERSHIP.toml # Applies to backend/ path
The generated CODEOWNERS file will combine all ownership rules from all OWNERSHIP.toml files found in your project.
Given the following project structure:
root/
├── OWNERSHIP.toml (user = "@platform-team", custom: *.js → @frontend-team)
├── backend/
│ └── OWNERSHIP.toml (user = "@backend-team")
The generated .github/CODEOWNERS file would look like:
# This file is automatically generated by Premex ownership plugin
# Do not edit manually.
# https://plugins.gradle.org/plugin/se.premex.ownership
# https://github.com/premex-ab/ownership-gradle-plugin
# OWNERSHIP.toml
* @platform-team
# Custom configurations
*.js @frontend-team
# backend/OWNERSHIP.toml
backend/ @backend-team
Here are some ideas that we are thinking about. We are also not limited to these and would love to learn more about your use cases.
- Support for verifying codeownership files is in place
- Better rules for validating content in ownership files
- Support for having codeownership files anywhere in the code and not only in a projects root
- Generate GitHub & Bitbucket codeownership files based on the toml files
- Generate html reports of code ownerships and code health