fix(gradle): change gradle glob to include root gradlew (#29206)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes https://github.com/nrwl/nx/issues/28865
This commit is contained in:
parent
e9a07da4ac
commit
7328a8dae4
127
packages/gradle/plugin.spec.ts
Normal file
127
packages/gradle/plugin.spec.ts
Normal file
@ -0,0 +1,127 @@
|
||||
import { CreateNodesContext } from '@nx/devkit';
|
||||
import { TempFs } from '@nx/devkit/internal-testing-utils';
|
||||
import { createNodesV2 } from './plugin';
|
||||
import { type GradleReport } from './src/utils/get-gradle-report';
|
||||
|
||||
let gradleReport: GradleReport;
|
||||
jest.mock('./src/utils/get-gradle-report', () => {
|
||||
return {
|
||||
GRADLE_BUILD_FILES: new Set(['build.gradle', 'build.gradle.kts']),
|
||||
populateGradleReport: jest.fn().mockImplementation(() => void 0),
|
||||
getCurrentGradleReport: jest.fn().mockImplementation(() => gradleReport),
|
||||
};
|
||||
});
|
||||
|
||||
describe('@nx/gradle/plugin', () => {
|
||||
let createNodesFunction = createNodesV2[1];
|
||||
let context: CreateNodesContext;
|
||||
let tempFs: TempFs;
|
||||
|
||||
beforeEach(async () => {
|
||||
tempFs = new TempFs('gradle-plugin');
|
||||
gradleReport = {
|
||||
gradleFileToGradleProjectMap: new Map<string, string>([
|
||||
['proj/build.gradle', 'proj'],
|
||||
]),
|
||||
buildFileToDepsMap: new Map<string, string>(),
|
||||
gradleFileToOutputDirsMap: new Map<string, Map<string, string>>([
|
||||
['proj/build.gradle', new Map([['build', 'build']])],
|
||||
]),
|
||||
gradleProjectToTasksTypeMap: new Map<string, Map<string, string>>([
|
||||
['proj', new Map([['test', 'Verification']])],
|
||||
]),
|
||||
gradleProjectToProjectName: new Map<string, string>([['proj', 'proj']]),
|
||||
gradleProjectNameToProjectRootMap: new Map<string, string>([
|
||||
['proj', 'proj'],
|
||||
]),
|
||||
gradleProjectToChildProjects: new Map<string, string[]>(),
|
||||
};
|
||||
context = {
|
||||
nxJsonConfiguration: {
|
||||
namedInputs: {
|
||||
default: ['{projectRoot}/**/*'],
|
||||
production: ['!{projectRoot}/**/*.spec.ts'],
|
||||
},
|
||||
},
|
||||
workspaceRoot: tempFs.tempDir,
|
||||
configFiles: [],
|
||||
};
|
||||
tempFs.createFileSync('package.json', JSON.stringify({ name: 'repo' }));
|
||||
tempFs.createFileSync(
|
||||
'my-app/project.json',
|
||||
JSON.stringify({ name: 'my-app' })
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetModules();
|
||||
tempFs.cleanup();
|
||||
tempFs = null;
|
||||
});
|
||||
|
||||
it('should create nodes', async () => {
|
||||
tempFs.createFileSync('gradlew', '');
|
||||
|
||||
const nodes = await createNodesFunction(
|
||||
['gradlew', 'proj/build.gradle'],
|
||||
undefined,
|
||||
context
|
||||
);
|
||||
|
||||
expect(nodes).toMatchInlineSnapshot(`
|
||||
[
|
||||
[
|
||||
"proj/build.gradle",
|
||||
{
|
||||
"projects": {
|
||||
"proj": {
|
||||
"metadata": {
|
||||
"targetGroups": {
|
||||
"Verification": [
|
||||
"test",
|
||||
],
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
"name": "proj",
|
||||
"targets": {
|
||||
"test": {
|
||||
"cache": true,
|
||||
"command": "./gradlew proj:test",
|
||||
"dependsOn": [
|
||||
"testClasses",
|
||||
],
|
||||
"inputs": [
|
||||
"default",
|
||||
"^production",
|
||||
],
|
||||
"metadata": {
|
||||
"help": {
|
||||
"command": "./gradlew help --task proj:test",
|
||||
"example": {
|
||||
"options": {
|
||||
"args": [
|
||||
"--rerun",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
"technologies": [
|
||||
"gradle",
|
||||
],
|
||||
},
|
||||
"options": {
|
||||
"cwd": ".",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
]
|
||||
`);
|
||||
});
|
||||
});
|
||||
@ -15,6 +15,8 @@ export const gradleConfigGlob = combineGlobPatterns(
|
||||
);
|
||||
|
||||
export const gradleConfigAndTestGlob = combineGlobPatterns(
|
||||
...Array.from(GRADLE_BUILD_FILES),
|
||||
...Array.from(GRALDEW_FILES),
|
||||
...Array.from(GRADLE_BUILD_FILES).map((file) => `**/${file}`),
|
||||
...Array.from(GRALDEW_FILES).map((file) => `**/${file}`),
|
||||
...GRADLE_TEST_FILES
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user