@nx/gradle 19.6.0 → 19.7.0-beta.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.
package/README.md CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  # Nx: Smart Monorepos · Fast CI
26
26
 
27
- Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
27
+ Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
28
28
 
29
29
  This package is a [Gradle plugin for Nx](https://nx.dev/gradle/overview).
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/gradle",
3
- "version": "19.6.0",
3
+ "version": "19.7.0-beta.0",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx",
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "migrations": "./migrations.json"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "19.6.0"
37
+ "@nx/devkit": "19.7.0-beta.0"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"
@@ -12,7 +12,7 @@ const createDependencies = async (_, context) => {
12
12
  return [];
13
13
  }
14
14
  const gradleDependenciesStart = performance.mark('gradleDependencies:start');
15
- const { gradleFileToGradleProjectMap, gradleProjectToProjectName, buildFileToDepsMap, } = (0, get_gradle_report_1.getCurrentGradleReport)();
15
+ const { gradleFileToGradleProjectMap, gradleProjectToProjectName, buildFileToDepsMap, gradleProjectToChildProjects, } = (0, get_gradle_report_1.getCurrentGradleReport)();
16
16
  const dependencies = new Set();
17
17
  for (const gradleFile of gradleFiles) {
18
18
  const gradleProject = gradleFileToGradleProjectMap.get(gradleFile);
@@ -21,6 +21,18 @@ const createDependencies = async (_, context) => {
21
21
  if (projectName && depsFile) {
22
22
  processGradleDependencies(depsFile, gradleProjectToProjectName, projectName, gradleFile, context, dependencies);
23
23
  }
24
+ gradleProjectToChildProjects.get(gradleProject)?.forEach((childProject) => {
25
+ if (childProject) {
26
+ const dependency = {
27
+ source: projectName,
28
+ target: childProject,
29
+ type: devkit_1.DependencyType.static,
30
+ sourceFile: gradleFile,
31
+ };
32
+ (0, devkit_1.validateDependency)(dependency, context);
33
+ dependencies.add(dependency);
34
+ }
35
+ });
24
36
  }
25
37
  const gradleDependenciesEnd = performance.mark('gradleDependencies:end');
26
38
  performance.measure('gradleDependencies', gradleDependenciesStart.name, gradleDependenciesEnd.name);
@@ -6,6 +6,7 @@ export interface GradleReport {
6
6
  gradleFileToOutputDirsMap: Map<string, Map<string, string>>;
7
7
  gradleProjectToTasksTypeMap: Map<string, Map<string, string>>;
8
8
  gradleProjectToProjectName: Map<string, string>;
9
+ gradleProjectToChildProjects: Map<string, string[]>;
9
10
  }
10
11
  export declare const GRADLE_BUILD_FILES: Set<string>;
11
12
  export declare const GRADLE_TEST_FILES: string[];
@@ -91,6 +91,10 @@ function processProjectReports(projectReportLines) {
91
91
  * e.g. {build.gradle.kts: { projectReportDir: '' testReportDir: '' }}
92
92
  */
93
93
  const gradleFileToOutputDirsMap = new Map();
94
+ /**
95
+ * Map of Gradle Project to its child projects
96
+ */
97
+ const gradleProjectToChildProjects = new Map();
94
98
  let index = 0;
95
99
  while (index < projectReportLines.length) {
96
100
  const line = projectReportLines[index].trim();
@@ -126,6 +130,11 @@ function processProjectReports(projectReportLines) {
126
130
  if (line.startsWith('buildDir: ')) {
127
131
  absBuildDirPath = line.substring('buildDir: '.length);
128
132
  }
133
+ if (line.startsWith('childProjects: ')) {
134
+ const childProjects = line.substring('childProjects: {'.length); // remove curly braces {} around childProjects
135
+ gradleProjectToChildProjects.set(gradleProject, childProjects.split(',').map((c) => c.trim().split('=')[0]) // e.g. get project name from text like "app=project ':app', mylibrary=project ':mylibrary'"
136
+ );
137
+ }
129
138
  if (line.includes('Dir: ')) {
130
139
  const [dirName, dirPath] = line.split(': ');
131
140
  const taskName = dirName.replace('Dir', '');
@@ -163,7 +172,9 @@ function processProjectReports(projectReportLines) {
163
172
  if (tasksFileLines[i + 1] === dashes) {
164
173
  const type = line.substring(0, line.length - ' tasks'.length);
165
174
  i++;
166
- while (tasksFileLines[++i] !== '') {
175
+ while (tasksFileLines[++i] !== '' &&
176
+ i < tasksFileLines.length &&
177
+ tasksFileLines[i]?.includes(' - ')) {
167
178
  const [taskName] = tasksFileLines[i].split(' - ');
168
179
  taskTypeMap.set(taskName, type);
169
180
  }
@@ -182,5 +193,6 @@ function processProjectReports(projectReportLines) {
182
193
  gradleFileToOutputDirsMap,
183
194
  gradleProjectToTasksTypeMap,
184
195
  gradleProjectToProjectName,
196
+ gradleProjectToChildProjects,
185
197
  };
186
198
  }