fix(gradle): fix gradle app deps (#27865)
<!-- 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/27819
This commit is contained in:
parent
5784b885bd
commit
2eb5592ac3
@ -32,9 +32,11 @@ describe('Gradle', () => {
|
||||
expect(projects).toContain('utilities');
|
||||
expect(projects).toContain(gradleProjectName);
|
||||
|
||||
const buildOutput = runCLI('build app', { verbose: true });
|
||||
let buildOutput = runCLI('build app', { verbose: true });
|
||||
// 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(
|
||||
@ -43,9 +45,14 @@ describe('Gradle', () => {
|
||||
`utilities/build/libs/utilities.jar`
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
runCLI(`build ${gradleProjectName}`, { verbose: true });
|
||||
}).not.toThrow();
|
||||
buildOutput = runCLI(`build ${gradleProjectName}`, { verbose: true });
|
||||
// root project depends on app, list and utilities
|
||||
expect(buildOutput).toContain('nx run app:build');
|
||||
expect(buildOutput).toContain(':app:classes');
|
||||
expect(buildOutput).toContain('nx run list:build');
|
||||
expect(buildOutput).toContain(':list:classes');
|
||||
expect(buildOutput).toContain('nx run utilities:build');
|
||||
expect(buildOutput).toContain(':utilities:classes');
|
||||
});
|
||||
|
||||
it('should track dependencies for new app', () => {
|
||||
@ -85,9 +92,11 @@ dependencies {
|
||||
return content;
|
||||
}
|
||||
);
|
||||
expect(() => {
|
||||
runCLI('build app2', { verbose: true });
|
||||
}).not.toThrow();
|
||||
|
||||
let buildOutput = runCLI('build app2', { verbose: true });
|
||||
// app2 depends on app
|
||||
expect(buildOutput).toContain('nx run app:build');
|
||||
expect(buildOutput).toContain(':app:classes');
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@ -11,8 +11,8 @@ antBuilderFactory: org.gradle.api.internal.project.DefaultAntBuilderFactory@5a5e
|
||||
artifacts: org.gradle.api.internal.artifacts.dsl.DefaultArtifactHandler_Decorated@3793af5a
|
||||
asDynamicObject: DynamicObject for root project 'My Application'
|
||||
baseClassLoaderScope: org.gradle.api.internal.initialization.DefaultClassLoaderScope@4dc8adab
|
||||
buildDir: /Users/emily/code/tmp/nx-android/build
|
||||
buildFile: /Users/emily/code/tmp/nx-android/build.gradle
|
||||
buildDir: /tmp/nx-android/build
|
||||
buildFile: /tmp/nx-android/build.gradle
|
||||
buildPath: :
|
||||
buildScriptSource: org.gradle.groovy.scripts.TextResourceScriptSource@622acc87
|
||||
buildTreePath: :
|
||||
@ -73,13 +73,13 @@ plugins: [org.gradle.api.plugins.HelpTasksPlugin$Inject@611c939a, org.gradle.bui
|
||||
processOperations: org.gradle.process.internal.DefaultExecActionFactory$DecoratingExecActionFactory@2bcbdbd2
|
||||
project: root project 'My Application'
|
||||
projectConfigurator: org.gradle.api.internal.project.BuildOperationCrossProjectConfigurator@e136ccb
|
||||
projectDir: /Users/emily/code/tmp/nx-android
|
||||
projectDir: /tmp/nx-android
|
||||
projectEvaluationBroadcaster: ProjectEvaluationListener broadcast
|
||||
projectEvaluator: org.gradle.configuration.project.LifecycleProjectEvaluator@4d3e0414
|
||||
projectPath: :
|
||||
projectReport: task ':projectReport'
|
||||
projectReportAll: task ':projectReportAll'
|
||||
projectReportDir: /Users/emily/code/tmp/nx-android/build/reports/project
|
||||
projectReportDir: /tmp/nx-android/build/reports/project
|
||||
projectReportDirName: project
|
||||
projects: [root project 'My Application']
|
||||
properties: {...}
|
||||
@ -89,7 +89,7 @@ publicType: org.gradle.api.plugins.ProjectReportsPluginConvention
|
||||
reporting: extension 'reporting'
|
||||
repositories: repository container
|
||||
resources: org.gradle.api.internal.resources.DefaultResourceHandler@3bfc23c4
|
||||
rootDir: /Users/emily/code/tmp/nx-android
|
||||
rootDir: /tmp/nx-android
|
||||
rootProject: root project 'My Application'
|
||||
rootScript: false
|
||||
script: false
|
||||
|
||||
@ -191,10 +191,16 @@ export function processProjectReports(
|
||||
absBuildDirPath = line.substring('buildDir: '.length);
|
||||
}
|
||||
if (line.startsWith('childProjects: ')) {
|
||||
const childProjects = line.substring('childProjects: {'.length); // remove curly braces {} around childProjects
|
||||
const childProjects = line.substring(
|
||||
'childProjects: {'.length,
|
||||
line.length - 1
|
||||
); // remove curly braces {} around childProjects
|
||||
gradleProjectToChildProjects.set(
|
||||
gradleProject,
|
||||
childProjects.split(',').map((c) => c.trim().split('=')[0]) // e.g. get project name from text like "app=project ':app', mylibrary=project ':mylibrary'"
|
||||
childProjects
|
||||
.split(',')
|
||||
.map((c) => c.trim().split('=')[0])
|
||||
.filter(Boolean) // e.g. get project name from text like "app=project ':app', mylibrary=project ':mylibrary'"
|
||||
);
|
||||
}
|
||||
if (line.includes('Dir: ')) {
|
||||
@ -228,7 +234,10 @@ export function processProjectReports(
|
||||
gradleFileToOutputDirsMap.set(buildFile, outputDirMap);
|
||||
gradleFileToGradleProjectMap.set(buildFile, gradleProject);
|
||||
gradleProjectToProjectName.set(gradleProject, projectName);
|
||||
gradleProjectNameToProjectRootMap.set(projectName, dirname(buildFile));
|
||||
gradleProjectNameToProjectRootMap.set(
|
||||
gradleProject,
|
||||
dirname(buildFile)
|
||||
);
|
||||
}
|
||||
if (line.endsWith('taskReport')) {
|
||||
const gradleProject = line.substring(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user