Skip to content
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

configure ktlint with custom rules #9

Merged
merged 10 commits into from
Aug 14, 2023
Merged

configure ktlint with custom rules #9

merged 10 commits into from
Aug 14, 2023

Conversation

aajtodd
Copy link
Contributor

@aajtodd aajtodd commented Aug 11, 2023

Issue #, if available:
n/a

Description of changes:
Create the ktlint and ktlintFormat tasks and include our custom ktlint-rules by default. This works by adding our custom lint rules project as a runtime dependency of the plugin. The buildscript classpath is then included as the classpath for the ktlint exec task. This allows dowstream projects to define additional project specific rules should the need arise by simpling adding them to the buildscript classpath

e.g.

buildscript {
    classpath("aws.sdk.kotlin:build-plugins")   // includes ktlint-rules
    classpath(project(":my-custom-rules"))
}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

* @param lintPaths list of paths relative to the project root to lint (or not lint).
*/
fun Project.configureLinting(lintPaths: List<String>) {
verifyRootProject { "AWS SDK lint configuration is expected to be configured on the root project" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "AWS SDK for Kotlin" or "Kotlin SDK"

Comment on lines +28 to +29
// TODO - is there anyway to align this with the version from libs.versions.toml in this project/repo
val ktlintVersion = "0.48.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Would it work to just use `val ktlintVersion: String by project" and pull it in from the root project? That would mean potentially separate versions across the repos but that's what we have now and we're not (yet) planning to commonize the version numbers right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are planning to commonize the version numbers (for ktlint anyway) because we've moved the rules into this plugin/project. Downstream consumers won't need to set ktlint version at all, just the paths to lint. Theres no real reason to make the downstream consumers set a version, it doesn't gain us anything really.

@@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
allprojects {
group = "aws.sdk.kotlin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct to have this aws.sdk.kotlin if it's meant to be shared among all our projects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't publishing this so it doesn't really matter. We have to choose some group though and the only groups we own are aws.smithy.kotlin and aws.sdk.kotlin. I don't care which it is but if you or anyone else has a preference thats fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to choose some group though

Ok, this one should be fine

@aajtodd aajtodd merged commit 39192c7 into main Aug 14, 2023
5 checks passed
@aajtodd aajtodd deleted the lint-rules branch August 14, 2023 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants