日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ant的设置properties

發布時間:2023/12/18 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ant的设置properties 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

特點

大小寫敏感;

不可改變,先到先得,誰先設定,之后的都不能改變。

怎樣設置

1 、設置 name 和 value 屬性值,比如: <property name="srcdir" value="${basedir}/src"/>

2 、 設置 name 和 refid 屬性值,比如: <property name="srcpath" refid="dao.compile.classpath"/> ,其中dao.compile.classpath 在別的地方定義。

3 、設置 name 和 location 屬性值,比如: <property name="srcdir" location="src"/> ,即將 srcdir 的值設 置為:當前項目根目錄的 /src 目錄。

4 、設置 file 屬性值,比如: <property file="build.properties"/> , 導入 build.properties 屬性文件中的屬性值

5 、設置 resource 屬性值,比如: <propety resource="build.properties"/>, 導入 build.properties 屬性文件中的屬性值

6 、設置 url 屬性值,比如: <property url="http://www.blogjava.net/wiflish/build.properties"/>, 導入http://www.blogjava.net/wiflish/build.properties 屬性文件中的屬性值。

7 、設置環境變量,比如: <property environment="env"/> ,設置系統的環境變量為前綴 env.

<property name="tomcat.home" value="${env.CATALINA_HOME}"/> 將系統的 tomcat 安裝目錄設置到 tomcat.home 屬性中。

內置屬性

Ant’s built-in properties:

basedir

The absolute path of the project’s basedir.

ant.file

The absolute path of the buildfile.

ant.version

The version of Ant.

ant.project.name

The name of the project that is currently executing.

ant.project.default-target

The name of the currently executing project’s default target.

ant.project.invoked-targets

A comma separated list of the targets that have been specified on the command line when invoking the current.

ant.java.version

The JVM version Ant detected.

ant.core.lib

The absolute path of the ant.jar file.

System properties

java.version

Java Runtime Environment version

java.vendor

Java Runtime Environment vendor

java.vendor.url

Java vendor URL

java.home

Java installation directory

java.vm.specification.version

Java Virtual Machine specification version

java.vm.specification.vendor

Java Virtual Machine specification vendor

java.vm.specification.name

Java Virtual Machine specification name

java.vm.version

Java Virtual Machine implementation version

java.vm.vendor

Java Virtual Machine implementation vendor

java.vm.name

Java Virtual Machine implementation name

java.specification.version

Java Runtime Environment specification version

java.specification.vendor

Java Runtime Environment specification vendor

java.specification.name

Java Runtime Environment specification name

java.class.version

Java class format version number

java.class.path

Java class path

java.library.path

List of paths to search when loading libraries

java.io.tmpdir

Default temp file path

java.compiler

Name of JIT compiler to use

java.ext.dirs

Path of extension directory or directories

os.name

Operating system name

os.arch

Operating system architecture

os.version

Operating system version

file.separator

File separator ("/" on UNIX)

path.separator

Path separator (":" on UNIX)

line.separator

Line separator ("\n" on UNIX)

user.name

User's account name

user.home

User's home directory

user.dir

User's current working directory

用法

${key_name},如:${os.name},它將得到當前操作系統的名稱。

需注意

1. 內置屬性basedir

-- 不需要定義就可以直接使用,${basedir},得到當前工程的絕對路徑

-- 當在<project>標簽的basedir屬性中指定basedir時,之后工程中出現的所有相對路徑都是相對于這個basedir所指向的路徑,且${basedir}的值也將變為<project>標簽中的basedir屬性所指定的值。

2. property的不變性在使用<available><ant><antcall>時會被打破

3. 可以在命令行通過-DpropertyName=propertyValue的方式指定property,注意,-D于propertyName之間沒有空格,使用這種方式指定的屬性最先被賦值,它是在執行build文件之前就已經賦值了的。

Q&A

How can I do something like <property name="prop" value="${${anotherprop}}"/> (double expanding the property)?

Without any external help you can not.

With <script/>, which needs external libraries, you can do

Xml代碼
  • <script language="javascript">
  • propname = project.getProperty("anotherprop");
  • project.setNewProperty("prop", propname);
  • </script>
  • With AntContrib (external task library) you can do <propertycopy name="prop" from="${anotherprop}"/> .

    With Ant 1.6 you can simulate the AntContribs <propertycopy> and avoid the need of an external library:

    Xml代碼
  • <macrodef name="propertycopy">
  • <attribute name="name"/>
  • <attribute name="from"/>
  • <sequential>
  • <property name="@{name}" value="${@{from}}"/>
  • </sequential>
  • </macrodef>
  • With the 'props' antlib (external, but also from Ant) you could do the dereferencing with ${${anotherprop} - not just in the property task - instead everywhere in your buildfile (after registering the required property helper).

    Xml代碼
  • <propertyhelper>
  • <props:nested />
  • </propertyhelper>
  • <property name="foo" value="foo.value" />
  • <property name="var" value="foo" />
  • <echo> ${${var}} = foo.value </echo>
  • With Flaka (external Ant Plugin) you could do the dereferencing with #{${anotherprop}} - not just in flaka tasks, but all tasks after installing flaka's property handler.

    Xml代碼
  • <project xmlns:fl="antlib:it.haefelinger.flaka">
  • <fl:install-property-handler/>
  • <property name="foo" value="foo.value"/>
  • <property name="var" value="foo" />
  • <property name="buildtype" value="test"/>
  • <property name="appserv_test" value="//testserver"/>
  • <echo>
  • #{${var}} = foo.value
  • <!-- nested property -->
  • #{appserv_${buildtype}}
  • </echo>
  • </project>
  • 轉載于:https://www.cnblogs.com/cl1024cl/p/6205635.html

    總結

    以上是生活随笔為你收集整理的ant的设置properties的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。