build.xml 8.07 KB
Newer Older
1 2
<project name="BytecodeOutline" default="plugin">

3
  <!-- defines the location of the asm project via asm.project.dir -->
ekuleshov's avatar
ekuleshov committed
4
  <property file="${user.home}/asm-build.properties"/>
5

ekuleshov's avatar
ekuleshov committed
6
  <property file="build.properties"/>
7

andrei's avatar
andrei committed
8
  <!-- defines product.version from asm etc  -->
9 10 11
  <property file="${asm.project.dir}/build.properties" />


12 13 14
  <property name="src"                value="${basedir}/src"/>
  <property name="externals"          value="${basedir}/externals"/>
  <property name="out"                value="${basedir}/output"/>
15
  <property name="lib"                value="${basedir}/lib"/>
16
  <property name="out.build"          value="${out}/build"/>
ekuleshov's avatar
ekuleshov committed
17

18 19 20
   <path id="saxon.classpath">
        <fileset dir="${saxon.home}" includes="*.jar"/>
    </path>
21

22 23 24 25 26 27 28 29 30 31 32 33 34 35
  	<tstamp><format property="plugin.date" pattern="yyyyMMddHHmm" /></tstamp>
	
	<target name="get-git-revision">
	<exec executable="git" spawn="false" outputproperty="git.revision">
	        <arg value="log"/>
	        <arg value="--pretty=format:%h"/>
	        <arg value="-n"/>
	        <arg value="1"/>
	</exec>
	    <echo>Got git revision ${git.revision}</echo>
	</target>
	
  <target name="init" depends="getasm,get-git-revision">
    <property name="plugin.qualifier" value="${plugin.date}-${git.revision}" />
36
    <!-- read plugin base version from META-INF/MANIFEST.MF to ${pluginVersion} -->
37
    <loadfile srcFile="${basedir}/META-INF/MANIFEST.MF" property="plugin.version">
38
      <filterchain>
39 40 41 42 43 44
          <tokenfilter>
          	<containsregex pattern="Bundle-Version: (.*)" replace="\1"/>
          </tokenfilter>
          <tokenfilter>
          	<replacestring from="qualifier" to="${plugin.qualifier}"/>
          </tokenfilter>
45 46 47 48 49 50 51 52 53 54 55
          <deletecharacters chars=" \n\r"/>
      </filterchain>
    </loadfile>

    <!-- read plugin id from META-INF/MANIFEST.MF to ${pluginId} -->
    <loadfile srcFile="${basedir}/META-INF/MANIFEST.MF" property="plugin.id">
      <filterchain>
          <tokenfilter><containsregex pattern="Bundle-SymbolicName:\s*([^;]+)(;.*)?" replace="\1"/></tokenfilter>
          <deletecharacters chars=" \n\r"/>
      </filterchain>
    </loadfile>
56 57
    <property name="plugin.jar"   value="${plugin.id}_${plugin.version}.jar"/>
    <property name="feature.jar"  value="${plugin.id}.feature_${plugin.version}.jar"/>
58 59
  </target>

60 61 62 63 64 65 66 67 68
    <scriptdef name="getAndCheckLibrary" language="javascript">
        <attribute name="url"/>
        <attribute name="path"/>
        <![CDATA[
           var URL = Java.type("java.net.URL");
           var File = Java.type("java.io.File");

           var path = attributes.get("path");
           var url = attributes.get("url");
69
           print(path + " / " + url);
70 71 72 73 74

           var file = new File(path);

           result = false;
           if(file.exists()){
75 76
               print("File exists.")
               result = true;
77 78 79 80 81 82 83 84 85 86 87 88
           }
           if(result == false){
               print("Downloading file...")
               get = project.createTask("get");
               get.setSrc(new URL(url));
               get.setDest(file)
               get.perform();
           }
        ]]>
    </scriptdef>

    <target name="getasm" >
89 90
    	<property name="asmRoot" value="http://download.eclipse.org/tools/orbit/downloads/drops2/R20180905201904/repository/plugins" />
    	<property name="asmVersion" value="6.2.1.v20180823-1831" />
91 92
    	<mkdir dir="${lib}"/>
        <getAndCheckLibrary
93
            url="${asmRoot}/org.objectweb.asm_${asmVersion}.jar"
94 95 96
            path="${lib}/asm-${asmVersion}.jar"
        />
        <getAndCheckLibrary
97
            url="${asmRoot}/org.objectweb.asm.analysis_${asmVersion}.jar"
98 99 100
            path="${lib}/asm-analysis-${asmVersion}.jar"
        />
        <getAndCheckLibrary
101
            url="${asmRoot}/org.objectweb.asm.commons_${asmVersion}.jar"
102 103 104
            path="${lib}/asm-commons-${asmVersion}.jar"
        />
        <getAndCheckLibrary
105
            url="${asmRoot}/org.objectweb.asm.tree_${asmVersion}.jar"
106 107 108
            path="${lib}/asm-tree-${asmVersion}.jar"
        />
        <getAndCheckLibrary
109
            url="${asmRoot}/org.objectweb.asm.util_${asmVersion}.jar"
110 111 112
            path="${lib}/asm-util-${asmVersion}.jar"
        />
    </target>
113

andrei's avatar
andrei committed
114

115
  <target name="compile" depends="init">
116
    <path id="classpath">
