Skip to content

Commit

Permalink
feat(executors): add NX_SKIP_GRADLE_WRAPPER environment variable (#503)
Browse files Browse the repository at this point in the history
Co-authored-by: khalilou88 <[email protected]>
  • Loading branch information
khalilou88 and khalilou88 authored Oct 6, 2023
1 parent 516a569 commit 931428c
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/common/src/lib/command/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { logger, workspaceRoot } from '@nx/devkit';
import { execSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';

export async function waitForever() {
return new Promise(() => {
Expand Down Expand Up @@ -39,12 +41,29 @@ export function getPmdExecutable() {
}

export function getGradleExecutable() {
const isWin = process.platform === 'win32';
let executable = isWin ? 'gradlew.bat' : './gradlew';
let executable = '';

if (process.env['NX_SKIP_GRADLE_WRAPPER'] === 'true') {
executable = 'gradle';
} else {
const isWrapperExists = isWrapperExistsFunction();

if (isWrapperExists) {
const isWin = process.platform === 'win32';
executable = isWin ? 'gradlew.bat' : './gradlew';
} else {
executable = 'gradle';
}
}

if (process.env['NX_GRADLE_CLI_OPTS']) {
executable += ` ${process.env['NX_GRADLE_CLI_OPTS']}`;
}

return executable;
}

function isWrapperExistsFunction() {
const gradlePath = path.join(workspaceRoot, 'gradlew');
return fs.existsSync(gradlePath);
}

0 comments on commit 931428c

Please sign in to comment.