From c37940d0754661a61b8978271ee34402d0b2d0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Sat, 4 Mar 2023 18:17:12 +0100 Subject: [PATCH 1/8] Reproduce issue with Smithy files in jars with urlencoded paths --- .../sbt-test/codegen-plugin/special-imports/build.sbt | 11 +++++++++++ .../special-imports/project/build.properties | 1 + .../special-imports/project/plugins.sbt | 9 +++++++++ .../special-imports/src/main/scala/Main.scala | 3 +++ .../src/sbt-test/codegen-plugin/special-imports/test | 2 ++ 5 files changed, 26 insertions(+) create mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt create mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/build.properties create mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/plugins.sbt create mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala create mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/test diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt new file mode 100644 index 000000000..da4fbb5cb --- /dev/null +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt @@ -0,0 +1,11 @@ +lazy val root = project + .in(file(".")) + .enablePlugins(Smithy4sCodegenPlugin) + .settings( + scalaVersion := "2.13.10", + libraryDependencies += "com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value, + + // 0.0.1-SNAPSHOT works fine because the file path doesn't have urlencoded characters + libraryDependencies += "org.polyvariant" %% "test-library-core" % "0.0.1+123-SNAPSHOT", + resolvers ++= Resolver.sonatypeOssRepos("snapshots") + ) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/build.properties b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/build.properties new file mode 100644 index 000000000..46e43a97e --- /dev/null +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.8.2 diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/plugins.sbt b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/plugins.sbt new file mode 100644 index 000000000..b8589b92c --- /dev/null +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/plugins.sbt @@ -0,0 +1,9 @@ +sys.props.get("plugin.version") match { + case Some(x) => + addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % x) + case _ => + sys.error( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +} diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala new file mode 100644 index 000000000..285768310 --- /dev/null +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala @@ -0,0 +1,3 @@ +object Main { + testlibrary.MyString("hello") +} diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/test new file mode 100644 index 000000000..66db6d200 --- /dev/null +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/test @@ -0,0 +1,2 @@ +# check if smithy4sCodegen works +> root/compile From c47e322c442ac86c847cda8f9b5d048ada3174b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Sat, 4 Mar 2023 18:20:07 +0100 Subject: [PATCH 2/8] Smithy4s scope --- .../src/sbt-test/codegen-plugin/special-imports/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt index da4fbb5cb..57e7d83ad 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt @@ -6,6 +6,6 @@ lazy val root = project libraryDependencies += "com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value, // 0.0.1-SNAPSHOT works fine because the file path doesn't have urlencoded characters - libraryDependencies += "org.polyvariant" %% "test-library-core" % "0.0.1+123-SNAPSHOT", + libraryDependencies += "org.polyvariant" %% "test-library-core" % "0.0.1+123-SNAPSHOT" % Smithy4s, resolvers ++= Resolver.sonatypeOssRepos("snapshots") ) From 3016060f972e505b640845c0f7bdd3e84750b10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Sat, 4 Mar 2023 18:58:26 +0100 Subject: [PATCH 3/8] Add tests for ModelLoader --- .../codegen/internals/ModelLoaderSpec.scala | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 modules/codegen/test/src/smithy4s/codegen/internals/ModelLoaderSpec.scala diff --git a/modules/codegen/test/src/smithy4s/codegen/internals/ModelLoaderSpec.scala b/modules/codegen/test/src/smithy4s/codegen/internals/ModelLoaderSpec.scala new file mode 100644 index 000000000..5e5ff4a0a --- /dev/null +++ b/modules/codegen/test/src/smithy4s/codegen/internals/ModelLoaderSpec.scala @@ -0,0 +1,61 @@ +package smithy4s.codegen.internals +import munit._ +import software.amazon.smithy.model.shapes.ShapeId +import java.util.stream.Collectors +import software.amazon.smithy.model.Model +import scala.jdk.CollectionConverters._ + +class ModelLoaderSpec extends FunSuite { + private def doLoad(dependencies: List[String], repositories: List[String]) = + ModelLoader + .load( + specs = Set.empty, + dependencies, + repositories, + transformers = Nil, + discoverModels = false, + localJars = Nil + ) + ._2 + + private def allNamespaces(model: Model): Set[String] = + model + .shapes() + .collect(Collectors.toList()) + .asScala + .toList + .map(_.getId().getNamespace()) + .toSet + + test("ModelLoader can load a dependency from s01") { + val model = doLoad( + dependencies = + List("org.polyvariant:test-library-core_2.13:0.0.1-SNAPSHOT"), + repositories = + List("https://s01.oss.sonatype.org/content/repositories/snapshots") + ) + + assertEquals( + allNamespaces(model), + Set("smithy.api", "smithy4s.meta", "testlibrary") + ) + + model.expectShape(ShapeId.from("testlibrary#MyString")) + } + + test("ModelLoader can load a dependency from s01 if it has a + in the name") { + val model = doLoad( + dependencies = + List("org.polyvariant:test-library-core_2.13:0.0.1+123-SNAPSHOT"), + repositories = + List("https://s01.oss.sonatype.org/content/repositories/snapshots") + ) + + assertEquals( + allNamespaces(model), + Set("smithy.api", "smithy4s.meta", "testlibrary") + ) + + model.expectShape(ShapeId.from("testlibrary#MyString")) + } +} From 9944706f862473b289b289fcc64f95c0cd3c9c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Mon, 6 Mar 2023 13:15:40 +0100 Subject: [PATCH 4/8] Update conversion code --- .../codegen/src/smithy4s/codegen/internals/ModelLoader.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala b/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala index c590de0e6..892ef8ff1 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala @@ -45,9 +45,9 @@ private[codegen] object ModelLoader { val currentClassLoader = this.getClass().getClassLoader() val deps = resolveDependencies(dependencies, localJars, repositories) - val modelsInJars = deps.flatMap { files => + val modelsInJars = deps.flatMap { file => val manifestUrl = - ModelDiscovery.createSmithyJarManifestUrl(files.getAbsolutePath()) + ModelDiscovery.createSmithyJarManifestUrl(file.toURI().toURL().getPath) try { ModelDiscovery.findModels(manifestUrl).asScala } catch { case _: ModelManifestException => Seq.empty From fca02159d8b06ef0abd0b936e544912c3d0532f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Mon, 6 Mar 2023 17:55:35 +0100 Subject: [PATCH 5/8] Create headers --- .../special-imports/src/main/scala/Main.scala | 16 ++++++++++++++++ .../codegen/internals/ModelLoaderSpec.scala | 16 ++++++++++++++++ .../codegen/internals/ScaladocSpec.scala | 16 ++++++++++++++++ .../src/smithy4s/schema/DefaultValueSpec.scala | 16 ++++++++++++++++ .../src-jvm/smithy4s/dynamic/ResourceSpec.scala | 16 ++++++++++++++++ .../test/src-jvm/smithy4s/dynamic/package.scala | 16 ++++++++++++++++ 6 files changed, 96 insertions(+) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala index 285768310..5d08c7bea 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + object Main { testlibrary.MyString("hello") } diff --git a/modules/codegen/test/src/smithy4s/codegen/internals/ModelLoaderSpec.scala b/modules/codegen/test/src/smithy4s/codegen/internals/ModelLoaderSpec.scala index 5e5ff4a0a..f909623ed 100644 --- a/modules/codegen/test/src/smithy4s/codegen/internals/ModelLoaderSpec.scala +++ b/modules/codegen/test/src/smithy4s/codegen/internals/ModelLoaderSpec.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s.codegen.internals import munit._ import software.amazon.smithy.model.shapes.ShapeId diff --git a/modules/codegen/test/src/smithy4s/codegen/internals/ScaladocSpec.scala b/modules/codegen/test/src/smithy4s/codegen/internals/ScaladocSpec.scala index dc7e16788..dba9ddde4 100644 --- a/modules/codegen/test/src/smithy4s/codegen/internals/ScaladocSpec.scala +++ b/modules/codegen/test/src/smithy4s/codegen/internals/ScaladocSpec.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s.codegen.internals final class ScaladocSpec extends munit.FunSuite { diff --git a/modules/core/test/src/smithy4s/schema/DefaultValueSpec.scala b/modules/core/test/src/smithy4s/schema/DefaultValueSpec.scala index 7143171f8..fe56015c7 100644 --- a/modules/core/test/src/smithy4s/schema/DefaultValueSpec.scala +++ b/modules/core/test/src/smithy4s/schema/DefaultValueSpec.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s package schema diff --git a/modules/dynamic/test/src-jvm/smithy4s/dynamic/ResourceSpec.scala b/modules/dynamic/test/src-jvm/smithy4s/dynamic/ResourceSpec.scala index b963e720c..816aad700 100644 --- a/modules/dynamic/test/src-jvm/smithy4s/dynamic/ResourceSpec.scala +++ b/modules/dynamic/test/src-jvm/smithy4s/dynamic/ResourceSpec.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s package dynamic diff --git a/modules/dynamic/test/src-jvm/smithy4s/dynamic/package.scala b/modules/dynamic/test/src-jvm/smithy4s/dynamic/package.scala index 93de8c7d9..6d3614deb 100644 --- a/modules/dynamic/test/src-jvm/smithy4s/dynamic/package.scala +++ b/modules/dynamic/test/src-jvm/smithy4s/dynamic/package.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2021-2022 Disney Streaming + * + * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://disneystreaming.github.io/TOST-1.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package smithy4s import smithy4s.dynamic.DummyIO._ From b382169799fa24514d58c191a17d09a1a2a97bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Mon, 13 Mar 2023 15:00:24 +0100 Subject: [PATCH 6/8] Remove scripted test --- .../codegen-plugin/special-imports/build.sbt | 11 ----------- .../special-imports/project/build.properties | 1 - .../special-imports/project/plugins.sbt | 9 --------- .../special-imports/src/main/scala/Main.scala | 19 ------------------- .../codegen-plugin/special-imports/test | 2 -- 5 files changed, 42 deletions(-) delete mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt delete mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/build.properties delete mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/plugins.sbt delete mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala delete mode 100644 modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/test diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt deleted file mode 100644 index 57e7d83ad..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/build.sbt +++ /dev/null @@ -1,11 +0,0 @@ -lazy val root = project - .in(file(".")) - .enablePlugins(Smithy4sCodegenPlugin) - .settings( - scalaVersion := "2.13.10", - libraryDependencies += "com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value, - - // 0.0.1-SNAPSHOT works fine because the file path doesn't have urlencoded characters - libraryDependencies += "org.polyvariant" %% "test-library-core" % "0.0.1+123-SNAPSHOT" % Smithy4s, - resolvers ++= Resolver.sonatypeOssRepos("snapshots") - ) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/build.properties b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/build.properties deleted file mode 100644 index 46e43a97e..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=1.8.2 diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/plugins.sbt b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/plugins.sbt deleted file mode 100644 index b8589b92c..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/project/plugins.sbt +++ /dev/null @@ -1,9 +0,0 @@ -sys.props.get("plugin.version") match { - case Some(x) => - addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % x) - case _ => - sys.error( - """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin - ) -} diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala deleted file mode 100644 index 5d08c7bea..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/src/main/scala/Main.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2021-2022 Disney Streaming - * - * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://disneystreaming.github.io/TOST-1.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -object Main { - testlibrary.MyString("hello") -} diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/test deleted file mode 100644 index 66db6d200..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/special-imports/test +++ /dev/null @@ -1,2 +0,0 @@ -# check if smithy4sCodegen works -> root/compile From 4a0473c2e1a7410d103b5515936b4897668f4e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Mon, 13 Mar 2023 15:06:58 +0100 Subject: [PATCH 7/8] Use FileSystems API --- .../codegen/internals/ModelLoader.scala | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala b/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala index 892ef8ff1..7dc7fef9a 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala @@ -31,6 +31,9 @@ import software.amazon.smithy.model.loader.ModelManifestException import java.io.File import java.net.URLClassLoader import scala.jdk.CollectionConverters._ +import java.nio.file.FileSystems +import scala.util.Using +import java.nio.file.Files private[codegen] object ModelLoader { @@ -46,11 +49,22 @@ private[codegen] object ModelLoader { val deps = resolveDependencies(dependencies, localJars, repositories) val modelsInJars = deps.flatMap { file => - val manifestUrl = - ModelDiscovery.createSmithyJarManifestUrl(file.toURI().toURL().getPath) - try { ModelDiscovery.findModels(manifestUrl).asScala } - catch { - case _: ModelManifestException => Seq.empty + Using.resource( + // Note: On JDK13+, the second parameter is redundant. + FileSystems.newFileSystem(file.toPath(), null) + ) { jarFS => + val p = jarFS.getPath("META-INF", "smithy", "manifest") + + if (Files.exists(p)) { + try ModelDiscovery.findModels(p.toUri().toURL()).asScala.toList + catch { + case e: ModelManifestException => + System.err.println( + s"Unexpected exception while loading model from $file, skipping: $e" + ) + Nil + } + } else Nil } } From a5b81a35fac4985d4eca3e7e0860d4ef258fbf57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Mon, 13 Mar 2023 15:09:55 +0100 Subject: [PATCH 8/8] Flip condition --- .../src/smithy4s/codegen/internals/ModelLoader.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala b/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala index 7dc7fef9a..26d904727 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/ModelLoader.scala @@ -55,7 +55,9 @@ private[codegen] object ModelLoader { ) { jarFS => val p = jarFS.getPath("META-INF", "smithy", "manifest") - if (Files.exists(p)) { + // model discovery would throw if we tried to pass a non-existent path + if (!Files.exists(p)) Nil + else { try ModelDiscovery.findModels(p.toUri().toURL()).asScala.toList catch { case e: ModelManifestException => @@ -64,7 +66,7 @@ private[codegen] object ModelLoader { ) Nil } - } else Nil + } } }