Skip to content

Commit

Permalink
feat: make maven group ID overridable
Browse files Browse the repository at this point in the history
  • Loading branch information
mbialon committed Jan 5, 2024
1 parent 2e0adcf commit a896b33
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
13 changes: 13 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export interface CdktfProviderProjectOptions extends cdk.JsiiProjectOptions {
* defaults to "hashicorp"
*/
readonly mavenOrg?: string;
/**
* defaults to "com.${mavenOrg}"
*/
readonly mavenGroupId?: string;
/**
* The year of the creation of the repository, for copyright purposes.
* Will fall back to the current year if not specified.
Expand Down Expand Up @@ -123,7 +127,8 @@ export class CdktfProviderProject extends cdk.JsiiProject {
const nugetName = `${nugetOrg}.${pascalCase(
namespace
)}.Providers.${pascalCase(providerName)}`;
const mavenName = `com.${mavenOrg}.${namespace}.providers.${getMavenName(
const mavenGroupId = options.mavenGroupId ?? `com.${mavenOrg}`;
const mavenName = `${mavenGroupId}.${namespace}.providers.${getMavenName(
providerName
)}`;
const repositoryUrl = `github.com/${githubNamespace}/${namespace}-provider-${providerName.replace(
Expand Down Expand Up @@ -151,7 +156,7 @@ export class CdktfProviderProject extends cdk.JsiiProject {
},
publishToMaven: {
javaPackage: mavenName,
mavenGroupId: `com.${mavenOrg}`,
mavenGroupId: mavenGroupId,
mavenArtifactId: `${namespace}-provider-${providerName}`,
mavenEndpoint,
},
Expand Down
26 changes: 26 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,29 @@ test("has a custom workflow and README if the project is deprecated", () => {
)
);
});

test("override maven org", () => {
const snapshot = synthSnapshot(getProject({ mavenOrg: "gofer" }));

expect(JSON.parse(snapshot["package.json"])).toHaveProperty(
"jsii.targets.java.maven.groupId",
"com.gofer"
);
expect(JSON.parse(snapshot["package.json"])).toHaveProperty(
"jsii.targets.java.package",
"com.gofer.cdktf.providers.random_provider"
);
});

test("override maven group id", () => {
const snapshot = synthSnapshot(getProject({ mavenGroupId: "dev.gofer" }));

expect(JSON.parse(snapshot["package.json"])).toHaveProperty(
"jsii.targets.java.maven.groupId",
"dev.gofer"
);
expect(JSON.parse(snapshot["package.json"])).toHaveProperty(
"jsii.targets.java.package",
"dev.gofer.cdktf.providers.random_provider"
);
});

0 comments on commit a896b33

Please sign in to comment.