@@ -63,21 +63,6 @@ def _build_image(
6363
6464 Raises: ConnectorImageBuildError if the build fails.
6565 """
66- connector_name = metadata .data .dockerRepository .split ("/" )[- 1 ]
67- if metadata .data .language == ConnectorLanguage .JAVA :
68- # For Java connectors, the context directory is the repo root.
69- context_dir = context_dir .parent .parent .parent
70- # For Java connectors, we need to build the connector tar file first.
71- response : subprocess .CompletedProcess [str ] = subprocess .run (
72- [
73- "./gradlew" ,
74- f":airbyte-integrations:connectors:{ connector_name } :distTar" ,
75- ],
76- cwd = context_dir ,
77- text = True ,
78- check = True ,
79- )
80-
8166 docker_args : list [str ] = [
8267 "docker" ,
8368 "build" ,
@@ -213,6 +198,22 @@ def build_connector_image(
213198
214199 base_tag = f"{ metadata .data .dockerRepository } :{ tag } "
215200 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+
216217 for arch in [ArchEnum .AMD64 , ArchEnum .ARM64 ]:
217218 docker_tag = f"{ base_tag } -{ arch .value } "
218219 docker_tag_parts = docker_tag .split ("/" )
0 commit comments