Enhancements to Android build
This commit is contained in:
parent
fd91ce76ce
commit
137a2cf7ec
|
@ -13,6 +13,7 @@ Servers/
|
|||
nohup.out
|
||||
.DS_Store
|
||||
*.orig
|
||||
tmp.txt
|
||||
|
||||
# Vagrant stuff.
|
||||
.vagrant
|
||||
|
|
|
@ -23,5 +23,6 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="target/hapi-fhir-android-1.2-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<version>1.2-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>com.phloc</groupId>
|
||||
<artifactId>phloc-schematron</artifactId>
|
||||
|
@ -56,6 +57,7 @@
|
|||
<artifactId>phloc-commons</artifactId>
|
||||
<version>${phloc_commons_version}</version>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient-android</artifactId>
|
||||
|
@ -113,10 +115,18 @@
|
|||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>${maven_failsafe_plugin_version}</version>
|
||||
<configuration>
|
||||
<classpathDependencyScopeExclude>compile+runtime</classpathDependencyScopeExclude>
|
||||
<classpathDependencyScopeExclude>compile+runtime+test</classpathDependencyScopeExclude>
|
||||
<additionalClasspathElements>
|
||||
<additionalClasspathElement>${project.build.directory}/hapi-fhir-android-${project.version}.jar</additionalClasspathElement>
|
||||
<additionalClasspathElement>${project.build.directory}/hapi-fhir-android-${project.version}-dstu2.jar</additionalClasspathElement>
|
||||
</additionalClasspathElements>
|
||||
<classpathDependencyExcludes>
|
||||
<classpathDependencyExclude>ca.uhn.hapi.fhir:hapi-fhir-base</classpathDependencyExclude>
|
||||
<!-- <classpathDependencyExclude>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</classpathDependencyExclude> -->
|
||||
<!-- <classpathDependencyExclude>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</classpathDependencyExclude> -->
|
||||
<classpathDependencyExclude>org.codehaus.woodstox:*</classpathDependencyExclude>
|
||||
<classpathDependencyExclude>javax.json:*</classpathDependencyExclude>
|
||||
<classpathDependencyExclude>org.glassfish:javax.json</classpathDependencyExclude>
|
||||
</classpathDependencyExcludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -133,19 +143,21 @@
|
|||
<version>2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>dstu</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||
<!-- <minimizeJar>true</minimizeJar> -->
|
||||
<createSourcesJar>true</createSourcesJar>
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
<shadedClassifierName>dstu</shadedClassifierName>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>commons-codec:commons-codec</include>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-base</include>
|
||||
<!--<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</include>-->
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
|
||||
<include>org.glassfish:javax.json</include>
|
||||
<include>org.codehaus.woodstox:woodstox-core-asl</include>
|
||||
<include>javax.xml.stream:stax-api</include>
|
||||
|
@ -178,6 +190,44 @@
|
|||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>dstu2</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||
<createSourcesJar>true</createSourcesJar>
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
<shadedClassifierName>dstu2</shadedClassifierName>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>commons-codec:commons-codec</include>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-base</include>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</include>
|
||||
<include>org.glassfish:javax.json</include>
|
||||
<include>org.codehaus.woodstox:woodstox-core-asl</include>
|
||||
<include>javax.xml.stream:stax-api</include>
|
||||
<include>javax.servlet:javax.servlet-api</include>
|
||||
<include>org.codehaus.woodstox:stax2-api</include>
|
||||
<include>org.apache.commons:*</include>
|
||||
<include>org.apache.httpcomponents:*</include>
|
||||
<include>org.glassfish:javax.json</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>javax.xml.stream</pattern>
|
||||
<shadedPattern>ca.uhn.fhir.repackage.javax.xml.stream</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>javax.json</pattern>
|
||||
<shadedPattern>ca.uhn.fhir.repackage.javax.json</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Observable;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
@ -14,9 +15,15 @@ import java.util.zip.ZipFile;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ctc.wstx.stax.WstxInputFactory;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
|
@ -24,8 +31,16 @@ import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
|||
public class BuiltJarIT {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BuiltJarIT.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
System.setProperty("javax.xml.stream.XMLInputFactory", "com.ctc.wstx.stax.WstxInputFactory");
|
||||
System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParser() {
|
||||
public void testParserXml() throws Exception {
|
||||
// fail("*******: " + WstxInputFactory.class.getProtectionDomain().getCodeSource().getLocation().toString());
|
||||
|
||||
FhirContext ctx = FhirContext.forDstu2();
|
||||
|
||||
Patient p = new Patient();
|
||||
|
@ -37,6 +52,26 @@ public class BuiltJarIT {
|
|||
assertEquals("system", p2.getIdentifierFirstRep().getSystemElement().getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParserJson() {
|
||||
FhirContext ctx = FhirContext.forDstu2();
|
||||
|
||||
Observation o = new Observation();
|
||||
o.getCode().setText("TEXT");
|
||||
o.setValue(new QuantityDt(123));
|
||||
o.addIdentifier().setSystem("system");
|
||||
|
||||
String str = ctx.newJsonParser().encodeResourceToString(o);
|
||||
Observation p2 = ctx.newJsonParser().parseResource(Observation.class, str);
|
||||
|
||||
assertEquals("TEXT", p2.getCode().getText());
|
||||
|
||||
QuantityDt dt = (QuantityDt) p2.getValue();
|
||||
dt.getComparatorElement().getValueAsEnum();
|
||||
|
||||
QuantityCompararatorEnum.GREATERTHAN.name();
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple client test - We try to connect to a server that doesn't exist, but
|
||||
* if we at least get the right exception it means we made it up to the HTTP/network stack
|
||||
|
@ -113,7 +148,7 @@ public class BuiltJarIT {
|
|||
|
||||
ourLog.info("File {} contains {} entries", file, names.size());
|
||||
ourLog.info("Total classes {} - Total methods {}", totalClasses, totalMethods);
|
||||
ourLog.info("Top classes {}", new ArrayList<ClassMethodCount>(topMethods).subList(topMethods.size() - 10, topMethods.size()));
|
||||
ourLog.info("Top classes {}", new ArrayList<ClassMethodCount>(topMethods).subList(Math.max(0,topMethods.size() - 10), topMethods.size()));
|
||||
|
||||
} finally {
|
||||
zip.close();
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -49,6 +50,7 @@ import org.codehaus.stax2.XMLOutputFactory2;
|
|||
import org.codehaus.stax2.io.EscapingWriterFactory;
|
||||
|
||||
import com.ctc.wstx.api.WstxInputProperties;
|
||||
import com.ctc.wstx.stax.WstxInputFactory;
|
||||
import com.ctc.wstx.stax.WstxOutputFactory;
|
||||
|
||||
/**
|
||||
|
@ -1546,7 +1548,16 @@ public class XmlUtil {
|
|||
|
||||
private static XMLInputFactory getOrCreateInputFactory() throws FactoryConfigurationError {
|
||||
if (ourInputFactory == null) {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
|
||||
try {
|
||||
Class.forName("ca.uhn.fhir.repackage.javax.xml.stream.XMLInputFactory");
|
||||
System.setProperty("javax.xml.stream.XMLInputFactory", "com.ctc.wstx.stax.WstxInputFactory");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
XMLInputFactory inputFactory;
|
||||
inputFactory = XMLInputFactory.newInstance();
|
||||
|
||||
if (!ourHaveLoggedStaxImplementation) {
|
||||
logStaxImplementation(inputFactory.getClass());
|
||||
|
@ -1576,6 +1587,14 @@ public class XmlUtil {
|
|||
|
||||
private static XMLOutputFactory getOrCreateOutputFactory() throws FactoryConfigurationError {
|
||||
if (ourOutputFactory == null) {
|
||||
|
||||
try {
|
||||
Class.forName("ca.uhn.fhir.repackage.javax.xml.stream.XMLOutputFactory");
|
||||
System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
|
||||
|
||||
if (!ourHaveLoggedStaxImplementation) {
|
||||
|
@ -1668,8 +1687,8 @@ public class XmlUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Character.toString((char) 167));
|
||||
public static void main(String[] args) throws FactoryConfigurationError, XMLStreamException {
|
||||
createXmlWriter(new StringWriter());
|
||||
}
|
||||
|
||||
private static final class ExtendedEntityReplacingXmlResolver implements XMLResolver {
|
||||
|
|
Loading…
Reference in New Issue