@nx/gradle
Version:
58 lines (57 loc) • 2.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.gradleConfigAndTestGlob = exports.gradleConfigGlob = exports.GRADLE_TEST_FILES = exports.GRALDEW_FILES = exports.GRADLE_BUILD_FILES = void 0;
exports.splitConfigFiles = splitConfigFiles;
const globs_1 = require("nx/src/utils/globs");
const node_path_1 = require("node:path");
exports.GRADLE_BUILD_FILES = new Set(['build.gradle', 'build.gradle.kts']);
exports.GRALDEW_FILES = new Set(['gradlew', 'gradlew.bat']);
exports.GRADLE_TEST_FILES = [
'**/src/test/java/**/*Test.java',
'**/src/test/kotlin/**/*Test.kt',
'**/src/test/java/**/*Tests.java',
'**/src/test/kotlin/**/*Tests.kt',
];
exports.gradleConfigGlob = (0, globs_1.combineGlobPatterns)(...Array.from(exports.GRADLE_BUILD_FILES).map((file) => `**/${file}`));
exports.gradleConfigAndTestGlob = (0, globs_1.combineGlobPatterns)(...Array.from(exports.GRADLE_BUILD_FILES), ...Array.from(exports.GRALDEW_FILES), ...Array.from(exports.GRADLE_BUILD_FILES).map((file) => `**/${file}`), ...Array.from(exports.GRALDEW_FILES).map((file) => `**/${file}`), ...exports.GRADLE_TEST_FILES);
/**
* This function split config files into build files, settings files, test files and project roots
* @param files list of files to split
* @returns object with buildFiles, gradlewFiles, testFiles and projectRoots
* For gradlewFiles, it will start with settings files and find the nearest gradlew file in the workspace
*/
function splitConfigFiles(files) {
const buildFiles = [];
const testFiles = [];
const gradlewFiles = [];
const projectRoots = new Set();
files.forEach((file) => {
const filename = (0, node_path_1.basename)(file);
const fileDirectory = (0, node_path_1.dirname)(file);
if (exports.GRADLE_BUILD_FILES.has(filename)) {
buildFiles.push(file);
projectRoots.add(fileDirectory);
}
else if (exports.GRALDEW_FILES.has(filename)) {
if (process.platform.startsWith('win')) {
if (filename === 'gradlew.bat') {
gradlewFiles.push(file);
}
}
else {
if (filename === 'gradlew') {
gradlewFiles.push(file);
}
}
}
else {
testFiles.push(file);
}
});
return {
buildFiles,
testFiles,
gradlewFiles,
projectRoots: Array.from(projectRoots),
};
}