UNPKG

@nx/gradle

Version:

The Nx Plugin for Gradle allows Gradle tasks to be run through Nx

61 lines (60 loc) 2.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.gradleConfigAndTestGlob = exports.gradleConfigGlob = exports.GRADLE_TEST_FILES = exports.GRADLE_VERSION_CATALOG_GLOB = exports.GRADLEW_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.GRADLEW_FILES = new Set(['gradlew', 'gradlew.bat']); exports.GRADLE_VERSION_CATALOG_GLOB = '**/gradle/*.versions.toml'; exports.GRADLE_TEST_FILES = [ '**/src/test/java/**/*Test.java', '**/src/test/kotlin/**/*Test.kt', '**/src/test/java/**/*Tests.java', '**/src/test/kotlin/**/*Tests.kt', '**/src/test/groovy/**/*Test.groovy', '**/src/test/groovy/**/*Tests.groovy', ]; 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.GRADLEW_FILES), ...Array.from(exports.GRADLE_BUILD_FILES).map((file) => `**/${file}`), ...Array.from(exports.GRADLEW_FILES).map((file) => `**/${file}`), ...exports.GRADLE_TEST_FILES, exports.GRADLE_VERSION_CATALOG_GLOB); /** * 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.GRADLEW_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), }; }