build: match Gradle maxWorkers and Test maxParallelForks

Use 1 if org.gradle.parallel is disabled


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/c3b62479
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/c3b62479
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/c3b62479

Branch: refs/heads/develop
Commit: c3b62479a37ca16775dad38b3c7f3f8c2dbc5ab2
Parents: 86b89c6
Author: Paul Merlin <[email protected]>
Authored: Sat Nov 19 16:32:25 2016 +0100
Committer: Paul Merlin <[email protected]>
Committed: Sat Nov 19 16:46:31 2016 +0100

----------------------------------------------------------------------
 .../main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy  | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/c3b62479/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy
----------------------------------------------------------------------
diff --git 
a/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy 
b/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy
index abd4b4f..2563abe 100644
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy
@@ -113,12 +113,16 @@ class AllProjectsPlugin implements Plugin<Project>
 
   private static void configureTest( Project project )
   {
+    // Match --max-workers and Test maxParallelForks, use 1 if parallel is 
disabled
+    def parallel = 
project.gradle.startParameter.parallelProjectExecutionEnabled
+    def maxTestWorkers = ( parallel ? 
project.gradle.startParameter.maxWorkerCount : 1 ) as int
     // The space in the directory name is intentional
     def allTestsDir = project.file( "$project.buildDir/tmp/test files" )
     project.tasks.withType( Test ) { Test testTask ->
       testTask.onlyIf { !project.hasProperty( 'skipTests' ) }
       testTask.testLogging.info.exceptionFormat = TestExceptionFormat.FULL
       testTask.maxHeapSize = '1g'
+      testTask.maxParallelForks = maxTestWorkers
       testTask.systemProperties = [ 'proxySet' : System.properties[ 'proxySet' 
],
                                     'proxyHost': System.properties[ 
'proxyHost' ],
                                     'proxyPort': System.properties[ 
'proxyPort' ] ]

Reply via email to