117
      <fileset dir="lib" includes="*.jar"/>
118
      <fileset dir="${eclipse.home}" includes="plugins/**/*.jar"/>
119 120
    </path>
    <mkdir dir="${out.build}"/>
121
    <javac destdir="${out.build}" debug="on" source="1.8" target="1.8" includeantruntime="false">
122 123 124
      <classpath refid="classpath"/>
      <src path="${src}"/>
      <include name="**/*.java"/>
125
    </javac>
126 127 128
  </target>

  <target name="jars" depends="compile">
129
    <copy todir="${out.build}" overwrite="true">
130
      <fileset dir="${src}">
131 132
        <include name="**/*.properties"/>
      </fileset>
133
    </copy>
134 135 136 137 138
  	
    <!-- set the values for plugin.version -->
  	<filterset id="version.filter">
        <filter token="PLUGIN_VERSION" value="${plugin.version}" />
        <filter token="FEATURE_VERSION" value="${plugin.version}" />
139
    </filterset>
140 141 142 143 144 145 146 147
  	
    <echo>plugin qualifier  ${plugin.qualifier}</echo>
    <echo>plugin version  ${plugin.version}</echo>
    <!-- Copy META-INF/MANIFEST.MF to ${out.dir}, "qualifier" to current version -->
    <copy file="META-INF/MANIFEST.MF" toFile="${out.build}/META-INF/MANIFEST.MF" overwrite="true">
      <filterset begintoken="q" endtoken="r"><filter token="ualifie" value="${plugin.qualifier}"/></filterset>
    </copy>
  	
148
  	<mkdir dir="${out}/site"/>
149
    <copy todir="${out}/site" overwrite="true">
150 151 152 153 154
      <fileset dir="${basedir}/site">
        <include name="**/*.xml"/>
      </fileset>
      <filterset refid="version.filter"/>
    </copy>
155

ekuleshov's avatar
ekuleshov committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169
    <zip zipfile="${out}/BytecodeOutlinesrc.zip">
      <zipfileset dir="${src}" includes="**/*" prefix="src"/>
      <fileset dir=".">
        <include name="icons/*"/>
        <include name="plugin.xml"/>
        <include name="build.properties"/>
        <include name="META-INF/*"/>
        <include name="build.xml"/>
        <include name="build.config"/>
        <include name=".project"/>
        <include name=".classpath"/>
        <include name="README.txt"/>
        <include name="LICENSE.txt"/>
      </fileset>
170
      <fileset dir="${out}/site">
171 172
        <include name="feature.xml"/>
        <include name="site.xml"/>
173
      </fileset>
174

175 176 177
    </zip>
  </target>

178
  <target name="plugin" depends="jars,xslt">
179
    <zip zipfile="${out}/${plugin.jar}">
180
      <zipfileset dir="${out}" includes="BytecodeOutlinesrc.zip"/>
181 182 183
      <fileset dir=".">
        <include name="icons/**/*"/>
        <include name="plugin.xml"/>
184
        <include name="about.html"/>
185 186 187
        <include name="about.ini"/>
        <include name="about.properties"/>
        <include name="about32.png"/>
188 189
        <include name="*.txt"/>
      </fileset>
190 191 192
      <fileset dir="${out.build}">
        <include name="**/*"/>
      </fileset>
193
      <zipfileset dir="${out}/doc" includes="toc.xml,opcodes.html,ref-*.html" prefix="doc"/>
194
    </zip>
ekuleshov's avatar
ekuleshov committed
195
  </target>
196

ekuleshov's avatar
ekuleshov committed
197 198
  <target name="feature" depends="plugin">
    <jar zipfile="${out}/${feature.jar}">
199
      <fileset dir="${out}/site" includes="feature.xml"/>
ekuleshov's avatar
ekuleshov committed
200 201
    </jar>
  </target>
202

203 204
  <target name="site" depends="cleanOutput,feature">
    <zip zipfile="${out}/${plugin.id}.update_${plugin.version}.zip">
205
      <zipfileset dir="${out}/site" includes="site.xml"/>
ekuleshov's avatar
ekuleshov committed
206 207
      <zipfileset dir="${out}" includes="${feature.jar}" prefix="features"/>
      <zipfileset dir="${out}" includes="${plugin.jar}"  prefix="plugins"/>
208 209
    </zip>
  </target>
210

211
  <target name="clean">
ekuleshov's avatar
ekuleshov committed
212 213
    <delete failonerror="false" includeEmptyDirs="true">
      <fileset dir="${out}" includes="**/*"/>
214
      <fileset dir="${lib}" includes="**/*"/>
ekuleshov's avatar
ekuleshov committed
215
    </delete>
216
  </target>
217 218 219 220 221 222
	
  <target name="cleanOutput">
    <delete failonerror="false" includeEmptyDirs="true">
      <fileset dir="${out}" includes="**/*"/>
    </delete>
  </target>
223

224 225
  <target name="xslt" depends="init">
    <mkdir dir="${out}/doc"/>
226
    <xslt basedir="." destdir="${out}/doc" includes="opcodes.xml" classpathref="saxon.classpath"
227
          style="opcodes-doc.xsl" force="true">
228
       <factory name="net.sf.saxon.TransformerFactoryImpl" />
229 230 231
    </xslt>
  </target>

232
</project>