From 132b8e2740b823763493e07e2062c11b4e7cf8ed Mon Sep 17 00:00:00 2001 From: magdziarek Date: Mon, 13 Feb 2023 09:40:22 +0100 Subject: [PATCH] feat: allow gradle daemon on unix --- lib/index.ts | 3 +- test/functional/gradle-plugin.spec.ts | 171 ++++++++++++++------------ 2 files changed, 91 insertions(+), 83 deletions(-) diff --git a/lib/index.ts b/lib/index.ts index 9521116..c6b3fd0 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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'); } diff --git a/test/functional/gradle-plugin.spec.ts b/test/functional/gradle-plugin.spec.ts index e7032f1..6280397 100644 --- a/test/functional/gradle-plugin.spec.ts +++ b/test/functional/gradle-plugin.spec.ts @@ -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 () => { @@ -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 () => { @@ -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 () => { @@ -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( @@ -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, ); @@ -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', () => { @@ -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', + ]), + ); }); });