<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2011 Michael Mimo Moratti.
   
    Michael Mimo Moratti licenses this file to you 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.
 -->
 <!--
 	Snapshot:
 	$> mvn clean deploy
 	
 	Stage:
 	$> mvn -DperformRelease=true release:clean release:prepare 
 	$> mvn -DperformRelease=true release:perform
 	
 	Release:
 	Login to: https://oss.sonatype.org
 	
 	Follow the guide: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
  -->
  <!-- 
  	Author: Michael Mimo Moratti (mimo@mimo.ch)
   -->
<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/maven-v4_0_0.xsd">

	<modelVersion>4.0.0</modelVersion>

	<groupId>ch.mimo</groupId>
	<artifactId>netty-icap</artifactId>
	<packaging>jar</packaging>
	<version>1.0.1.GA</version>

	<name>The Netty ICAP Protocol Codec Project</name>
	<url>http://icap.mimo.ch/</url>
	<description>ICAP Codec implementation for JBoss Netty</description>
	<licenses>
		<license>
			<name>Apache License, Version 2.0</name>
			<url>http://www.apache.org/licenses/LICENSE-2.0</url>
		</license>
	</licenses>
	<inceptionYear>2011</inceptionYear>
	<developers>
		<developer>
			<id>mimo</id>
			<name>Michael Mimo Moratti</name>
			<email>mimo@mimo.ch</email>
		</developer>
	</developers>
	<scm>
		<connection>scm:git:git@github.com:jmimo/netty-icap.git</connection>
		<developerConnection>scm:git:git@github.com:jmimo/netty-icap.git</developerConnection>
		<url>git@github.com:jmimo/netty-icap.git</url>
	</scm>
	<dependencies>
		<dependency>
			<groupId>org.jboss.netty</groupId>
			<artifactId>netty</artifactId>
			<version>3.2.5.Final</version>
			<!-- version>4.0.0.Alpha1-SNAPSHOT</version -->
		</dependency>
		<dependency>
			<groupId>org.apache.felix</groupId>
			<artifactId>org.osgi.core</artifactId>
			<version>1.4.0</version>
			<scope>compile</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.8.1</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<properties />
	<profiles>
		<profile>
			<id>documentation</id>
			<activation>
				<property>
					<name>performRelease</name>
					<value>true</value>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jxr-plugin</artifactId>
						<version>2.2</version>
						<executions>
							<execution>
								<id>generate-xref</id>
								<phase>package</phase>
								<goals>
									<goal>jxr</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<inputEncoding>UTF-8</inputEncoding>
							<outputEncoding>UTF-8</outputEncoding>
							<linkJavadoc>true</linkJavadoc>
							<destDir>${project.build.directory}/docbkx/xref</destDir>
							<javadocDir>${project.build.directory}/docbkx/api</javadocDir>
							<stylesheet>${basedir}/src/main/xref/stylesheet.css</stylesheet>
							<docTitle>${project.name} Source Xref (${project.version})</docTitle>
							<windowTitle>${project.name} Source Xref (${project.version})</windowTitle>
						</configuration>
					</plugin>
					<plugin>
						<groupId>com.agilejava.docbkx</groupId>
						<artifactId>docbkx-maven-plugin</artifactId>
						<version>2.0.13</version>
						<executions>
							<execution>
								<goals>
									<goal>generate-html</goal>
									<goal>generate-pdf</goal>
								</goals>
								<phase>generate-sources</phase>
							</execution>
						</executions>
						<dependencies>
							<dependency>
								<groupId>net.sf.docbook</groupId>
								<artifactId>docbook-xml</artifactId>
								<version>5.0-all</version>
								<classifier>resources</classifier>
								<type>zip</type>
								<scope>runtime</scope>
							</dependency>
							<dependency>
								<groupId>net.sf.offo</groupId>
								<artifactId>fop-hyph</artifactId>
								<version>1.2</version>
							</dependency>
						</dependencies>
						<configuration>
							<xincludeSupported>true</xincludeSupported>
							<foCustomization>${basedir}/src/docbkx/customization/pdf.xsl</foCustomization>
							<!-- htmlStylesheet -->
					        <entities>
					            <entity>
					              <name>version</name>
					              <value>${project.version}</value>
					            </entity>
					        </entities>
							<includes>icap-codec.xml</includes>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>sign-and-package</id>
			<activation>
				<property>
					<name>performRelease</name>
					<value>true</value>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.6</version>
						<executions>
							<execution>
								<id>copy-gnupg-keyrings-to-workspace</id>
								<phase>verify</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<echo message="copy gnupg keyrings to build directory" />
										<copy todir="${project.build.directory}/gnupg" verbose="true">
											<fileset dir="${gpg.homedir}" />
										</copy>
										<chmod perm="700" verbose="true">
											<fileset dir="${project.build.directory}/gnupg" />
										</chmod>							
									</target>
								</configuration>
							</execution>
						</executions>
						<dependencies>
							<dependency>
								<groupId>org.apache.ant</groupId>
								<artifactId>ant</artifactId>
								<version>1.8.2</version>
							</dependency>
							<dependency>
								<groupId>org.apache.ant</groupId>
								<artifactId>ant-launcher</artifactId>
								<version>1.8.2</version>
							</dependency>
						</dependencies>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>1.2</version>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<homedir>${project.build.directory}/gnupg</homedir>
							<passphrase>${gpg.password}</passphrase>
						</configuration>
					</plugin>
					<plugin>
						<artifactId>maven-assembly-plugin</artifactId>
						<version>2.2</version>
						<executions>
							<execution>
								<id>generate-distribution</id>
								<phase>package</phase>
								<goals>
									<goal>single</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<descriptors>
								<descriptor>${basedir}/src/main/assembly/default.xml</descriptor>
							</descriptors>
							<attach>${attach-distribution}</attach>
							<appendAssemblyId>true</appendAssemblyId>
							<tarLongFileMode>gnu</tarLongFileMode>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.4.3</version>
				<configuration>
					<encoding>UTF-8</encoding>
				</configuration>
				<executions>
					<execution>
						<id>copy-legal-info</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${basedir}/target/license/META-INF</outputDirectory>
							<resources>
								<resource>
									<directory>${basedir}</directory>
									<filtering>false</filtering>
									<includes>
										<include>COPYRIGHT.txt</include>
										<include>LICENSE.txt</include>
										<include>NOTICE.txt</include>
										<include>license/*.txt</include>
									</includes>
								</resource>
							</resources>
						</configuration>
					</execution>
					<!-- execution>
						<id>copy-documentation</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${basedir}/target/</outputDirectory>
							<resources>
								<resource>
									<directory>${basedir}/src/main/docbook</directory>
									<filtering>true</filtering>
								</resource>
							</resources>
						</configuration>
					</execution -->
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3</version>
				<configuration>
					<encoding>UTF-8</encoding>
					<source>1.6</source>
					<target>1.6</target>
					<debug>true</debug>
					<optimize>true</optimize>
					<showDeprecations>true</showDeprecations>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.5</version>
				<configuration>
					<forkMode>never</forkMode>
					<excludes>
						<exclude>**/Abstract*</exclude>
						<exclude>**/TestUtil*</exclude>
					</excludes>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>2.3.4</version>
				<extensions>true</extensions>
				<configuration>
					<instructions>
						<Bundle-SymbolicName>${project.groupId}</Bundle-SymbolicName>
						<Bundle-DocURL>${project.url}</Bundle-DocURL>
						<Bundle-Activator>
							ch.mimo.netty.icap.container.osgi.NettyIcapBundleActivator
		            </Bundle-Activator>
						<Export-Package>
							!ch.mimo.netty.example.*,
							ch.mimo.netty.*;version=${project.version}
		            </Export-Package>
						<Private-Package>
							ch.mimo.netty.example.*,
		            </Private-Package>
						<Import-Package>
							*;resolution:=optional
		            </Import-Package>
						<Eclipse-BuddyPolicy>registered</Eclipse-BuddyPolicy>
						<Bundle-BuddyPolicy>registered</Bundle-BuddyPolicy>
						<Main-Class>ch.mimo.netty.handler.codec.icap.Version</Main-Class>
					</instructions>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-source-plugin</artifactId>
				<version>2.1.1</version>
				<executions>
					<execution>
						<id>attach-source</id>
						<phase>package</phase>
						<goals>
							<goal>jar</goal>
						</goals>
						<configuration>
							<attach>true</attach>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>2.8</version>
				<executions>
					<execution>
						<id>create-jar</id>
						<phase>package</phase>
						<goals>
							<goal>jar</goal>
						</goals>
						<configuration>
							<attach>true</attach>
						</configuration>
					</execution>
				</executions>
				<configuration>
          			<destDir>${project.build.directory}/docbkx/api</destDir>
					<excludePackageNames>ch.mimo.netty.example*</excludePackageNames>
					<javadocDirectory>${basedir}/src/main/javadoc</javadocDirectory>
					<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
					<version>true</version>
					<author>true</author>
					<doctitle>${project.name} API Reference (${project.version})</doctitle>
					<windowtitle>${project.name} API Reference (${project.version})</windowtitle>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.6</version>
				<executions>
					<execution>
						<id>write-version</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<taskdef resource="net/sf/antcontrib/antlib.xml" />
								<exec executable="git" outputproperty="gitOutput" resultproperty="gitExitCode" failonerror="false" failifexecutionfails="false">
									<arg value="log" />
									<arg value="-1" />
									<arg value="--format=format:%h" />
								</exec>
								<if>
									<equals arg2="0" arg1="${gitExitCode}" />
									<then>
										<property name="buildNumber" value="${gitOutput}" />
									</then>
									<else>
										<property name="buildNumber" value="unknown" />
									</else>
								</if>
								<echo message="Build number: ${buildNumber}" />
								<echo message="// DO NOT MODIFY - WILL BE OVERWRITTEN DURING THE BUILD PROCESS${line.separator}package ch.mimo.netty.handler.codec.icap;${line.separator}/**${line.separator} * Provides the version information of this Project.${line.separator} */${line.separator}public final class Version {${line.separator} /** The version identifier. */${line.separator} public static final String ID = &quot;${project.version}-${buildNumber}&quot;;${line.separator} /** Prints out the version identifier to stdout. */${line.separator} public static void main(String[] args) { System.out.println(ID); }${line.separator} private Version() { super(); }${line.separator}}${line.separator}" file="${basedir}/src/main/java/ch/mimo/netty/handler/codec/icap/Version.java" />
							</target>
						</configuration>
					</execution>
					<execution>
						<id>remove-examples</id>
						<phase>package</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<taskdef resource="net/sf/antcontrib/antlib.xml" />
								<if>
									<or>
										<equals arg2="jar" arg1="${project.packaging}" />
										<equals arg2="bundle" arg1="${project.packaging}" />
									</or>
									<then>
										<move file="${project.build.directory}/${project.build.finalName}.jar" tofile="${project.build.directory}/${project.build.finalName}.orig.jar" />
										<zip destfile="${project.build.directory}/${project.build.finalName}.jar">
											<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}.orig.jar" dirmode="755">
												<include name="META-INF/MANIFEST.MF" />
											</zipfileset>
											<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}.orig.jar" dirmode="755">
												<exclude name="META-INF/MANIFEST.MF" />
												<exclude name="*/*/*/example/**" />
											</zipfileset>
										</zip>
										<delete file="${project.build.directory}/${project.build.finalName}.orig.jar" />
										<checksum file="${project.build.directory}/${project.build.finalName}.jar" algorithm="md5" forceoverwrite="yes" />
										<checksum file="${project.build.directory}/${project.build.finalName}.jar" algorithm="sha1" forceoverwrite="yes" />
										<move file="${project.build.directory}/${project.build.finalName}-sources.jar" tofile="${project.build.directory}/${project.build.finalName}-sources.orig.jar" />
										<zip destfile="${project.build.directory}/${project.build.finalName}-sources.jar">
											<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}-sources.orig.jar" dirmode="755">
												<include name="META-INF/MANIFEST.MF" />
											</zipfileset>
											<zipfileset filemode="644" src="${project.build.directory}/${project.build.finalName}-sources.orig.jar" dirmode="755">
												<exclude name="META-INF/MANIFEST.MF" />
												<exclude name="*/*/*/example/**" />
											</zipfileset>
										</zip>
										<delete file="${project.build.directory}/${project.build.finalName}-sources.orig.jar" />
										<checksum file="${project.build.directory}/${project.build.finalName}-sources.jar" algorithm="md5" forceoverwrite="yes" />
										<checksum file="${project.build.directory}/${project.build.finalName}-sources.jar" algorithm="sha1" forceoverwrite="yes" />
										<checksum file="${project.build.directory}/${project.build.finalName}-javadoc.jar" algorithm="md5" forceoverwrite="yes" />		
										<checksum file="${project.build.directory}/${project.build.finalName}-javadoc.jar" algorithm="sha1" forceoverwrite="yes" />										
									</then>
								</if>
							</target>
						</configuration>
					</execution>
				</executions>
				<dependencies>
					<dependency>
						<groupId>org.apache.ant</groupId>
						<artifactId>ant</artifactId>
						<version>1.8.2</version>
					</dependency>
					<dependency>
						<groupId>org.apache.ant</groupId>
						<artifactId>ant-launcher</artifactId>
						<version>1.8.2</version>
					</dependency>
					<dependency>
						<groupId>ant-contrib</groupId>
						<artifactId>ant-contrib</artifactId>
						<version>1.0b3</version>
						<exclusions>
							<exclusion>
								<groupId>ant</groupId>
								<artifactId>ant</artifactId>
							</exclusion>
						</exclusions>
					</dependency>
				</dependencies>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<version>2.8</version>
				<configuration>
					<downloadSources>true</downloadSources>
					<addVersionToProjectName>true</addVersionToProjectName>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<formats>
						<format>html</format>
						<format>xml</format>
					</formats>
					<instrumentation>
						<excludes>
							<exclude>ch/mimo/netty/example/**/*.class</exclude>
							<exclude>ch/mimo/netty/icap/container/**/*.class</exclude>
							<exclude>ch/mimo/netty/handler/codec/icap/Version.class</exclude>
							<exclude>ch/mimo/netty/handler/codec/icap/socket/**/*.class</exclude>
							<exclude>ch/mimo/netty/handler/codec/icap/**/*Test.class</exclude>
							<exclude>ch/mimo/netty/handler/codec/icap/**/*Configuration.class</exclude>
							<exclude>ch/mimo/netty/handler/codec/icap/**/*Preparation.class</exclude>
						</excludes>
					</instrumentation>
				</configuration>
			</plugin>
	        <plugin>
	          <groupId>org.apache.maven.plugins</groupId>
	          <artifactId>maven-deploy-plugin</artifactId>
	          <version>2.6</version>
	        </plugin>
			<plugin>
				<artifactId>maven-release-plugin</artifactId>
				<version>2.1</version>
				<configuration>
					<!-- We don't want to use the default release profile because it causes 
						the JavaDoc and source jars to be deployed twice. -->
					<useReleaseProfile>false</useReleaseProfile>
					<!-- Activate a custom profile called "release" -->
					<!-- arguments>-PperformRelease=true</arguments -->
					<mavenExecutorId>forked-path</mavenExecutorId>
					<arguments>-DperformRelease=true</arguments>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<distributionManagement>
		<snapshotRepository>
			<id>sonatype-nexus-snapshots</id>
			<name>Sonatype Nexus Snapshots</name>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
		</snapshotRepository>
		<repository>
			<id>sonatype-nexus-staging</id>
			<name>Sonatype Nexus Staging</name>
			<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
		</repository>
	</distributionManagement>
</project>

