<!-- ====================================================================== -->
<!-- Copyright (c) 2005 Contributors                                        -->
<!-- All rights reserved.                                                   -->
<!-- This program and the accompanying materials are made available         -->
<!-- under the terms of the Eclipse Public License v1.0                     -->
<!-- which accompanies this distribution and is available at                -->
<!-- http://www.eclipse.org/legal/epl-v10.html                              -->
<!--                                                                        -->
<!-- Contributors: (See CVS checkin's)                                      -->
<!-- ====================================================================== -->

<project name="eclipse.plugins" default="eclipse.plugins" basedir=".">
    <property name="aspectj.modules.dir" location="${basedir}/.."/>
    <import file="${aspectj.modules.dir}/build/build-properties.xml" />

    <target name="info">
        <echo>
  Assembles the Eclipse plugins.
            
  Relies on ../build/build-properties.xml for some definitions, and
  the build must have produced the AspectJ distribution already.
  
  Define $${build.version.eclipse.plugins} to avoid "9.9.9" for
  "DEVELOPMENT" (the default).
        </echo>
    </target>

    <target name="init-eclipse-plugins" depends="init-properties">
        <property name="ep.dir"
                  location="${aspectj.modules.dir}/eclipse.plugin"
        />

        <condition property="build.version.eclipse.plugins"
                   value="9.9.9"
        >
            <equals arg1="DEVELOPMENT" arg2="${build.version.long}" />
        </condition>
        <condition property="build.version.eclipse.plugins"
                   value="${build.version.long}"
        >
            <not>
                <equals arg1="DEVELOPMENT"
                        arg2="${build.version.long}"
                />
            </not>
        </condition>
        <jar-property name="ep.aspectjrt.jar"
                      location="${aj.dist.dir}/tools/lib/aspectjrt.jar"
        />
        <property name="ep.eclipse.dist.dir"
                  location="${aj.dist.dir}/ide/eclipse"
        />
    </target>

    <target name="eclipse.plugins"
            depends="do-rt,do-source,do-ajde,do-doc"
    />

    <target name="do-rt" depends="init-eclipse-plugins">

        <property name="name.rt" value="org.aspectj.aspectjrt" />
        <mkdir dir="${ep.eclipse.dist.dir}/${name.rt}" />
        <copy todir="${ep.eclipse.dist.dir}/${name.rt}"
              file="${ep.aspectjrt.jar}"
        />
        <build-eclipse-plugin name="${name.rt}" />
    </target>

    <target name="do-source" depends="init-eclipse-plugins">
        <property name="name.source"
                  value="org.aspectj.ajde.source"
        />
        <clean-dir dir="${ep.eclipse.dist.dir}/${name.source}/src" />
        <copy todir="${ep.eclipse.dist.dir}/${name.source}/src"
              file="${aspectj.modules.dir}/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip"
        />
        <!-- verify source dirs included:
        grep 'kind="src"' */.classpath | sed '/testsrc/d;/path="\//d;s|\/.*path="|\/|;s|".*||'
        compare filelist: ${aspectj.tools.modules}
        -->
        <zip destfile="${ep.eclipse.dist.dir}/${name.source}/src/aspectjsrc.zip"
        >
            <fileset dir="${aspectj.modules.dir}/ajbrowser/src" />
            <fileset dir="${aspectj.modules.dir}/ajde/src" />
            <fileset dir="${aspectj.modules.dir}/ajde.core/src" />
            <fileset dir="${aspectj.modules.dir}/ajdoc/src" />
            <fileset dir="${aspectj.modules.dir}/asm/src" />
            <fileset dir="${aspectj.modules.dir}/aspectj5rt/java5-src"
            />
            <fileset dir="${aspectj.modules.dir}/aspectj5rt/src" />
            <fileset dir="${aspectj.modules.dir}/bridge/src" />
            <fileset dir="${aspectj.modules.dir}/loadtime/src" />
            <fileset dir="${aspectj.modules.dir}/org.aspectj.matcher/src" />
            <fileset dir="${aspectj.modules.dir}/loadtime5/java5-src"
            />
            <fileset dir="${aspectj.modules.dir}/org.aspectj.ajdt.core/src"
            />
            <!--fileset dir="${aspectj.modules.dir}/org.aspectj.lib/src"
            /-->
            <fileset dir="${aspectj.modules.dir}/runtime/src" />
            <fileset dir="${aspectj.modules.dir}/taskdefs/src" />
            <fileset dir="${aspectj.modules.dir}/util/src" />
            <fileset dir="${aspectj.modules.dir}/weaver/src" />
            <fileset dir="${aspectj.modules.dir}/weaver5/java5-src" />
        </zip>
        <build-eclipse-plugin name="${name.source}" />
    </target>

    <target name="do-ajde" depends="init-eclipse-plugins">
        <property name="name.ajde" value="org.aspectj.ajde" />
        <jar-property name="ep.aspectjtools.jar"
                      location="${aj.dist.dir}/tools/lib/aspectjtools.jar"
        />
        <clean-dir dir="${ep.eclipse.dist.dir}/${name.ajde}" />
        <copy todir="${ep.eclipse.dist.dir}/${name.ajde}">
            <fileset file="${ep.aspectjrt.jar}" />
            <fileset file="${ep.aspectjtools.jar}" />
        </copy>
        <jar destfile="${ep.eclipse.dist.dir}/${name.ajde}/ajde.jar">
            <zipfileset src="${ep.aspectjtools.jar}"
                        includes="org/aspectj/**"
            />
            <!-- TODO dangerous assumption: only org.aspectj?  not org.eclipse or org.osgi? -->
        </jar>
        <build-eclipse-plugin name="${name.ajde}" />
    </target>

    <target name="do-doc" depends="init-eclipse-plugins">
        <available property="ep.docs.available"
                   file="${aj.dist.dir}/docs/doc/examples/build.xml"
        />
        <fail unless="ep.docs.available"
              message="no doc in ${aj.dist.dir}"
        />
        <property name="name.doc" value="org.aspectj.ajde.doc" />
        <clean-dir dir="${ep.eclipse.dist.dir}/${name.doc}/doc" />
        <copy todir="${ep.eclipse.dist.dir}/${name.doc}/doc">
            <fileset dir="${aj.dist.dir}/docs/doc" />
        </copy>
        <build-eclipse-plugin name="${name.doc}" />
    </target>

    <macrodef name="build-eclipse-plugin">
        <attribute name="name" />
        <sequential>
            <mkdir dir="${ep.eclipse.dist.dir}/@{name}" />
            <copy todir="${ep.eclipse.dist.dir}/@{name}">
                <fileset dir="${ep.dir}/@{name}" />
            </copy>
            <replace file="${ep.eclipse.dist.dir}/@{name}/plugin.xml"
                     token="build.version.eclipse.plugins"
                     value="${build.version.eclipse.plugins}"
            />
            <jar destfile="${ep.eclipse.dist.dir}/@{name}_${build.version.eclipse.plugins}.jar"
            >
                <fileset dir="${ep.eclipse.dist.dir}/@{name}" />
            </jar>
        </sequential>
    </macrodef>

</project>
