Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: corrected formating for java provider dependencies #3468

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ class GradlePackageManager extends JavaPackageManager {
}

public async addPackage(
packageName: string,
packageFQN: string,
packageVersion = "latest.release"
): Promise<void> {
const buildGradlePath = path.join(this.workingDirectory, "build.gradle");
Expand All @@ -665,14 +665,20 @@ class GradlePackageManager extends JavaPackageManager {
);
}

const packageSegments = packageFQN.split(".");
const packageName = packageSegments.pop();
const groupName = packageSegments.join(".");
const dependencySpecifier = `${groupName}:${packageName}`;
const dependencyAndVersionSpecifier = `${dependencySpecifier}:${packageVersion}`;

const existingDependency = buildGradleLines.findIndex((line) =>
line.includes(packageName)
line.includes(dependencySpecifier)
);
if (existingDependency !== -1) {
buildGradleLines.splice(existingDependency, 1);
}

const newPackageDependency = `\timplementation '${packageName}:${packageVersion}'`;
const newPackageDependency = `\timplementation '${dependencyAndVersionSpecifier}'`;
buildGradleLines.splice(dependencyBlockStart + 1, 0, newPackageDependency);

await fs.writeFile(buildGradlePath, buildGradleLines.join("\n"));
Expand All @@ -694,7 +700,10 @@ class GradlePackageManager extends JavaPackageManager {
}
return dep.name.includes("cdktf-provider-");
})
.map((dep) => ({ name: dep!.name, version: dep!.version }));
.map((dep) => ({
name: `com.hashicorp.${dep!.name}`,
version: dep!.version,
}));

return dependencyList;
}
Expand Down
Loading