UNPKG

@jnxplus/nx-maven

Version:

[![npm version](https://badge.fury.io/js/@jnxplus%2Fnx-maven.svg)](https://badge.fury.io/js/@jnxplus%2Fnx-maven)

76 lines 3.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createNodes = void 0; const devkit_1 = require("@nx/devkit"); const fs_1 = require("fs"); const path = require("path"); const graph_utils_1 = require("./graph-utils"); exports.createNodes = [ 'nx.json', (_, opts) => { var _a; const workspaceData = (0, graph_utils_1.getWorkspaceData)(opts); const mavenProjects = workspaceData.projects; const projects = {}; for (const project of mavenProjects) { if (project.skipProject) { continue; } let projectName; let targets = {}; const projectJsonPath = path.join(project.projectAbsolutePath, 'project.json'); if ((0, fs_1.existsSync)(projectJsonPath)) { const projectJson = (0, devkit_1.readJsonFile)(projectJsonPath); projectName = projectJson.name; if (projectName !== project.artifactId) { throw new Error(`ProjectName ${projectName} and artifactId ${project.artifactId} should be the same`); } targets = projectJson.targets; for (const [targetName] of Object.entries(targets !== null && targets !== void 0 ? targets : {})) { const target = targets[targetName]; (0, graph_utils_1.validateTargetInputs)(targetName, 'project.json', target.inputs); if ((0, graph_utils_1.ifOutputDirLocalRepoNotPresent)(target === null || target === void 0 ? void 0 : target.options) && (workspaceData.targetDefaults.includes(targetName) || ((_a = target.outputs) !== null && _a !== void 0 ? _a : []).some((element) => element === '{options.outputDirLocalRepo}'))) { const effectiveVersion = (0, graph_utils_1.getEffectiveVersion)(project, workspaceData); const outputDirLocalRepo = (0, graph_utils_1.getOutputDirLocalRepo)(workspaceData.localRepo, project.groupId, project.artifactId, effectiveVersion); target.options = Object.assign(Object.assign({}, target.options), { outputDirLocalRepo: outputDirLocalRepo }); } } } else { const effectiveVersion = (0, graph_utils_1.getEffectiveVersion)(project, workspaceData); const outputDirLocalRepo = (0, graph_utils_1.getOutputDirLocalRepo)(workspaceData.localRepo, project.groupId, project.artifactId, effectiveVersion); projectName = project.artifactId; let outputs; if (project.isPomPackaging) { outputs = ['{options.outputDirLocalRepo}']; } else { outputs = ['{projectRoot}/target', '{options.outputDirLocalRepo}']; } const buildTargetName = (opts === null || opts === void 0 ? void 0 : opts.buildTargetName) ? opts.buildTargetName : 'build'; targets = { [buildTargetName]: { executor: '@jnxplus/nx-maven:run-task', outputs: outputs, options: { task: (0, graph_utils_1.getTask)(project.isRootProject), outputDirLocalRepo: outputDirLocalRepo, }, }, }; } projects[project.projectRoot] = { root: project.projectRoot, name: projectName, targets: targets, tags: ['nx-maven'], }; } return { projects: projects }; }, ]; //# sourceMappingURL=create-nodes.js.map