<?xml version="1.0" encoding="UTF-8"?>
<!--

 Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

 This code is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.  Oracle designates this
 particular file as subject to the "Classpath" exception as provided
 by Oracle in the LICENSE file that accompanied this code.

 This code 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
 version 2 for more details (a copy is included in the LICENSE file that
 accompanied this code).

 You should have received a copy of the GNU General Public License version
 2 along with this work; if not, write to the Free Software Foundation,
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 or visit www.oracle.com if you need additional information or have any
 questions.
-->
<!DOCTYPE someant  [
  <!ENTITY links SYSTEM "javadoctools/links.xml">
  <!ENTITY properties SYSTEM "javadoctools/properties.xml">
  <!ENTITY replaces SYSTEM "javadoctools/replaces.xml">
  <!ENTITY disallowed-links SYSTEM "javadoctools/disallowed-links.xml">
]>

<project name="ml-build" default="build" basedir=".">
<!--  <import file="../nbbuild/default.xml"/> -->

  <target name="assure-ant">
      <fail message="You need Ant version 1.7.0 or later to build NetBeans.">
          <condition>
              <not>
                  <antversion atleast="1.7.0"/>
              </not>
          </condition>
      </fail>
  </target>

  <!-- Fallback for ant.core.lib - it is not set in some cases - 124554 -->
  <available property="ant.core.lib" value="${ant.home}/lib/ant.jar" file="${ant.home}/lib/ant.jar"/>
  <!-- if the previous location is not correct than find the ant.jar from the java.class.path value -->
  <pathconvert property="ant.core.lib">
    <mapper type="regexp" from="${path.separator}([^${path.separator}]*ant.jar)${path.separator}" to="\1"/>
    <path location="${path.separator}${java.class.path}${path.separator}"/>
  </pathconvert>

  <target name="bootstrap"
          description="Bootstrap NetBeans-specific Ant extensions."
          depends="assure-ant">
    <property file="build.properties"/>
    <property name="main.dir" location=".."/>
    <property name="jh.jar" value="visualvm/netbeans/harness/jsearch*.jar"/>
    <property name="jsearch.jar" value="visualvm/netbeans/harness/jsearch*.jar"/>

    <mkdir dir="build/antclasses"/>
    <echo message="Bootstrapping NetBeans-specific Ant extensions..."/>
    <path id="bootstrap-cp">
     <pathelement location="${ant.core.lib}"/>
     <fileset dir="${main.dir}">
        <!-- For JavaHelp indexing: -->
        <include name="${jh.jar}"/>
        <!-- For JavaHelp link checking: -->
        <include name="${jsearch.jar}"/>
        <include name="visualvm/netbeans/harness/tasks.jar"/>
      </fileset>
    </path>
    <!-- Sanity check: -->
    <pathconvert pathsep=":" property="class.files.in.antsrc">
        <path>
            <fileset dir="antsrc">
                <include name="**/*.class"/>
            </fileset>
        </path>
    </pathconvert>
    <fail>
        <condition>
            <not>
                <equals arg1="${class.files.in.antsrc}" arg2=""/>
            </not>
        </condition>
        You have stray *.class files in ${basedir}/antsrc which you must remove.
        Probably you failed to clean your sources before updating. Try: ant hg-clean
    </fail>
    <!-- OK, continue: -->
    <javac srcdir="antsrc" destdir="build/antclasses" deprecation="true" debug="true" source="1.5" target="1.5">
      <classpath refid="bootstrap-cp"/>
      <compilerarg line="-Xlint -Xlint:-serial"/>
    </javac>
    <jar jarfile="l10nantext.jar">
      <fileset dir="build/antclasses"/>
      <fileset dir="antsrc">
        <exclude name="**/*.java"/>
        <exclude name="**/package.html"/>
        <exclude name="package-list"/>
      </fileset>
    </jar>
  </target>

  <target name="precopy">
    <delete dir="en.nbms"/>
    <mkdir dir="en.nbms/visualvm"/>
    <copy todir="en.nbms/visualvm">
      <fileset dir="../visualvm/build/updates">
        <include name="*.nbm"/>
      </fileset>
    </copy>
  </target>
  
  <target name="build" depends="bootstrap,precopy">
    <delete dir="dist"/>
    <taskdef name="jhindexer"
         classname="org.netbeans.nbbuild.JHIndexer"
         classpath="${main.dir}/visualvm/netbeans/harness/tasks.jar"/>
    <taskdef name="locjhindexer"
         classname="org.netbeans.nbbuild.LocJHIndexer"
         classpath="l10nantext.jar:${main.dir}/visualvm/netbeans/harness/tasks.jar"/>
    <taskdef name="repeat"
         classname="org.netbeans.nbbuild.Repeat"
         classpath="l10nantext.jar:${main.dir}/visualvm/netbeans/harness/tasks.jar"/>

    <property name="locjhindexer.jhall" value="${main.dir}/${jh.jar}"/>
    <property name="locales" value="ja,zh_CN"/>
    <property name="dist.dir" location="build"/>
    <property name="nbms.dist.dir" location="dist/nbms"/>
    <property name="nbms.dir" location="en.nbms"/>
    <property name="keystore" location=""/>
    <property name="storepass" value=""/>
    <property name="nbm_alias" value="nb_ide"/>
     
    <taskdef name="package-build" classname="org.netbeans.l10n.Package">
      <classpath>
          <pathelement path="l10nantext.jar"/>
          <pathelement path="${main.dir}/visualvm/netbeans/harness/tasks.jar"/>
      </classpath>
    </taskdef>
    <package-build src="src" locales="${locales}" dist="${dist.dir}" nbms="${nbms.dir}" nbmsDist="${nbms.dist.dir}" 
                    keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}">
            <classpath>
                <pathelement location="${main.dir}/visualvm/netbeans/harness/tasks.jar"/>
                <fileset dir="${main.dir}">
                    <include name="visualvm/netbeans/harness/jsearch*.jar"/>
                </fileset>
            </classpath>
    </package-build>
    <unzip src="../visualvm/nb_ml.zip" dest="build"/>
    <zip destfile="dist/visualvm_ml.zip" duplicate="preserve">
      <zipfileset dir="build/netbeans" filemode="755" prefix="visualvm">
          <include name="**/lib/nbexec*"/>
          <include name="profiler*/lib/deployed/**/hpux*/lib*.sl"/>
          <include name="profiler*/lib/deployed/**/lib*.so"/>
      </zipfileset>
      <zipfileset dir="build/netbeans" prefix="visualvm">
          <include name="p*/**"/>
          <exclude name="**/lib/nbexec*"/>
          <exclude name="profiler*/lib/deployed/**/hpux*/lib*.sl"/>
          <exclude name="profiler*/lib/deployed/**/lib*.so"/>
      </zipfileset>
      <zipfileset src="../visualvm/dist/visualvm.zip"/>
      <zipfileset dir="build" prefix="visualvm">
        <include name="visualvm/**"/>
      </zipfileset>
    </zip>
     
  </target>

</project>
