1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2024-11-22 17:42:46 +01:00
IntelliJ-IdeaVim/build.xml
2012-11-01 19:38:25 +04:00

275 lines
9.8 KiB
XML

<project name="IdeaVim">
<!--
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2009 Rick Maddy, Oleg Shpynov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-->
<property file="build.properties"/>
<property name="idea" value="${basedir}/idea"/>
<property name="src" value="${basedir}/src"/>
<property name="resources" value="${basedir}/resources"/>
<property name="test" value="${basedir}/test"/>
<property name="keymap" value="${basedir}/keymap"/>
<property name="idea.home" value="${idea}/unzip"/>
<property environment="env"/>
<property name="tools.jar" value="${env.JAVA_HOME}/lib/tools.jar"/>
<property name="version" value="${version-id}.${build.number}"/>
<property name="filename" value="ideavim-${version}"/>
<!--Output-->
<property name="out" value="${basedir}/out"/>
<property name="classes" value="${out}/classes"/>
<property name="build" value="${out}/build"/>
<property name="dist" value="${out}/dist"/>
<property name="test-reports" value="${out}/test-reports"/>
<!-- Define task -->
<path id="ant-contrib">
<pathelement path="lib/ant-contrib-1.0b3.jar"/>
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="ant-contrib"/>
<path id="build.classpath">
<fileset dir="${idea.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${java.home}/lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${classes}"/>
</path>
<path id="test.classpath">
<path refid="build.classpath"/>
<pathelement path="${tools.jar}"/>
</path>
<!-- Clean all the generated stuff -->
<target name="clean" description="Removes all generated files">
<delete dir="${out}"/>
</target>
<!-- Compile all the sources to the ${classes} folder -->
<target name="compile">
<mkdir dir="${classes}"/>
<taskdef name="javac2" classname="com.intellij.ant.Javac2">
<classpath refid="build.classpath"/>
</taskdef>
<!-- The task requires the following libraries from IntelliJ IDEA distribution: -->
<!-- javac2.jar; jdom.jar; asm.jar; asm-commons.jar -->
<javac2 destdir="${classes}" debug="on" fork="true" includeantruntime="false">
<classpath refid="build.classpath"/>
<src path="${src}"/>
<include name="com/maddyhome/idea/**"/>
</javac2>
</target>
<!-- Create ideavim.jar for packing inside zip plugin package -->
<target name="jar">
<mkdir dir="${classes}"/>
<mkdir dir="${classes}/META-INF"/>
<copy file="resources/META-INF/plugin.xml" todir="${classes}/META-INF">
<filterset>
<filter token="VERSION" value="${version}"/>
<filter token="SINCE-VERSION" value="${platform-version}"/>
</filterset>
</copy>
<copy todir="${classes}">
<fileset dir="${src}" excludes="**/*.java"/>
</copy>
<copy todir="${classes}">
<fileset dir="${resources}"/>
</copy>
<mkdir dir="${build}"/>
<jar basedir="${classes}" jarfile="${build}/IdeaVim.jar" compress="yes"/>
</target>
<!-- Create help files -->
<target name="help" depends="clean, compile">
<mkdir dir="${build}/help/txt"/>
<mkdir dir="${build}/help/vim"/>
<copy todir="${build}/help/txt">
<fileset dir="help/txt">
<include name="*.txt"/>
</fileset>
<filterset>
<filter token="VERSION" value="${version}"/>
</filterset>
</copy>
<!-- Generate tags by shortcuts or actions -->
<fileset dir="${build}/help/txt" id="txt.files">
<include name="*.txt"/>
</fileset>
<pathconvert property="helpfiles" refid="txt.files" pathsep=" "/>
<java failonerror="true" classname="com.maddyhome.idea.vim.help.MakeTags" classpath="${classes}"
output="${build}/help/vim/tags" error="error">
<arg line="${helpfiles}"/>
</java>
<exec executable="sort" output="${build}/help/vim/tags.sort">
<arg value="-u"/>
<arg file="${build}/help/vim/tags"/>
</exec>
<move file="${build}/help/vim/tags.sort" tofile="${build}/help/vim/tags"/>
<exec executable="perl">
<arg file="help/vim2jh.pl"/>
<arg path="${build}/help"/>
<arg path="${build}/help/vim/tags"/>
<arg line="${helpfiles}"/>
</exec>
<copy todir="${build}/help">
<fileset dir="help">
<include name="images/"/>
</fileset>
</copy>
<copy todir="${build}/help">
<fileset dir="help/jh">
<include name="*"/>
</fileset>
<filterset>
<filter token="VERSION" value="${version}"/>
</filterset>
</copy>
<delete dir="${build}/help/txt"/>
<fileset dir="${build}/help/vim" id="html.files">
<include name="*.html"/>
</fileset>
<pathconvert property="htmlfiles" refid="html.files" pathsep=" "/>
<propertyregex property="srchfiles" input="${htmlfiles}" regexp="${build}/help/" replace="" global="true"/>
<java classname="com.sun.java.help.search.Indexer" classpath="lib/jhall.jar" fork="true" dir="${build}/help">
<arg value="-db"/>
<arg value="MasterSearchIndex"/>
<arg line="${srchfiles}"/>
</java>
<jar basedir="${build}/help" jarfile="${build}/help.jar"/>
</target>
<target name="build" depends="unzip, clean, compile, jar, help" description="Compiles all source code and created plugin jar file"/>
<!-- Download IntelliJ IDEA distribution -->
<target name="download" description="Downloads IntelliJ IDEA artifacts">
<mkdir dir="${idea}"/>
<get src="${idea.download.url}" dest="${idea}" skipexisting="true"/>
</target>
<!-- Unpack idea-*.zip file for ideavim compilation -->
<target name="unzip" depends="download" description="Unzip downloaded artifacts and set up idea.home">
<delete dir="${idea}/unzip"/>
<mkdir dir="${idea}/unzip"/>
<basename property="idea.filename" file="${idea.download.url}"/>
<unzip dest="${idea}/unzip">
<fileset dir="${idea}" includes="${idea.filename}"/>
</unzip>
</target>
<target name="dist" depends="dist-src, dist-bin" description="Creates the src and bin distribution files"/>
<!-- Prepare layout for plugin distribution and creates zip file which can be published -->
<target name="dist-bin" depends="clean, build" description="Creates a zip file containing the plugin sources">
<delete dir="${build}/IdeaVim"/>
<mkdir dir="${build}/IdeaVim"/>
<copy todir="${build}/IdeaVim">
<fileset dir="${basedir}" includes="license/**"/>
<fileset dir="${keymap}" includes="**"/>
</copy>
<copy todir="${build}/IdeaVim/lib">
<fileset dir="${build}" includes="*.jar" excludes="help.jar"/>
</copy>
<copy todir="${build}/IdeaVim/help">
<fileset dir="${build}" includes="help.jar"/>
</copy>
<copy file="${basedir}/README.txt" tofile="${build}/IdeaVim/README">
<filterset>
<filter token="VERSION" value="${version}"/>
<filter token="PLATFORM_VERSION" value="${platform-version}"/>
</filterset>
</copy>
<copy file="${basedir}/CHANGES.txt" tofile="${build}/IdeaVim/CHANGES">
<filterset>
<filter token="VERSION" value="${version}"/>
<filter token="PLATFORM_VERSION" value="${platform-version}"/>
</filterset>
</copy>
<zip basedir="${build}" zipfile="${dist}/${filename}.zip" compress="true" includes="IdeaVim/**"/>
</target>
<!-- Packs all the sources -->
<target name="dist-src" depends="clean" description="Creates the source tar file">
<mkdir dir="${dist}"/>
<tar basedir="." destfile="${dist}/${filename}-src.tar.gz" excludes=".git/**,.idea/**,idea/**,*.iws,*.iml" compression="gzip"/>
</target>
<target name="compile-tests" depends="compile">
<mkdir dir="${classes}"/>
<taskdef name="javac2" classname="com.intellij.ant.Javac2">
<classpath refid="build.classpath"/>
</taskdef>
<javac2 destdir="${classes}" debug="on" fork="true" includeantruntime="false">
<classpath refid="build.classpath"/>
<src path="${test}"/>
<include name="org/jetbrains/plugins/ideavim/**"/>
</javac2>
</target>
<target name="prepare-tests" depends="compile-tests">
<mkdir dir="${classes}/META-INF"/>
<copy file="resources/META-INF/plugin.xml" todir="${classes}/META-INF">
<filterset>
<filter token="VERSION" value="${version}"/>
<filter token="SINCE-VERSION" value="${platform-version}"/>
</filterset>
</copy>
<copy todir="${classes}">
<fileset dir="${resources}"/>
</copy>
<mkdir dir="${out}/IdeaVim"/>
<copy todir="${out}/IdeaVim">
<fileset dir="${keymap}" includes="**"/>
</copy>
</target>
<target name="test" depends="unzip, clean, prepare-tests">
<mkdir dir="${test-reports}"/>
<junit fork="true" logfailedtests="false" printsummary="true">
<classpath refid="test.classpath"/>
<jvmarg value="-Xmx256M"/>
<jvmarg value="-ea"/>
<jvmarg value="-Djava.awt.headless=true"/>
<jvmarg value="-Didea.plugins.path=${out}"/>
<jvmarg value="-Didea.load.plugins.id=IdeaVIM"/>
<formatter type="plain"/>
<batchtest todir="${test-reports}">
<fileset dir="${test}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
</project>