<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>com.wigeogis.wigeoweb.installers</groupId>
	<artifactId>wigeoweb-installer-generator</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>wigeoweb-installer-generator</name>
	<url>http://maven.apache.org</url>
	<dependencies>
		<dependency>
			<groupId>org.codehaus.izpack</groupId>
			<artifactId>izpack-standalone-compiler</artifactId>
			<version>${izpack-standalone.version}</version>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.codehaus.plexus</groupId>
			<artifactId>plexus-maven-plugin</artifactId>
			<version>1.3.8</version>
		</dependency>
		<!--
		<dependency>
			<groupId>org.codehaus.plexus</groupId>
			<artifactId>plexus-utils</artifactId>
			<version>1.5.6</version>
		</dependency>
-->
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.0.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-embedder</artifactId>
			<version>3.0-beta-3</version>
		</dependency>
		<!--
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-embedder</artifactId>
			<version>2.0.1</version>
		</dependency>
-->
		<!--
<dependency>
  <groupId>org.apache.maven</groupId>
  <artifactId>maven-embedder-dep</artifactId>
  <version>2.0.1</version>
  </dependency>
  -->
		<!-- 
<dependency>
    <groupId>org.jvnet.hudson</groupId>
    <artifactId>maven-embedder</artifactId>
    <version>2.0.4-hudson-1</version>
