-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gradle): change gradle glob to include root gradlew
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": ".", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
] | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters