@nx/gradle 22.1.0-rc.4 → 22.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAKpB,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAepB,OAAO,EACL,mBAAmB,EAEpB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAMnE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,QAE5E;AAED,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAoC5D,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAE3C,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,EACvD,gBAAe,aAAkB,EACjC,gBAAe,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAM,MAG5D,mBAAc,EACd,SAAS,mBAAmB,GAAG,SAAS,EACxC,SAAS,oBAAoB;;;;;;;;EA+B9B,CAAC"}
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAIpB,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAepB,OAAO,EACL,mBAAmB,EAEpB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAoFnE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,QAE5E;AAED,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAwF5D,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAE3C,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,EACvD,gBAAe,aAAkB,EACjC,gBAAe,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAM,MAG5D,mBAAc,EACd,SAAS,mBAAmB,GAAG,SAAS,EACxC,SAAS,oBAAoB;;;;;;;;EA+B9B,CAAC"}
@@ -14,6 +14,63 @@ const gradle_plugin_options_1 = require("./utils/gradle-plugin-options");
14
14
  function readProjectsCache(cachePath) {
15
15
  return (0, node_fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
16
16
  }
17
+ /**
18
+ * Strips nxConfig from project and all targets, returning only Gradle-detected configuration.
19
+ */
20
+ function stripNxConfig(project) {
21
+ const { nxConfig, targets, ...rest } = project;
22
+ const cleanedTargets = {};
23
+ if (targets) {
24
+ for (const [targetName, target] of Object.entries(targets)) {
25
+ const { nxConfig: targetNxConfig, ...targetRest } = target;
26
+ cleanedTargets[targetName] = targetRest;
27
+ }
28
+ }
29
+ return {
30
+ ...rest,
31
+ targets: cleanedTargets,
32
+ };
33
+ }
34
+ /**
35
+ * Extracts only nxConfig properties from project and targets.
36
+ * Returns undefined if no nxConfig exists.
37
+ */
38
+ function extractNxConfigOnly(project) {
39
+ const projectWithNxConfig = project;
40
+ const projectLevelNxConfig = projectWithNxConfig.nxConfig;
41
+ const targetsWithNxConfig = {};
42
+ let hasAnyNxConfig = false;
43
+ // Extract target-level nxConfig
44
+ if (project.targets) {
45
+ for (const [targetName, target] of Object.entries(project.targets)) {
46
+ const targetNxConfig = target.nxConfig;
47
+ if (targetNxConfig && Object.keys(targetNxConfig).length > 0) {
48
+ targetsWithNxConfig[targetName] = targetNxConfig;
49
+ hasAnyNxConfig = true;
50
+ }
51
+ }
52
+ }
53
+ // Check if we have project-level nxConfig
54
+ if (projectLevelNxConfig && Object.keys(projectLevelNxConfig).length > 0) {
55
+ hasAnyNxConfig = true;
56
+ }
57
+ if (!hasAnyNxConfig) {
58
+ return undefined;
59
+ }
60
+ // Build result with only nxConfig properties
61
+ let result = {};
62
+ // Merge project-level nxConfig into root
63
+ if (projectLevelNxConfig) {
64
+ result = {
65
+ ...projectLevelNxConfig,
66
+ };
67
+ }
68
+ // Add target-level nxConfig if any exist
69
+ if (Object.keys(targetsWithNxConfig).length > 0) {
70
+ result.targets = targetsWithNxConfig;
71
+ }
72
+ return result;
73
+ }
17
74
  function writeTargetsToCache(cachePath, results) {
18
75
  (0, devkit_1.writeJsonFile)(cachePath, results);
19
76
  }
@@ -26,11 +83,54 @@ exports.createNodesV2 = [
26
83
  const projectsCache = readProjectsCache(cachePath);
27
84
  await (0, get_project_graph_from_gradle_plugin_1.populateProjectGraph)(context.workspaceRoot, gradlewFiles.map((f) => (0, node_path_1.join)(context.workspaceRoot, f)), options);
28
85
  const report = (0, get_project_graph_from_gradle_plugin_1.getCurrentProjectGraphReport)();
29
- const { nodes, externalNodes, buildFiles = [] } = report;
86
+ const { nodes, externalNodes = {}, buildFiles = [] } = report;
30
87
  // Combine buildFilesFromSplitConfigFiles and buildFiles, making each value distinct
31
88
  const allBuildFiles = Array.from(new Set([...buildFilesFromSplitConfigFiles, ...buildFiles]));
32
89
  try {
33
- return (0, devkit_1.createNodesFromFiles)((0, exports.makeCreateNodesForGradleConfigFile)(nodes, projectsCache, externalNodes), allBuildFiles, options, context);
90
+ const results = [];
91
+ const normalizedOptions = (0, gradle_plugin_options_1.normalizeOptions)(options);
92
+ for (const gradleFilePath of allBuildFiles) {
93
+ // Skip on Vercel and Netlify
94
+ if (process.env.VERCEL || process.env.NETLIFY) {
95
+ continue;
96
+ }
97
+ const projectRoot = (0, node_path_1.dirname)(gradleFilePath);
98
+ const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, normalizedOptions ?? {}, context);
99
+ // Get project from cache or nodes
100
+ projectsCache[hash] ??=
101
+ nodes[projectRoot] ?? nodes[(0, node_path_1.join)(devkit_1.workspaceRoot, projectRoot)];
102
+ const project = projectsCache[hash];
103
+ if (!project) {
104
+ continue;
105
+ }
106
+ const normalizedProjectRoot = (0, devkit_1.normalizePath)(projectRoot);
107
+ // Result 1: Gradle-detected configuration (without nxConfig)
108
+ const gradleConfig = stripNxConfig(project);
109
+ gradleConfig.root = normalizedProjectRoot;
110
+ results.push([
111
+ gradleFilePath,
112
+ {
113
+ projects: {
114
+ [normalizedProjectRoot]: gradleConfig,
115
+ },
116
+ externalNodes: externalNodes,
117
+ },
118
+ ]);
119
+ // Result 2: nxConfig-only configuration (if exists)
120
+ const nxConfigOnly = extractNxConfigOnly(project);
121
+ if (nxConfigOnly) {
122
+ nxConfigOnly.root = normalizedProjectRoot;
123
+ results.push([
124
+ gradleFilePath,
125
+ {
126
+ projects: {
127
+ [normalizedProjectRoot]: nxConfigOnly,
128
+ },
129
+ },
130
+ ]);
131
+ }
132
+ }
133
+ return results;
34
134
  }
35
135
  finally {
36
136
  writeTargetsToCache(cachePath, projectsCache);