Skip to content

Commit

Permalink
enable groovy formatting in airbyte-ci format config, remove spotless…
Browse files Browse the repository at this point in the history
… from gradle build (#33013)

Co-authored-by: postamar <postamar@users.noreply.github.com>
  • Loading branch information
postamar and postamar authored Dec 1, 2023
1 parent 300ce85 commit 30a5127
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 102 deletions.
14 changes: 7 additions & 7 deletions airbyte-cdk/java/airbyte-cdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ subprojects { subproject ->
}
}
// This repository is only defined and used in the context of an artifact publishing
// It's different from the 'airbyte-public-jars' defined in settings.graddle only in its omission
// It's different from the 'airbyte-public-jars' defined in settings.graddle only in its omission
// of the 'public' directory. Any artifacts publish here will be available in the 'airbyte-public-jars' repo
repositories {
maven {
name 'airbyte-repo'
url 'https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars/'
url 'https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars/'
credentials {
username System.getenv('CLOUDREPO_USER')
password System.getenv('CLOUDREPO_PASSWORD')
Expand All @@ -53,10 +53,10 @@ subprojects { subproject ->
description = "Airbyte Connector Development Kit (CDK) for Java."

def recursiveTasks = [
'assemble',
'build',
'integrationTestJava',
'publish',
'assemble',
'build',
'integrationTestJava',
'publish',
'publishToMavenLocal',
'test',
]
Expand Down Expand Up @@ -117,4 +117,4 @@ def cleanLocalCache = tasks.register('cleanLocalCache') {
cleanLocalCache.configure {
dependsOn tasks.named('clean')
dependsOn subprojects.collect { it.tasks.named('clean') }
}
}
2 changes: 1 addition & 1 deletion airbyte-cdk/java/airbyte-cdk/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dependencies {
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testFixturesImplementation 'org.projectlombok:lombok:1.18.20'
testFixturesAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
testFixturesAnnotationProcessor 'org.projectlombok:lombok:1.18.20'

testImplementation libs.junit.jupiter.system.stubs

Expand Down
2 changes: 1 addition & 1 deletion airbyte-cdk/java/airbyte-cdk/db-destinations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dependencies {
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testFixturesImplementation 'org.projectlombok:lombok:1.18.20'
testFixturesAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
testFixturesAnnotationProcessor 'org.projectlombok:lombok:1.18.20'

implementation ('org.apache.hadoop:hadoop-common:3.3.3') {exclude group: 'org.slf4j', module: 'slf4j-log4j12' exclude group: 'org.slf4j', module: 'slf4j-reload4j'}
implementation ('org.apache.hadoop:hadoop-mapreduce-client-core:3.3.3') {exclude group: 'org.slf4j', module: 'slf4j-log4j12' exclude group: 'org.slf4j', module: 'slf4j-reload4j'}
Expand Down
4 changes: 2 additions & 2 deletions airbyte-cdk/java/airbyte-cdk/db-sources/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.jsonschema2pojo.SourceType
import org.jsoup.Jsoup;
import org.jsoup.Jsoup

buildscript {
dependencies {
Expand Down Expand Up @@ -113,7 +113,7 @@ dependencies {
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testFixturesImplementation 'org.projectlombok:lombok:1.18.20'
testFixturesAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
testFixturesAnnotationProcessor 'org.projectlombok:lombok:1.18.20'

testImplementation libs.junit.jupiter.system.stubs

Expand Down
4 changes: 2 additions & 2 deletions airbyte-cdk/java/airbyte-cdk/s3-destinations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testFixturesImplementation 'org.projectlombok:lombok:1.18.20'
testFixturesAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
testFixturesAnnotationProcessor 'org.projectlombok:lombok:1.18.20'

implementation ('org.apache.hadoop:hadoop-aws:3.3.3') { exclude group: 'org.slf4j', module: 'slf4j-log4j12'}
implementation ('org.apache.hadoop:hadoop-mapreduce-client-core:3.3.3') {exclude group: 'org.slf4j', module: 'slf4j-log4j12' exclude group: 'org.slf4j', module: 'slf4j-reload4j'}
Expand Down Expand Up @@ -53,4 +53,4 @@ java {
compileTestJava {
options.compilerArgs += "-Xlint:-try"
}
}
}
2 changes: 1 addition & 1 deletion airbyte-cdk/java/airbyte-cdk/typing-deduping/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ java {
compileJava {
options.compilerArgs.remove("-Werror")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ dependencies {
}
implementation ('org.apache.parquet:parquet-avro:1.12.0') { exclude group: 'org.slf4j', module: 'slf4j-log4j12'}
implementation ('com.github.airbytehq:json-avro-converter:1.1.0') { exclude group: 'ch.qos.logback', module: 'logback-classic'}

implementation 'com.azure:azure-storage-blob:12.18.0'
}
9 changes: 0 additions & 9 deletions airbyte-integrations/connectors/destination-gcs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,3 @@ dependencies {
testImplementation 'org.apache.commons:commons-lang3:3.11'
testImplementation 'org.xerial.snappy:snappy-java:1.1.8.4'
}









Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ dependencies {
testImplementation 'org.apache.commons:commons-lang3:3.11'
// integrationTestJavaImplementation project(':airbyte-integrations:connectors:source-bigquery')
}

1 change: 0 additions & 1 deletion airbyte-integrations/connectors/source-db2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ dependencies {

integrationTestJavaImplementation 'org.apache.commons:commons-lang3:3.11'
}

1 change: 0 additions & 1 deletion airbyte-integrations/connectors/source-mysql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,3 @@ jsonSchema2Pojo {
includeConstructors = false
includeSetters = true
}

Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ dependencies {


}

Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ dependencies {

integrationTestJavaImplementation 'org.apache.commons:commons-lang3:3.11'
}

50 changes: 0 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import com.github.spotbugs.snom.SpotBugsTask

// The buildscript block defines dependencies in order for .gradle file evaluation.
// This is separate from application dependencies.
// See https://stackoverflow.com/questions/17773817/purpose-of-buildscript-block-in-gradle.
buildscript {
dependencies {
classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.20.0'
}
}

plugins {
id 'base'
Expand Down Expand Up @@ -107,48 +99,6 @@ rootProject.tasks.named('clean').configure {
dependsOn cleanPythonVenv
}

// format tasks per project
allprojects {

def createFormatTarget = { pattern ->
ArrayList<String> excludes = [
'**/build', // Ignore new build files as well as the ones ignored when running this through airbyte-ci
'.gradle' // Ignore the gradle version that is downloaded in the container
]
// Build the FileTree.
return fileTree(dir: projectDir, include: pattern, exclude: excludes)
}

// Apply spotless formatting.
apply plugin: 'com.diffplug.spotless'
spotless {
def javaTarget = createFormatTarget('**/*.java')
if (!javaTarget.isEmpty()) {
java {
// See also spotless-maven-pom.xml which is used by airbyte-ci, its config should stay in sync with this one.
target javaTarget
importOrder()
eclipse('4.21').configFile(rootProject.file('tools/gradle/codestyle/java-google-style.xml'))
removeUnusedImports()
trimTrailingWhitespace()
}
}
def groovyGradleTarget = createFormatTarget('**/*.gradle')
if (!groovyGradleTarget.isEmpty()) {
groovyGradle {
target groovyGradleTarget
}
}
}

if (rootProject.ext.skipSlowTests) {
// Format checks should be run via airbyte-ci.
tasks.matching { it.name =~ /spotless.*Check/ }.configureEach {
enabled = false
}
}
}


def getCDKTargetVersion() {
def props = new Properties()
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ dependencies {

tasks.withType(Jar).configureEach {
duplicatesStrategy DuplicatesStrategy.INCLUDE
}
}
8 changes: 3 additions & 5 deletions buildSrc/src/main/groovy/airbyte-docker-legacy.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import java.nio.file.Paths
import java.security.MessageDigest
import java.util.concurrent.ConcurrentHashMap
import org.apache.commons.text.StringSubstitutor
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.Plugin
Expand All @@ -14,11 +17,6 @@ import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction

import java.security.MessageDigest
import java.nio.file.Paths

import org.apache.commons.text.StringSubstitutor

/**
* AirbyteDockerLegacyTask is the task which builds a docker image based on a Dockerfile.
*
Expand Down
28 changes: 14 additions & 14 deletions buildSrc/src/main/groovy/airbyte-java-cdk.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
This class facilites detecting the Java CDK target version via readCdkTargetVersion().
*/

import java.util.Properties
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.testing.Test
import java.util.Properties

class AirbyteJavaCdkPlugin implements Plugin<Project> {

Expand All @@ -24,35 +24,35 @@ class AirbyteJavaCdkPlugin implements Plugin<Project> {
project.ext.getCdkTargetVersion = {
return readCdkTargetVersion(project)
}
project.getTasks().create("disableLocalCdkRefs", DisableLocalCdkRefsTask.class);
project.getTasks().create("assertNotUsingLocalCdk", AssertNotUsingLocalCdkTask.class);
project.getTasks().create("disableLocalCdkRefs", DisableLocalCdkRefsTask.class)
project.getTasks().create("assertNotUsingLocalCdk", AssertNotUsingLocalCdkTask.class)
}

public static class DisableLocalCdkRefsTask extends DefaultTask {
@TaskAction
public void disableLocalCdkRefs() {
// Step through the project tree and set useLocalCdk to false on all connectors
getProject().fileTree(dir: '.', include: '**/build.gradle').forEach(file -> {
String content = file.getText();
String content = file.getText()
if (content.contains("useLocalCdk = true")) {
content = content.replace("useLocalCdk = true", "useLocalCdk = false");
file.setText(content);
System.out.println("Updated " + file.getPath());
content = content.replace("useLocalCdk = true", "useLocalCdk = false")
file.setText(content)
System.out.println("Updated " + file.getPath())
}
});
})
}
}

public static class AssertNotUsingLocalCdkTask extends DefaultTask {
@TaskAction
public void assertNotUsingLocalCdk() {
List<String> foundPaths = new ArrayList<>();
List<String> foundPaths = new ArrayList<>()

for (File file : getProject().fileTree(dir: '.', include: '**/build.gradle')) {
String content = file.getText();
String content = file.getText()
if (content.contains("useLocalCdk = true")) {
System.err.println("Found usage of 'useLocalCdk = true' in " + file.getPath());
foundPaths.add(file.getPath());
System.err.println("Found usage of 'useLocalCdk = true' in " + file.getPath())
foundPaths.add(file.getPath())
}
}

Expand All @@ -62,8 +62,8 @@ class AirbyteJavaCdkPlugin implements Plugin<Project> {
"This must be set to 'false' before merging to the main branch. \n" +
"NOTE: You can run './gradlew disableLocalCdkRefs' to automatically set it to 'false' on all projects.",
String.join("\n", foundPaths)
);
throw new RuntimeException(errorMessage);
)
throw new RuntimeException(errorMessage)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/groovy/airbyte-python.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,3 @@ class AirbytePythonPlugin implements Plugin<Project> {
}
}
}

2 changes: 0 additions & 2 deletions spotless-maven-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@
<includes>
<include>**/*.gradle</include>
</includes>
<!-- TODO enable a better gradle formatting config
<importOrder />
<removeSemicolons />
<trimTrailingWhitespace />
<endWithNewline />
-->
</groovy>
</configuration>
</plugin>
Expand Down

0 comments on commit 30a5127

Please sign in to comment.