Try to get HAPI building on JDK9

This commit is contained in:
James Agnew 2018-01-31 06:41:24 -06:00
parent b61887e841
commit 4af52c160f
7 changed files with 109 additions and 22 deletions

View File

@ -25,5 +25,5 @@ before_script:
script:
# - mvn -e -B clean install && cd hapi-fhir-ra && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID clean test jacoco:report coveralls:report
# - mvn -Dci=true -e -B -P ALLMODULES,NOPARALLEL,ERRORPRONE clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
- mvn -Dci=true -e -B -P ALLMODULES,REDUCED_JPA_TESTS,ERRORPRONE clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report
- mvn -Dci=true -e -B -P ALLMODULES,REDUCED_JPA_TESTS,ERRORPRONE_JDK8 clean install && cd hapi-fhir-jacoco && mvn -e -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID jacoco:report coveralls:report

View File

@ -4,4 +4,4 @@ cache:
- C:\maven\
- C:\Users\appveyor\.m2\repository
build_script:
- cmd: mvn -P MINPARALLEL,ALLMODULES install
- cmd: mvn -P MINPARALLEL,ALLMODULES,ERRORPRONE_JDK8 install

View File

@ -190,20 +190,22 @@
<groupId>com.phloc</groupId>
<artifactId>phloc-commons</artifactId>
</dependency>
<!--
These have been added as explicit dependencies
as JDK9 no longer includes them by default
-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>

View File

@ -550,6 +550,27 @@
</configuration>
</execution>
</executions>
<dependencies>
<!--
These have been added as explicit dependencies
as JDK9 no longer includes them by default
-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb_api_version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb_core_version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb_core_version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>

View File

@ -13,6 +13,9 @@ import ca.uhn.fhir.tinder.ValueSetGenerator;
import ca.uhn.fhir.tinder.VelocityHelper;
import ca.uhn.fhir.tinder.model.*;
import ca.uhn.fhir.tinder.model.SimpleSetter.Parameter;
import com.google.common.base.Charsets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.WordUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -455,8 +458,8 @@ public abstract class BaseStructureParser {
scanForTypeNameConflicts(theNext, typeNames);
}
public void setExtensions(ArrayList<Extension> theExts) {
myExtensions = theExts;
public void setExtensions(ArrayList<Extension> theExtensions) {
myExtensions = theExtensions;
}
public void setVelocityProperties(String theVelocityProperties) {
@ -464,12 +467,7 @@ public abstract class BaseStructureParser {
}
private void write(BaseRootType theResource, File theFile, String thePackageBase) throws IOException, MojoFailureException {
FileOutputStream fos = new FileOutputStream(theFile, false);
OutputStreamWriter w = new OutputStreamWriter(fos, "UTF-8");
ourLog.debug("Writing file: {}", theFile.getAbsolutePath());
ArrayList<String> imports = new ArrayList<String>();
ArrayList<String> imports = new ArrayList<>();
for (String next : myImports) {
next = Resource.correctName(next);
if (next.contains(".")) {
@ -535,10 +533,36 @@ public abstract class BaseStructureParser {
}
InputStreamReader templateReader = new InputStreamReader(templateIs);
v.evaluate(ctx, w, "", templateReader);
ByteArrayOutputStream byteArrayWriter = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(byteArrayWriter, Charsets.UTF_8);
v.evaluate(ctx, outputStreamWriter, "", templateReader);
outputStreamWriter.flush();
w.close();
fos.close();
byte[] bytesToWrite = byteArrayWriter.toByteArray();
boolean actuallyWrite = false;
if (!theFile.exists()) {
actuallyWrite = true;
} else if (FileUtils.sizeOf(theFile) != bytesToWrite.length) {
actuallyWrite = true;
} else {
byte[] existingBytes = IOUtils.toByteArray(new FileInputStream(theFile));
if (!Arrays.equals(existingBytes, bytesToWrite)) {
actuallyWrite = true;
}
}
if (!actuallyWrite) {
ourLog.info("Skipping writing already up-to-date file: {}", theFile.getAbsolutePath());
return;
}
ourLog.debug("Writing file: {}", theFile.getAbsolutePath());
try (FileOutputStream fos = new FileOutputStream(theFile, false)) {
fos.write(bytesToWrite);
fos.flush();
}
}
public void writeAll(File theOutputDirectory, File theResourceOutputDirectory, String thePackageBase) throws MojoFailureException {

47
pom.xml
View File

@ -408,6 +408,8 @@
<!-- Dependency Versions -->
<derby_version>10.14.1.0</derby_version>
<jaxb_api_version>2.3.0</jaxb_api_version>
<jaxb_core_version>2.3.0</jaxb_core_version>
<jersey_version>2.25.1</jersey_version>
<jetty_version>9.4.8.v20171121</jetty_version>
<!--<hibernate_version>5.2.10.Final</hibernate_version>-->
@ -580,11 +582,26 @@
<artifactId>javax.json-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb_api_version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb_core_version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb_core_version}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
@ -1063,9 +1080,9 @@
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate-maven-plugin</artifactId>
<version>2.0.0</version>
<version>2.1.1</version>
<configuration>
<export>false</export>
<execute>false</execute>
<skip>false</skip>
<scanDependencies>false</scanDependencies>
<scanTestClasses>false</scanTestClasses>
@ -1972,10 +1989,7 @@
</build>
</profile>
<profile>
<id>ERRORPRONE</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>ERRORPRONE_JDK8</id>
<build>
<plugins>
<plugin>
@ -1988,6 +2002,27 @@
</plugins>
</build>
</profile>
<profile>
<id>ERRORPRONE_JDK9</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>javac-with-errorprone</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -93,6 +93,11 @@
not respect any chained method parameters (e.g. MedicationRequest?medication.code=123).
Thanks to @manjusampath for reporting!
</action>
<action type="fix">
A few fixes went into the build which should now allow HAPI FHIR
to build correctly on JDK 9.0. Currently building is supported on
JDK 8.x and 9.x only.
</action>
</release>
<release version="3.2.0" date="2018-01-13">
<action type="add">