Skip to content

Commit

Permalink
Remove --enable-preview from gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdanfox committed Jul 12, 2022
1 parent 64543d0 commit 0de3b6a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ buildscript {
repositories {
mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } }
gradlePluginPortal() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } }
mavenLocal()
}

dependencies {
Expand All @@ -27,7 +26,7 @@ buildscript {
classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.11.0'
classpath 'com.palantir.gradle.conjure:gradle-conjure:5.28.0'
classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.25.0'
classpath 'com.palantir.baseline:gradle-baseline-java:9.9.9'
classpath 'com.palantir.baseline:gradle-baseline-java:4.147.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.15.0'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.6.0'
Expand All @@ -53,7 +52,6 @@ allprojects {

repositories {
mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } }
mavenLocal()
}

configurations.all {
Expand All @@ -75,7 +73,6 @@ subprojects {
apply plugin: 'java-library'
apply plugin: 'org.inferred.processors'
apply plugin: 'com.palantir.baseline-class-uniqueness'
apply plugin: 'com.palantir.baseline-enable-preview-flag'

tasks.withType(JavaCompile) {
options.compilerArgs += ['-Werror']
Expand Down
2 changes: 0 additions & 2 deletions conjure-java-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ idea {
}
}

enablePreview = true // TODO(dfox): this is ugly

tasks.checkstyleIntegrationInput.enabled = false

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,9 +1014,7 @@ private static MethodSpec createWrapperAcceptMethod(
private static ClassName wrapperClass(ClassName unionClass, FieldName memberTypeName, Options options) {
if (options.sealedUnions()) {
return ClassName.get(
unionClass.packageName(),
unionClass.simpleName(),
StringUtils.capitalize(memberTypeName.get()));
unionClass.packageName(), unionClass.simpleName(), StringUtils.capitalize(memberTypeName.get()));
} else {
return ClassName.get(
unionClass.packageName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,28 @@ void record_equality() {
assertThat(foo.equals(helloAgain)).isTrue();
}

@Test
void switch_statement_compiles() {
Union2 myUnion = Union2.foo("hello");
switch (myUnion) {
case Union2.Foo foo -> System.out.println(foo.getValue());
case Union2.Bar bar -> System.out.println(bar.getValue());
case Union2.Baz baz -> System.out.println(baz.getValue());
case Union2.UnknownVariant unknownWrapper -> System.out.println(unknownWrapper);
}
}

@Test
void throwOnUnknown_allows_narrowing_to_a_specific_subtype() {
Union2 myUnion = Union2.foo("hello");
Union2.Known narrowedSubtype = myUnion.throwOnUnknown();
switch (narrowedSubtype) {
case Union2.Foo foo -> System.out.println(foo.getValue());
case Union2.Bar bar -> System.out.println(bar.getValue());
case Union2.Baz baz -> System.out.println(baz.getValue());
}
}
// These tests require Java 17 AND --enable-preview, see https://github.com/palantir/gradle-baseline/pull/2319
// @Test
// void switch_statement_compiles() {
// Union2 myUnion = Union2.foo("hello");
// switch (myUnion) {
// case Union2.Foo foo -> System.out.println(foo.getValue());
// case Union2.Bar bar -> System.out.println(bar.getValue());
// case Union2.Baz baz -> System.out.println(baz.getValue());
// case Union2.UnknownVariant unknownWrapper -> System.out.println(unknownWrapper);
// }
// }
//
// @Test
// void throwOnUnknown_allows_narrowing_to_a_specific_subtype() {
// Union2 myUnion = Union2.foo("hello");
// Union2.Known narrowedSubtype = myUnion.throwOnUnknown();
// switch (narrowedSubtype) {
// case Union2.Foo foo -> System.out.println(foo.getValue());
// case Union2.Bar bar -> System.out.println(bar.getValue());
// case Union2.Baz baz -> System.out.println(baz.getValue());
// }
// }

@Test
void serialization() throws JsonProcessingException {
Expand Down

0 comments on commit 0de3b6a

Please sign in to comment.