From 944d547a5850b153127786def08d354a553aa4a9 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Mon, 20 Nov 2023 07:45:04 +0900 Subject: [PATCH] reproduce code for issue 479 --- src/sbt-test/shading/jdk17/build.sbt | 19 +++++++++++++++++++ .../shading/jdk17/project/plugins.sbt | 7 +++++++ src/sbt-test/shading/jdk17/test | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 src/sbt-test/shading/jdk17/build.sbt create mode 100644 src/sbt-test/shading/jdk17/project/plugins.sbt create mode 100644 src/sbt-test/shading/jdk17/test diff --git a/src/sbt-test/shading/jdk17/build.sbt b/src/sbt-test/shading/jdk17/build.sbt new file mode 100644 index 00000000..c9d696c4 --- /dev/null +++ b/src/sbt-test/shading/jdk17/build.sbt @@ -0,0 +1,19 @@ +scalaVersion := "2.13.12" + +assembly / assemblyShadeRules := Seq( + ShadeRule.rename("example.A" -> "example.B").inProject +) + +TaskKey[Unit]("writeSealedJavaCodeIf17") := { + if (scala.util.Properties.isJavaAtLeast("17")) { + IO.write( + file("A.java"), + """package example; + + public sealed interface A { + final class X implements A {} + } + """ + ) + } +} diff --git a/src/sbt-test/shading/jdk17/project/plugins.sbt b/src/sbt-test/shading/jdk17/project/plugins.sbt new file mode 100644 index 00000000..fe8e573d --- /dev/null +++ b/src/sbt-test/shading/jdk17/project/plugins.sbt @@ -0,0 +1,7 @@ +{ + val pluginVersion = System.getProperty("plugin.version") + if (pluginVersion == null) + throw new RuntimeException("""|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) + else addSbtPlugin("com.eed3si9n" % "sbt-assembly" % pluginVersion) +} diff --git a/src/sbt-test/shading/jdk17/test b/src/sbt-test/shading/jdk17/test new file mode 100644 index 00000000..9a31b6de --- /dev/null +++ b/src/sbt-test/shading/jdk17/test @@ -0,0 +1,2 @@ +> writeSealedJavaCodeIf17 +> assembly