using ant-contrib with IntelliJ version 12

The following worked for me. Please advise me if you had a better method.

Step0. create an Ant script like "build_for_debug.xml"
Step1. add the script to the Ant Build Tool Window (you can find it in the very right vertical side bar or in the main manu View > Tool Windows > Ant Build)
          just drap-and-drop the ant build file from the project window to the ant build window
Step2. add the path to ant-contrib :
          * in the Ant Build Tool Window select the "build_for_debug.xml" item and right-click (or on the window menu) to "Properties"
          * choose "Additional ClassPath" and "Add" : select the ant-contrib-1.0b3.jar file from any specific folder on your system
Step3. declare the ant-contrib features in "build_for_debug.xml" before using them :
          <taskdef resource="net/sf/antcontrib/antcontrib.properties" />



Example Ant Build file :


<taskdef resource="net/sf/antcontrib/antcontrib.properties" />

<echo message="The current user is : ${user.name}" />
<property name="current_user_of_this_script.value" value="${user.name}" />
<if>
     <equals arg1="${current_user_of_this_script.value}" arg2="myspecificusernameonmycomputer"/>
     <then>
           <var name="deploy_source_jar_files_folder.dir" value="/Users/myspecificusernameonmycomputer/Dropbox/myproject_sw_deploy_jar_files" />
     </then>
</if>
<if>
     <isset property="deploy_source_jar_files_folder.dir"/>
     <then>
           <copy todir="${deploy_source_jar_files_folder.dir}">
                <fileset dir="${dist.dir}" />
           </copy>
          <tstamp>
               <format property="TODAY_FR" pattern="yyyy-MM-dd HH:mm:ss zzz" locale="fr,FR"/>
          </tstamp>
          <echo>the current date is ${TODAY_FR}</echo>
          <echo file="${deploy_source_jar_files_folder.dir}/alljarfileslog.txt" append="true">${specific.prjname}.jar ${TODAY_FR} ${dist.dir}${specific.prjname}.jar</echo>
     </then>
</if>
1 comment
Comment actions Permalink

Hello.

But what is the problem?

I've checked my test project. There ant file has no additional classpath, and the ant contrib is defined like:

    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
        <classpath>
            <pathelement location="./lib/ant-contrib-1.0b3.jar"/>
        </classpath>
    </taskdef>

But I believe, this is not the only or "best" method, just one that works.

Regards,
Alexander.

Message was edited by: Alexander Chernikov

0

Please sign in to leave a comment.