Skip to content

Commit

Permalink
fix(gradle): fix missing tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Mar 19, 2024
1 parent 8baddb5 commit ce7599d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
13 changes: 6 additions & 7 deletions packages/gradle/src/plugin/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export const createNodes: CreateNodes<GradlePluginOptions> = [

try {
const {
tasksMap,
gradleProjectToTasksTypeMap,
gradleFileToOutputDirsMap,
gradleFileToGradleProjectMap,
Expand All @@ -96,16 +95,16 @@ export const createNodes: CreateNodes<GradlePluginOptions> = [
return;
}

const availableTaskNames = tasksMap.get(gradleFilePath) as string[];
const tasksTypeMap = gradleProjectToTasksTypeMap.get(
gradleProject
) as Map<string, string>;
const tasks: GradleTask[] = availableTaskNames.map((taskName) => {
return {
type: tasksTypeMap.get(taskName) ?? 'Unknown',
let tasks: GradleTask[] = [];
for (let [taskName, taskType] of tasksTypeMap.entries()) {
tasks.push({
type: taskType,
name: taskName,
};
});
});
}

const outputDirs = gradleFileToOutputDirsMap.get(gradleFilePath) as Map<
string,
Expand Down
15 changes: 1 addition & 14 deletions packages/gradle/src/utils/get-gradle-report.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { readFileSync } from 'node:fs';
import { dirname, join, relative } from 'node:path';
import { join, relative } from 'node:path';

import { workspaceRoot } from '@nx/devkit';
import { hashWithWorkspaceContext } from 'nx/src/utils/workspace-context';

import { execGradle } from './exec-gradle';

Expand All @@ -11,7 +10,6 @@ interface GradleReport {
buildFileToDepsMap: Map<string, string>;
gradleFileToOutputDirsMap: Map<string, Map<string, string>>;
gradleProjectToTasksTypeMap: Map<string, Map<string, string>>;
tasksMap: Map<string, string[]>;
gradleProjectToProjectName: Map<string, string>;
}

Expand Down Expand Up @@ -54,10 +52,6 @@ function processProjectReports(projectReportLines: string[]): GradleReport {
*/
const gradleProjectToGradleFileMap = new Map<string, string>();
const dependenciesMap = new Map<string, string>();
/**
* Map of Gradle Build File to available tasks
*/
const tasksMap = new Map<string, string[]>();
/**
* Map of Gradle Build File to tasks type map
*/
Expand Down Expand Up @@ -95,7 +89,6 @@ function processProjectReports(projectReportLines: string[]): GradleReport {
let projectName: string,
absBuildFilePath: string,
absBuildDirPath: string;
const tasks: string[] = [];
const outputDirMap = new Map<string, string>();
for (const line of propertyReportLines) {
if (line.startsWith('name: ')) {
Expand All @@ -107,10 +100,6 @@ function processProjectReports(projectReportLines: string[]): GradleReport {
if (line.startsWith('buildDir: ')) {
absBuildDirPath = line.substring('buildDir: '.length);
}
if (line.includes(': task ')) {
const taskSegments = line.split(': task ');
tasks.push(taskSegments[0]);
}
if (line.includes('Dir: ')) {
const [dirName, dirPath] = line.split(': ');
const taskName = dirName.replace('Dir', '');
Expand Down Expand Up @@ -141,7 +130,6 @@ function processProjectReports(projectReportLines: string[]): GradleReport {
gradleFileToGradleProjectMap.set(buildFile, gradleProject);
gradleProjectToGradleFileMap.set(gradleProject, buildFile);
gradleProjectToProjectName.set(gradleProject, projectName);
tasksMap.set(buildFile, tasks);
}
if (line.endsWith('taskReport')) {
const gradleProject = line.substring(
Expand Down Expand Up @@ -179,7 +167,6 @@ function processProjectReports(projectReportLines: string[]): GradleReport {
buildFileToDepsMap,
gradleFileToOutputDirsMap,
gradleProjectToTasksTypeMap,
tasksMap,
gradleProjectToProjectName,
};
}

0 comments on commit ce7599d

Please sign in to comment.