@nx/gradle 23.0.0-beta.17 → 23.0.0-beta.19

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/gradle",
3
- "version": "23.0.0-beta.17",
3
+ "version": "23.0.0-beta.19",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx",
6
6
  "repository": {
@@ -40,13 +40,13 @@
40
40
  "migrations": "./migrations.json"
41
41
  },
42
42
  "dependencies": {
43
- "@nx/devkit": "23.0.0-beta.17",
43
+ "@nx/devkit": "23.0.0-beta.19",
44
44
  "toml-eslint-parser": "^0.10.0",
45
45
  "tree-kill": "^1.2.2",
46
46
  "tslib": "^2.3.0"
47
47
  },
48
48
  "devDependencies": {
49
- "nx": "23.0.0-beta.17"
49
+ "nx": "23.0.0-beta.19"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"
@@ -2,7 +2,7 @@ import { CreateNodesV2, CreateNodesContextV2, ProjectConfiguration, ProjectGraph
2
2
  import { GradlePluginOptions } from './utils/gradle-plugin-options';
3
3
  type GradleTargets = Record<string, Partial<ProjectConfiguration>>;
4
4
  export declare const createNodesV2: CreateNodesV2<GradlePluginOptions>;
5
- export declare const makeCreateNodesForGradleConfigFile: (projects: Record<string, Partial<ProjectConfiguration>>, projectsCache?: GradleTargets, externalNodes?: Record<string, ProjectGraphExternalNode>) => (gradleFilePath: any, options: GradlePluginOptions | undefined, context: CreateNodesContextV2) => Promise<{
5
+ export declare const makeCreateNodesForGradleConfigFile: (projects: Record<string, Partial<ProjectConfiguration>>, projectsCache?: GradleTargets, externalNodes?: Record<string, ProjectGraphExternalNode>, hashes?: string[]) => (gradleFilePath: any, options: GradlePluginOptions | undefined, context: CreateNodesContextV2, idx?: number) => Promise<{
6
6
  projects?: undefined;
7
7
  externalNodes?: undefined;
8
8
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin/nodes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAEpB,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAcpB,OAAO,EACL,mBAAmB,EAEpB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAgFnE,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CA0F5D,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;;;;;;;;EAyB9B,CAAC"}
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin/nodes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAEpB,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAcpB,OAAO,EACL,mBAAmB,EAEpB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAgFnE,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CA8F5D,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,EAC5D,SAAS,MAAM,EAAE,MAGjB,mBAAc,EACd,SAAS,mBAAmB,GAAG,SAAS,EACxC,SAAS,oBAAoB,EAC7B,MAAM,MAAM;;;;;;;;EAyCb,CAAC"}
@@ -82,9 +82,12 @@ exports.createNodesV2 = [
82
82
  try {
83
83
  const results = [];
84
84
  const normalizedOptions = (0, gradle_plugin_options_1.normalizeOptions)(options);
85
- for (const gradleFilePath of allBuildFiles) {
86
- const projectRoot = (0, node_path_1.dirname)(gradleFilePath);
87
- const hash = await (0, internal_1.calculateHashForCreateNodes)(projectRoot, normalizedOptions ?? {}, context);
85
+ const buildFileProjectRoots = allBuildFiles.map((f) => (0, node_path_1.dirname)(f));
86
+ const buildFileHashes = await (0, internal_1.calculateHashesForCreateNodes)(buildFileProjectRoots, normalizedOptions ?? {}, context);
87
+ for (let i = 0; i < allBuildFiles.length; i++) {
88
+ const gradleFilePath = allBuildFiles[i];
89
+ const projectRoot = buildFileProjectRoots[i];
90
+ const hash = buildFileHashes[i];
88
91
  // Get project from cache or nodes
89
92
  if (!pluginCache.has(hash)) {
90
93
  const nodeProject = nodes[projectRoot] ?? nodes[(0, node_path_1.join)(devkit_1.workspaceRoot, projectRoot)];
@@ -130,10 +133,23 @@ exports.createNodesV2 = [
130
133
  }
131
134
  },
132
135
  ];
133
- const makeCreateNodesForGradleConfigFile = (projects, projectsCache = {}, externalNodes = {}) => async (gradleFilePath, options, context) => {
136
+ const makeCreateNodesForGradleConfigFile = (projects, projectsCache = {}, externalNodes = {}, hashes) => async (gradleFilePath, options, context, idx) => {
134
137
  const projectRoot = (0, node_path_1.dirname)(gradleFilePath);
135
138
  options = (0, gradle_plugin_options_1.normalizeOptions)(options);
136
- const hash = await (0, internal_1.calculateHashForCreateNodes)(projectRoot, options ?? {}, context);
139
+ let hash;
140
+ if (hashes && idx !== undefined) {
141
+ hash = hashes[idx];
142
+ if (hash === undefined) {
143
+ throw new Error(`Failed to compute hash for gradle project at ${projectRoot}`);
144
+ }
145
+ }
146
+ else {
147
+ const [computed] = await (0, internal_1.calculateHashesForCreateNodes)([projectRoot], options ?? {}, context);
148
+ if (computed === undefined) {
149
+ throw new Error(`Failed to compute hash for gradle project at ${projectRoot}`);
150
+ }
151
+ hash = computed;
152
+ }
137
153
  projectsCache[hash] ??=
138
154
  projects[projectRoot] ?? projects[(0, node_path_1.join)(devkit_1.workspaceRoot, projectRoot)];
139
155
  const project = projectsCache[hash];
@@ -14,7 +14,7 @@ export interface GradlePluginOptions {
14
14
  * Switch to the default `@nx/gradle` plugin.
15
15
  */
16
16
  export declare const createNodesV2: CreateNodesV2<GradlePluginOptions>;
17
- export declare const makeCreateNodesForGradleConfigFile: (gradleReport: GradleReport, pluginCache: PluginCache<Partial<ProjectConfiguration>>, gradleProjectRootToTestFilesMap?: Record<string, string[]>) => (gradleFilePath: any, options: GradlePluginOptions | undefined, context: CreateNodesContextV2) => Promise<{
17
+ export declare const makeCreateNodesForGradleConfigFile: (gradleReport: GradleReport, pluginCache: PluginCache<Partial<ProjectConfiguration>>, gradleProjectRootToTestFilesMap?: Record<string, string[]>, hashes?: string[]) => (gradleFilePath: any, options: GradlePluginOptions | undefined, context: CreateNodesContextV2, idx?: number) => Promise<{
18
18
  projects?: undefined;
19
19
  } | {
20
20
  projects: {
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin-v1/nodes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAGrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAGL,YAAY,EACb,MAAM,2BAA2B,CAAC;AAsBnC,MAAM,WAAW,mBAAmB;IAClC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,C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CAAiC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM,EAC9D,SAAS,MAAM,EAAE,MAGjB,mBAAc,EACd,SAAS,mBAAmB,GAAG,SAAS,EACxC,SAAS,oBAAoB,EAC7B,MAAM,MAAM;;;;;;EAgDb,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,WAAW,oCAAgB,CAAC"}
@@ -40,17 +40,32 @@ exports.createNodesV2 = [
40
40
  const gradleReport = (0, get_gradle_report_1.getCurrentGradleReport)();
41
41
  const gradleProjectRootToTestFilesMap = getGradleProjectRootToTestFilesMap(testFiles, projectRoots);
42
42
  try {
43
- return (0, devkit_1.createNodesFromFiles)((0, exports.makeCreateNodesForGradleConfigFile)(gradleReport, pluginCache, gradleProjectRootToTestFilesMap), buildFiles, options, context);
43
+ const buildFileProjectRoots = buildFiles.map((f) => (0, node_path_1.dirname)(f));
44
+ const buildFileHashes = await (0, internal_1.calculateHashesForCreateNodes)(buildFileProjectRoots, normalizeOptions(options) ?? {}, context);
45
+ return (0, devkit_1.createNodesFromFiles)((0, exports.makeCreateNodesForGradleConfigFile)(gradleReport, pluginCache, gradleProjectRootToTestFilesMap, buildFileHashes), buildFiles, options, context);
44
46
  }
45
47
  finally {
46
48
  pluginCache.writeToDisk();
47
49
  }
48
50
  },
49
51
  ];
50
- const makeCreateNodesForGradleConfigFile = (gradleReport, pluginCache, gradleProjectRootToTestFilesMap = {}) => async (gradleFilePath, options, context) => {
52
+ const makeCreateNodesForGradleConfigFile = (gradleReport, pluginCache, gradleProjectRootToTestFilesMap = {}, hashes) => async (gradleFilePath, options, context, idx) => {
51
53
  const projectRoot = (0, node_path_1.dirname)(gradleFilePath);
52
54
  options = normalizeOptions(options);
53
- const hash = await (0, internal_1.calculateHashForCreateNodes)(projectRoot, options ?? {}, context);
55
+ let hash;
56
+ if (hashes && idx !== undefined) {
57
+ hash = hashes[idx];
58
+ if (hash === undefined) {
59
+ throw new Error(`Failed to compute hash for gradle project at ${projectRoot}`);
60
+ }
61
+ }
62
+ else {
63
+ const [computed] = await (0, internal_1.calculateHashesForCreateNodes)([projectRoot], options ?? {}, context);
64
+ if (computed === undefined) {
65
+ throw new Error(`Failed to compute hash for gradle project at ${projectRoot}`);
66
+ }
67
+ hash = computed;
68
+ }
54
69
  if (!pluginCache.has(hash)) {
55
70
  pluginCache.set(hash, await createGradleProject(gradleReport, gradleFilePath, options, context, gradleProjectRootToTestFilesMap[projectRoot]));
56
71
  }