This is a development focused supplement to CONTRIBUTING.md.
Installing pre-commit hook is optional but can save you some headache when pushing unformatted code.
Installing git pre-commit hook that formats code with Ktlint:
cp scripts/git/pre-commit .git/hooks/pre-commit
Before writing a commit message read this article.
Before pushing any changes make sure project builds without errors with:
./gradlew build
This repository follows the Kotlin coding conventions. That are enforced by ktlint and .editorconfig.
You can check style with:
./gradlew ktlintCheck
Use JUnit 5 for testing.
Uou can check coverage in build/reports/kover/
after running:
./gradlew test coverage
Before submitting a pull request test your changes on a local project. There are few ways for testing locally a gradle plugin:
Publish plugin to the local maven repository
- Publish plugin to your local maven repository (
$HOME/.m2
) with:./gradlew publishToMavenLocal -Pversion="<SOME_VERSION>" && ls -la ~/.m2/repository/com/coditory/gradle/integration-test-plugin
- Add section to
settings.gradle.kts
:// Instruct a sample project to use maven local to find the plugin pluginManagement { repositories { mavenLocal() gradlePluginPortal() } }
- Add dependency:
plugins { id("com.coditory.integration-test") version "<SOME_VERSION>" }
Import plugin jar Add plugin jar to the sample project (that uses the tested plugin):
buildscript {
dependencies {
classpath(files("<PLUGIN_PROJECT_PATH>/build/libs/integration-test-plugin.jar"))
}
}
apply(plugin = "com.coditory.integration-test")
The easiest way to validate plugin's module metadata is to publish the plugin to a dummy local repository.
Add to build.gradle.kts
:
publishing {
repositories {
maven {
name = "localPluginRepository"
url = uri("./local-plugin-repository")
}
}
}
...and publish the plugin with:
./gradlew publish -Pversion=0.0.1