buildproperties ==================================
#public info
module = test
JAVA_HOME = C:\\j
sdk
_
keystore = Yoinn
store
# 別名
alias = Yoinn
# keystore密碼
storepass = password
# 主密碼
keypass = password
# 證書文件名
cer
file = NeuLion
cer
# dname info
# dname {CN=
OU=
O=
L=
ST=
C=
}
# 名字與姓氏
dname
CN = name
# 組織單位名稱
dname
OU = organizationUnitName
# 組織名稱
dname
O = organizationName
# 所在的城市或區域名稱
dname
L = DL
# 所在的州或省份名稱
dname
ST = LN
# 該單位的兩字母國家代碼
dname
C = CN
# about keytool
keytool = keytool
exe
keytool
home = ${JAVA_HOME}/bin
# about jarsigner
jarsigner = jarsigner
exe
jarsigner
home = ${JAVA_HOME}/bin
buildxml ================================
<!
Copyright (c)
by Yoinn
All Rights Reserved
>
<project name=
JarSignerBuilder
default=
jarsigner
basedir=
>
<!
set global properties for this build
>
<property file=
build
properties
/>
<property name=
dist
value=
/dist
/>
<property name=
deploy
dir
value=
${basedir}
/>
<!
*********************************************************
>
<!
dname {CN=
OU=
O=
L=
ST=
C=
} ?
>
<!
名字與姓氏
>
<property name=
commonName
value=
${dname
CN}
/>
<!
組織單位名稱
>
<property name=
organizationUnit
value=
${dname
OU}
/>
<!
組織名稱
>
<property name=
organizationName
value=
${dname
O}
/>
<!
所在的城市或區域名稱
>
<property name=
localityName
value=
${dname
L}
/>
<!
所在的州或省份名稱
>
<property name=
stateName
value=
${dname
ST}
/>
<!
該單位的兩字母國家代碼
>
<property name=
country
value=
${dname
C}
/>
<property name=
dname
value=
CN=${commonName}
OU=${organizationUnit}
O=${organizationName}
L=${localityName}
ST=${stateName}
C=${country}
/>
<!
*********************************************************
>
<target name=
init
>
<mkdir dir=
${dist}
/>
</target>
<target name=
keytool
depends=
undeploy
>
<echo message=
keytool
/>
<echo message=
dname = { ${dname} }
/>
<exec dir=
${deploy
dir}
executable=
${keytool
home}/${keytool}
os=
Windows
>
<arg line=
genkey
/>
<arg line=
dname ${dname}
/>
<arg line=
keystore ${keystore}
/>
<arg line=
alias ${alias}
/>
<arg line=
storepass ${storepass}
/>
<arg line=
keypass ${keypass}
/>
</exec>
<exec dir=
${deploy
dir}
executable=
${keytool
home}/${keytool}
os=
Windows
>
<arg line=
export
/>
<arg line=
keystore ${keystore}
/>
<arg line=
storepass ${storepass}
/>
<arg line=
alias ${alias}
/>
<arg line=
file ${cer
file}
/>
</exec>
<echo message=
keytool
done
/>
</target>
<target name=
jarsigner
depends=
keytool
>
<!
Sign the jar
>
<echo message=
jarsigner
/>
<exec dir=
${deploy
dir}
executable=
${jarsigner
home}/${jarsigner}
os=
Windows
>
<arg line=
keystore ${keystore}
/>
<arg line=
storepass ${storepass}
/>
<arg line=
${module}
jar
/>
<arg line=
${alias}
/>
</exec>
<echo message=
jarsigner
done
/>
<delete file=
${keystore}
/>
<delete file=
${cer
file}
/>
<delete dir=
${dist}
/>
</target>
<target name=
undeploy
>
<delete file=
${keystore}
/>
<delete file=
${cer
file}
/>
</target>
</project>
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28454.html