Skip to content

Commit

Permalink
Automatically wire up the --enable-preview option if necessary (#1033)
Browse files Browse the repository at this point in the history
sls-packaging will automatically include the `--enable-preview` jvm arg in launcher-static.yml if `com.palantir.baseline-enable-preview-flag` is applied.
iamdanfox authored Nov 18, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5301c96 commit 730a9ad
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-1033.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: feature
feature:
description: sls-packaging will automatically include the `--enable-preview` jvm
arg in launcher-static.yml if `com.palantir.baseline-enable-preview-flag` is applied.
links:
- https://github.com/palantir/sls-packaging/pull/1033
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
import com.palantir.gradle.dist.tasks.ConfigTarTask;
import com.palantir.gradle.dist.tasks.CreateManifestTask;
import java.io.File;
import java.util.Collections;
import java.util.stream.Collectors;
import org.gradle.api.Action;
import org.gradle.api.InvalidUserCodeException;
@@ -71,6 +72,19 @@ public void apply(Project project) {
JavaServiceDistributionExtension distributionExtension =
project.getExtensions().create("distribution", JavaServiceDistributionExtension.class, project);

// In baseline 3.52.0 we added this new plugin as a one-liner to add the --enable-preview flag wherever
// necessary (https://github.com/palantir/gradle-baseline/pull/1549). We're using the extraProperties thing to
// avoid taking a compile dependency on baseline.
project.getPlugins().withId("com.palantir.baseline-enable-preview-flag", _withId -> {
distributionExtension.defaultJvmOpts(project.provider(() -> {
Provider<Boolean> enablePreview = (Provider<Boolean>) project.getExtensions()
.getExtraProperties()
.getProperties()
.get("enablePreview");
return enablePreview.get() ? Collections.singletonList("--enable-preview") : Collections.emptyList();
}));
});

// Set default configuration to look for product dependencies to be runtimeClasspath
distributionExtension.setProductDependenciesConfig(
project.getConfigurations().getByName("runtimeClasspath"));

0 comments on commit 730a9ad

Please sign in to comment.