fix(gradle): fix gradle not working for spring (#23130)
<!-- 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` --> ## 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
e15720ba4f
commit
35f0618347
@ -39,6 +39,10 @@ describe('Gradle', () => {
|
|||||||
`list/build/libs/list.jar`,
|
`list/build/libs/list.jar`,
|
||||||
`utilities/build/libs/utilities.jar`
|
`utilities/build/libs/utilities.jar`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(() => {
|
||||||
|
runCLI(`build ${gradleProjectName}`, { verbose: true });
|
||||||
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should track dependencies for new app', () => {
|
it('should track dependencies for new app', () => {
|
||||||
|
|||||||
@ -82,7 +82,7 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
"targets": {
|
"targets": {
|
||||||
"test": {
|
"test": {
|
||||||
"cache": false,
|
"cache": false,
|
||||||
"command": "../gradlew test",
|
"command": "./gradlew proj:test",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"classes",
|
"classes",
|
||||||
],
|
],
|
||||||
@ -95,9 +95,6 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
"gradle",
|
"gradle",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"options": {
|
|
||||||
"cwd": "proj",
|
|
||||||
},
|
|
||||||
"outputs": undefined,
|
"outputs": undefined,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -147,7 +144,7 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
"targets": {
|
"targets": {
|
||||||
"test": {
|
"test": {
|
||||||
"cache": false,
|
"cache": false,
|
||||||
"command": "../../../gradlew test",
|
"command": "./gradlew proj:test",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"classes",
|
"classes",
|
||||||
],
|
],
|
||||||
@ -160,9 +157,6 @@ describe('@nx/gradle/plugin', () => {
|
|||||||
"gradle",
|
"gradle",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"options": {
|
|
||||||
"cwd": "nested/nested/proj",
|
|
||||||
},
|
|
||||||
"outputs": undefined,
|
"outputs": undefined,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import { existsSync } from 'node:fs';
|
|||||||
import { dirname, join } from 'node:path';
|
import { dirname, join } from 'node:path';
|
||||||
import { projectGraphCacheDirectory } from 'nx/src/utils/cache-directory';
|
import { projectGraphCacheDirectory } from 'nx/src/utils/cache-directory';
|
||||||
|
|
||||||
import { getGradleRelativePath } from '../utils/exec-gradle';
|
import { getGradleExecFile } from '../utils/exec-gradle';
|
||||||
import { getGradleReport } from '../utils/get-gradle-report';
|
import { getGradleReport } from '../utils/get-gradle-report';
|
||||||
|
|
||||||
const cacheableTaskType = new Set(['Build', 'Verification']);
|
const cacheableTaskType = new Set(['Build', 'Verification']);
|
||||||
@ -126,10 +126,10 @@ export const createNodes: CreateNodes<GradlePluginOptions> = [
|
|||||||
|
|
||||||
const { targets, targetGroups } = createGradleTargets(
|
const { targets, targetGroups } = createGradleTargets(
|
||||||
tasks,
|
tasks,
|
||||||
projectRoot,
|
|
||||||
options,
|
options,
|
||||||
context,
|
context,
|
||||||
outputDirs
|
outputDirs,
|
||||||
|
gradleProject
|
||||||
);
|
);
|
||||||
const project = {
|
const project = {
|
||||||
name: projectName,
|
name: projectName,
|
||||||
@ -155,10 +155,10 @@ export const createNodes: CreateNodes<GradlePluginOptions> = [
|
|||||||
|
|
||||||
function createGradleTargets(
|
function createGradleTargets(
|
||||||
tasks: GradleTask[],
|
tasks: GradleTask[],
|
||||||
projectRoot: string,
|
|
||||||
options: GradlePluginOptions | undefined,
|
options: GradlePluginOptions | undefined,
|
||||||
context: CreateNodesContext,
|
context: CreateNodesContext,
|
||||||
outputDirs: Map<string, string>
|
outputDirs: Map<string, string>,
|
||||||
|
gradleProject: string
|
||||||
): {
|
): {
|
||||||
targetGroups: Record<string, string[]>;
|
targetGroups: Record<string, string[]>;
|
||||||
targets: Record<string, TargetConfiguration>;
|
targets: Record<string, TargetConfiguration>;
|
||||||
@ -172,12 +172,9 @@ function createGradleTargets(
|
|||||||
|
|
||||||
const outputs = outputDirs.get(task.name);
|
const outputs = outputDirs.get(task.name);
|
||||||
targets[targetName] = {
|
targets[targetName] = {
|
||||||
command: `${getGradleRelativePath(
|
command: `${getGradleExecFile()} ${
|
||||||
join(context.workspaceRoot, projectRoot)
|
gradleProject ? gradleProject + ':' : ''
|
||||||
)} ${task.name}`,
|
}${task.name}`,
|
||||||
options: {
|
|
||||||
cwd: projectRoot,
|
|
||||||
},
|
|
||||||
cache: cacheableTaskType.has(task.type),
|
cache: cacheableTaskType.has(task.type),
|
||||||
inputs: inputsMap[task.name],
|
inputs: inputsMap[task.name],
|
||||||
outputs: outputs ? [outputs] : undefined,
|
outputs: outputs ? [outputs] : undefined,
|
||||||
|
|||||||
@ -29,15 +29,8 @@ export function getGradleBinaryPath(): string {
|
|||||||
return gradleBinaryPath;
|
return gradleBinaryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGradleRelativePath(path: string): string {
|
export function getGradleExecFile(): string {
|
||||||
const gradleBinaryPath = getGradleBinaryPath();
|
return process.platform.startsWith('win') ? '.\\gradlew.bat' : './gradlew';
|
||||||
let relativePath = relative(path, gradleBinaryPath);
|
|
||||||
if (relativePath.startsWith('gradlew')) {
|
|
||||||
relativePath = process.platform.startsWith('win')
|
|
||||||
? `.\\${relativePath}`
|
|
||||||
: `./${relativePath}`;
|
|
||||||
}
|
|
||||||
return relativePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function execGradleAsync(
|
export function execGradleAsync(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user