POM now packages SystemSchema.json and SystemSchema class now loads the packaged SystemSchema.json

This commit is contained in:
David Noble
2019-09-30 14:43:00 -07:00
parent cbcd1e91f4
commit e7b2350bc0
2 changed files with 16 additions and 45 deletions

View File

@@ -10,7 +10,7 @@ Licensed under the MIT License.
<groupId>com.azure.data</groupId>
<artifactId>azure-cosmos-serialization</artifactId>
<version>2.9.5-SNAPSHOT</version>
<version>2.9.5</version>
<packaging>jar</packaging>
<name>Microsoft Azure Cosmos Serialization API</name>
@@ -250,29 +250,6 @@ Licensed under the MIT License.
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/../schemas</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
@@ -286,24 +263,16 @@ Licensed under the MIT License.
</execution>
</executions>
</plugin>
<!--plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase/>
<id>default-cli</id>
<configuration>
<target/>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin-->
</plugins>
<resources>
<resource>
<filtering>false</filtering>
<directory>${project.basedir}/../schemas</directory>
<includes>
<include>SystemSchema.json</include>
</includes>
</resource>
</resources>
</build>
<developers>

View File

@@ -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));
}
}