Skip to content

Commit

Permalink
fix(gradle): check if java is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi committed Jan 9, 2025
1 parent a77e3ef commit 2a6ddc0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/gradle/src/utils/get-project-report-lines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AggregateCreateNodesError, logger } from '@nx/devkit';
import { execGradleAsync } from './exec-gradle';
import { existsSync } from 'fs';
import { dirname, join } from 'path';
import { execSync } from 'child_process';

export const fileSeparator = process.platform.startsWith('win')
? 'file:///'
Expand Down Expand Up @@ -32,6 +33,24 @@ export async function getProjectReportLines(
return [];
}

try {
execSync('java --version', {
cwd: dirname(gradlewFile),
});
} catch (e) {
throw new AggregateCreateNodesError(
[
[
gradlewFile,
new Error(
`Could not find java. Please install java and try again: https://www.java.com/en/download/help/index_installing.html. ${e.message}`
),
],
],
[]
);
}

try {
projectReportBuffer = await execGradleAsync(gradlewFile, [
'projectReportAll',
Expand Down

0 comments on commit 2a6ddc0

Please sign in to comment.