<?xml version="1.0" encoding="UTF-8"?>
<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">
  <parent>
    <artifactId>bku</artifactId>
    <groupId>at.gv.egiz</groupId>
    <version>1.2.1-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>at.gv.egiz</groupId>
  <artifactId>BKUWebStart</artifactId>
  <packaging>jar</packaging>
  <name>BKU Web Start</name>
  <!-- 
   | IMPORTANT: update jnlp/resources/version.xml (BKUWebStart and utils) and
   | include-webstart profile in BKUOnline if version changes
   |-->
  <version>1.0.5-SNAPSHOT</version>
  <url>http://mocca.egovlabs.gv.at/</url>
  <description>Bürgerkartenumgebung (MOCCA Web Start)</description>

  <build>

    <plugins>

      <!--plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <overlays>
            <overlay>
              <groupId>at.gv.egiz</groupId>
              <artifactId>BKULocal</artifactId>
              <type>war</type>
              <targetPath>classes/BKULocal</targetPath>
            </overlay>
          </overlays>
        </configuration>
      </plugin-->

      <plugin>
         <!-- unpack BKULocal prior to webstart jar generation to include -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <!-- unpack BKULocalWar to classpath
          <execution>
            <id>unpack BKULocal webapp</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>at.gv.egiz</includeGroupIds>
              <includeArtifactIds>BKULocal</includeArtifactIds>
              <includeTypes>war</includeTypes>
              <outputDirectory>${project.build.directory}/classes/BKULocalWar</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution-->

          <!--execution>
            <id>copy</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>at.gv.egiz</groupId>
                  <artifactId>BKULocal</artifactId>
                  <version>[ version ]</version>
                  <type>[ packaging ]</type>
                  <classifier> [classifier - optional] </classifier>
                  <overWrite>[ true or false ]</overWrite>
                  <outputDirectory>[ output directory ]</outputDirectory>
                  <destFileName>[ filename ]</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution-->
          <execution>
            <id>copy BKULocal webapp</id>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>at.gv.egiz</includeGroupIds>
              <includeArtifactIds>BKULocal</includeArtifactIds>
              <includeTypes>war</includeTypes>
              <outputDirectory>${project.build.directory}/classes/</outputDirectory>
              <stripVersion>true</stripVersion>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo.webstart</groupId>
        <artifactId>webstart-maven-plugin</artifactId>
        <executions>
          <execution>
          <!-- need lifecycle phase binding, otherwise
           |   LifecycleSpecificationException: No lifecycle phase binding can be found for goal: jnlp -->
            <phase>package</phase>
            <goals>
             <!-- IMPORTANT: USE jnlp-inline, otherwise no execution in install phase and
                  the .zip artifact is not installed
                  (parallel lifecycle build finished prior to install phase?) -->
              <goal>jnlp-inline</goal>
            </goals>
          </execution>
        </executions>
        <configuration>

          <excludeTransitive>false</excludeTransitive>

          <!-- causes unsignAlreadySignedJars to fail
               (cf. http://jira.codehaus.org/browse/MWEBSTART-107)
          <libPath>lib</libPath-->

          <!--resourcesDirectory>${project.basedir}/src/main/jnlp/resources</resourcesDirectory-->

          <jnlp>
            <inputTemplateResourcePath>${project.basedir}/src/main/jnlp</inputTemplateResourcePath>
            <inputTemplate>template.xml</inputTemplate>
            <outputFile>mocca.jnlp</outputFile>
            <mainClass>at.gv.egiz.bku.webstart.BKULauncher</mainClass>
            <j2seVersion>1.6+</j2seVersion>
            <offlineAllowed>true</offlineAllowed>
            <allPermissions>true</allPermissions>
          </jnlp>

          <sign>
            <alias>test-applet signer</alias>
            <keystore>${project.basedir}/keystore.ks</keystore>
            <storepass>storepass</storepass>
            <keypass>keypass</keypass> <!-- we need to override passwords easily from the command line. ${keypass} -->
            <verify>true</verify> <!-- verify that the signing operation succeeded -->
            <keystoreConfig>
              <delete>false</delete> <!-- delete the keystore -->
              <gen>false</gen>       <!-- optional shortcut to generate the store. -->
            </keystoreConfig>
          </sign>

          <!-- BUILDING PROCESS -->
          <pack200>true</pack200>
          <!--gzip>true</gzip--> <!-- default force when pack200 false, true when pack200 selected ?? -->

          <!-- causes a version attribute to be output in each jar resource element, optional, default is false -->
          <outputJarVersions>true</outputJarVersions>

          <!-- unsign IAIK-JCE (webstart error:  JAR-Ressourcen in JNLP-Datei sind nicht von demselben Zertifikat signiert) -->
          <unsignAlreadySignedJars>true</unsignAlreadySignedJars>

          <!--install>false</install--> <!-- not yet supported -->
          <verbose>true</verbose>

        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>maven-buildnumber-plugin</artifactId>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <doCheck>false</doCheck>
          <doUpdate>false</doUpdate>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
            <manifestEntries>
              <Implementation-Build>${project.version}-r${buildNumber}</Implementation-Build>
            </manifestEntries>
          </archive>
          <verbose>true</verbose>
        </configuration>
      </plugin>
    </plugins>
  </build>
  
  <dependencies>
    <dependency>
      <groupId>at.gv.egiz</groupId>
      <artifactId>BKULocal</artifactId>
      <version>1.0.6-SNAPSHOT</version>
      <type>war</type>
    </dependency>
    <dependency>
      <artifactId>utils</artifactId>
      <groupId>at.gv.egiz</groupId>
      <version>1.2.1-SNAPSHOT</version>
      <exclusions>
        <exclusion>
          <artifactId>iaik_ecc_signed</artifactId>
          <groupId>iaik</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.0.4</version>
    </dependency>
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty</artifactId>
      <version>6.1.15</version>
    </dependency>
  </dependencies>

<!--

  <profiles>
    <profile>
      <id>webapp</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo.webstart</groupId>
            <artifactId>webstart-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>process-resources</phase>
                <goals>
                  <goal>jnlp-download-servlet</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <templateDirectory>${project.basedir}/src/main/jnlp</templateDirectory>
              <jnlpFiles>
                <jnlpFile>
                  <templateFilename>template.xml</templateFilename>
                  <outputFilename>mocca.jnlp</outputFilename>
                  <jarResources>
                    <jarResource>
                      <groupId>at.gv.egiz</groupId>
                      <artifactId>BKUWebStart</artifactId>
                      <version>1.0-SNAPSHOT</version>
                      <mainClass>at.gv.egiz.bku.webstart.BKULauncher</mainClass>
                    </jarResource>
                  </jarResources>
                </jnlpFile>
              </jnlpFiles>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    
    
    <profile>
      <id>standalone</id>
      <build>
        <plugins>
    ...
        </plugins>
      </build>
    </profile>
  </profiles>
  -->

  <profiles>
    <profile>
      <id>standalone (non-webstart)</id>
      <build>
        <plugins>
          <plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
							<mainClass>at.gv.egiz.bku.webstart.BKULauncher</mainClass>
						</manifest>
						<manifestEntries>
							<mode>development</mode>
							<url>${pom.url}</url>
							<SplashScreen-Image>splash_standalone.png</SplashScreen-Image>
						</manifestEntries>
					</archive>
				</configuration>
			</plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>