Skip to content

Commit

Permalink
Merge pull request #253 from snyk/feat/only-block-daemon-on-windows
Browse files Browse the repository at this point in the history
feat: allow gradle daemon on unix
  • Loading branch information
ola magdziarek authored Feb 13, 2023
2 parents 6758a55 + 132b8e2 commit 73f5458
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 83 deletions.
3 changes: 2 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ function buildArgs(
args.push('--init-script', formattedInitScript);
}

if (!options.daemon) {
const isWin = /^win/.test(os.platform());
if (isWin && !options.daemon) {
args.push('--no-daemon');
}

Expand Down
171 changes: 89 additions & 82 deletions test/functional/gradle-plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ describe('Gradle Plugin', () => {
{},
gradleVersion,
);
expect(result).toEqual([
'snykResolvedDepsJson',
'-q',
'--no-daemon',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
]);
expect(result).toEqual(
expect.arrayContaining([
'snykResolvedDepsJson',
'-q',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
]),
);
});

it('check build args with array (new configuration arg)', async () => {
Expand All @@ -35,19 +36,20 @@ describe('Gradle Plugin', () => {
},
gradleVersion,
);
expect(result).toEqual([
'snykResolvedDepsJson',
'-q',
`-Pconfiguration=confRegex`,
'--no-daemon',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
'--build-file',
'build.gradle',
]);
expect(result).toEqual(
expect.arrayContaining([
'snykResolvedDepsJson',
'-q',
`-Pconfiguration=confRegex`,
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
'--build-file',
'build.gradle',
]),
);
});

it('check build args with array (new configuration arg) with --deamon', async () => {
Expand All @@ -62,18 +64,20 @@ describe('Gradle Plugin', () => {
},
gradleVersion,
);
expect(result).toEqual([
'snykResolvedDepsJson',
'-q',
`-Pconfiguration=confRegex`,
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
'--build-file',
'build.gradle',
]);
expect(result).toEqual(
expect.arrayContaining([
'snykResolvedDepsJson',
'-q',
`-Pconfiguration=confRegex`,
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
'--build-file',
'build.gradle',
]),
);
});

it('check build args with array (legacy configuration arg)', async () => {
Expand All @@ -86,19 +90,20 @@ describe('Gradle Plugin', () => {
},
gradleVersion,
);
expect(result).toEqual([
'snykResolvedDepsJson',
'-q',
'--no-daemon',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
'--build-file',
'build.gradle',
`-Pconfiguration=^compile$`,
]);
expect(result).toEqual(
expect.arrayContaining([
'snykResolvedDepsJson',
'-q',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
'--build-file',
'build.gradle',
`-Pconfiguration=^compile$`,
]),
);
});

it(
Expand All @@ -114,19 +119,19 @@ describe('Gradle Plugin', () => {
},
gradleVersion,
);
expect(result).toEqual([
'snykResolvedDepsJson',
'-q',
'--no-daemon',

'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-I',
'/tmp/init.gradle',
'--build-file',
'build.gradle',
`-Pconfiguration=^compile$`,
]);
expect(result).toEqual(
expect.arrayContaining([
'snykResolvedDepsJson',
'-q',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-I',
'/tmp/init.gradle',
'--build-file',
'build.gradle',
`-Pconfiguration=^compile$`,
]),
);
},
JEST_TIMEOUT,
);
Expand All @@ -141,16 +146,17 @@ describe('Gradle Plugin', () => {
},
gradleVersion,
);
expect(result).toEqual([
'snykResolvedDepsJson',
'-q',
'--no-daemon',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
]);
expect(result).toEqual(
expect.arrayContaining([
'snykResolvedDepsJson',
'-q',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
]),
);
});

it('make sure configuration cache is switched off for Gradle 7', () => {
Expand All @@ -161,16 +167,17 @@ describe('Gradle Plugin', () => {
{},
'Gradle 7',
);
expect(result).toEqual([
'snykResolvedDepsJson',
'-q',
'--no-daemon',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
'--no-configuration-cache',
]);
expect(result).toEqual(
expect.arrayContaining([
'snykResolvedDepsJson',
'-q',
'-Dorg.gradle.parallel=',
'-Dorg.gradle.console=plain',
'-PonlySubProject=.',
'-I',
'/tmp/init.gradle',
'--no-configuration-cache',
]),
);
});
});

0 comments on commit 73f5458

Please sign in to comment.