diff --git a/e2e/gradle/src/gradle-import.test.ts b/e2e/gradle/src/gradle-import.test.ts index 18f14d75d6..67cbe04d78 100644 --- a/e2e/gradle/src/gradle-import.test.ts +++ b/e2e/gradle/src/gradle-import.test.ts @@ -184,6 +184,12 @@ describe('Nx Import Gradle', () => { `${directory}/gradlew`, `${directory}/gradlew.bat` ); + const nxJson = readJson('nx.json'); + const gradlePlugin = nxJson.plugins.find( + (plugin) => plugin.plugin === '@nx/gradle' + ); + gradlePlugin.exclude = []; + updateJson('nx.json', () => nxJson); expect(() => { runCLI(`show projects`); runCLI('build groovy-app'); diff --git a/packages/gradle/src/utils/get-project-report-lines.ts b/packages/gradle/src/utils/get-project-report-lines.ts index 319b4d40d9..3c5ae4606b 100644 --- a/packages/gradle/src/utils/get-project-report-lines.ts +++ b/packages/gradle/src/utils/get-project-report-lines.ts @@ -22,17 +22,7 @@ export async function getProjectReportLines( ): Promise { let projectReportBuffer: Buffer; - // if there is no build.gradle or build.gradle.kts file, we cannot run the projectReport nor projectReportAll task - if ( - !existsSync(join(dirname(gradlewFile), 'build.gradle')) && - !existsSync(join(dirname(gradlewFile), 'build.gradle.kts')) - ) { - logger.warn( - `Could not find build file near ${gradlewFile}. Please run 'nx generate @nx/gradle:init' to generate the necessary tasks.` - ); - return []; - } - + // Attempt to run projectReport or projectReportAll task, regardless of build.gradle or build.gradle.kts location try { projectReportBuffer = await execGradleAsync(gradlewFile, [ 'projectReportAll', diff --git a/packages/nx/src/command-line/init/implementation/check-compatible-with-plugins.ts b/packages/nx/src/command-line/init/implementation/check-compatible-with-plugins.ts index 3f2ccf40c2..9cb3d51121 100644 --- a/packages/nx/src/command-line/init/implementation/check-compatible-with-plugins.ts +++ b/packages/nx/src/command-line/init/implementation/check-compatible-with-plugins.ts @@ -1,5 +1,5 @@ import { existsSync } from 'node:fs'; -import { join } from 'node:path'; +import { join, relative } from 'node:path'; import { bold } from 'chalk'; import { NxJsonConfiguration } from '../../../config/nx-json'; @@ -83,7 +83,13 @@ function findPluginAndFilesWithError( }, ]; } - excludeFiles = excludeFiles.filter(Boolean); + excludeFiles = excludeFiles.filter(Boolean).map((excludeFile) => { + const file = excludeFile.file; + excludeFile.file = file.startsWith(workspaceRoot) + ? relative(workspaceRoot, file) + : file; + return excludeFile; + }); return { pluginIndex, excludeFiles, diff --git a/packages/nx/src/project-graph/utils/project-configuration-utils.ts b/packages/nx/src/project-graph/utils/project-configuration-utils.ts index 03acafe6b7..7b259671cf 100644 --- a/packages/nx/src/project-graph/utils/project-configuration-utils.ts +++ b/packages/nx/src/project-graph/utils/project-configuration-utils.ts @@ -409,7 +409,7 @@ export async function createProjectConfigurationsWithPlugins( e : // This represents a single plugin erroring out with a hard error. new AggregateCreateNodesError([[null, e]], []); - if (pluginIndex) { + if (pluginIndex !== undefined) { error.pluginIndex = pluginIndex; } formatAggregateCreateNodesError(error, pluginName);