mirror of
https://github.com/gradle/gradle-build-action
synced 2024-11-27 12:02:15 +00:00
parent
4301451b53
commit
3c11eee5f9
4 changed files with 46 additions and 38 deletions
43
dist/main/index.js
vendored
43
dist/main/index.js
vendored
|
@ -73282,19 +73282,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.executeGradleBuild = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const exec = __importStar(__nccwpck_require__(1514));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const gradlew = __importStar(__nccwpck_require__(2335));
|
||||
function executeGradleBuild(executable, root, args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const toExecute = executable !== null && executable !== void 0 ? executable : gradlew.locateGradleWrapperScript(root);
|
||||
verifyIsExecutableScript(toExecute);
|
||||
const toExecute = executable !== null && executable !== void 0 ? executable : gradlew.gradleWrapperScript(root);
|
||||
const status = yield exec.exec(toExecute, args, {
|
||||
cwd: root,
|
||||
ignoreReturnCode: true
|
||||
|
@ -73305,14 +73300,6 @@ function executeGradleBuild(executable, root, args) {
|
|||
});
|
||||
}
|
||||
exports.executeGradleBuild = executeGradleBuild;
|
||||
function verifyIsExecutableScript(toExecute) {
|
||||
try {
|
||||
fs_1.default.accessSync(toExecute, fs_1.default.constants.X_OK);
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(`Gradle script '${toExecute}' is not executable.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
@ -73349,27 +73336,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.locateGradleWrapperScript = exports.installScriptFilename = exports.wrapperScriptFilename = void 0;
|
||||
exports.gradleWrapperScript = exports.installScriptFilename = exports.wrapperScriptFilename = void 0;
|
||||
const path = __importStar(__nccwpck_require__(1017));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
function wrapperScriptFilename() {
|
||||
return IS_WINDOWS ? 'gradlew.bat' : 'gradlew';
|
||||
return IS_WINDOWS ? 'gradlew.bat' : './gradlew';
|
||||
}
|
||||
exports.wrapperScriptFilename = wrapperScriptFilename;
|
||||
function installScriptFilename() {
|
||||
return IS_WINDOWS ? 'gradle.bat' : 'gradle';
|
||||
}
|
||||
exports.installScriptFilename = installScriptFilename;
|
||||
function locateGradleWrapperScript(buildRootDirectory) {
|
||||
function gradleWrapperScript(buildRootDirectory) {
|
||||
validateGradleWrapper(buildRootDirectory);
|
||||
return path.resolve(buildRootDirectory, wrapperScriptFilename());
|
||||
return wrapperScriptFilename();
|
||||
}
|
||||
exports.locateGradleWrapperScript = locateGradleWrapperScript;
|
||||
exports.gradleWrapperScript = gradleWrapperScript;
|
||||
function validateGradleWrapper(buildRootDirectory) {
|
||||
const wrapperScript = path.resolve(buildRootDirectory, wrapperScriptFilename());
|
||||
verifyExists(wrapperScript, 'Gradle Wrapper script');
|
||||
verifyIsExecutableScript(wrapperScript);
|
||||
const wrapperProperties = path.resolve(buildRootDirectory, 'gradle/wrapper/gradle-wrapper.properties');
|
||||
if (!fs_1.default.existsSync(wrapperProperties)) {
|
||||
throw new Error(`Cannot locate a Gradle wrapper properties file at '${wrapperProperties}'. Specify 'gradle-version' or 'gradle-executable' for projects without Gradle wrapper configured.`);
|
||||
verifyExists(wrapperProperties, 'Gradle wrapper properties file');
|
||||
}
|
||||
function verifyExists(file, description) {
|
||||
if (!fs_1.default.existsSync(file)) {
|
||||
throw new Error(`Cannot locate ${description} at '${file}'. Specify 'gradle-version' or 'gradle-executable' for projects without Gradle wrapper configured.`);
|
||||
}
|
||||
}
|
||||
function verifyIsExecutableScript(toExecute) {
|
||||
try {
|
||||
fs_1.default.accessSync(toExecute, fs_1.default.constants.X_OK);
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(`Gradle script '${toExecute}' is not executable.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
dist/main/index.js.map
vendored
2
dist/main/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -1,12 +1,11 @@
|
|||
import * as core from '@actions/core'
|
||||
import * as exec from '@actions/exec'
|
||||
import fs from 'fs'
|
||||
import * as gradlew from './gradlew'
|
||||
|
||||
export async function executeGradleBuild(executable: string | undefined, root: string, args: string[]): Promise<void> {
|
||||
// Use the provided executable, or look for a Gradle wrapper script to run
|
||||
const toExecute = executable ?? gradlew.locateGradleWrapperScript(root)
|
||||
verifyIsExecutableScript(toExecute)
|
||||
const toExecute = executable ?? gradlew.gradleWrapperScript(root)
|
||||
|
||||
const status: number = await exec.exec(toExecute, args, {
|
||||
cwd: root,
|
||||
ignoreReturnCode: true
|
||||
|
@ -16,11 +15,3 @@ export async function executeGradleBuild(executable: string | undefined, root: s
|
|||
core.setFailed(`Gradle build failed: see console output for details`)
|
||||
}
|
||||
}
|
||||
|
||||
function verifyIsExecutableScript(toExecute: string): void {
|
||||
try {
|
||||
fs.accessSync(toExecute, fs.constants.X_OK)
|
||||
} catch (err) {
|
||||
throw new Error(`Gradle script '${toExecute}' is not executable.`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,23 +4,39 @@ import fs from 'fs'
|
|||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
export function wrapperScriptFilename(): string {
|
||||
return IS_WINDOWS ? 'gradlew.bat' : 'gradlew'
|
||||
return IS_WINDOWS ? 'gradlew.bat' : './gradlew'
|
||||
}
|
||||
|
||||
export function installScriptFilename(): string {
|
||||
return IS_WINDOWS ? 'gradle.bat' : 'gradle'
|
||||
}
|
||||
|
||||
export function locateGradleWrapperScript(buildRootDirectory: string): string {
|
||||
export function gradleWrapperScript(buildRootDirectory: string): string {
|
||||
validateGradleWrapper(buildRootDirectory)
|
||||
return path.resolve(buildRootDirectory, wrapperScriptFilename())
|
||||
return wrapperScriptFilename()
|
||||
}
|
||||
|
||||
function validateGradleWrapper(buildRootDirectory: string): void {
|
||||
const wrapperScript = path.resolve(buildRootDirectory, wrapperScriptFilename())
|
||||
verifyExists(wrapperScript, 'Gradle Wrapper script')
|
||||
verifyIsExecutableScript(wrapperScript)
|
||||
|
||||
const wrapperProperties = path.resolve(buildRootDirectory, 'gradle/wrapper/gradle-wrapper.properties')
|
||||
if (!fs.existsSync(wrapperProperties)) {
|
||||
verifyExists(wrapperProperties, 'Gradle wrapper properties file')
|
||||
}
|
||||
|
||||
function verifyExists(file: string, description: string): void {
|
||||
if (!fs.existsSync(file)) {
|
||||
throw new Error(
|
||||
`Cannot locate a Gradle wrapper properties file at '${wrapperProperties}'. Specify 'gradle-version' or 'gradle-executable' for projects without Gradle wrapper configured.`
|
||||
`Cannot locate ${description} at '${file}'. Specify 'gradle-version' or 'gradle-executable' for projects without Gradle wrapper configured.`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function verifyIsExecutableScript(toExecute: string): void {
|
||||
try {
|
||||
fs.accessSync(toExecute, fs.constants.X_OK)
|
||||
} catch (err) {
|
||||
throw new Error(`Gradle script '${toExecute}' is not executable.`)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue