diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 8561a6a98..7d8b5b65f 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -62,4 +62,48 @@ + + + + org.codehaus.mojo + buildnumber-maven-plugin + true + + + standard + validate + + create + + + + downstream + validate + + create-metadata + + + ${project.build.directory}/generated-sources/properties + fhir-build.properties + orgfhir.buildnumber + orgfhir.timestamp + yyyy-MM-dd'T'HH:mm:ss.SXXX + orgfhir.version + + + + + + + + src/main/resources + true + + + ${project.build.directory}/generated-sources/properties + false + + + + diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtil.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtil.java new file mode 100644 index 000000000..40f28e0d5 --- /dev/null +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtil.java @@ -0,0 +1,79 @@ +package org.hl7.fhir.utilities; + +/* + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2019 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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. + * #L% + */ + +import java.io.InputStream; +import java.util.Properties; + +import static org.apache.commons.lang3.StringUtils.defaultIfBlank; +import static org.apache.commons.lang3.StringUtils.left; + +/** + * Used internally by HAPI to log the version of the HAPI FHIR framework + * once, when the framework is first loaded by the classloader. + */ +public class VersionUtil { + + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ca.uhn.fhir.util.VersionUtil.class); + private static String ourVersion; + private static String ourBuildNumber; + private static String ourBuildTime; + + static { + initialize(); + } + + public static String getBuildNumber() { + return ourBuildNumber; + } + + public static String getBuildTime() { + return ourBuildTime; + } + + public static String getVersion() { + return ourVersion; + } + + private static void initialize() { + try (InputStream is = ca.uhn.fhir.util.VersionUtil.class.getResourceAsStream("/fhir-build.properties")) { + + Properties p = new Properties(); + if (is != null) { + p.load(is); + } + + ourVersion = p.getProperty("orgfhir.version"); + ourVersion = defaultIfBlank(ourVersion, "(unknown)"); + + ourBuildNumber = p.getProperty("orgfhir.buildnumber"); + ourBuildTime = p.getProperty("orgfhir.timestamp"); + + } catch (Exception e) { + ourLog.warn("Unable to determine version information", e); + } + } + + public static String getVersionString() { + return "Version " + getVersion() + " - Built " + getBuildTime() + " - Git " + left(getBuildNumber(), 12); + } + +} diff --git a/org.hl7.fhir.validation.cli/.classpath b/org.hl7.fhir.validation.cli/.classpath new file mode 100644 index 000000000..2a469492a --- /dev/null +++ b/org.hl7.fhir.validation.cli/.classpath @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.hl7.fhir.validation.cli/.project b/org.hl7.fhir.validation.cli/.project new file mode 100644 index 000000000..aa11a1a25 --- /dev/null +++ b/org.hl7.fhir.validation.cli/.project @@ -0,0 +1,21 @@ + + + org.hl7.fhir.validation + An open-source implementation of the FHIR specification in Java. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + org.hl7.fhir.utilities + org.hl7.fhir.convertors + org.hl7.fhir.dstu2 + org.hl7.fhir.dstu2016may + org.hl7.fhir.dstu3 + org.hl7.fhir.r4 + + + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml new file mode 100644 index 000000000..d7acda0ef --- /dev/null +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + + + ca.uhn.hapi.fhir + org.hl7.fhir.core + 3.7.3-SNAPSHOT + ../pom.xml + + + org.hl7.fhir.validation.cli + jar + + + + + ca.uhn.hapi.fhir + org.hl7.fhir.validation + ${project.version} + + + + + ch.qos.logback + logback-classic + + + org.apache.commons + commons-compress + + + org.apache.httpcomponents + httpclient + + + org.fhir + ucum + 1.0.2 + + + xpp3 + xpp3 + + + xpp3 + xpp3_xpath + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + + + org.hl7.fhir.r4.validation.Validator + + + true + + + + + + + + diff --git a/org.hl7.fhir.validation/src/main/resources/.keep.15 b/org.hl7.fhir.validation.cli/src/main/java/.keep.16 similarity index 100% rename from org.hl7.fhir.validation/src/main/resources/.keep.15 rename to org.hl7.fhir.validation.cli/src/main/java/.keep.16 diff --git a/org.hl7.fhir.validation.cli/src/main/resources/logback.xml b/org.hl7.fhir.validation.cli/src/main/resources/logback.xml new file mode 100644 index 000000000..1c8de9da3 --- /dev/null +++ b/org.hl7.fhir.validation.cli/src/main/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + INFO + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} [%file:%line] %msg%n + + + + + + + + \ No newline at end of file diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 19b28f2b7..3d89ea899 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -89,27 +89,6 @@ - - maven-assembly-plugin - - - package - - single - - - - jar-with-dependencies - - - - org.hl7.fhir.r4.validation.Validator - - - - - - diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r4/validation/Validator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r4/validation/Validator.java index 2bf905df4..1c113b6d5 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r4/validation/Validator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r4/validation/Validator.java @@ -75,6 +75,7 @@ import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.r4.model.StructureDefinition; import org.hl7.fhir.r4.utils.ToolingExtensions; +import org.hl7.fhir.utilities.VersionUtil; import org.hl7.fhir.utilities.cache.ToolsVersion; import org.hl7.fhir.utilities.xhtml.XhtmlComposer; @@ -100,6 +101,7 @@ public class Validator { public static void main(String[] args) throws Exception { + System.out.println("FHIR Validation tool " + VersionUtil.getVersionString()); if (hasParam(args, "-tests")) { try { Class clazz = Class.forName("org.hl7.fhir.validation.r4.tests.ValidationEngineTests"); @@ -108,7 +110,6 @@ public class Validator { e.printStackTrace(); } } else if (args.length == 0 || hasParam(args, "help") || hasParam(args, "?") || hasParam(args, "-?") || hasParam(args, "/?") ) { - System.out.println("FHIR Validation tool v"+Constants.VERSION+" ("+ToolsVersion.TOOLS_VERSION+")"); System.out.println(""); System.out.println("The FHIR validation tool validates a FHIR resource or bundle."); System.out.println("The validation tool compares a resource against the base definitions and any"); @@ -245,7 +246,6 @@ public class Validator { } } } else { - System.out.println("FHIR Validator Build "+getGitBuild()); System.out.print("Arguments:"); for (String s : args) System.out.print(s.contains(" ") ? " \""+s+"\"" : " "+s); diff --git a/pom.xml b/pom.xml index a977210ae..95b014433 100644 --- a/pom.xml +++ b/pom.xml @@ -125,6 +125,7 @@ org.hl7.fhir.convertors org.hl7.fhir.validation + org.hl7.fhir.validation.cli