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 c6cb024 commit 63c7ccf
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 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,38 @@ export async function getProjectReportLines(
return [];
}

try {
execSync('java --version');
} 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 {
await execGradleAsync(gradlewFile, ['wrapper']);
} catch (e) {
throw new AggregateCreateNodesError(
[
[
gradlewFile,
new Error(
`Could not find Gradle. Please install Gradle and try again: https://gradle.org/install/. ${e.message}`
),
],
],
[]
);
}

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

0 comments on commit 63c7ccf

Please sign in to comment.