<?xml version="1.0"?>
<!-- 
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 * 
 * Licensed 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.
 */
 -->


<project 
  xmlns:j="jelly:core"
  xmlns:ant="jelly:ant"
  xmlns:dist="dist"
  xmlns:license="license"
  xmlns:maven="jelly:maven"
  xmlns:util="jelly:util">


  <!--==================================================================-->
  <!-- Generate NSIS Instller.exe file                                  -->
  <!--==================================================================-->    
  <goal name="nsis"
    description="Generate NSIS Installer .exe"
    prereqs="nsis:installer">
    <ant:echo>Installer generated successfully</ant:echo>
  </goal>

  <goal name="nsis:generate-project"
    description="Generate NSIS project.nsh file">
    
    <maven:param-check value="${maven.dist.bin.assembly.dir}" fail="true" 
    	message="'maven.dist.bin.assembly.dir' must be specified. It is the directory containing files to be placed in the installer"/>

    <mkdir dir="${maven.build.dir}"/>

    <j:set var="generatedFileName" value="${maven.build.dir}/project.nsh"/>
        
    <ant:echo>Creating ${generatedFileName} ...</ant:echo>
    <j:file name="${generatedFileName}" prettyPrint="false" xmlns="dummy" omitXmlDeclaration="true" escapeText="false">
      <j:import file="${maven.nsis.project.template}" inherit="true"/>    
    </j:file>
    
  </goal>
	
  <goal name="nsis:generate-setup"
    description="Generate NSIS .nsi file">

    <mkdir dir="${maven.build.dir}"/>

    <j:set var="generatedFileName" value="${maven.build.dir}/setup.nsi"/>
        
    <ant:echo>Creating ${generatedFileName} ...</ant:echo>
    <j:file name="${generatedFileName}" prettyPrint="false" xmlns="dummy" omitXmlDeclaration="true" escapeText="false">
      <j:import file="${maven.nsis.setup.template}" inherit="true"/>    
    </j:file>
    
  </goal>


  <!--==================================================================-->
  <!-- Generate NSIS  .exe file                                         -->
  <!--==================================================================-->    
  <goal name="nsis:installer"
    description="Generate NSIS .exe file"
    prereqs="nsis:generate-project,nsis:generate-setup">
  
    <j:set var="script" value="${maven.build.dir}/setup.nsi"/>

    <!-- call makensis.exe with the setup.nsh file -->
    <ant:exec executable="${maven.nsis.exe}">
      <arg value="/V2"/>
      <arg value="${script}"/>
    </ant:exec>
  </goal>


</project>
