fix(gradle): fix find root for projects (#27651)
<!-- 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 #
This commit is contained in:
parent
564834462e
commit
6cb0720009
@ -3,7 +3,7 @@
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "e2e/gradle",
|
||||
"projectType": "application",
|
||||
"implicitDependencies": ["eslint"],
|
||||
"implicitDependencies": ["gradle"],
|
||||
"// targets": "to see all targets run: nx show project e2e-gradle --web",
|
||||
"targets": {}
|
||||
}
|
||||
|
||||
@ -34,8 +34,8 @@ describe('Gradle', () => {
|
||||
|
||||
const buildOutput = runCLI('build app', { verbose: true });
|
||||
// app depends on list and utilities
|
||||
expect(buildOutput).toContain('nx run list:build');
|
||||
expect(buildOutput).toContain('nx run utilities:build');
|
||||
expect(buildOutput).toContain(':list:classes');
|
||||
expect(buildOutput).toContain(':utilities:classes');
|
||||
|
||||
checkFilesExist(
|
||||
`app/build/libs/app.jar`,
|
||||
@ -85,9 +85,9 @@ dependencies {
|
||||
return content;
|
||||
}
|
||||
);
|
||||
const buildOutput = runCLI('build app2', { verbose: true });
|
||||
// app2 depends on app
|
||||
expect(buildOutput).toContain('nx run app:build');
|
||||
expect(() => {
|
||||
runCLI('build app2', { verbose: true });
|
||||
}).not.toThrow();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@ -24,12 +24,18 @@ describe('processGradleDependencies', () => {
|
||||
'app',
|
||||
{
|
||||
projects: {
|
||||
'utilities/number-utils': {
|
||||
'number-utils': {
|
||||
root: 'utilities/number-utils',
|
||||
name: 'number-utils',
|
||||
},
|
||||
'utilities/string-utils': {
|
||||
'string-utils': {
|
||||
root: 'utilities/string-utils',
|
||||
name: 'string-utils',
|
||||
},
|
||||
utilities: {
|
||||
root: 'utilities',
|
||||
name: 'utilities',
|
||||
},
|
||||
},
|
||||
} as any,
|
||||
dependencies
|
||||
@ -68,13 +74,16 @@ describe('processGradleDependencies', () => {
|
||||
'app',
|
||||
{
|
||||
projects: {
|
||||
'utilities/number-utils': {
|
||||
'number-utils': {
|
||||
root: 'utilities/number-utils',
|
||||
name: 'number-utils',
|
||||
},
|
||||
'utilities/string-utils': {
|
||||
'string-utils': {
|
||||
root: 'utilities/string-utils',
|
||||
name: 'string-utils',
|
||||
},
|
||||
utilities: {
|
||||
root: 'utilities',
|
||||
name: 'utilities',
|
||||
},
|
||||
},
|
||||
|
||||
@ -35,7 +35,9 @@ export const createDependencies: CreateDependencies = async (
|
||||
|
||||
for (const gradleFile of gradleFiles) {
|
||||
const gradleProject = gradleFileToGradleProjectMap.get(gradleFile);
|
||||
const projectName = context.projects[dirname(gradleFile)].name;
|
||||
const projectName = Object.values(context.projects).find(
|
||||
(project) => project.root === dirname(gradleFile)
|
||||
)?.name;
|
||||
const depsFile = buildFileToDepsMap.get(gradleFile);
|
||||
|
||||
if (projectName && depsFile) {
|
||||
@ -125,11 +127,13 @@ export function processGradleDependencies(
|
||||
const targetProjectRoot = gradleProjectNameToProjectRoot.get(
|
||||
gradleProjectName
|
||||
) as string;
|
||||
const target = context.projects[targetProjectRoot]?.name;
|
||||
if (target) {
|
||||
const targetProjectName = Object.values(context.projects).find(
|
||||
(project) => project.root === targetProjectRoot
|
||||
)?.name;
|
||||
if (targetProjectName) {
|
||||
const dependency: RawProjectGraphDependency = {
|
||||
source: sourceProjectName,
|
||||
target,
|
||||
target: targetProjectName,
|
||||
type: DependencyType.static,
|
||||
sourceFile: gradleFile,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user