</dependency>	
-->
		<dependency>
			<groupId>org.apache.ant</groupId>
			<artifactId>ant</artifactId>
			<version>1.8.2</version>
		</dependency>
		<dependency>
			<groupId>ant-contrib</groupId>
			<artifactId>ant-contrib</artifactId>
			<version>1.0b3</version>
		</dependency>
	</dependencies>
	<build>
		<defaultGoal>package</defaultGoal>
		<finalName>${project.artifactId}</finalName>
		<plugins>
			<!-- configure the compiler to use 1.5  -->
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<encoding>${project.build.sourceEncoding}</encoding>
					<source>1.5</source>
					<target>1.5</target>
				</configuration>
			</plugin>
			<!--  copy other checked resource into staging area, expected by install.xml -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<id>create-staging-area</id>
						<phase>process-resources</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<tasks>
								<copy todir="${staging.dir}">
									<fileset dir="${basedir}/src/izpack"/>
								</copy>
							</tasks>
						</configuration>
					</execution>
					<execution>
						<id>unpack-dependency-component-descriptors</id>
						<phase>compile</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<tasks>
								<taskdef resource="net/sf/antcontrib/antlib.xml">
									<classpath>
										<pathelement location="${settings.localRepository}/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
									</classpath>
								</taskdef>
								<var name="all_jars_list" value=""/>
								<var name="all_plexus_descriptors_list" value=""/>
								<for param="filename">
									<path>
										<fileset dir="${staging.dir}/dependency" includes="*.jar"/>
									</path>
									<sequential>
										<var name="jarname_wo_ext" unset="true"/>
										<propertyregex override="yes" property="jarname_wo_ext" input="@{filename}" regexp="(([a-zA-Z0-9_\-]+)(?=\.jar))" select="\1" casesensitive="false"/>
										<echo message="${jarname_wo_ext}"/>
										<var name="all_jars_list" value="${all_jars_list}${line.separator}&lt;jar src=&quot;dependency/${jarname_wo_ext}.jar&quot;/&gt;"/>
										<unzip src="@{filename}" dest="${staging.dir}/dependency/${jarname_wo_ext}"/>
										<path>
											<fileset id="plexus-component-descriptors" dir="${staging.dir}/dependency/${jarname_wo_ext}" includes="**/components.xml"/>
										</path>
										<sequential>
											<if>
												<available file="${staging.dir}/dependency/${jarname_wo_ext}/META-INF/plexus/components.xml"/>
												<then>
													<var name="all_plexus_descriptors_list" value="${all_plexus_descriptors_list}${line.separator}&lt;descriptor&gt;target/staging/dependency/${jarname_wo_ext}/META-INF/plexus/components.xml&lt;/descriptor&gt;"/>
												</then>
											</if>
										</sequential>
									</sequential>
								</for>
								<echo message="USE THIS JAR LIST for install.xml (IzPack)"/>
								<echo message="${all_jars_list}"/>
								<echo message="USE THIS PLEXUS DESCRIPTORS  LIST for pom.ml (plugin ... &lt;artifactId&gt;plexus-component-metadata&lt;/artifactId&gt; ...)"/>
								<echo message="${all_plexus_descriptors_list}"/>
							</tasks>
						</configuration>
					</execution>
					<execution>
						<id>replace-componentes-xml-of-plexus</id>
						<phase>install</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<tasks>
								<unjar src="${project.build.directory}/wigeoweb-installer-generator-standard.jar" dest="${tmp.unjar.dir}"/>
								<copy file="${staging.dir}/META-INF/plexus/components.xml" todir="${tmp.unjar.dir}/META-INF/plexus"/>
								<jar destfile="${project.build.directory}/wigeoweb-installer.jar" basedir="${tmp.unjar.dir}">
									<manifest>
										<attribute name="Main-Class" value="com.izforge.izpack.installer.Installer"/>
									</manifest>
								</jar>
							</tasks>
						</configuration>
					</execution>
				</executions>
				<dependencies>
					<dependency>
						<groupId>ant</groupId>
						<artifactId>ant-nodeps</artifactId>
						<version>1.6.5</version>
					</dependency>
				</dependencies>
			</plugin>
			<plugin>
				<groupId>org.codehaus.plexus</groupId>
				<artifactId>plexus-component-metadata</artifactId>
				<version>1.5.5</version>
				<executions>
					<execution>
						<id>merge-components</id>
						<phase>compile</phase>
						<goals>
							<goal>merge-metadata</goal>
						</goals>
						<configuration>
							<output>${staging.dir}/META-INF/plexus/components.xml</output>
							<descriptors>
								<descriptor>target/staging/dependency/aether-impl/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/doxia-core/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/maven-aether-provider/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/maven-artifact-manager/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/maven-compat/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/maven-core/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/maven-model-builder/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/maven-profile/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/maven-project/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/maven-settings-builder/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/plexus-cdc/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/plexus-cipher/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/plexus-maven-plugin/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/plexus-sec-dispatcher/META-INF/plexus/components.xml</descriptor>
								<descriptor>target/staging/dependency/spice-inject-plexus/META-INF/plexus/components.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!--  prepare dependencies so that izpack jar tag to pickup at compile time -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>2.0</version>
				<executions>
					<execution>
						<id>standard-installer</id>
						<phase>process-resources</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<stripVersion>true</stripVersion>
							<excludeGroupIds>org.codehaus.izpack</excludeGroupIds>
							<!-- dont want standalone compiler -->
							<outputDirectory>${staging.dir}/dependency</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!--  see install.xml to see how MyHelloPanel is used -->
			<plugin>
				<groupId>org.codehaus.izpack</groupId>
				<artifactId>izpack-maven-plugin</artifactId>
				<version>1.0-alpha-5</version>
				<dependencies>
					<dependency>
						<groupId>org.codehaus.izpack</groupId>
						<artifactId>izpack-standalone-compiler</artifactId>
						<version>${izpack-standalone.version}</version>
					</dependency>
				</dependencies>
				<configuration>
					<izpackBasedir>${staging.dir}</izpackBasedir>
					<customPanelDirectory>${staging.dir}</customPanelDirectory>
				</configuration>
				<executions>
					<execution>
						<id>standard-installer</id>
						<phase>package</phase>
						<goals>
							<goal>izpack</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<properties>
		<staging.dir>${project.build.directory}/staging</staging.dir>
		<tmp.unjar.dir>${project.build.directory}/unjar</tmp.unjar.dir>
		<izpack-standalone.version>4.3.1</izpack-standalone.version>
	</properties>
</project>
