Skip to content

Commit 7dc883e

Browse files
committed
Update dependencies, migrate to jvm toolchains, add github community files
1 parent 148f83c commit 7dc883e

22 files changed

+298
-118
lines changed

.github/CONTRIBUTING.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Contributing
2+
3+
## Commit messages
4+
Before writing a commit message read [this article](https://chris.beams.io/posts/git-commit/).
5+
6+
## Build
7+
Before pushing any changes make sure project builds without errors with:
8+
```
9+
./gradlew build
10+
```
11+
12+
## Code conventions
13+
This repository follows the [Kotlin coding conventions](https://kotlinlang.org/docs/reference/coding-conventions.html).
14+
That are enforced by ktlint and [.editorconfig](../.editorconfig).
15+
16+
You can check style with:
17+
```
18+
./gradlew ktlintCheck
19+
```
20+
21+
## Unit tests
22+
We use [JUnit 5](https://junit.org/junit5/docs/current/user-guide/) for testing.
23+
Please use the `Spec.kt` suffix on new test classes.
24+
25+
## Validate changes locally
26+
Before submitting a pull request test your changes on a local project.
27+
There are few ways for testing locally a gradle plugin:
28+
29+
**Publish plugin to the local maven repository**
30+
Publish plugin to local repository with:
31+
```sh
32+
./gradlew publishToMavenLocal
33+
```
34+
35+
...and add section to `settings.gradle.kts` to the sample project (that uses the tested plugin):
36+
```kt
37+
// Instruct a sample project to use maven local to find the plugin
38+
pluginManagement {
39+
repositories {
40+
mavenLocal()
41+
gradlePluginPortal()
42+
}
43+
}
44+
```
45+
46+
**Import plugin jar**
47+
Add plugin jar to the sample project (that uses the tested plugin):
48+
49+
```kt
50+
buildscript {
51+
dependencies {
52+
classpath(files("<PLUGIN_PROJECT_PATH>/build/libs/build-plugin.jar"))
53+
}
54+
}
55+
56+
apply(plugin = "com.coditory.build")
57+
```
58+
59+
## Validating plugin module metadata
60+
The easiest way to validate plugin's module metadata is to publish the plugin to a dummy local repository.
61+
62+
Add to `build.gradle.kts`:
63+
```
64+
publishing {
65+
repositories {
66+
maven {
67+
name = "localPluginRepository"
68+
url = uri("./local-plugin-repository")
69+
}
70+
}
71+
}
72+
```
73+
74+
...and publish the plugin with:
75+
```
76+
./gradlew publish -Pversion=0.0.1
77+
```

.github/ISSUE_TEMPLATE/bug_report.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug report
3+
about: Reporting bugs and other issues
4+
labels: bug
5+
---
6+
<!-- The bug you're experiencing might have already be reported! -->
7+
<!-- Please search in the [issues](https://github.com/coditory/gradle-build-plugin/issues) before creating one. -->
8+
9+
## Context
10+
<!-- How has this issue affected you? What are you trying to accomplish? -->
11+
<!-- Providing context helps us come up with a solution that is most useful in the real world -->
12+
13+
## Expected Behavior
14+
<!-- Tell us what should happen -->
15+
16+
## Observed Behavior
17+
<!-- Tell us what happens instead of the expected behavior -->
18+
19+
## Steps to Reproduce
20+
<!-- Provide a link to a live example, or an unambiguous set of steps to -->
21+
<!-- reproduce this bug. Include code to reproduce, if relevant -->
22+
23+
## Your Environment
24+
<!-- Include as many relevant details about the environment you experienced the bug in -->
25+
* Plugin version:
26+
* Java (and/or Kotlin) version:
27+
* Gradle version:
28+
* Gradle scan link (add `--scan` option when running the gradle task):
29+
* Link to your project (if it's a public repository):

.github/ISSUE_TEMPLATE/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blank_issues_enabled: false
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Feature request
3+
about: Suggest new features/changes
4+
labels: feature
5+
---
6+
<!-- Your feature request may already be reported! -->
7+
<!-- Please search in the [issues](https://github.com/coditory/gradle-build-plugin/issues) before creating a new one. -->
8+
9+
## Context
10+
<!--- What are you trying to accomplish? -->
11+
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
12+
13+
## Expected Behavior
14+
<!--- If you're suggesting a change/improvement, tell us how it should work -->
15+
<!--- Propose a solution -->
16+
17+
## Current Behavior
18+
<!--- If suggesting a change/improvement, explain the difference from the current behavior if it exists -->

.github/PULL_REQUEST_TEMPLATE.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- Thanks for submitting a pull request! -->
2+
## Changes
3+
<!-- Shortly describe what you want to accomplish with this PR -->
4+
<!-- Add a link to the issue if available -->
5+
6+
## Checklist
7+
- [ ] I have tested that there is no similar [pull request](https://github.com/coditory/gradle-build-plugin/pulls) already submitted
8+
- [ ] I have read [contributing.md](https://github.com/coditory/gradle-build-plugin/blob/master/.github/CONTRIBUTING.md) and applied to the rules
9+
- [ ] I have unit tested code changes and performed a self-review
10+
- [ ] I have [tested plugin change locally](https://github.com/coditory/gradle-build-plugin/blob/master/.github/CONTRIBUTING.md#validate-changes-locally) on a sample project

.github/dependabot.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@ updates:
33
- package-ecosystem: "gradle"
44
directory: "/"
55
schedule:
6-
interval: "monthly"
6+
interval: "weekly"
7+
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/labeler.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
source:
2+
- "src/**"
3+
4+
build:
5+
- "**/*.gradle"
6+
- "**/*.gradle.kts"
7+
8+
ci:
9+
- ".github/**"
10+
11+
documentation:
12+
- "**/*.md"
13+
- "docs/**"
14+
15+
license:
16+
- "LICENSE"
17+
18+
gradle:
19+
- "gradlew"
20+
- "gradlew.bat"
21+
- ".gradle/**"
22+
- "gradle/**"
23+
24+
git:
25+
- ".gitignore"
26+
27+
style:
28+
- ".editorconfig"
29+
- ".idea/codeStyles/**"

.github/workflows/build.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
name: Build
22

3-
on:
4-
workflow_dispatch:
5-
push:
3+
on: [pull_request, push, workflow_dispatch]
64

75
jobs:
86
build:
97
runs-on: ubuntu-latest
10-
if: github.event_name != 'push' || startsWith(github.ref, 'refs/tags/') == false
8+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
119
steps:
1210
- name: Checkout
1311
uses: actions/checkout@v3
1412

1513
- name: Skip duplicates and docs
1614
id: skip
17-
uses: fkirc/skip-duplicate-actions@v4
15+
uses: fkirc/skip-duplicate-actions@v5
1816
with:
1917
paths_ignore: '["**/README.md", "LICENSE", ".gitignore", ".editorconfig", ".idea/**"]'
2018

.github/workflows/pull-request.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "Pull Request"
2+
3+
on: [pull_request_target]
4+
5+
jobs:
6+
label-pr:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
steps:
12+
- uses: actions/labeler@v4
13+
with:
14+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
15+
16+
dependabot:
17+
runs-on: ubuntu-latest
18+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
19+
permissions:
20+
pull-requests: write
21+
contents: write
22+
steps:
23+
- name: Dependabot metadata
24+
id: dependabot-metadata
25+
uses: dependabot/[email protected]
26+
27+
- name: Enable auto-merge for Dependabot PRs
28+
run: gh pr merge --auto --rebase "$PR_URL"
29+
env:
30+
PR_URL: ${{ github.event.pull_request.html_url }}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Approve patch and minor updates
34+
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
35+
run: gh pr review $PR_URL --approve -b "Pull request **approved** because **it includes a patch or minor update**"
36+
env:
37+
PR_URL: ${{ github.event.pull_request.html_url }}
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
required: true
1919
default: RELEASE
2020
release:
21-
types: [ published ]
21+
types: [published]
2222

2323
jobs:
2424
release:

.github/workflows/stale.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'Stale issues and PRs'
2+
on:
3+
schedule:
4+
- cron: '30 1 * * *'
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v7
11+
with:
12+
# PRs
13+
stale-pr-message: 'This PR is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 10 days.'
14+
days-before-pr-stale: 120
15+
close-pr-message: 'This PR was closed because it has been stalled for 10 days with no activity.'
16+
days-before-pr-close: 10
17+
exempt-all-pr-assignees: true
18+
exempt-pr-labels: 'awaiting-approval,work-in-progress'
19+
stale-pr-label: 'stale'
20+
# Issues
21+
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
22+
days-before-issue-stale: 60
23+
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
24+
days-before-issue-close: 5
25+
exempt-issue-assignees: true
26+
exempt-issue-labels: 'awaiting-approval,work-in-progress'
27+
stale-issue-label: 'stale'

.idea/codeStyles/Project.xml

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+27-6
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ tasks.withType(Test) {
3838
}
3939
4040
tasks.withType(JavaCompile) {
41-
// by default target newest LTS JVM
42-
sourceCompatibility = "17"
43-
targetCompatibility = "17"
4441
// make all test/main builds use UTF-8
4542
options.encoding = "UTF-8"
4643
// produce error on lint problems
@@ -55,12 +52,12 @@ tasks.withType(GroovyCompile) {
5552
}
5653
5754
tasks.withType(KotlinCompile) {
58-
// by default target newest LTS JVM
59-
kotlinOptions.jvmTarget = "17"
6055
// produce errors on warnings
6156
kotlinOptions.allWarningsAsErrors = true
6257
}
6358
59+
// the most recent ktlint version (that does not cause problems)
60+
// https://github.com/JLLeitschuh/ktlint-gradle/issues/589
6461
ktlint {
6562
version.set("0.45.2")
6663
}
@@ -74,7 +71,7 @@ jacocoTestReport {
7471
}
7572
}
7673
77-
// defaults for Javadoc
74+
// make javadoc less strict to limit noisy logs
7875
javadoc {
7976
source = sourceSets.main.allJava
8077
classpath = configurations.compileClasspath
@@ -89,3 +86,27 @@ javadoc {
8986
}
9087
}
9188
```
89+
90+
You're responsible to setup jvm toolchains:
91+
```
92+
// build.gradle for java:
93+
java {
94+
toolchain {
95+
languageVersion = JavaLanguageVersion.of(11)
96+
}
97+
}
98+
99+
// build.gradle.kts for kotlin >=1.8:
100+
kotlin {
101+
jvmToolchain {
102+
languageVersion.set(JavaLanguageVersion.of(11))
103+
}
104+
}
105+
106+
// build.gradle.kts of for kotlin <1.8
107+
kotlin {
108+
jvmToolchain {
109+
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
110+
}
111+
}
112+
```

0 commit comments

Comments
 (0)