Skip to content

Commit

Permalink
fix(gradle): fix gradle plugin path (nrwl#22405)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Mar 20, 2024
1 parent a44475c commit 64b2396
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/gradle/src/generators/init/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('@nx/gradle:init', () => {
"classesTargetName": "classes",
"testTargetName": "test",
},
"plugin": "@nx/gradle/plugin",
"plugin": "@nx/gradle",
},
]
`);
Expand All @@ -49,15 +49,15 @@ describe('@nx/gradle:init', () => {
"classesTargetName": "classes",
"testTargetName": "test",
},
"plugin": "@nx/gradle/plugin",
"plugin": "@nx/gradle",
},
]
`);
});

it('should not add plugin if already in array', async () => {
updateNxJson(tree, {
plugins: ['@nx/gradle/plugin'],
plugins: ['@nx/gradle'],
});
await initGenerator(tree, {
skipFormat: true,
Expand All @@ -66,7 +66,7 @@ describe('@nx/gradle:init', () => {
const nxJson = readNxJson(tree);
expect(nxJson.plugins).toMatchInlineSnapshot(`
[
"@nx/gradle/plugin",
"@nx/gradle",
]
`);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/gradle/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function addPlugin(tree: Tree) {
if (!hasGradlePlugin(tree)) {
nxJson.plugins ??= [];
nxJson.plugins.push({
plugin: '@nx/gradle/plugin',
plugin: '@nx/gradle',
options: {
testTargetName: 'test',
classesTargetName: 'classes',
Expand Down
4 changes: 1 addition & 3 deletions packages/gradle/src/utils/has-gradle-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { readNxJson, Tree } from '@nx/devkit';
export function hasGradlePlugin(tree: Tree): boolean {
const nxJson = readNxJson(tree);
return !!nxJson.plugins?.some((p) =>
typeof p === 'string'
? p === '@nx/gradle/plugin'
: p.plugin === '@nx/gradle/plugin'
typeof p === 'string' ? p === '@nx/gradle' : p.plugin === '@nx/gradle'
);
}

0 comments on commit 64b2396

Please sign in to comment.