enable groovy formatting in airbyte-ci format config, remove spotless from gradle build (#33013)
Co-authored-by: postamar <postamar@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import org.jsonschema2pojo.SourceType
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.Jsoup
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
|
||||
@@ -49,12 +49,3 @@ dependencies {
|
||||
testImplementation 'org.apache.commons:commons-lang3:3.11'
|
||||
testImplementation 'org.xerial.snappy:snappy-java:1.1.8.4'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,4 +33,3 @@ dependencies {
|
||||
testImplementation 'org.apache.commons:commons-lang3:3.11'
|
||||
// integrationTestJavaImplementation project(':airbyte-integrations:connectors:source-bigquery')
|
||||
}
|
||||
|
||||
|
||||
@@ -34,4 +34,3 @@ dependencies {
|
||||
|
||||
integrationTestJavaImplementation 'org.apache.commons:commons-lang3:3.11'
|
||||
}
|
||||
|
||||
|
||||
@@ -53,4 +53,3 @@ jsonSchema2Pojo {
|
||||
includeConstructors = false
|
||||
includeSetters = true
|
||||
}
|
||||
|
||||
|
||||
@@ -37,4 +37,3 @@ dependencies {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -39,4 +39,3 @@ dependencies {
|
||||
|
||||
integrationTestJavaImplementation 'org.apache.commons:commons-lang3:3.11'
|
||||
}
|
||||
|
||||
|
||||
50
build.gradle
50
build.gradle
@@ -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'
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -24,8 +24,8 @@ 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 {
|
||||
@@ -33,26 +33,26 @@ class AirbyteJavaCdkPlugin implements Plugin<Project> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,4 +183,3 @@ class AirbytePythonPlugin implements Plugin<Project> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,10 @@
|
||||
<includes>
|
||||
<include>**/*.gradle</include>
|
||||
</includes>
|
||||
<!-- TODO enable a better gradle formatting config
|
||||
<importOrder />
|
||||
<removeSemicolons />
|
||||
<trimTrailingWhitespace />
|
||||
<endWithNewline />
|
||||
-->
|
||||
</groovy>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
Reference in New Issue
Block a user