Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1302 fixes java fork options serialization issue and adds tmpdir to task properties #1313

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.FileSystemOperations;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.*;
import org.gradle.process.JavaForkOptions;
Expand All @@ -26,9 +28,6 @@ public abstract class PlantumlTask extends SourceTask {
@Inject
protected abstract FileSystemOperations getFileSystemOperations();

@Inject
protected abstract JavaForkOptionsFactory getJavaForkOptionsFactory();

@Classpath
public abstract ConfigurableFileCollection getPlantumlClasspath();

Expand All @@ -49,18 +48,23 @@ public abstract class PlantumlTask extends SourceTask {
public abstract Property<Boolean> getDeleteOutputBeforeBuild();

@Input
@Getter
@Setter
private JavaForkOptions forkOptions;
public abstract MapProperty<String, Object> getSystemProperties();

@Input
public abstract ListProperty<String> getJvmArgs();

@Input
public abstract Property<Boolean> getDebug();

@OutputDirectory
public abstract DirectoryProperty getTmpDir();

public PlantumlTask() {
this.setGroup("plantuml");
getWithMetadata().convention(true);
getIncludePattern().convention("**/*.puml");
getDeleteOutputBeforeBuild().convention(true);

forkOptions = getJavaForkOptionsFactory().newJavaForkOptions();
getForkOptions().systemProperty("java.awt.headless", true);
getTmpDir().set(getTemporaryDir());
}

@TaskAction
Expand All @@ -72,7 +76,25 @@ public void execute() {

WorkQueue workQueue = getWorkerExecutor().processIsolation(process -> {
process.getClasspath().from(getPlantumlClasspath());
getForkOptions().copyTo(process.getForkOptions());

process.forkOptions(javaForkOptions -> {

javaForkOptions.systemProperty("java.awt.headless", true);
javaForkOptions.systemProperty("java.io.tmpdir", getTmpDir().get().getAsFile().getAbsolutePath());

if (getSystemProperties().isPresent()) {
javaForkOptions.systemProperties(getSystemProperties().get());
}

if (getJvmArgs().isPresent()) {
javaForkOptions.jvmArgs(getJvmArgs().get());
}

if (getDebug().isPresent()) {
javaForkOptions.setDebug(getDebug().get());
}

});
});

for (File file : getSource().matching(p -> p.include(getIncludePattern().get()))) {
Expand Down
Loading