Skip to content

Commit

Permalink
build: projectName and artifactId should be the same
Browse files Browse the repository at this point in the history
  • Loading branch information
khalilou88 committed Dec 28, 2023
1 parent 81cc3b5 commit 308a8bc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/nx-maven/src/graph/create-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,26 @@ export const createNodes: CreateNodes = [
mavenRootDirectory,
);

const pomXmlContent = readXml(pomXmlFilePath);
const artifactId = getArtifactId(pomXmlContent);

if (existsSync(projectJsonPath)) {
const projectJson = readJsonFile(projectJsonPath);
projectName = projectJson.name;

if (projectName !== artifactId) {
throw new Error(
`ProjectName ${projectName} and artifactId ${artifactId} should be the same`,
);
}

targets = projectJson.targets;
for (const [targetName] of Object.entries(targets ?? {})) {
if (
(targets[targetName].outputs ?? []).some(
(element: string) => element === '{options.outputDirLocalRepo}',
)
) {
const pomXmlContent = readXml(pomXmlFilePath);
const artifactId = getArtifactId(pomXmlContent);
const groupId = getGroupId(artifactId, pomXmlContent);
const projectVersion = getEffectiveVersion(
artifactId,
Expand All @@ -71,8 +79,6 @@ export const createNodes: CreateNodes = [
}
}
} else {
const pomXmlContent = readXml(pomXmlFilePath);
const artifactId = getArtifactId(pomXmlContent);
const groupId = getGroupId(artifactId, pomXmlContent);
const projectVersion = getEffectiveVersion(
artifactId,
Expand Down

0 comments on commit 308a8bc

Please sign in to comment.