Skip to content

Commit 214fb87

Browse files
committed
Bring back jvmoptions
1 parent d41c195 commit 214fb87

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

src/main/groovy/nebula/plugin/clojuresque/tasks/ClojureRun.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package nebula.plugin.clojuresque.tasks
22

33
import nebula.plugin.clojuresque.Util
4+
import nebula.plugin.utils.tasks.ConfigureUtil
45
import org.gradle.api.file.ConfigurableFileCollection
56
import org.gradle.api.model.ObjectFactory
67
import 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

src/main/groovy/nebula/plugin/clojuresque/tasks/ClojureTest.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package nebula.plugin.clojuresque.tasks
1414

1515
import nebula.plugin.clojuresque.Util
16+
import nebula.plugin.utils.tasks.ConfigureUtil
1617
import org.gradle.api.file.ConfigurableFileCollection
1718
import org.gradle.api.model.ObjectFactory
1819
import 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,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

0 commit comments

Comments
 (0)