<?xml version="1.0"?>
<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>
    <groupId>org.opennms</groupId>
    <artifactId>org.opennms.features</artifactId>
    <version>1.9.94-RRP-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.opennms.features</groupId>
  <artifactId>org.opennms.features.remote-poller-jnlp</artifactId>
  <packaging>jar</packaging>
  <name>OpenNMS Remote Poller (JNLP)</name>
  <url>http://maven.apache.org</url>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.groovy.maven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-key</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <source>
                def keystore = new File(project.properties['webstart.keystore'])
                if (!keystore.exists()) {
                  keystore.parentFile.mkdirs();
                  println "keystore is missing, generating for alias '${project.properties['webstart.keyalias']}'"
                  def args = [
                    keystore: project.properties['webstart.keystore'],
                    alias: project.properties['webstart.keyalias'],
                    storepass: project.properties['webstart.storepass'],
                    dname: "cn=${project.properties['webstart.dnameCn']}"
                  ]
                  if (project.properties['webstart.keypass']) {
                    args.put('keypass', project.properties['webstart.keypass'])
                  }
                  def ant = new AntBuilder();
                  ant.genkey(args)
                }
              </source>
            </configuration>
          </execution>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo.webstart</groupId>
        <artifactId>webstart-maven-plugin</artifactId>
        <version>1.0-beta-2</version>
        <executions>
          <execution>
            <id>gui-app</id>
            <goals>
              <goal>jnlp-download-servlet</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <jnlpFiles>
                <jnlpFile>
                  <templateFilename>app.vm</templateFilename>
                  <outputFilename>app.jnlp</outputFilename>
                  <jarResources>
                    <jarResource>
                      <groupId>org.opennms.features</groupId>
                      <artifactId>org.opennms.features.remote-poller</artifactId>
                      <version>${project.version}</version>
                      <mainClass>org.opennms.poller.remote.Main</mainClass>
                    </jarResource>
                  </jarResources>
                </jnlpFile>
              </jnlpFiles>
            </configuration>
          </execution>
          <execution>
            <id>headless-app</id>
            <goals>
              <goal>jnlp-download-servlet</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <jnlpFiles>
                <jnlpFile>
                  <templateFilename>headless.vm</templateFilename>
                  <outputFilename>headless.jnlp</outputFilename>
                  <jarResources>
                    <jarResource>
                      <groupId>org.opennms.features</groupId>
                      <artifactId>org.opennms.features.remote-poller</artifactId>
                      <version>${project.version}</version>
                      <mainClass>org.opennms.poller.remote.Main</mainClass>
                    </jarResource>
                  </jarResources>
                </jnlpFile>
              </jnlpFiles>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <templateDirectory>src/main/jnlp</templateDirectory>
          <outputJarVersions>false</outputJarVersions>
          <verbose>false</verbose>
          <verifyjar>true</verifyjar>
          <sign>
            <keystore>${webstart.keystore}</keystore>
            <keypass>${webstart.keypass}</keypass>
            <storepass>${webstart.storepass}</storepass>
            <alias>${webstart.keyalias}</alias>
            <dnameCn>${webstart.dnameCn}</dnameCn>
            <dnameCn>${webstart.dnameCn}</dnameCn>
          </sign>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptors>
            <descriptor>src/assembly/jnlp.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.opennms.features</groupId>
      <artifactId>org.opennms.features.remote-poller</artifactId>
    </dependency>
  </dependencies>
</project>
