From e7b2350bc03c89136b4771d3cca79f3a0ebb6b3b Mon Sep 17 00:00:00 2001 From: David Noble Date: Mon, 30 Sep 2019 14:43:00 -0700 Subject: [PATCH] POM now packages SystemSchema.json and SystemSchema class now loads the packaged SystemSchema.json --- java/pom.xml | 51 ++++--------------- .../hybridrow/layouts/SystemSchema.java | 10 ++-- 2 files changed, 16 insertions(+), 45 deletions(-) diff --git a/java/pom.xml b/java/pom.xml index 559e337..19219bb 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -10,7 +10,7 @@ Licensed under the MIT License. com.azure.data azure-cosmos-serialization - 2.9.5-SNAPSHOT + 2.9.5 jar Microsoft Azure Cosmos Serialization API @@ -250,29 +250,6 @@ Licensed under the MIT License. - - org.apache.maven.plugins - maven-resources-plugin - 3.1.0 - - - copy-resources - validate - - copy-resources - - - ${project.build.outputDirectory} - - - ${project.basedir}/../schemas - true - - - - - - org.apache.maven.plugins maven-source-plugin @@ -286,24 +263,16 @@ Licensed under the MIT License. - + + + false + ${project.basedir}/../schemas + + SystemSchema.json + + + diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java index 0b5d0d3..5cb455f 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java @@ -45,12 +45,14 @@ public final class SystemSchema { try (final InputStream stream = getResourceAsStream("SystemSchema.json")) { namespace = Namespace.parse(stream); } catch (IOException cause) { - String message = lenientFormat("failed to initialize %s due to %s", cause); + String message = lenientFormat("failed to initialize %s due to %s", SystemSchema.class, cause); throw new IllegalStateException(message, cause); } return new LayoutResolverNamespace(namespace.orElseThrow(() -> { - String message = lenientFormat("failed to initialize %s due to system schema parse error"); + String message = lenientFormat( + "failed to initialize %s due to system schema parse error", + SystemSchema.class); return new IllegalStateException(message); })); }); @@ -73,11 +75,11 @@ public final class SystemSchema { while (urls.hasMoreElements()) { final URL url = urls.nextElement(); - if (url.toString().startsWith(location)) { + if (url.getFile().endsWith(name)) { return url.openStream(); } } - throw new FileNotFoundException(lenientFormat("cannot find resource at code source location %s", location)); + throw new FileNotFoundException(lenientFormat("cannot find %s at %s", name, location)); } }