java CDK: hoist top-level gradle projects into CDK (#31960)
Co-authored-by: postamar <postamar@users.noreply.github.com>
This commit is contained in:
@@ -9,7 +9,7 @@ import org.gradle.api.tasks.testing.Test
|
||||
|
||||
class AirbyteJavaConnectorExtension {
|
||||
|
||||
boolean useLocalCdk = false
|
||||
boolean useLocalCdk = true
|
||||
String cdkVersionRequired
|
||||
List<String> features = [] // e.g. 'db-sources', 'db-destinations'
|
||||
Project project
|
||||
@@ -24,27 +24,21 @@ class AirbyteJavaConnectorExtension {
|
||||
features.each { feature ->
|
||||
submoduleNames.add(feature)
|
||||
}
|
||||
project.dependencies {
|
||||
// Import transitive (compileOnly) first party CDK dependencies.
|
||||
// TODO: Bring these into the CDK or refactor them out.
|
||||
implementation project.project(':airbyte-api')
|
||||
implementation project.project(':airbyte-commons')
|
||||
implementation project.project(':airbyte-commons-cli')
|
||||
implementation project.project(':airbyte-config-oss:config-models-oss')
|
||||
implementation project.project(':airbyte-config-oss:init-oss')
|
||||
implementation project.project(':airbyte-json-validation')
|
||||
|
||||
testImplementation project.project(':airbyte-api')
|
||||
testImplementation project.project(':airbyte-commons')
|
||||
testImplementation project.project(':airbyte-config-oss:config-models-oss')
|
||||
testImplementation project.project(':airbyte-test-utils')
|
||||
|
||||
integrationTestJavaImplementation project.project(':airbyte-config-oss:config-models-oss')
|
||||
integrationTestJavaImplementation project.project(':airbyte-config-oss:init-oss')
|
||||
integrationTestJavaImplementation project.project(':airbyte-connector-test-harnesses:acceptance-test-harness')
|
||||
}
|
||||
if (useLocalCdk) {
|
||||
project.dependencies {
|
||||
implementation project.project(':airbyte-cdk:java:airbyte-cdk:airbyte-commons')
|
||||
implementation project.project(':airbyte-cdk:java:airbyte-cdk:airbyte-json-validation')
|
||||
implementation project.project(':airbyte-cdk:java:airbyte-cdk:airbyte-commons-cli')
|
||||
implementation project.project(':airbyte-cdk:java:airbyte-cdk:airbyte-api')
|
||||
implementation project.project(':airbyte-cdk:java:airbyte-cdk:config-models-oss')
|
||||
implementation project.project(':airbyte-cdk:java:airbyte-cdk:init-oss')
|
||||
testImplementation project.project(':airbyte-cdk:java:airbyte-cdk:airbyte-commons')
|
||||
testImplementation project.project(':airbyte-cdk:java:airbyte-cdk:airbyte-json-validation')
|
||||
testImplementation project.project(':airbyte-cdk:java:airbyte-cdk:airbyte-api')
|
||||
testImplementation project.project(':airbyte-cdk:java:airbyte-cdk:config-models-oss')
|
||||
integrationTestJavaImplementation project.project(':airbyte-cdk:java:airbyte-cdk:config-models-oss')
|
||||
integrationTestJavaImplementation project.project(':airbyte-cdk:java:airbyte-cdk:init-oss')
|
||||
integrationTestJavaImplementation project.project(':airbyte-cdk:java:airbyte-cdk:acceptance-test-harness')
|
||||
submoduleNames.each { submoduleName ->
|
||||
// Add the CDK module to the dependencies
|
||||
def cdkModule = project.project(":airbyte-cdk:java:airbyte-cdk:${submoduleName}")
|
||||
@@ -60,6 +54,19 @@ class AirbyteJavaConnectorExtension {
|
||||
}
|
||||
} else {
|
||||
project.dependencies {
|
||||
implementation "io.airbyte.cdk:airbyte-cdk-airbyte-commons:${cdkVersionRequired}"
|
||||
implementation "io.airbyte.cdk:airbyte-cdk-airbyte-json-validation:${cdkVersionRequired}"
|
||||
implementation "io.airbyte.cdk:airbyte-cdk-airbyte-commons-cli:${cdkVersionRequired}"
|
||||
implementation "io.airbyte.cdk:airbyte-cdk-airbyte-api:${cdkVersionRequired}"
|
||||
implementation "io.airbyte.cdk:airbyte-cdk-config-models-oss:${cdkVersionRequired}"
|
||||
implementation "io.airbyte.cdk:airbyte-cdk-init-oss:${cdkVersionRequired}"
|
||||
testImplementation "io.airbyte.cdk:airbyte-cdk-airbyte-commons:${cdkVersionRequired}"
|
||||
testImplementation "io.airbyte.cdk:airbyte-cdk-airbyte-json-validation:${cdkVersionRequired}"
|
||||
testImplementation "io.airbyte.cdk:airbyte-cdk-airbyte-api:${cdkVersionRequired}"
|
||||
testImplementation "io.airbyte.cdk:airbyte-cdk-config-models-oss:${cdkVersionRequired}"
|
||||
integrationTestJavaImplementation "io.airbyte.cdk:airbyte-cdk-config-models-oss:${cdkVersionRequired}"
|
||||
integrationTestJavaImplementation "io.airbyte.cdk:airbyte-cdk-init-oss:${cdkVersionRequired}"
|
||||
integrationTestJavaImplementation "io.airbyte.cdk:airbyte-cdk-acceptance-test-harness:${cdkVersionRequired}"
|
||||
submoduleNames.each { submoduleName ->
|
||||
// Add the cdkModule to the dependencies
|
||||
def cdkModule = "io.airbyte.cdk:airbyte-cdk-${submoduleName}:${cdkVersionRequired}"
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
abstract class AirbyteStandardSourceTestFileConfiguration {
|
||||
Closure prehook = {} // default no-op
|
||||
Closure posthook = {}
|
||||
String configPath
|
||||
String configuredCatalogPath
|
||||
String specPath
|
||||
String statePath
|
||||
}
|
||||
|
||||
class AirbyteStandardSourceTestFilePlugin implements Plugin<Project> {
|
||||
static void assertNotNull(String param, String paramName) {
|
||||
if (param == null || param == "") {
|
||||
throw new IllegalArgumentException("${paramName} parameter must be provided")
|
||||
}
|
||||
}
|
||||
|
||||
static void validateConfig(AirbyteStandardSourceTestFileConfiguration config) {
|
||||
assertNotNull(config.configPath, 'configPath')
|
||||
assertNotNull(config.specPath, 'specPath')
|
||||
assertNotNull(config.configuredCatalogPath, 'configuredCatalogPath')
|
||||
}
|
||||
|
||||
void apply(Project project) {
|
||||
def config = project.extensions.create('airbyteStandardSourceTestFile', AirbyteStandardSourceTestFileConfiguration)
|
||||
|
||||
def standardSourceTestFile = project.tasks.register('standardSourceTestFile') {
|
||||
doFirst {
|
||||
try {
|
||||
config.prehook.call()
|
||||
project.exec {
|
||||
validateConfig(config)
|
||||
def targetMountDirectory = "/test_input"
|
||||
def args = [
|
||||
'docker', 'run', '--rm', '-i',
|
||||
// provide access to the docker daemon
|
||||
'-v', "/var/run/docker.sock:/var/run/docker.sock",
|
||||
// A container within a container mounts from the host filesystem, not the parent container.
|
||||
// this forces /tmp to be the same directory for host, parent container, and child container.
|
||||
'-v', "/tmp:/tmp",
|
||||
// mount the project dir. all provided input paths must be relative to that dir.
|
||||
'-v', "${project.projectDir.absolutePath}:${targetMountDirectory}",
|
||||
'--name', "std-fs-source-test-${project.name}",
|
||||
'airbyte/base-standard-source-test-file:dev',
|
||||
'--imageName', DockerHelpers.getDevTaggedImage(project.projectDir, 'Dockerfile'),
|
||||
'--catalog', "${targetMountDirectory}/${config.configuredCatalogPath}",
|
||||
'--spec', "${targetMountDirectory}/${config.specPath}",
|
||||
'--config', "${targetMountDirectory}/${config.configPath}",
|
||||
]
|
||||
|
||||
if (config.statePath != null) {
|
||||
args.add("--state")
|
||||
args.add("${targetMountDirectory}/${config.statePath}")
|
||||
}
|
||||
|
||||
commandLine args
|
||||
}
|
||||
} finally {
|
||||
config.posthook.call()
|
||||
}
|
||||
}
|
||||
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
standardSourceTestFile.configure {
|
||||
dependsOn project.project(':airbyte-integrations:bases:base-standard-source-test-file').tasks.named('assemble')
|
||||
dependsOn project.tasks.named('assemble')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user