File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed
src/main/groovy/nebula/plugin Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ dependencies {
3939 implementation ' org.clojure:clojure:1.10.3'
4040 implementation ' org.clojure:tools.namespace:1.1.0'
4141 implementation ' us.bpsm:edn-java:0.4.3'
42-
4342 testImplementation gradleTestKit()
4443 testImplementation ' com.netflix.nebula:nebula-publishing-plugin:5.+'
4544}
Original file line number Diff line number Diff line change 11package nebula.plugin.clojuresque.tasks
22
33import nebula.plugin.clojuresque.Util
4+ import nebula.plugin.utils.tasks.ConfigureUtil
45import org.gradle.api.file.ConfigurableFileCollection
56import org.gradle.api.model.ObjectFactory
67import org.gradle.api.tasks.*
@@ -28,6 +29,9 @@ abstract class ClojureRun extends ClojureSourceTask {
2829
2930 private final ObjectFactory objects
3031
32+ @Internal
33+ def jvmOptions = {}
34+
3135 @Inject
3236 ClojureRun (ExecOperations execOperations , ObjectFactory objects ) {
3337 this . execOperations = execOperations
@@ -51,6 +55,7 @@ abstract class ClojureRun extends ClojureSourceTask {
5155 execOperations. javaexec {
5256 setMainClass(" clojure.main" )
5357 args(' -' )
58+ ConfigureUtil . configure delegate, jvmOptions
5459 classpath = objectFactory. fileCollection(). from(
5560 this . srcDirs,
5661 this . classpath
Original file line number Diff line number Diff line change 1313package nebula.plugin.clojuresque.tasks
1414
1515import nebula.plugin.clojuresque.Util
16+ import nebula.plugin.utils.tasks.ConfigureUtil
1617import org.gradle.api.file.ConfigurableFileCollection
1718import org.gradle.api.model.ObjectFactory
1819import org.gradle.api.provider.ListProperty
@@ -53,6 +54,8 @@ abstract class ClojureTest extends ClojureSourceTask {
5354
5455 private final ObjectFactory objects
5556
57+ @Internal
58+ def jvmOptions = {}
5659
5760 @Inject
5861 ClojureTest (ExecOperations execOperations , ObjectFactory objects ) {
@@ -87,6 +90,7 @@ abstract class ClojureTest extends ClojureSourceTask {
8790 execOperations. javaexec {
8891 setMainClass(" clojure.main" )
8992 args(' -' )
93+ ConfigureUtil . configure delegate, jvmOptions
9094 classpath = objectFactory. fileCollection(). from(
9195 this . srcDirs,
9296 this . outputDir,
Original file line number Diff line number Diff line change 1+ package nebula.plugin.utils.tasks
2+
3+ /**
4+ * A utility class to help configuring objects.
5+ *
6+ * @author Meikel Brandmeyer
7+ */
8+ class ConfigureUtil {
9+ /**
10+ * Configures the <code >target</code> object. It sets it as the delegate
11+ * of the <code >configureFn</code> closure and calls the latter. Passes
12+ * the target object also as first argument to the closure should it
13+ * support it.
14+ *
15+ * @param target the object to configure
16+ * @param configureFn a closure to be executed with <code >target</code> as delegate
17+ * @return <code >target</code>
18+ */
19+ static configure (Object target , Closure configureFn = {}) {
20+ def fn = configureFn. clone()
21+
22+ fn. resolveStrategy = Closure . DELEGATE_FIRST
23+ fn. delegate = target
24+
25+ if (fn. maximumNumberOfParameters == 0 )
26+ fn. call()
27+ else
28+ fn. call(target)
29+
30+ target
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments