|
16 | 16 | from airbyte_cdk.models.connector_metadata import ConnectorLanguage, MetadataFile
|
17 | 17 | from airbyte_cdk.utils.docker_image_templates import (
|
18 | 18 | DOCKERIGNORE_TEMPLATE,
|
| 19 | + JAVA_CONNECTOR_DOCKERFILE_TEMPLATE, |
19 | 20 | MANIFEST_ONLY_DOCKERFILE_TEMPLATE,
|
20 | 21 | PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE,
|
21 | 22 | )
|
@@ -197,6 +198,22 @@ def build_connector_image(
|
197 | 198 |
|
198 | 199 | base_tag = f"{metadata.data.dockerRepository}:{tag}"
|
199 | 200 | arch_images: list[str] = []
|
| 201 | + |
| 202 | + if metadata.data.language == ConnectorLanguage.JAVA: |
| 203 | + # This assumes that the repo root ('airbyte') is three levels above the |
| 204 | + # connector directory (airbyte/airbyte-integrations/connectors/source-foo). |
| 205 | + repo_root = connector_directory.parent.parent.parent |
| 206 | + # For Java connectors, we need to build the connector tar file first. |
| 207 | + subprocess.run( |
| 208 | + [ |
| 209 | + "./gradlew", |
| 210 | + f":airbyte-integrations:connectors:{connector_name}:distTar", |
| 211 | + ], |
| 212 | + cwd=repo_root, |
| 213 | + text=True, |
| 214 | + check=True, |
| 215 | + ) |
| 216 | + |
200 | 217 | for arch in [ArchEnum.AMD64, ArchEnum.ARM64]:
|
201 | 218 | docker_tag = f"{base_tag}-{arch.value}"
|
202 | 219 | docker_tag_parts = docker_tag.split("/")
|
@@ -248,10 +265,7 @@ def get_dockerfile_template(
|
248 | 265 | return MANIFEST_ONLY_DOCKERFILE_TEMPLATE
|
249 | 266 |
|
250 | 267 | if metadata.data.language == ConnectorLanguage.JAVA:
|
251 |
| - raise ValueError( |
252 |
| - f"Java and Kotlin connectors are not yet supported. " |
253 |
| - "Please use airbyte-ci or gradle to build your image." |
254 |
| - ) |
| 268 | + return JAVA_CONNECTOR_DOCKERFILE_TEMPLATE |
255 | 269 |
|
256 | 270 | raise ValueError(
|
257 | 271 | f"Unsupported connector language: {metadata.data.language}. "
|
@@ -322,10 +336,20 @@ def verify_connector_image(
|
322 | 336 | )
|
323 | 337 | # check that the output is valid JSON
|
324 | 338 | if result.stdout:
|
325 |
| - try: |
326 |
| - json.loads(result.stdout) |
327 |
| - except json.JSONDecodeError: |
328 |
| - logger.error("Invalid JSON output from spec command.") |
| 339 | + found_spec_output = False |
| 340 | + for line in result.stdout.split("\n"): |
| 341 | + if line.strip(): |
| 342 | + try: |
| 343 | + # Check if the line is a valid JSON object |
| 344 | + msg = json.loads(line) |
| 345 | + if isinstance(msg, dict) and "type" in msg and msg["type"] == "SPEC": |
| 346 | + found_spec_output = True |
| 347 | + |
| 348 | + except json.JSONDecodeError as e: |
| 349 | + logger.warning(f"Invalid JSON output from spec command: {e}: {line}") |
| 350 | + |
| 351 | + if not found_spec_output: |
| 352 | + logger.error("No valid JSON output found for spec command.") |
329 | 353 | return False
|
330 | 354 | else:
|
331 | 355 | logger.error("No output from spec command.")
|
|
0 commit comments