build.xml 6.87 KB
Newer Older
Stephan Janosch's avatar
Stephan Janosch committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
<?xml version="1.0" ?>

<project name="GefExtractAnnotationListPlugin" default="distribute" basedir="">

    <property file="plugin.properties"/>
    <property name="build" location="build"/>
    <property name="classes" location="classes"/>
    <property name="src" location="src"/>

    <path id="classpath">
        <fileset dir="../../geneiousPlugins/geneious-10.2.3-devkit/examples/GeneiousFiles/lib">
            <include name="GeneiousPublicAPI.jar"/>
            <include name="jdom.jar"/>
            <include name="jebl.jar"/>
        </fileset>
    </path>

    <target name= "distribute" depends="build">
        <copy file="${build}/${short-plugin-name}.jar" tofile="${build}/${short-plugin-name}.gplugin"/>
        <echo message="Created ${build}/${short-plugin-name}.gplugin"/>

        <!--If your plugin consists of a folder you should build it into
        a zip file with extension gplugin. See commented example below.
        Remove above line and uncomment these to use-->
        <!--
        <zip zipfile="${build}/${short-plugin-name}.gplugin">
            <fileset dir="${build}/${plugin-name}"/>
        </zip>
        -->
    </target>

    <target name="build" depends="compile">
        <jar jarfile="${build}/${short-plugin-name}.jar">
            <fileset dir="${classes}"/>
            <fileset dir="">
                <include name="plugin.properties"/>
            </fileset>
        </jar>

        <!--build example for folder type plugin. Remove above
        lines and uncomment these to use-->
        <!--
        <jar jarfile="${build}/${short-plugin-name}.jar">
            <fileset dir="${classes}"/>
        </jar>
        <mkdir dir="${build}/${plugin-name}"/>
        <copy todir="${build}/${plugin-name}">
            <fileset dir="${build}">
                <include name="ExtraFiles"/>
                <include name="ExtraFiles/*"/>
                <include name="${short-plugin-name}.jar"/>
            </fileset>
            <fileset dir="docs">
                <include name="readme.txt"/>
            </fileset>
        </copy>
        -->
    </target>

    <target name="compile" depends="prepare">
        <javac target="1.8" source="1.8" destdir="${classes}" debug="true">
            <classpath refid="classpath"/>
            <src path="${src}"/>
        </javac>
    </target>

    <target name="prepare">
        <mkdir dir="${build}"/>
        <mkdir dir="${classes}"/>
    </target>

    <target name="clean">
        <delete dir="${build}"/>
        <delete dir="${classes}"/>
    </target>

    <target name="copyPluginAndRename">
        <!-- This task renames this plugin, including source code files and build scripts.
        To use it, enter the appropriate values for the first 3 properties and then run it.
        The 3rd property value must be identical to the second except with "." replaced with "/" -->
        <property name="newPluginName" value="GefExtractAnnotationListPlugin"/>
        <property name="newPluginPackageName" value="de.mpicbg.gef.extractannotationlist.extractannotationlist"/>
        <property name="newPluginPackagePath" value="de/mpicbg/gef/extractannotationlist/extractannotationlist"/>

        <property name="oldPluginName" value="GefExtractAnnotationListPlugin"/>
        <property name="oldPluginPackageName" value="de.mpicbg.gef.extractannotationlist"/>
        <property name="oldPluginPackagePath" value="de/mpicbg/gef/extractannotationlist"/>
        <!--It doesn't appear we can automatically replace "." with "/" in a property in basic ant without relying on the ant-contrib package being installed-->

        <property name="destDir" value="../${newPluginName}"/>

        <fail message="You must set the newPluginName property in the ant task XML before running this">
            <condition><equals arg1="${oldPluginName}" arg2="${newPluginName}"/></condition>
        </fail>
        <fail message="You must set the newPluginPackageName property in the ant task XML before running this">
            <condition><equals arg1="${oldPluginPackageName}" arg2="${newPluginPackageName}"/></condition>
        </fail>
        <fail message="You must set the newPluginPackagePath property in the ant task XML before running this">
            <condition><equals arg1="${oldPluginPackagePath}" arg2="${newPluginPackagePath}"/></condition>
        </fail>

        <copy todir="${destDir}">
            <fileset dir=""/>
        </copy>

        <replace dir="${destDir}" token="${oldPluginPackageName}" value="${newPluginPackageName}"/>
        <replace dir="${destDir}" token="${oldPluginPackagePath}" value="${newPluginPackagePath}"/>
        <replace dir="${destDir}" token="${oldPluginName}" value="${newPluginName}"/>

        <move todir="${destDir}/src/${newPluginPackagePath}">
            <fileset dir="${destDir}/src/${oldPluginPackagePath}"/>
        </move>

        <move todir="${destDir}/src/${newPluginPackagePath}">
            <fileset dir="${destDir}/src/${newPluginPackagePath}"/>
            <mapper type="glob" from="${oldPluginName}*.java" to="${newPluginName}*.java"/>
        </move>

        <move todir="${destDir}">
            <fileset dir="${destDir}"/>
            <mapper type="glob" from="${oldPluginName}.*" to="${newPluginName}.*"/>
        </move>

        <!-- edit intellij project files -->

        <copy todir="../.ideaBackup" overwrite="true">
            <fileset dir="../.idea"/>
        </copy>

        <copy file="../.idea/modules.xml" tofile="../.idea/modules.xml.new" overwrite="true">
            <filterchain>
                <tokenfilter>
                    <replaceregex byline="true" flags="s"
                                  pattern="(.*)${oldPluginName}/${oldPluginName}(.*)${oldPluginName}/${oldPluginName}(.*)$"
                                  replace="\0&#10;\1${newPluginName}/${newPluginName}\2${newPluginName}/${newPluginName}\3"/>
                </tokenfilter>
            </filterchain>
        </copy>
        <fixcrlf file="../.idea/modules.xml.new"/>
        <move file="../.idea/modules.xml.new" tofile="../.idea/modules.xml" overwrite="true"/>

		<copy file="../.idea/runConfigurations/${oldPluginName}__64_bit_.xml" tofile="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" overwrite="true"/>
        <replace file="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" token="${oldPluginPackageName}" value="${newPluginPackageName}"/>
        <replace file="../.idea/runConfigurations/${newPluginName}__64_bit_.xml" token="${oldPluginName}" value="${newPluginName}"/>

		<copy file="../.idea/runConfigurations/${oldPluginName}__32_bit_.xml" tofile="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" overwrite="true"/>
        <replace file="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" token="${oldPluginPackageName}" value="${newPluginPackageName}"/>
        <replace file="../.idea/runConfigurations/${newPluginName}__32_bit_.xml" token="${oldPluginName}" value="${newPluginName}"/>


    </target>
</project>