build.xml
author rnovak@netbeans.org
Tue, 05 Oct 2010 13:40:04 +0200
branchrelease61
changeset 1006 9a207f6e12c8
parent 1002 a4844e6f0599
permissions -rw-r--r--
marking as branch release61
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <!--
     3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4 
     5 Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
     6 
     7 
     8 The contents of this file are subject to the terms of either the GNU
     9 General Public License Version 2 only ("GPL") or the Common
    10 Development and Distribution License("CDDL") (collectively, the
    11 "License"). You may not use this file except in compliance with the
    12 License. You can obtain a copy of the License at
    13 http://www.netbeans.org/cddl-gplv2.html
    14 or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    15 specific language governing permissions and limitations under the
    16 License.  When distributing the software, include this License Header
    17 Notice in each file and include the License file at
    18 nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
    19 particular file as subject to the "Classpath" exception as provided
    20 by Sun in the GPL Version 2 section of the License file that
    21 accompanied this code. If applicable, add the following below the
    22 License Header, with the fields enclosed by brackets [] replaced by
    23 your own identifying information:
    24 "Portions Copyrighted [year] [name of copyright owner]"
    25 
    26 Contributor(s):
    27 
    28 The Original Software is NetBeans. The Initial Developer of the Original
    29 Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
    30 Microsystems, Inc. All Rights Reserved.
    31 
    32 If you wish your version of this file to be governed by only the CDDL
    33 or only the GPL Version 2, indicate your decision by adding
    34 "[Contributor] elects to include this software in this distribution
    35 under the [CDDL or GPL Version 2] license." If you do not indicate a
    36 single choice of license, a recipient has the option to distribute
    37 your version of this file under either the CDDL, the GPL Version 2 or
    38 to extend the choice of license to its licensees as provided above.
    39 However, if you add GPL Version 2 code and therefore, elected the GPL
    40 Version 2 license, then the option applies only if the new code is
    41 made subject to such option by the copyright holder.
    42 -->
    43 <!DOCTYPE someant  [
    44   <!ENTITY links SYSTEM "javadoctools/links.xml">
    45   <!ENTITY properties SYSTEM "javadoctools/properties.xml">
    46   <!ENTITY replaces SYSTEM "javadoctools/replaces.xml">
    47   <!ENTITY disallowed-links SYSTEM "javadoctools/disallowed-links.xml">
    48 ]>
    49 
    50 <project name="ml-build" default="build" basedir=".">
    51 
    52   <import file="../nbbuild/default.xml"/>
    53 
    54   <target name="assure-ant">
    55       <fail message="You need Ant version 1.7.0 or later to build NetBeans.">
    56           <condition>
    57               <not>
    58                   <antversion atleast="1.7.0"/>
    59               </not>
    60           </condition>
    61       </fail>
    62   </target>
    63 
    64   <!-- Fallback for ant.core.lib - it is not set in some cases - 124554 -->
    65   <available property="ant.core.lib" value="${ant.home}/lib/ant.jar" file="${ant.home}/lib/ant.jar"/>
    66   <!-- if the previous location is not correct than find the ant.jar from the java.class.path value -->
    67   <pathconvert property="ant.core.lib">
    68     <mapper type="regexp" from="${path.separator}([^${path.separator}]*ant.jar)${path.separator}" to="\1"/>
    69     <path location="${path.separator}${java.class.path}${path.separator}"/>
    70   </pathconvert>
    71 
    72   <target name="bootstrap"
    73           description="Bootstrap NetBeans-specific Ant extensions."
    74           depends="assure-ant">
    75     <property file="build.properties"/>
    76     <property name="main.dir" location=".."/>
    77     <property name="jh.jar" value="apisupport.harness/external/jsearch*.jar"/>
    78     <property name="jsearch.jar" value="javahelp/external/jh*.jar"/>
    79 
    80     <mkdir dir="build/antclasses"/>
    81     <echo message="Bootstrapping NetBeans-specific Ant extensions..."/>
    82     <path id="bootstrap-cp">
    83      <pathelement location="${ant.core.lib}"/>
    84      <fileset dir="${main.dir}">
    85         <!-- For JavaHelp indexing: -->
    86         <include name="${jh.jar}"/>
    87         <!-- For JavaHelp link checking: -->
    88         <include name="${jsearch.jar}"/>
    89         <include name="nbbuild/nbantext.jar"/>
    90       </fileset>
    91     </path>
    92     <!-- Sanity check: -->
    93     <pathconvert pathsep=":" property="class.files.in.antsrc">
    94         <path>
    95             <fileset dir="antsrc">
    96                 <include name="**/*.class"/>
    97             </fileset>
    98         </path>
    99     </pathconvert>
   100     <fail>
   101         <condition>
   102             <not>
   103                 <equals arg1="${class.files.in.antsrc}" arg2=""/>
   104             </not>
   105         </condition>
   106         You have stray *.class files in ${basedir}/antsrc which you must remove.
   107         Probably you failed to clean your sources before updating. Try: ant hg-clean
   108     </fail>
   109     <!-- OK, continue: -->
   110     <javac srcdir="antsrc" destdir="build/antclasses" deprecation="true" debug="true" source="1.5" target="1.5">
   111       <classpath refid="bootstrap-cp"/>
   112       <compilerarg line="-Xlint -Xlint:-serial"/>
   113     </javac>
   114     <jar jarfile="l10nantext.jar">
   115       <fileset dir="build/antclasses"/>
   116       <fileset dir="antsrc">
   117         <exclude name="**/*.java"/>
   118         <exclude name="**/package.html"/>
   119         <exclude name="package-list"/>
   120       </fileset>
   121     </jar>
   122   </target>
   123 
   124   <target name="-hg-check-can-clean">
   125     <available property="can.hg.clean" type="dir" file="../.hg"/>
   126   </target>
   127   <target name="-hg-clean-alternative" depends="-hg-check-can-clean" unless="can.hg.clean">
   128     <antcall target="-real-clean"/>
   129   </target>
   130   <target name="hg-clean" depends="-hg-clean-alternative" if="can.hg.clean"
   131           description="Clean everything possible.">
   132     <antcall target="-do-hg-clean">
   133       <!-- <include name="."/> does not seem to work in a dirset -->
   134       <param name="basedir" location="."/>
   135     </antcall>
   136   </target>
   137   <target name="-do-hg-clean">
   138     <echo>Cleaning untracked files in ${basedir}...</echo>
   139     <exec executable="hg" failonerror="yes" outputproperty="hg.unknown.files">
   140       <arg value="--cwd"/>
   141       <arg file="."/>
   142       <arg value="status"/>
   143       <arg value="--unknown"/>
   144       <arg value="--no-status"/>
   145     </exec>
   146     <fail message="Will not run clean; checkout contains unknown and not ignored files (did you forget to hg add?):&#10;${hg.unknown.files}">
   147         <condition>
   148             <not>
   149                 <equals arg1="${hg.unknown.files}" arg2=""/>
   150             </not>
   151         </condition>
   152     </fail>
   153     <exec executable="hg" failonerror="yes">
   154       <arg value="--cwd"/>
   155       <arg file="."/>
   156       <arg value="--config"/>
   157       <arg value="extensions.purge="/>
   158       <arg value="--verbose"/>
   159       <arg value="clean"/>
   160       <arg value="--all"/>
   161       <arg value="--exclude"/>
   162       <!-- Do not use **/nbproject/private/ as this will match some test/{results,work} dirs: -->
   163       <arg value="glob:{*/nbproject/private/**,*/*/nbproject/private/**,**/user.build.properties,nbbuild/misc/build-site-local.sh}"/>
   164     </exec>
   165   </target>
   166 
   167  <target name="build" depends="bootstrap">
   168     <taskdef name="jhindexer"
   169          classname="org.netbeans.nbbuild.JHIndexer"
   170          classpath="${main.dir}/nbbuild/nbantext.jar"/>
   171     <taskdef name="locjhindexer"
   172          classname="org.netbeans.nbbuild.LocJHIndexer"
   173          classpath="${main.dir}/nbbuild/nbantext.jar"/>
   174 
   175      <property name="locjhindexer.jhall" value="${main.dir}/${jh.jar}"/>
   176      <property name="locales" value="ja,zh_CN,pt_BR"/>
   177      <property name="dist.dir" location="dist"/>
   178      <property name="nbms.dist.dir" location="nbms"/>
   179      <property name="nbms.dir" location="../nbbuild/nbms"/>
   180      <property name="keystore" location=""/>
   181      <property name="storepass" value=""/>
   182      <property name="nbm_alias" value="nb_ide"/>
   183      
   184      <taskdef name="package-build" classname="org.netbeans.l10n.Package">
   185         <classpath>
   186             <pathelement path="l10nantext.jar"/>
   187             <pathelement path="${main.dir}/nbbuild/nbantext.jar"/>
   188         </classpath>
   189      </taskdef>
   190      <package-build src="src" locales="${locales}" dist="${dist.dir}" nbms="${nbms.dir}" nbmsDist="${nbms.dist.dir}" 
   191                     keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
   192      <copy todir="${dist.dir}" flatten="true">
   193          <fileset dir="src">
   194             <include name="*/other/ide.branding/release/*.html"/>
   195          </fileset>
   196      </copy>
   197      <copy todir="${dist.dir}/nb6.1" flatten="true">
   198          <fileset dir="src">
   199             <include name="*/other/ide.branding/release/*.pdf"/>
   200          </fileset>
   201      </copy>
   202  </target>
   203 
   204  <target name="build-community-nbms" depends="bootstrap,init-tasks">
   205       <taskdef name="repeat" classname="org.netbeans.nbbuild.Repeat"
   206                classpath="${main.dir}/nbbuild/nbantext.jar"/>
   207 
   208       <pathconvert property="dlocales" setonempty="false">
   209           <path path="${locales}"/>
   210           <chainedmapper>
   211           <filtermapper>
   212               <replacestring from="," to="_"/>
   213               <replacestring from="-" to="_"/>
   214           </filtermapper>
   215           <flattenmapper/>
   216           </chainedmapper>
   217       </pathconvert>
   218 
   219       <property name="netbeans.dest.dir.ml" location="nbms/community/${dlocales}"/>
   220       <mkdir dir="${netbeans.dest.dir.ml}"/>
   221 
   222       <property name="netbeans.build.dir.ml" location="build/community"/>
   223       <delete dir="${netbeans.build.dir.ml}"/>
   224       <mkdir dir="${netbeans.build.dir.ml}"/>
   225 
   226       <tstamp>
   227           <format property="spec.version" pattern="yyyy.M.d.kmm" locale="en" />
   228       </tstamp>
   229       <delete file="build/ml/cluster-nbms-ml.properties"/>
   230 
   231       <pathconvert property="base.dir" pathsep=",">
   232           <path>
   233               <pathelement location="dist"/>
   234           </path>
   235       </pathconvert>
   236 
   237       <echo>Base dir: ${base.dir}</echo>
   238 
   239       <pathconvert property="comm.clusters.list" pathsep=",">
   240           <path>
   241               <dirset dir="dist" id="cluster.dirs">
   242                   <include name="*"/>
   243                   <exclude name="nb*.*"/>
   244               </dirset>
   245           </path>
   246           <map from="${base.dir}/" to=""/>
   247       </pathconvert>
   248 
   249       <echo>Cluster dirs: ${comm.clusters.list}</echo>
   250       <condition property="is.localized" value="true">
   251           <not>
   252              <equals arg1="${comm.clusters.list}" arg2="" trim="true"/>
   253           </not>
   254       </condition>
   255       <echo>IS localized: ${is.localized}</echo>
   256 
   257       <antcall target="build-all-nbm-ml"/>
   258   </target>
   259 
   260   <target name="build-all-nbm-ml" if="is.localized">
   261       <repeat target="build-one-nbm-ml" name="one.cluster.dir.ml" values="${comm.clusters.list}"/>
   262       <antcall target="build-one-nbm-ml" inheritall="false">
   263           <param name="is.kit" value="true"/>
   264           <param name="locales" value="${locales}"/>
   265           <param name="dlocales" value="${dlocales}"/>
   266           <param name="one.cluster.dir.ml" value="nb6.1"/>
   267           <param name="nb.cluster.nb" value="${nb.cluster.nb}"/>
   268           <param name="comm.clusters.list" value="${comm.clusters.list}"/>
   269           <param name="spec.version" value="${spec.version}"/>
   270           <param name="netbeans.dest.dir.ml" value="${netbeans.dest.dir.ml}"/>
   271           <param name="netbeans.build.dir.ml" value="${netbeans.build.dir.ml}"/>
   272           <param name="buildnumber" value="${buildnumber}"/>
   273       </antcall>
   274   </target>
   275 
   276 
   277   <target name="-create-cluster-ml-nbm-metadata" unless="is.kit">
   278       <echo file="build/ml/nbms/tmp/manifest.mf">OpenIDE-Module: ${code.name}
   279 OpenIDE-Module-Localizing-Bundle: ${code.name.base.slashes}/Bundle.properties
   280 OpenIDE-Module-Specification-Version: ${spec.version}
   281 </echo>
   282       <echo file="build/ml/nbms/classes/${code.name.base.slashes}/Bundle.properties">
   283 OpenIDE-Module-Name=NetBeans 6.1 ${one.cluster.dir.ml} cluster localization (${locales})
   284 OpenIDE-Module-Display-Category=Localization
   285 OpenIDE-Module-Short-Description=NetBeans 6.1 ${one.cluster.dir.ml} cluster localization (${locales})
   286 OpenIDE-Module-Long-Description=Delivers ${locales} localization for all modules in ${one.cluster.dir.ml} cluster of NetBeans 6.1
   287 </echo>
   288   </target>
   289  
   290     <target name="-prepare-localizing-bundles" if="one.kit.locale">
   291        <echo file="build/ml/nbms/classes/${code.name.base.slashes}/Bundle_${one.kit.locale}.properties">
   292 OpenIDE-Module-Name=NetBeans 6.1 ${one.kit.locale} localization plugin
   293 OpenIDE-Module-Display-Category=Localization
   294 OpenIDE-Module-Short-Description=NetBeans 6.1 ${one.kit.locale} localization plugin
   295 OpenIDE-Module-Long-Description=Delivers ${one.kit.locale} localization of whole NetBeans 6.1
   296 </echo>
   297        <!-- try to look for Bundle properties file provided by translation team -->
   298        <copy file="l10n_uc_kits/${code.name.base.slashes}/../${one.kit.locale}/Bundle.properties"
   299              tofile="build/ml/nbms/classes/${code.name.base.slashes}/Bundle_${one.kit.locale}.properties"
   300              overwrite="true"
   301              failonerror="false"/>
   302        <!-- enforce display category to be "Localization", the same for all umbrella kit NBMs -->
   303        <propertyfile file="build/ml/nbms/classes/${code.name.base.slashes}/Bundle_${one.kit.locale}.properties">
   304          <entry key="OpenIDE-Module-Display-Category" value="Localization"/>
   305        </propertyfile>
   306     </target>
   307 
   308     <target name="-create-kit-ml-nbm-metadata" if="is.kit">
   309       <echo file="build/ml/nbms/tmp/manifest.mf">OpenIDE-Module: ${code.name}
   310 OpenIDE-Module-Localizing-Bundle: ${code.name.base.slashes}/Bundle.properties
   311 OpenIDE-Module-Specification-Version: ${spec.version}
   312 OpenIDE-Module-Module-Dependencies: ${kit.deps}
   313 </echo>
   314        <!-- prepare localization jarfiles - it's just for localized info.xml files inf NBMs -->
   315 <!--
   316        <repeat target="-prepare-localizing-bundles" name="one.kit.locale" values="${locales}"/>
   317        <property name="locjar.locales" value="${locales}"/>
   318        <locjar jarfile="${cluster}/${module.jar}"
   319                basedir="build/ml/nbms/classes"
   320                compress="false"/>
   321        <delete>
   322            <fileset dir="build/ml/nbms/classes/${code.name.base.slashes}" includes="Bundle_*.properties"/>
   323        </delete>
   324 -->
   325 
   326        <!-- create default Bundle properties -->
   327        <echo file="build/ml/nbms/classes/${code.name.base.slashes}/Bundle.properties">
   328 OpenIDE-Module-Name=NetBeans 6.1 ${locales} localization kit
   329 OpenIDE-Module-Display-Category=Localization
   330 OpenIDE-Module-Short-Description=NetBeans 6.1 ${locales} localization kit
   331 OpenIDE-Module-Long-Description=Delivers ${locales} localization of whole NetBeans 6.1
   332 </echo>
   333        <!-- try to look for Bundle properties file provided by translation team -->
   334        <copy file="../translatedfiles/src/nbbuild/${code.name.base.slashes}/Bundle.properties"
   335              tofile="build/ml/nbms/classes/${code.name.base.slashes}/Bundle.properties"
   336              overwrite="true"
   337              failonerror="false"/>
   338        <!-- enforce display category to be "Localization", the same for all umbrella kit NBMs -->
   339        <propertyfile file="build/ml/nbms/classes/${code.name.base.slashes}/Bundle.properties">
   340          <entry key="OpenIDE-Module-Display-Category" value="Localization"/>
   341        </propertyfile>
   342   </target>
   343 
   344   <target name="-check-ml-nbm-props">
   345       <condition property="run.ml.nbm.build" value="true">
   346           <and>
   347               <isset property="locales"/>
   348               <isset property="dlocales"/>
   349               <isset property="one.cluster.dir.ml"/>
   350               <isset property="comm.clusters.list"/>
   351               <isset property="spec.version"/>
   352               <isset property="netbeans.dest.dir.ml"/>
   353               <isset property="netbeans.build.dir.ml"/>
   354           </and>
   355       </condition>
   356   </target>
   357 
   358   <target name="build-one-nbm-ml" depends="init-tasks,-check-ml-nbm-props" if="run.ml.nbm.build">
   359       <property file="build/ml/cluster-nbms-ml.properties"/>
   360 
   361       <echo>Cluster dir: ${one.cluster.dir.ml}</echo>
   362 
   363       <pathconvert property="cluster.package.dir" setonempty="false">
   364           <path path="${one.cluster.dir.ml}"/>
   365           <chainedmapper>
   366           <filtermapper>
   367               <replacestring from="," to="_"/>
   368               <replacestring from="-" to="_"/>
   369               <replacestring from="." to="_"/>
   370           </filtermapper>
   371           <flattenmapper/>
   372           </chainedmapper>
   373       </pathconvert>
   374       <property name="cluster" location="${netbeans.build.dir.ml}/${one.cluster.dir.ml}"/>
   375 
   376       <delete dir="build/ml/nbms"/>
   377       <delete dir="${netbeans.build.dir.ml}"/>
   378       <mkdir dir="${netbeans.build.dir.ml}/${one.cluster.dir.ml}"/>
   379       <copy todir="${netbeans.build.dir.ml}/${one.cluster.dir.ml}">
   380           <fileset dir="dist/${one.cluster.dir.ml}"/>
   381       </copy>
   382 
   383       <condition property="code.name.base" value="org.netbeans.localization.${cluster.package.dir}.${dlocales}">
   384           <not>
   385               <isset property="is.kit"/>
   386           </not>
   387       </condition>
   388       <condition property="code.name.base" value="org.netbeans.localization.kit.${cluster.package.dir}.${dlocales}">
   389           <isset property="is.kit"/>
   390       </condition>
   391 
   392       <pathconvert property="code.name.base.slashes" setonempty="false">
   393           <path path="${code.name.base}"/>
   394           <chainedmapper>
   395               <flattenmapper/>
   396               <filtermapper>
   397                   <replacestring from="." to="/"/>
   398               </filtermapper>
   399           </chainedmapper>
   400       </pathconvert>
   401       <pathconvert property="code.name.base.dashes" setonempty="false">
   402           <path path="${code.name.base}"/>
   403           <chainedmapper>
   404               <flattenmapper/>
   405               <filtermapper>
   406                   <replacestring from="." to="-"/>
   407               </filtermapper>
   408           </chainedmapper>
   409       </pathconvert>
   410       <property name="public.packages" value="${code.name.base}.*"/>
   411       <property name="code.name" value="${code.name.base}/1"/>
   412       <mkdir dir="build/ml/nbms/classes/${code.name.base.slashes}"/>
   413       <mkdir dir="build/ml/nbms/tmp"/>
   414       <antcall target="-create-cluster-ml-nbm-metadata"/>
   415       <antcall target="-create-kit-ml-nbm-metadata"/>
   416       <property name="is.autoload" value="false"/>
   417       <property name="is.eager" value="false"/>
   418       <condition property="module.jar.dir" value="modules">
   419           <!-- set module.jar.dir property only when building kit NBM - leads to               AutoUpdate-Show-In-Client manifest attribute is set to true -->
   420           <isset property="is.kit"/>
   421       </condition>
   422       <property name="module.jar" value="modules/${code.name.base.dashes}.jar"/>      <mkdir dir="${cluster}/modules"/>
   423       <jarwithmoduleattributes jarfile="${cluster}/${module.jar}"
   424           compress="${build.package.compress}"
   425           index="${build.package.index}"
   426           manifest="build/ml/nbms/tmp/manifest.mf">
   427           <fileset dir="build/ml/nbms/classes"/>
   428       </jarwithmoduleattributes>
   429       <createmodulexml xmldir="${cluster}/config/Modules">
   430           <enabled dir="${cluster}">
   431               <include name="${module.jar}"/>
   432           </enabled>
   433       </createmodulexml>
   434       <patternset id="module.files">
   435           <!-- include name="${module.jar}"/ -->
   436           <include name="**/*.jar"/>
   437           <include name="config/Modules/${code.name.base.dashes}.xml"/>
   438       </patternset>
   439       <property name="module.files.toString" refid="module.files"/>
   440       <echo level="verbose">Basic matching module files (${code.name.base.dashes}): ${module.files.toString}</echo>
   441       <genlist outputfiledir="${cluster}" module="${module.jar}">
   442           <fileset dir="${cluster}">
   443               <patternset refid="module.files"/>
   444           </fileset>
   445       </genlist>
   446       <property name="license.file.override" location="build/ml/nbms/license"/>
   447       <property name="extra.license.files" value=""/>
   448       <taskdef name="releasefileslicense" classname="org.netbeans.nbbuild.extlibs.ReleaseFilesLicense" classpath="${nb_all}/nbbuild/nbantext.jar"/>
   449       <releasefileslicense license="${license.file.override}" standardlicense="${nb_all}/nbbuild/standard-nbm-license.txt" extralicensefiles="${extra.license.files}"/>
   450       <taskdef name="makenbm" classname="org.netbeans.nbbuild.MakeNBM" classpath="${nb_all}/nbbuild/nbantext.jar"/>
   451       <property name="nbm_alias" value="nb_ide"/>
   452       <makenbm file="build/ml/${code.name.base.dashes}.nbm"
   453                productdir="${cluster}"
   454                module="${module.jar}"
   455                homepage="http://translatedfiles.netbeans.org/"
   456                distribution="http://translatedfiles.netbeans.org/"
   457                needsrestart="true"
   458                global="true"
   459                targetcluster="${one.cluster.dir.ml}"
   460                releasedate=""
   461                moduleauthor="">
   462           <license file="${license.file.override}"/>
   463           <signature keystore="${keystore}" storepass="${storepass}" alias="${nbm_alias}"/>
   464       </makenbm>
   465       <move todir="${netbeans.dest.dir.ml}" file="build/ml/${code.name.base.dashes}.nbm"/>
   466       <property file="build/ml/cluster-nbms-ml.properties"/>
   467       <condition property="new.kit.deps" value="${code.name} &gt; ${spec.version}">
   468           <and>
   469               <not>
   470                   <isset property="kit.deps"/>
   471               </not>
   472               <not>
   473                   <isset property="is.kit"/>
   474               </not>
   475           </and>
   476       </condition>
   477       <condition property="new.kit.deps" value="${kit.deps},${code.name} &gt; ${spec.version}">
   478           <and>
   479               <isset property="kit.deps"/>
   480               <not>
   481                   <isset property="is.kit"/>
   482               </not>
   483           </and>
   484       </condition>
   485       <condition property="new.kit.deps" value="${kit.deps}">
   486           <isset property="is.kit"/>
   487       </condition>
   488       <propertyfile file="build/ml/cluster-nbms-ml.properties">
   489           <entry key="kit.deps" value="${new.kit.deps}"/>
   490       </propertyfile>
   491 
   492  </target>
   493 
   494 </project>