<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>ca.uhn.hapi.fhir</groupId>
		<artifactId>hapi-fhir</artifactId>
		<version>1.5</version>
		<relativePath>../pom.xml</relativePath>
	</parent>

	<artifactId>hapi-fhir-android</artifactId>
	<packaging>jar</packaging>

	<name>HAPI FHIR - Android</name>

	<dependencies>
	
		<!-- 
		This is here, at the top, for the unit tests because otherwise the
		logger spews out all kinds of junk during unit tests 
		-->
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<scope>test</scope>
		</dependency>
	
	
		<dependency>
			<groupId>ca.uhn.hapi.fhir</groupId>
			<artifactId>hapi-fhir-base</artifactId>
			<version>1.5</version>
			<exclusions>
				<!--
				<exclusion>
					<groupId>org.apache.httpcomponents</groupId>
					<artifactId>httpclient</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.apache.httpcomponents</groupId>
					<artifactId>httpcore</artifactId>
				</exclusion>
				-->
				<exclusion>
					<groupId>commons-codec</groupId>
					<artifactId>commons-codec</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>ca.uhn.hapi.fhir</groupId>
			<artifactId>hapi-fhir-structures-dstu</artifactId>
			<version>1.5</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>ca.uhn.hapi.fhir</groupId>
			<artifactId>hapi-fhir-structures-dstu2</artifactId>
			<version>1.5</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>ca.uhn.hapi.fhir</groupId>
			<artifactId>hapi-fhir-structures-dstu3</artifactId>
			<version>1.5</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient-android</artifactId>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-android</artifactId>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
		</dependency>
		<dependency>
			<groupId>commons-codec</groupId>
			<artifactId>commons-codec</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</dependency>

		<!-- Android does not come with the Servlet API bundled, and MethodUtil 
			requires it. 
			
			We provide a dummy implementation of servlet api to reduce size 
			and prevent from rewriting the BaseMethodBinding and friends.
			-->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<scope>compile</scope>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-deploy-plugin</artifactId>
				<configuration>
					<skip>false</skip>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<configuration>
					<classpathDependencyScopeExclude>compile+runtime+test+provided</classpathDependencyScopeExclude>
					<additionalClasspathElements>
						<additionalClasspathElement>${project.build.directory}/hapi-fhir-android-${project.version}-dstu2.jar</additionalClasspathElement>
					</additionalClasspathElements>
					<classpathDependencyExcludes>
						<classpathDependencyExclude>ca.uhn.hapi.fhir:hapi-fhir-base</classpathDependencyExclude>
						<classpathDependencyExclude>org.codehaus.woodstox:*</classpathDependencyExclude>
						<classpathDependencyExclude>javax.json:*</classpathDependencyExclude>
						<classpathDependencyExclude>org.glassfish:javax.json</classpathDependencyExclude>
					</classpathDependencyExcludes>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>integration-test</goal>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<configuration>
					<createDependencyReducedPom>true</createDependencyReducedPom>
					<createSourcesJar>true</createSourcesJar>
					<shadedArtifactAttached>true</shadedArtifactAttached>
					<artifactSet>
						<includes combine.children="append">
							<include>ca.uhn.hapi.fhir:hapi-fhir-base</include>
							<include>org.glassfish:javax.json</include>
							<include>org.codehaus.woodstox:woodstox-core-asl</include>
							<include>javax.xml.stream:stax-api</include>
							<include>org.codehaus.woodstox:stax2-api</include>
							<include>org.glassfish:javax.json</include>
							<!--
							<include>net.sourceforge.cobertura:cobertura</include>
							<include>org.apache.commons:*</include>
							<include>org.apache.httpcomponents:*</include>
							<include>commons-codec:commons-codec</include>
							-->
							<include>javax.servlet:javax.servlet-api</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>
					<filters combine.children="append">
						<!-- Exclude server side stuff, except exceptions which are used clientside -->
						<filter>	
							<artifact>ca.uhn.hapi.fhir:hapi-fhir-base</artifact>
							<excludes>
								<!-- Exclude test stuff which depends on httpservlet -->
								<exclude>ca/uhn/fhir/util/ITestingUiClientFactory</exclude>
								<!-- Exclude server side stuff. This could be made nicer if code was divided into shared, server and client -->
								<!--exclude>ca/uhn/fhir/rest/server/Add*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Apache*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Bundle*</exclude>
								<exclude>ca/uhn/fhir/rest/server/ETag*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Fifo*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Hard*</exclude>
								<exclude>ca/uhn/fhir/rest/server/IBundle*</exclude>
								<exclude>ca/uhn/fhir/rest/server/IDynamic*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Incoming*</exclude>
								<exclude>ca/uhn/fhir/rest/server/IPaging*</exclude>
								<exclude>ca/uhn/fhir/rest/server/IServerAdd*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Resource*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Rest*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Search*</exclude>
								<exclude>ca/uhn/fhir/rest/server/Simple*</exclude>
								<exclude>ca/uhn/fhir/rest/server/audit/**</exclude>
								<exclude>ca/uhn/fhir/rest/server/interceptor/**</exclude-->
								<!-- Exclude Phloc validator to make android libs small -->
								<exclude>ca/uhn/fhir/validation/schematron/SchematronBaseValidator*</exclude>
								<!-- Exclude Thymeleaf to make android libs small -->
								<exclude>ca/uhn/fhir/narrative/*Thymeleaf*</exclude>
							</excludes>
						</filter>
					</filters>
				</configuration>
				<executions>
					<!-- shaded jar -->
					<execution>
						<id>shaded</id>
						<phase>package</phase> 
 						<goals> 
 							<goal>shade</goal> 
 						</goals>						
					</execution>		
					<!-- dstu jar -->
					<execution>
						<id>dstu</id>
						<phase>package</phase> 
 						<goals> 
 							<goal>shade</goal> 
 						</goals>
						<configuration>
							<shadedClassifierName>dstu</shadedClassifierName>
							<artifactSet>
								<includes>
									<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
								</includes>
							</artifactSet>
							<!-- Exclude server side stuff, except exceptions which are used clientside -->
							<!--filters>
								<filter>
									<artifact>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</artifact>
									<excludes>
										<exclude>ca/uhn/fhir/rest/server/**</exclude>
									</excludes>
								</filter>
							</filters-->
						</configuration>
					</execution>
					<!-- dstu2 jar -->
					<execution>
						<id>dstu2</id>
						<phase>package</phase> 
 						<goals> 
 							<goal>shade</goal> 
 						</goals>
						<configuration>
							<shadedClassifierName>dstu2</shadedClassifierName>
							<artifactSet>
								<includes>
									<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</include>
								</includes>
							</artifactSet>
							<!-- Exclude server side stuff, except exceptions which are used clientside -->
							<!--filters>
								<filter>
									<artifact>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</artifact>
									<excludes>
										<exclude>ca/uhn/fhir/rest/server/**</exclude>
									</excludes>
								</filter>
							</filters-->
						</configuration>
					</execution>
					<!-- dstu3 jar -->
					<execution>
						<id>dstu3</id>
						<phase>package</phase> 
 						<goals> 
 							<goal>shade</goal> 
 						</goals>
						<configuration>
							<shadedClassifierName>dstu3</shadedClassifierName>
							<artifactSet>
								<includes>
									<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3</include>
								</includes>
							</artifactSet>
							<!-- Exclude server side stuff, except exceptions which are used clientside -->
							<!--filters>
								<filter>
									<artifact>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</artifact>
									<excludes>
										<exclude>ca/uhn/fhir/rest/server/**</exclude>
									</excludes>
								</filter>
							</filters-->
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
			<id>DIST</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-assembly-plugin</artifactId>
						<version>${maven_assembly_plugin_version}</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>single</goal>
								</goals>
								<configuration>
									<attach>true</attach>
									<descriptors>
										<descriptor>${project.basedir}/src/assembly/android-sources.xml</descriptor>
										<descriptor>${project.basedir}/src/assembly/android-javadoc.xml</descriptor>
									</descriptors>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>
