Ant 脚本打印系统属性变量、ant内置属性
Ant 脚本打印系统属性变量、ant内置属性
作用
编写ant脚本的时候,经常会引用到系统属性,本脚本用于打印系统常用属性(System.getProperties
)与环境变量(Environment
)等,供编写脚本的时候参考。
脚本
脚本参考了:
代码内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="print_properties" default="print" basedir=".">
<property environment="env"/>
<target name="print">
<!-- ================== Ant's built-in properties ============================ -->
<echo message="|-- Ant's built-in properties:"/>
<echo message="|"/>
<!-- The absolute path of the project’s basedir. -->
<echo message="|basedir=${basedir}"/>
<!-- The absolute path of the buildfile. -->
<echo message="|ant.file=${ant.file}"/>
<!-- The version of Ant. -->
<echo message="|ant.version=${ant.version}"/>
<!-- The name of the project that is currently executing. -->
<echo message="|ant.project.name=${ant.project.name}"/>
<!-- The name of the currently executing project’s default target. -->
<echo message="|ant.project.default-target=${ant.project.default-target}"/>
<!-- A comma separated list of the targets that have been specified on the command line when invoking the current. -->
<echo message="|ant.project.invoked-targets=${ant.project.invoked-targets}"/>
<!-- The JVM version Ant detected. -->
<echo message="|ant.java.version=${ant.java.version}"/>
<!-- The absolute path of the ant.jar file. -->
<echo message="|ant.core.lib=${ant.core.lib}"/>
<!-- =============================== System properties ==================================== -->
<echo message="|-- System properties:"/>
<echo message="|"/>
<echo message="|sun.boot.library.path=${sun.boot.library.path}"/>
<echo message="|file.encoding=${file.encoding}"/>
<echo message="|user.language=${user.language}"/>
<echo message="|user.region=${user.region}"/>
<!-- Java Runtime Environment version -->
<echo message="|java.version=${java.version}"/>
<!-- Java Runtime Environment vendor -->
<echo message="|java.vendor=${java.vendor}"/>
<!-- Java vendor URL -->
<echo message="|java.vendor.url=${java.vendor.url}"/>
<!-- Java installation directory -->
<echo message="|java.home=${java.home}"/>
<!-- Java Virtual Machine specification version -->
<echo message="|java.vm.specification.version=${java.vm.specification.version}"/>
<!-- Java Virtual Machine specification vendor -->
<echo message="|java.vm.specification.vendor=${java.vm.specification.vendor}"/>
<!-- Java Virtual Machine specification name -->
<echo message="|java.vm.specification.name=${java.vm.specification.name}"/>
<!-- Java Virtual Machine implementation version -->
<echo message="|java.vm.version=${java.vm.version}"/>
<!-- Java Virtual Machine implementation vendor -->
<echo message="|java.vm.vendor=${java.vm.vendor}"/>
<!-- Java Virtual Machine implementation name -->
<echo message="|java.vm.name=${java.vm.name}"/>
<!-- Java Runtime Environment specification version -->
<echo message="|java.specification.version=${java.specification.version}"/>
<!-- Java Runtime Environment specification vendor -->
<echo message="|java.specification.vendor=${java.specification.vendor}"/>
<!-- Java Runtime Environment specification name -->
<echo message="|java.specification.name=${java.specification.name}"/>
<!-- Java class format version number -->
<echo message="|java.class.version=${java.class.version}"/>
<!-- Java class path -->
<echo message="|java.class.path=${java.class.path}"/>
<!-- List of paths to search when loading libraries -->
<echo message="|java.library.path=${java.library.path}"/>
<!-- Default temp file path -->
<echo message="|java.io.tmpdir=${java.io.tmpdir}"/>
<!-- Name of JIT compiler to use -->
<echo message="|java.compiler=${java.compiler}"/>
<!-- Path of extension directory or directories -->
<echo message="|java.ext.dirs=${java.ext.dirs}"/>
<!-- Operating system name -->
<echo message="|os.name=${os.name}"/>
<!-- Operating system architecture -->
<echo message="|os.arch=${os.arch}"/>
<!-- Operating system version -->
<echo message="|os.version=${os.version}"/>
<!-- File separator ("/" on UNIX) -->
<echo message="|file.separator=${file.separator}"/>
<!-- Path separator (":" on UNIX) -->
<echo message="|path.separator=${path.separator}"/>
<!-- Line separator ("\n" on UNIX) -->
<echo message="|line.separator=${line.separator}"/>
<!-- User's account name -->
<echo message="|user.name=${user.name}"/>
<!-- User's home directory -->
<echo message="|user.home=${user.home}"/>
<!-- User's current working directory -->
<echo message="|user.dir=${user.dir}"/>
<!-- =============================== Environment 环境变量 ================================== -->
<property environment="env"/>
<echo message="|-- Environment:"/>
<echo message="|"/>
<echo message="|PATH={env.PATH}"/>
</target>
</project>