From 0de3b6ada451c6cccde2a0cbada7cb5a6da6ebf6 Mon Sep 17 00:00:00 2001 From: Dan Fox Date: Tue, 12 Jul 2022 17:52:46 +0100 Subject: [PATCH] Remove --enable-preview from gradle --- build.gradle | 5 +-- conjure-java-core/build.gradle | 2 - .../conjure/java/types/UnionGenerator.java | 4 +- .../conjure/java/types/Union2Tests.java | 43 ++++++++++--------- 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index ec70e82d3..b8c8c0016 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,6 @@ buildscript { repositories { mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } } gradlePluginPortal() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } } - mavenLocal() } dependencies { @@ -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' @@ -53,7 +52,6 @@ allprojects { repositories { mavenCentral() { metadataSources { mavenPom(); ignoreGradleMetadataRedirection() } } - mavenLocal() } configurations.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'] diff --git a/conjure-java-core/build.gradle b/conjure-java-core/build.gradle index c480bb3be..074c444ed 100644 --- a/conjure-java-core/build.gradle +++ b/conjure-java-core/build.gradle @@ -32,8 +32,6 @@ idea { } } -enablePreview = true // TODO(dfox): this is ugly - tasks.checkstyleIntegrationInput.enabled = false dependencies { diff --git a/conjure-java-core/src/main/java/com/palantir/conjure/java/types/UnionGenerator.java b/conjure-java-core/src/main/java/com/palantir/conjure/java/types/UnionGenerator.java index b8624b538..ddf204086 100644 --- a/conjure-java-core/src/main/java/com/palantir/conjure/java/types/UnionGenerator.java +++ b/conjure-java-core/src/main/java/com/palantir/conjure/java/types/UnionGenerator.java @@ -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(), diff --git a/conjure-java-core/src/test/java/com/palantir/conjure/java/types/Union2Tests.java b/conjure-java-core/src/test/java/com/palantir/conjure/java/types/Union2Tests.java index f123003ee..3a1a895f4 100644 --- a/conjure-java-core/src/test/java/com/palantir/conjure/java/types/Union2Tests.java +++ b/conjure-java-core/src/test/java/com/palantir/conjure/java/types/Union2Tests.java @@ -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 {