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