-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,498 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,43 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- '*.md' | ||
workflow_dispatch: | ||
inputs: | ||
reason: | ||
description: 'Reason for manual run' | ||
required: false | ||
|
||
concurrency: | ||
group: build-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
gradle: | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 17 | ||
|
||
- name: Validate Gradle Wrapper | ||
uses: gradle/actions/wrapper-validation@v3 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Execute check | ||
run: './gradlew check -s' | ||
|
||
- name: Execute buildHealth for main project | ||
run: './gradlew buildHealth -s' |
This file contains 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,46 @@ | ||
name: publish | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
reason: | ||
description: 'Reason for manual run' | ||
required: false | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
publish: | ||
env: | ||
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_SECRET_KEY }} | ||
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }} | ||
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME_XYZ_BLOCK }} | ||
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD_XYZ_BLOCK }} | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'block/kotlin-formatter' && github.ref == 'refs/heads/main' | ||
|
||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 17 | ||
|
||
- name: Validate Gradle Wrapper | ||
uses: gradle/actions/wrapper-validation@v3 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Execute check | ||
run: './gradlew check -s' | ||
|
||
- name: Execute buildHealth | ||
run: './gradlew buildHealth -s' | ||
|
||
- name: Publish artifacts | ||
run: './gradlew publishToMavenCentral -s --no-configuration-cache' |
This file contains 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,45 @@ | ||
name: Main | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '*.md' | ||
workflow_dispatch: | ||
inputs: | ||
reason: | ||
description: 'Reason for manual run' | ||
required: false | ||
|
||
concurrency: | ||
group: build-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
gradle: | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'zulu' | ||
java-version: 17 | ||
|
||
- name: Validate Gradle Wrapper | ||
uses: gradle/actions/wrapper-validation@v3 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
|
||
- name: Execute check | ||
run: './gradlew check -s' | ||
|
||
- name: Execute buildHealth | ||
run: './gradlew buildHealth -s' |
This file contains 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
This file contains 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,5 @@ | ||
# Kotlin Formatter | ||
|
||
## Version 0.1 | ||
|
||
First OSS release. |
Validating CODEOWNERS rules …
This file contains 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,24 @@ | ||
# This CODEOWNERS file denotes the project leads | ||
# and encodes their responsibilities for code review. | ||
|
||
# Instructions: At a minimum, replace the '@GITHUB_USER_NAME_GOES_HERE' | ||
# here with at least one project lead. | ||
|
||
# Lines starting with '#' are comments. | ||
# Each line is a file pattern followed by one or more owners. | ||
# The format is described: https://github.blog/2017-07-06-introducing-code-owners/ | ||
|
||
# These owners will be the default owners for everything in the repo. | ||
* @wsutina @staktrace | ||
|
||
|
||
# ----------------------------------------------- | ||
# BELOW THIS LINE ARE TEMPLATES, UNUSED | ||
# ----------------------------------------------- | ||
# Order is important. The last matching pattern has the most precedence. | ||
# So if a pull request only touches javascript files, only these owners | ||
# will be requested to review. | ||
# *.js @octocat @github/js | ||
|
||
# You can also use email addresses if you prefer. | ||
# docs/* [email protected] |
This file contains 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,101 @@ | ||
# Contribution Guide | ||
|
||
There are many ways to be an open source contributor, and we're here to help you on your way! You may: | ||
|
||
* Raise an issue or feature request in our [issue tracker](#issues) | ||
* Help another contributor with one of their questions, or a code review | ||
* Suggest improvements to our Getting Started documentation by supplying a Pull Request | ||
* Evangelize our work together in conferences, podcasts, and social media spaces. | ||
|
||
This guide is for you. | ||
|
||
## Build | ||
|
||
### macOS / Linux | ||
```shell | ||
$> ./gradlew build | ||
``` | ||
|
||
### Windows | ||
```shell | ||
$> gradlew.bat build | ||
``` | ||
|
||
## Build the CLI Tool | ||
To build and install the CLI tool: | ||
|
||
```shell | ||
$> ./gradlew :kotlin-format:installShadowDist | ||
``` | ||
This will install the CLI to `kotlin-format/build/install/kotlin-format-shadow/` | ||
|
||
## Test | ||
|
||
### macOS / Linux | ||
```shell | ||
$> ./gradlew test | ||
``` | ||
|
||
### Windows | ||
```shell | ||
$> gradlew.bat test | ||
``` | ||
|
||
### Gradle build scans | ||
|
||
This project is configured to publish build scans to the public | ||
[build scan service](https://scans.gradle.com/). Publication is disabled by default but can be | ||
enabled by creating a `local.properties` file with the following contents: | ||
|
||
```properties | ||
kotlin.editor.build.scans.enable=true | ||
``` | ||
|
||
This file should not be checked into version control. | ||
|
||
--- | ||
|
||
## Communications | ||
|
||
### Issues | ||
|
||
Anyone from the community is welcome (and encouraged!) to raise issues via | ||
[GitHub Issues](https://github.com/block/kotlin-formatter/issues) | ||
|
||
### Continuous Integration | ||
|
||
Build and Test cycles are run on every commit to every branch on [GitHub Actions](https://github.com/block/kotlin-formatter/actions). | ||
|
||
## Contribution | ||
|
||
We review contributions to the codebase via GitHub's Pull Request mechanism. We have | ||
the following guidelines to ease your experience and help our leads respond quickly | ||
to your valuable work: | ||
|
||
* Start by proposing a change either in Issues (most appropriate for small | ||
change requests or bug fixes) or in Discussions (most appropriate for design | ||
and architecture considerations, proposing a new feature, or where you'd | ||
like insight and feedback) | ||
* Cultivate consensus around your ideas; the project leads will help you | ||
pre-flight how beneficial the proposal might be to the project. Developing early | ||
buy-in will help others understand what you're looking to do, and give you a | ||
greater chance of your contributions making it into the codebase! No one wants to | ||
see work done in an area that's unlikely to be incorporated into the codebase. | ||
* Fork the repo into your own namespace/remote | ||
* Work in a dedicated feature branch. Atlassian wrote a great | ||
[description of this workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) | ||
* When you're ready to offer your work to the project, first: | ||
* Squash your commits into a single one (or an appropriate small number of commits), and | ||
rebase atop the upstream `main` branch. This will limit the potential for merge | ||
conflicts during review, and helps keep the audit trail clean. A good writeup for | ||
how this is done is | ||
[here](https://medium.com/@slamflipstrom/a-beginners-guide-to-squashing-commits-with-git-rebase-8185cf6e62ec), and if you're | ||
having trouble - feel free to ask a member or the community for help or leave the commits as-is, and flag that you'd like | ||
rebasing assistance in your PR! We're here to support you. | ||
* Open a PR in the project to bring in the code from your feature branch. | ||
* The maintainers noted in the `CODEOWNERS` file will review your PR and optionally | ||
open a discussion about its contents before moving forward. | ||
* Remain responsive to follow-up questions, be open to making requested changes, and... | ||
You're a contributor! | ||
* And remember to respect everyone in our global development community. Guidelines | ||
are established in our `CODE_OF_CONDUCT.md`. |
This file contains 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 |
---|---|---|
@@ -1,3 +1,37 @@ | ||
# Kotlin Formatter | ||
|
||
**A command-line tool for formatting Kotlin source code files**. It ensures consistent code style across projects and integrates seamlessly into development workflows. | ||
**A command-line tool for formatting Kotlin source code files**, implemented as a wrapper around [ktfmt](https://github.com/facebook/ktfmt/tree/main). | ||
|
||
It can be used to automate code formatting, ensuring a clean and consistent codebase, while integrating seamlessly into development workflows. | ||
|
||
The tool can: | ||
|
||
- **Format files and directories**: Apply consistent formatting to files, directories, or standard input. | ||
- **Integrate with Git workflows**: | ||
- **Pre-commit**: Format staged files before committing. | ||
- **Pre-push**: Check committed files before pushing. | ||
|
||
|
||
## Usage | ||
|
||
```bash | ||
kotlin-format [OPTIONS] [FILES...] | ||
``` | ||
### Options | ||
|
||
| Option | Description | | ||
|-------------------------|-------------------------------------------------------------------------------------------| | ||
| `--set-exit-if-changed` | Exit with a non-zero code if any files needed changes. | | ||
| `--dry-run` | Display the changes that would be made without writing them to disk. | | ||
| `--pre-commit` | Format staged files as part of the pre-commit process. *Mutually exclusive with `--pre-push`.* | | ||
| `--pre-push` | Check committed files as part of the pre-push process. *Mutually exclusive with `--pre-commit`.* | | ||
| `--push-commit=<text>` | The SHA of the commit to use for pre-push. Defaults to `HEAD`. | | ||
| `--print-stats` | Emit performance-related statistics to help diagnose performance issues. | | ||
| `-h, --help` | Show help message and exit. | | ||
|
||
### Arguments | ||
|
||
| Argument | Description | | ||
|---------------|--------------------------------------------| | ||
| `<files>` | Files or directories to format. Use `-` for standard input. | | ||
|
This file contains 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,13 @@ | ||
# Releasing Guide | ||
Release procedure for Kotlin Formatter | ||
|
||
1. Update CHANGELOG | ||
1. Update README if needed | ||
1. Bump version number in `gradle.properties` to next stable version (removing the `-SNAPSHOT` | ||
suffix). | ||
1. `git commit -am "chore: prepare for release x.y." && git push` | ||
1. Publish the snapshot to Maven Central by invoking the `publish` action on github. | ||
1. `git tag -a vx.y -m "Version x.y."` | ||
1. Update version number `gradle.properties` to next snapshot version (x.y-SNAPSHOT) | ||
1. `git commit -am "chore: prepare next development version."` | ||
1. `git push && git push --tags` |
This file contains 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,4 @@ | ||
plugins { | ||
alias(libs.plugins.kotlin) apply false | ||
alias(libs.plugins.dependencyAnalysis) | ||
} |
This file contains 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,48 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("java-gradle-plugin") | ||
alias(libs.plugins.kotlin) | ||
alias(libs.plugins.dependencyAnalysis) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
create("settings") { | ||
id = "block.settings" | ||
implementationClass = "xyz.block.gradle.SettingsPlugin" | ||
} | ||
} | ||
} | ||
|
||
kotlin { | ||
explicitApi() | ||
} | ||
|
||
dependencies { | ||
implementation(libs.dependencyAnalysisPlugin) | ||
implementation(libs.develocityPlugin) | ||
implementation(libs.kotlinGradlePlugin) | ||
} | ||
|
||
val javaTarget = JavaLanguageVersion.of(libs.versions.java.get()) | ||
|
||
java { | ||
toolchain { | ||
languageVersion = javaTarget | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile> { | ||
options.release.set(javaTarget.asInt()) | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
jvmTarget = javaTarget.toString() | ||
} | ||
} | ||
|
||
tasks.named<Test>("test") { | ||
useJUnitPlatform() | ||
} |
Oops, something went wrong.