You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by cc...@apache.org on 2017/12/17 19:43:19 UTC
groovy git commit: Enable parallel builds
Repository: groovy
Updated Branches:
refs/heads/master 088b7190a -> 67090f98a
Enable parallel builds
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/67090f98
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/67090f98
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/67090f98
Branch: refs/heads/master
Commit: 67090f98a0cc90d82c2969e464e42ec98807d435
Parents: 088b719
Author: Cedric Champeau <cc...@apache.org>
Authored: Sun Dec 17 16:41:50 2017 +0100
Committer: Cedric Champeau <cc...@apache.org>
Committed: Sun Dec 17 20:42:54 2017 +0100
----------------------------------------------------------------------
build.gradle | 1 +
gradle.properties | 5 ++-
gradle/parallel-build-fixes.gradle | 57 +++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/67090f98/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index b99ccf0..1d61df1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -461,6 +461,7 @@ apply from: 'gradle/idea.gradle'
apply from: 'gradle/eclipse.gradle'
apply from: 'gradle/quality.gradle'
apply from: 'gradle/jdk9.gradle'
+apply from: 'gradle/parallel-build-fixes.gradle'
// If a local configuration file for tweaking the build is present, apply it
if (file('user.gradle').exists()) {
http://git-wip-us.apache.org/repos/asf/groovy/blob/67090f98/gradle.properties
----------------------------------------------------------------------
diff --git a/gradle.properties b/gradle.properties
index 54141a8..5265fe8 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -36,4 +36,7 @@ javaDoc_mx=1g
org.gradle.jvmargs=-Xms800m -Xmx1500m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
# enable the Gradle build cache
-org.gradle.caching=true
\ No newline at end of file
+org.gradle.caching=true
+
+# enable --parallel
+org.gradle.parallel=true
http://git-wip-us.apache.org/repos/asf/groovy/blob/67090f98/gradle/parallel-build-fixes.gradle
----------------------------------------------------------------------
diff --git a/gradle/parallel-build-fixes.gradle b/gradle/parallel-build-fixes.gradle
new file mode 100644
index 0000000..00eff8d
--- /dev/null
+++ b/gradle/parallel-build-fixes.gradle
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import groovy.transform.CompileStatic
+import org.gradle.api.execution.TaskExecutionListener
+
+import java.util.concurrent.Semaphore
+
+// This file contains fixes to make sure the build runs properly with --parallel
+
+// Asciidoctor JRuby is not thread-safe, we can only run one at a time
+gradle.taskGraph.addTaskExecutionListener(new MaxConcurrentTasksOfKind('org.asciidoctor.gradle.AsciidoctorTask'))
+
+// Limit the number of concurrent test tasks
+gradle.taskGraph.addTaskExecutionListener(new MaxConcurrentTasksOfKind('org.gradle.api.tasks.testing.Test', 2))
+
+
+/**
+ * Prevents tasks from a simple type to be executed concurrently
+ */
+@CompileStatic
+class MaxConcurrentTasksOfKind implements TaskExecutionListener {
+ private final Semaphore semaphore;
+ private final String clazz
+
+ MaxConcurrentTasksOfKind(String clazz, int maxConcurrent = 1) {
+ this.clazz = clazz
+ this.semaphore = new Semaphore(maxConcurrent)
+ }
+
+ void beforeExecute(Task task) {
+ if (task.class.name.startsWith(clazz)) {
+ semaphore.acquire()
+ }
+ }
+
+ void afterExecute(Task task, TaskState state) {
+ if (task.class.name.startsWith(clazz)) {
+ semaphore.release()
+ }
+ }
+}
\ No newline at end of file