Search code examples
antnsis

How to compile NSIS script using ant?


I have created NSIS script for my java project.I have installed nsis plugin in my eclipse.using plugin I have created nsi file.Now i want to compile the nsi file.I have try to using Ant in eclipse.

<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="nsis" basedir=".">
    <property name="build.path" value="build"/> 
        <property name="deploy.dir" value="/opt/test"></property>
    <path id="library.classpath">
            <fileset dir="lib">
                <include name="nsisant-1.2.jar"/>
            </fileset>
        </path>
    <target name="nsis" description="compile nsis script">
        <mkdir dir="${build.path}/nsis"/>
        <nsis script="setup.nsi">
            <classpath refid="library.classpath"/>
        </nsis>
    </target>
    </project>

But it throws following error.

 BUILD FAILED
    build.xml:12: Problem: failed to create task or type nsis
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any <presetdef>/<macrodef> declarations have taken place.

I dont know why this happen?? How to compile nsi file using ant? or Is there any other way there to compile without using ant?


Solution

  • Using a dedicated nsis task seems to be the best way, but maybe not the simplest. I just execute makensis.exe using such syntax:

    <exec executable="C:\Program_Files\NSIS\makensis.exe" failonerror="true" >
      <!-- providing some nsis definitions -->
      <arg value="/DPROJECT_NAME=${ant.project.name}"/>
      <!-- passing the script -->
      <arg value="${basedir}\raport.nsi"/>
    </exec>
    

    As for your second question: yes, you can compile nsis script without ant. For example:

    C:\Program_Files\NSIS\makensis.exe /DPROJECT_NAME=this-project my-script.nsi
    

    Being on Linux you also should have makensis somewhere.

    The PROJECT_NAME stuff is my customization. In simplest case you don't supply any definitions, omitting that part.