1. Content of the native2ascii. bat file:
@ Echo off
@ Setlocal
Set JAVA_HOME = % JDK6_HOME %
If "% JAVA_HOME %" = "" goto noJavaHome
Set cmd = % JAVA_HOME % \ bin \ java-Xms256m-Xmx512m-cp build \ lib \ ant. jar; build \ lib \ optional. jar; % JAVA_HOME % \ lib \ tools. jar; % JAVA_HOME %
\ Jre \ lib \ rt. jar org. apache. tools. ant. Main
Set build = % CMD %-buildfile native2ascii. xml
If "X % 1" = "Xnative" goto native
: Native
% BUILD %-propertyfile build. properties native
Goto mainEnd
: NoJavaHome
Echo.
Echo Warning: JAVA_HOME environment variable is not set.
Echo If build fails because sun. * classes cocould not be found
Echo you will need to set the JAVA_HOME environment variable
Echo to the installation directory of java.
Echo.
: MainEnd
@ Endlocal
2. Content of the native2ascii. xml file:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Project name = "MIT" default = "native" basedir = ".">
<Property name = "dist. dir" value = "./dist"/>
<Property name = "webapp. dir" value = "./web"/>
<Target name = "native">
<Echo message = "Convert Resource Files"/>
<! -- Convert Resource Files -->
<Native2ascii encoding = "ISO-8859-1" src = "$ {webapp. dir}/WEB-INF/classes/resources/en_US "dest =" $ {dist. dir}/classes "primary des = "*. properties "/>
<Native2ascii encoding = "GBK" src = "$ {webapp. dir}/WEB-INF/classes/resources/zh_CN "dest =" $ {dist. dir}/classes "primary des = "*. properties "/>
<Native2ascii encoding = "GBK" src = "$ {webapp. dir}/WEB-INF/classes/resources/zh_TW "dest =" $ {dist. dir}/classes "primary des = "*. properties "/>
<Native2ascii encoding = "ISO-8859-1" src = "$ {webapp. dir}/WEB-INF/classes/resources/nl_NL "dest =" $ {dist. dir}/classes "primary des = "*. properties "/>
<Native2ascii encoding = "EUC-JP" src = "$ {webapp. dir}/WEB-INF/classes/resources/ja_JP "dest =" $ {dist. dir}/classes "primary des = "*. properties "/>
</Target>
</Project>
3. The <project> element has a default attribute that specifies the target to be executed by default. That is, if no parameter is input when native2ascii batch file is executed, the task specified in default is executed by default.
4. Passing parameters in Batch Processing
(1) command
D: \ dev \ RB-2.1.x-gx> native2ascii
Is the native2ascii. bat file running the D: \ dev \ RB-2.1.x-gx directory
(2) Enter native2ascii native in the command line.
Input the native parameter to the batch file native2ascii. bat.
In the given native2ascii. bat file, when the native parameter is passed in, the batch processing program will
If "X % 1" = "Xnative" goto native
Find the batch processing block:
: Native
% BUILD %-propertyfile build. properties native
Goto mainEnd
Then execute:
% BUILD %-propertyfile build. properties native
The native in this command is a parameter passed to the native2ascii. xml file, which is used to specify the target of the native2ascii. xml file. If this parameter is not specified, the default attribute of the <project> element in the native2ascii. xml file is executed by default.
Author: csz_363874279qqcom