5
5
import org .gradle .api .file .ConfigurableFileCollection ;
6
6
import org .gradle .api .file .DirectoryProperty ;
7
7
import org .gradle .api .file .FileSystemOperations ;
8
+ import org .gradle .api .provider .ListProperty ;
9
+ import org .gradle .api .provider .MapProperty ;
8
10
import org .gradle .api .provider .Property ;
9
11
import org .gradle .api .tasks .*;
10
12
import org .gradle .process .JavaForkOptions ;
@@ -26,9 +28,6 @@ public abstract class PlantumlTask extends SourceTask {
26
28
@ Inject
27
29
protected abstract FileSystemOperations getFileSystemOperations ();
28
30
29
- @ Inject
30
- protected abstract JavaForkOptionsFactory getJavaForkOptionsFactory ();
31
-
32
31
@ Classpath
33
32
public abstract ConfigurableFileCollection getPlantumlClasspath ();
34
33
@@ -49,18 +48,23 @@ public abstract class PlantumlTask extends SourceTask {
49
48
public abstract Property <Boolean > getDeleteOutputBeforeBuild ();
50
49
51
50
@ Input
52
- @ Getter
53
- @ Setter
54
- private JavaForkOptions forkOptions ;
51
+ public abstract MapProperty <String , Object > getSystemProperties ();
52
+
53
+ @ Input
54
+ public abstract ListProperty <String > getJvmArgs ();
55
+
56
+ @ Input
57
+ public abstract Property <Boolean > getDebug ();
58
+
59
+ @ OutputDirectory
60
+ public abstract DirectoryProperty getTmpDir ();
55
61
56
62
public PlantumlTask () {
57
63
this .setGroup ("plantuml" );
58
64
getWithMetadata ().convention (true );
59
65
getIncludePattern ().convention ("**/*.puml" );
60
66
getDeleteOutputBeforeBuild ().convention (true );
61
-
62
- forkOptions = getJavaForkOptionsFactory ().newJavaForkOptions ();
63
- getForkOptions ().systemProperty ("java.awt.headless" , true );
67
+ getTmpDir ().set (getTemporaryDir ());
64
68
}
65
69
66
70
@ TaskAction
@@ -72,7 +76,25 @@ public void execute() {
72
76
73
77
WorkQueue workQueue = getWorkerExecutor ().processIsolation (process -> {
74
78
process .getClasspath ().from (getPlantumlClasspath ());
75
- getForkOptions ().copyTo (process .getForkOptions ());
79
+
80
+ process .forkOptions (javaForkOptions -> {
81
+
82
+ javaForkOptions .systemProperty ("java.awt.headless" , true );
83
+ javaForkOptions .systemProperty ("java.io.tmpdir" , getTmpDir ().get ().getAsFile ().getAbsolutePath ());
84
+
85
+ if (getSystemProperties ().isPresent ()) {
86
+ javaForkOptions .systemProperties (getSystemProperties ().get ());
87
+ }
88
+
89
+ if (getJvmArgs ().isPresent ()) {
90
+ javaForkOptions .jvmArgs (getJvmArgs ().get ());
91
+ }
92
+
93
+ if (getDebug ().isPresent ()) {
94
+ javaForkOptions .setDebug (getDebug ().get ());
95
+ }
96
+
97
+ });
76
98
});
77
99
78
100
for (File file : getSource ().matching (p -> p .include (getIncludePattern ().get ()))) {
0 commit comments