Skip to content

Commit

Permalink
chore: support kotlin build scripts (#49462)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpgrailsdev authored Dec 13, 2024
1 parent bcc147a commit 70f240e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
20 changes: 13 additions & 7 deletions airbyte-ci/connectors/connector_ops/connector_ops/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def has_local_cdk_ref(build_file: Path) -> bool:
"""Return true if the build file uses the local CDK.
Args:
build_file (Path): Path to the build.gradle file of the project.
build_file (Path): Path to the build.gradle/build.gradle.kts file of the project.
Returns:
bool: True if using local CDK.
Expand All @@ -148,7 +148,7 @@ def get_gradle_dependencies_block(build_file: Path) -> str:
"""Get the dependencies block of a Gradle file.
Args:
build_file (Path): Path to the build.gradle file of the project.
build_file (Path): Path to the build.gradle/build.gradle.kts file of the project.
Returns:
str: The dependencies block of the Gradle file.
Expand Down Expand Up @@ -215,7 +215,7 @@ def get_all_gradle_dependencies(
"""Recursively retrieve all transitive dependencies of a Gradle project.
Args:
build_file (Path): Path to the build.gradle file of the project.
build_file (Path): Path to the build.gradle/build.gradle.kts file of the project.
found_dependencies (List[Path]): List of dependencies that have already been found. Defaults to None.
Returns:
Expand All @@ -225,10 +225,12 @@ def get_all_gradle_dependencies(
found_dependencies = []
project_dependencies, test_dependencies = parse_gradle_dependencies(build_file)
all_dependencies = project_dependencies + test_dependencies if with_test_dependencies else project_dependencies
valid_build_files = ["build.gradle", "build.gradle.kts"]
for dependency_path in all_dependencies:
if dependency_path not in found_dependencies and Path(dependency_path / "build.gradle").exists():
found_dependencies.append(dependency_path)
get_all_gradle_dependencies(dependency_path / "build.gradle", with_test_dependencies, found_dependencies)
for build_file in valid_build_files:
if dependency_path not in found_dependencies and Path(dependency_path / build_file).exists():
found_dependencies.append(dependency_path)
get_all_gradle_dependencies(dependency_path / build_file, with_test_dependencies, found_dependencies)

return found_dependencies

Expand Down Expand Up @@ -706,10 +708,14 @@ def __repr__(self) -> str:
@functools.lru_cache(maxsize=2)
def get_local_dependency_paths(self, with_test_dependencies: bool = True) -> Set[Path]:
dependencies_paths = []
build_script = "build.gradle"
if Path(self.code_directory / "build.gradle.kts").exists():
build_script = "build.gradle.kts"

if self.language == ConnectorLanguage.JAVA:
dependencies_paths += [Path("./airbyte-cdk/java/airbyte-cdk"), Path("./airbyte-cdk/bulk")]
dependencies_paths += get_all_gradle_dependencies(
self.code_directory / "build.gradle", with_test_dependencies=with_test_dependencies
self.code_directory / build_script, with_test_dependencies=with_test_dependencies
)
return sorted(list(set(dependencies_paths)))

Expand Down
3 changes: 2 additions & 1 deletion airbyte-ci/connectors/pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,8 @@ airbyte-ci connectors --language=low-code migrate-to-manifest-only
## Changelog

| Version | PR | Description |
| ------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|---------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| 4.46.4 | [#49462](https://github.com/airbytehq/airbyte/pull/49462) | Support Kotlin Gradle build scripts in connectors. |
| 4.46.3 | [#49465](https://github.com/airbytehq/airbyte/pull/49465) | Fix `--use-local-cdk` on rootless connectors. |
| 4.46.2 | [#49136](https://github.com/airbytehq/airbyte/pull/49136) | Fix failed install of python components due to non-root permissions. |
| 4.46.1 | [#49146](https://github.com/airbytehq/airbyte/pull/49146) | Update `crane` image address as the one we were using has been deleted by the maintainer. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ async def _run(self, *args: Any, **kwargs: Any) -> StepResult:
".root",
".env",
"build.gradle",
"build.gradle.kts",
"gradle.properties",
"gradle",
"gradlew",
"settings.gradle",
"build.gradle",
"tools/gradle",
"spotbugs-exclude-filter-file.xml",
"buildSrc",
Expand Down
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/pipelines/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pipelines"
version = "4.46.3"
version = "4.46.4"
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
authors = ["Airbyte <[email protected]>"]

Expand Down
8 changes: 4 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ rootProject.name = 'airbyte'
def cdkPath = rootDir.toPath().resolve('airbyte-cdk/java/airbyte-cdk')
if (cdkPath.toFile().exists()) {
cdkPath.eachDir { dir ->
def buildFiles = file(dir).list { file, name -> name == "build.gradle" }
def buildFiles = file(dir).list { file, name -> name.matches("build\\.gradle(?:\\.kts)?") }
if (buildFiles.length == 1) {
def path = ":airbyte-cdk:java:airbyte-cdk:${dir.getFileName()}"
include path
Expand All @@ -153,7 +153,7 @@ if (cdkPath.toFile().exists()) {
def bulkCdkCorePath = rootDir.toPath().resolve('airbyte-cdk/bulk/core')
if (bulkCdkCorePath.toFile().exists()) {
bulkCdkCorePath.eachDir { dir ->
def buildFiles = file(dir).list { file, name -> name == "build.gradle" }
def buildFiles = file(dir).list { file, name -> name.matches("build\\.gradle(?:\\.kts)?") }
if (buildFiles.length == 1) {
def path = ":airbyte-cdk:bulk:core:${dir.getFileName()}"
include path
Expand All @@ -164,7 +164,7 @@ if (bulkCdkCorePath.toFile().exists()) {
def bulkCdkToolkitPath = rootDir.toPath().resolve('airbyte-cdk/bulk/toolkits')
if (bulkCdkToolkitPath.toFile().exists()) {
bulkCdkToolkitPath.eachDir { dir ->
def buildFiles = file(dir).list { file, name -> name == "build.gradle" }
def buildFiles = file(dir).list { file, name -> name.matches("build\\.gradle(?:\\.kts)?") }
if (buildFiles.length == 1) {
def path = ":airbyte-cdk:bulk:toolkits:${dir.getFileName()}"
include path
Expand All @@ -176,7 +176,7 @@ if (bulkCdkToolkitPath.toFile().exists()) {
// Include all java connector projects.
def integrationsPath = rootDir.toPath().resolve('airbyte-integrations/connectors')
integrationsPath.eachDir { dir ->
def buildFiles = file(dir).list { file, name -> name == "build.gradle" }
def buildFiles = file(dir).list { file, name -> name.matches("build\\.gradle(?:\\.kts)?") }
if (buildFiles.length != 1) {
// Ignore python and other non-gradle connectors.
return
Expand Down

0 comments on commit 70f240e

Please sign in to comment.