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

chore: gradlefied spotless (do not merge) #50940

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
airbyteBulkConnector {
core = 'load'
toolkits = []
cdk = 'local'
// cdk = 'local'
}

application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
airbyteBulkConnector {
core = 'load'
toolkits = ['load-iceberg-parquet']
cdk = 'local'
// cdk = 'local'
}

application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
airbyteBulkConnector {
core = "load"
toolkits = listOf()
cdk = "local"
// cdk = "local"
}

application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
airbyteBulkConnector {
core = 'load'
toolkits = ['load-s3']
cdk = 'local'
// cdk = 'local'
}

application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ application {
airbyteBulkConnector {
core = 'extract'
toolkits = ['extract-jdbc', 'extract-cdc']
cdk = '0.249'
// cdk = '0.249'
}

dependencies {
Expand Down
49 changes: 48 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id 'com.github.spotbugs' version '6.0.7'
id 'org.jetbrains.kotlin.jvm' version '2.0.0'
id 'com.google.devtools.ksp' version '2.0.0-1.0.24'
id 'com.diffplug.spotless' version '6.13.0'
}

allprojects {
Expand All @@ -18,9 +19,9 @@ allprojects {
apply plugin: 'com.github.spotbugs'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.google.devtools.ksp'
// apply plugin: 'com.diffplug.spotless'
apply plugin: 'idea'


// By default gradle uses directory as the project name. That works very well in a single project environment but
// projects clobber each other in an environments with subprojects when projects are in directories named identically.
def sub = rootDir.relativePath(projectDir.parentFile).replace('/', '.')
Expand Down Expand Up @@ -236,3 +237,49 @@ allprojects {
options.addStringOption('Xdoclint:none', '-quiet')
}
}

subprojects { subproject ->
apply plugin: 'groovy'
apply plugin: 'com.diffplug.spotless'

spotless {
java {
googleJavaFormat() // TODO: Pin version here
target 'src/**/*.java'
targetExclude '**/generated/**/*'
targetExclude '**/other_generated/**/*'
importOrder() // Match the import order configuration
// eclipse {
// version '4.21'
// file 'tools/gradle/codestyle/java-google-style.xml'
// }
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
kotlin {
ktlint() // TODO: Pin version here
target 'src/**/*.kt'
targetExclude '**/generated/**/*'
// Match the KTFmt configuration
ktfmt()
// version '0.39'
// style 'KOTLINLANG'
// }
}
groovy {
// includes {
// include '**/*.gradle'
// }
importOrder()
// removeSemicolons()
trimTrailingWhitespace()
endWithNewline()
}
format 'misc', {
target '**/*.gradle', '**/*.md', '**/*.yaml', '**/*.yml'
prettier().config(['tabWidth': 4, 'useTabs': false])
targetExclude '**/generated/**/*'
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you get this to be fast? I've tried this and found it to be painfully slow and gave up. Which is why, in the past, the spotless plugin was applied only at the root project and targeted all **/*.java files, but that wasn't a panacea either.

1 change: 1 addition & 0 deletions buildSrc/src/main/groovy/airbyte-bulk-connector.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class AirbyteBulkConnectorExtension {
// Use a temporary configuration to find the Micronaut version
// in the transitive dependencies of the Bulk CDK base.
def tempConfiguration = project.configurations.detachedConfiguration()
// NOTE: I think this is failing: ("Could not get unknown property 'first' for project of type org.gradle.api.Project.")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was not able to debug this and I'll probably need assistance to do so. Commenting out cdk = '...' worked but I think there's something else going on.

My best analysis is that in places like like 73, we are asking for .first as if this is a collection or list object, where it is actually already a singular Project object. That might be wrong, and I'm not at all clear why no one else would be running into this besides myself. Could be a version conflict or or issue on my local workspace, although I tried all the obvious things like aligning JDK and Gradle version... 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

We could simply choose to not apply formatting on gradle-groovy files. I believe there's an effort underway led by @jdpgrailsdev to move to gradle-kotlin.

def baseDependency = (cdk == "local")
? project.dependencies.create(fromSource.first)
: project.dependencies.create(fromJar.first)
Expand Down
64 changes: 0 additions & 64 deletions spotless-maven-pom.xml

This file was deleted.

Loading