firstmatchmapper

http://ant.apache.org/manual/Types/mapper.html

      <target>       
        <copy todir="${basedir}/src/main/lib" >
        <!-- copy todir="${project.build.directory}/lib" > -->
          <!-- dirset  dir="${basedir}/src/main/lib">
           <include name="**/*"></include>
          </dirset> -->
          <fileset dir="${basedir}/src/main/lib">
           <include name="**/*"></include>
          </fileset>
          <firstmatchmapper>
           <globmapper from="*.gif" to="*.jar"/>
          </firstmatchmapper>
        </copy>
        <delete>
          <fileset dir="${basedir}/src/main/lib" includes="**/*.gif"></fileset>
        </delete>
       </target>

Some tasks take source files and create target files. Depending on the task, it may be quite obvious which name a target file will have (using javac, you know there will be .class files for your .java files) - in other cases you may want to specify the target files, either to help Apache Ant or to get an extra bit of functionality.

While source files are usually specified as filesets, you don't specify target files directly - instead, you tell Ant how to find the target file(s) for one source file. An instance of org.apache.tools.ant.util.FileNameMapper is responsible for this. It constructs target file names based on rules that can be parameterized with from and to attributes - the exact meaning of which is implementation-dependent.

These instances are defined in <mapper> elements with the following attributes:

AttributeDescriptionRequired
typespecifies one of the built-in implementations.Exactly one of these
classnamespecifies the implementation by class name.
classpaththe classpath to use when looking up classname.No
classpathrefthe classpath to use, given as reference to a path defined elsewhere.No
fromthe from attribute for the given implementation.Depends on implementation.
tothe to attribute for the given implementation.Depends on implementation.

Note that Ant will not automatically convert / or \ characters in the to and from attributes to the correct directory separator of your current platform. If you need to specify this separator, use ${file.separator} instead. For the regexpmapper, ${file.separator} will not work, as on windows it is the '\' character, and this is an escape character for regular expressions, one should use the handledirsep attribute instead.

Parameters specified as nested elements

The classpath can be specified via a nested <classpath>, as well - that is, a path-like structure.

Since Ant 1.7.0, nested File Mappers can be supplied via either <mapper> elements or <typedef>'d implementations of org.apache.tools.ant.util.FileNameMapper. If nested File Mappers are specified by either means, the mapper will be implicitly configured as a composite mapper.


 

The built-in mapper types are:

All built-in mappers are case-sensitive.

As of Ant 1.7.0, each of the built-in mapper implementation types is directly accessible using a specific tagname. This makes it possible for filename mappers to support attributes in addition to the generally available to and from.
The <mapper type|classname="..."> usage form remains valid for reasons of backward compatibility.

identity

The target file name is identical to the source file name. Both to and from will be ignored.

Examples:

<mapper type="identity"/>
<identitymapper/>

Source file nameTarget file name
A.javaA.java
foo/bar/B.javafoo/bar/B.java
C.propertiesC.properties
Classes/dir/dir2/A.propertiesClasses/dir/dir2/A.properties

flatten

The target file name is identical to the source file name, with all leading directory information stripped off. Both to and from will be ignored.

Examples:

<mapper type="flatten"/>
<flattenmapper/>

Source file nameTarget file name
A.javaA.java
foo/bar/B.javaB.java
C.propertiesC.properties
Classes/dir/dir2/A.propertiesA.properties

merge

The target file name will always be the same, as defined by to - from will be ignored.

Examples:
<mapper type="merge" to="archive.tar"/>
<mergemapper to="archive.tar"/>

Source file nameTarget file name
A.javaarchive.tar
foo/bar/B.javaarchive.tar
C.propertiesarchive.tar
Classes/dir/dir2/A.propertiesarchive.tar

glob

Both to and from are required and define patterns that may contain at most one *. For each source file that matches the from pattern, a target file name will be constructed from the to pattern by substituting the * in the to pattern with the text that matches the * in the from pattern. Source file names that don't match the from pattern will be ignored.

Examples:

<mapper type="glob" from="*.java" to="*.java.bak"/>
<globmapper from="*.java" to="*.java.bak"/>

Source file nameTarget file name
A.javaA.java.bak
foo/bar/B.javafoo/bar/B.java.bak
C.propertiesignored
Classes/dir/dir2/A.propertiesignored

<mapper type="glob" from="C*ies" to="Q*y"/>
<globmapper from="C*ies" to="Q*y"/>

Source file nameTarget file name
A.javaignored
foo/bar/B.javaignored
C.propertiesQ.property
Classes/dir/dir2/A.propertiesQlasses/dir/dir2/A.property

The globmapper mapper can take the following extra attributes.

AttributeDescriptionRequired
casesensitiveIf this is false, the mapper will ignore case when matching the glob pattern. This attribute can be true or false, the default is true. Since Ant 1.6.3.No
handledirsepIf this is specified, the mapper will ignore the difference between the normal directory separator characters - \ and /. This attribute can be true or false, the default is false. This attribute is useful for cross-platform build files. Since Ant 1.6.3.No

An example:

      <pathconvert property="x" targetos="unix">
        <path path="Aj.Java"/>
        <mapper>
        <chainedmapper>
          <flattenmapper/>
          <globmapper from="a*.java" to="*.java.bak" casesensitive="no"/>
        </chainedmapper>
        </mapper>
      </pathconvert>
      <echo>x is ${x}</echo>
    

will output "x is j.java.bak".

and

      <pathconvert property="x" targetos="unix">
        <path path="d/e/f/j.java"/>
        <mapper>
          <globmapper from="${basedir}\d/e\*" to="*" ignoredirchar="yes"/>
        </mapper>
      </pathconvert>
      <echo>x is ${x}</echo>
    

will output "x is f/j.java".

regexp

Both to and from are required and define regular expressions. If the source file name (as a whole or in part) matches the from pattern, the target file name will be constructed from the to pattern, using \0 to \9 as back-references for the full match (\0) or the matches of the subexpressions in parentheses. The to pattern determines the whole file name, so if you wanted to replace the extension of a file you should not use from="\.old$" to=".new" but rather from="(.*)\.old$" to="\1.new" (or rather use a glob mapper in this case).

Source files not matching the from pattern will be ignored.

Note that you need to escape a dollar-sign ($) with another dollar-sign in Ant.

The regexp mapper needs a supporting library and an implementation of org.apache.tools.ant.util.regexp.RegexpMatcher that hides the specifics of the library. Since Ant 1.8.0 Ant requires Java 1.4 to run, so the implementation based on the java.util.regex package will always be available. You can still use Jakarta ORO or Jakarta Regex instead if your provide the corresponding jar in your CLASSPATH.

For information about using gnu.regexp or gnu.rex with Ant, see this article.

If you want to use one of the regular expression libraries other than java.util.regex you need to also use the corresponding ant-[apache-oro, apache-regexp].jar from the Ant release you are using. Make sure, both will be loaded from the same classpath, that is either put them into your CLASSPATH, ANT_HOME/lib directory or a nested <classpath> element of the mapper - you cannot have ant-[apache-oro, apache-regexp].jar in ANT_HOME/lib and the library in a nested <classpath>.

Ant will choose the regular-expression library based on the following algorithm:

  • If the system property ant.regexp.matcherimpl has been set, it is taken as the name of the class implementing org.apache.tools.ant.util.regexp.RegexpMatcher that should be used.
  • If it has not been set, uses the JDK 1.4 classes.

Examples:

<mapper type="regexp" from="^(.*)\.java$$" to="\1.java.bak"/>
<regexpmapper from="^(.*)\.java$$" to="\1.java.bak"/>

Source file nameTarget file name
A.javaA.java.bak
foo/bar/B.javafoo/bar/B.java.bak
C.propertiesignored
Classes/dir/dir2/A.propertiesignored

<mapper type="regexp" from="^(.*)/([^/]+)/([^/]*)$$" to="\1/\2/\2-\3"/>
<regexpmapper from="^(.*)/([^/]+)/([^/]*)$$" to="\1/\2/\2-\3"/>

Source file nameTarget file name
A.javaignored
foo/bar/B.javafoo/bar/bar-B.java
C.propertiesignored
Classes/dir/dir2/A.propertiesClasses/dir/dir2/dir2-A.properties

<mapper type="regexp" from="^(.*)\.(.*)$$" to="\2.\1"/>
<regexpmapper from="^(.*)\.(.*)$$&" to="\2.\1"/>

Source file nameTarget file name
A.javajava.A
foo/bar/B.javajava.foo/bar/B
C.propertiesproperties.C
Classes/dir/dir2/A.propertiesproperties.Classes/dir/dir2/A

<mapper type="regexp" from="^(.*?)(\$$[^/\\\.]*)?\.class$$" to="\1.java"/>
<regexpmapper from="^(.*?)(\$$[^/\\\.]*)?\.class$$" to="\1.java"/>

Source file nameTarget file name
ClassLoader.classClassLoader.java
java/lang/ClassLoader.classjava/lang/ClassLoader.java
java\lang\ClassLoader$1.classjava\lang\ClassLoader.java
java/lang/ClassLoader$foo$1.classjava/lang/ClassLoader.java

The regexpmapper mapper can take the following extra attributes.

AttributeDescriptionRequired
casesensitiveIf this is false, the mapper will ignore case when matching the pattern. This attribute can be true or false, the default is true. Since Ant 1.6.3.No
handledirsepIf this is specified, the mapper will treat a \ character in a filename as a / for the purposes of matching. This attribute can be true or false, the default is false. This attribute is useful for cross-platform build files. Since Ant 1.6.3.No

An example:

      <pathconvert property="x" targetos="unix">
        <path path="Aj.Java"/>
        <chainedmapper>
          <flattenmapper/>
          <regexpmapper from="a(.*)\.java" to="\1.java.bak" casesensitive="no"/>
        </chainedmapper>
      </pathconvert>
      <echo>x is ${x}</echo>
    

will output "x is j.java.bak".

and

    <pathconvert property="hd.prop" targetos="windows">
      <path path="d\e/f\j.java"/>
      <chainedmapper>
        <regexpmapper from="${basedir}/d/e/(.*)" to="\1" handledirsep="yes"/>
      </chainedmapper>
    </pathconvert>
    

will set hd.prop to "f\j.java".

package

Sharing the same syntax as the glob mapper, the package mapper replaces directory separators found in the matched source pattern with dots in the target pattern placeholder. This mapper is particularly useful in combination with <uptodate> and <junit> output.

The to and from attributes are both required.

Example:

<mapper type="package" from="*Test.java" to="TEST-*Test.xml"/>
<packagemapper from="*Test.java" to="TEST-*Test.xml"/>

Source file nameTarget file name
org/apache/tools/ant/util/PackageMapperTest.javaTEST-org.apache.tools.ant.util.PackageMapperTest.xml
org/apache/tools/ant/util/Helper.javaignored

unpackage (since Ant 1.6.0)

This mapper is the inverse of the package mapper. It replaces the dots in a package name with directory separators. This is useful for matching XML formatter results against their JUnit test test cases. The mapper shares the sample syntax as the glob mapper.

The to and from attributes are both required.

Example:

<mapper type="unpackage" from="TEST-*Test.xml" to="${test.src.dir}/*Test.java">
<unpackagemapper from="TEST-*Test.xml" to="${test.src.dir}/*Test.java">

Source file nameTarget file name
TEST-org.acme.AcmeTest.xml${test.src.dir}/org/acme/AcmeTest.java

composite (since Ant 1.7.0)

This mapper implementation can contain multiple nested mappers. File mapping is performed by passing the source filename to each nested <mapper> in turn, returning all results. The to and from attributes are ignored.

Starting with Ant 1.8.0 the order of the mapped results is the same as the order of the nested mappers; prior to Ant 1.8.0 the order has been undefined.

Examples:

<compositemapper>
  <identitymapper/>
  <packagemapper from="*.java" to="*"/>
</compositemapper>

Source file nameTarget file names
foo/bar/A.javafoo/bar/A.java
foo.bar.A

The composite mapper has no corresponding <mapper type> attribute.

chained (since Ant 1.7.0)

This mapper implementation can contain multiple nested mappers. File mapping is performed by passing the source filename to the first nested mapper, its results to the second, and so on. The target filenames generated by the last nested mapper comprise the ultimate results of the mapping operation. The to and from attributes are ignored.

Examples:

<chainedmapper>
  <flattenmapper/>
  <globmapper from="*" to="new/path/*"/>
  <mapper>
    <globmapper from="*" to="*1"/>
    <globmapper from="*" to="*2"/>
  </mapper>
</chainedmapper>

Source file nameTarget file names
foo/bar/A.javanew/path/A.java1
new/path/A.java2
boo/far/B.javanew/path/B.java1
new/path/B.java2

The chained mapper has no corresponding <mapper type> attribute.

filtermapper (since Ant 1.6.3)

This mapper implementation applies a filterchain to the source file name.

Examples:

<filtermapper>
  <replacestring from="\" to="/"/>
</filtermapper>

Source file nameTarget file names
foo\bar\A.javafoo/bar/A.java

<filtermapper>
  <scriptfilter language="beanshell">
    self.setToken(self.getToken().toUpperCase());
  </scriptfilter>
</filtermapper>

Source file nameTarget file names
foo\bar\A.javaFOO\BAR\A.JAVA

The filtermapper has no corresponding <mapper type> attribute.

scriptmapper (since Ant 1.7)

This mapper executes a script written in Apache BSF or JSR 223 supported language, once per file to map.

The script can be declared inline or in a specified file.

See the Script task for an explanation of scripts and dependencies.

AttributeDescriptionRequired
languageScripting languageYes
managerThe script engine manager to use. See the script task for using this attribute.No - default is "auto"
srcFile containing the scriptNo
setbeanswhether to have all properties, references and targets as global variables in the script. since Ant 1.8.0No, default is "true".
classpathThe classpath to pass into the script.No
classpathrefThe classpath to use, given as a reference to a path defined elsewhere.No

This filename mapper can take a nested <classpath> element. See the script task on how to use this element.

Example:

<scriptmapper language="javascript">
  self.addMappedName(source.toUpperCase());
  self.addMappedName(source.toLowerCase());
</scriptmapper>

Source file nameTarget file names
foo\bar\A.javaFOO\BAR\A.JAVA
foo\bar\a.java

To use this mapper, the scripts need access to the source file, and the ability to return multiple mappings. Here are the relevant beans and their methods. The script is called once for every source file, with the list of mapped names reset after every invocation.

Script beanDescription
source: StringThe file/path to map
selfthe scriptmapper itself
self.addMappedName(String name)Add a new mapping
self.clear()Reset the list of files.

The scriptmapper has no corresponding <mapper type> attribute.

firstmatchmapper (since Ant 1.8.0)

This mapper supports an arbitrary number of nested mappers and returns the results of the first mapper that matches. This is different from composite mapper which collects the results of all matching children.

Examples:

<firstmatchmapper>
  <globmapper from="*.txt" to="*.bak"/>
  <globmapper from="*A.*" to="*B.*"/>
</firstmatchmapper>

Source file nameTarget file names
foo/bar/A.txtfoo/bar/A.bak
foo/bar/A.javafoo/bar/B.java

The firstmatchmapper has no corresponding <mapper type> attribute.

cutdirsmapper (since Ant 1.8.2)

This mapper strips a configured number of leading directories from the source file name.

Examples:

<cutdirsmapper dirs="1"/>

Source file nameTarget file names
foo/bar/A.txtbar/A.txt

The cutdirsmapper has no corresponding <mapper type> attribute.

AttributeDescriptionRequired
dirsNumber of directories to strip (must be a positive number).Yes

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
4S店客户管理小程序-毕业设计,基于微信小程序+SSM+MySql开发,源码+数据库+论文答辩+毕业论文+视频演示 社会的发展和科学技术的进步,互联网技术越来越受欢迎。手机也逐渐受到广大人民群众的喜爱,也逐渐进入了每个用户的使用。手机具有便利性,速度快,效率高,成本低等优点。 因此,构建符合自己要求的操作系统是非常有意义的。 本文从管理员、用户的功能要求出发,4S店客户管理系统中的功能模块主要是实现管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理,用户客户端:首页、车展、新闻头条、我的。门店客户端:首页、车展、新闻头条、我的经过认真细致的研究,精心准备和规划,最后测试成功,系统可以正常使用。分析功能调整与4S店客户管理系统实现的实际需求相结合,讨论了微信开发者技术与后台结合java语言和MySQL数据库开发4S店客户管理系统的使用。 关键字:4S店客户管理系统小程序 微信开发者 Java技术 MySQL数据库 软件的功能: 1、开发实现4S店客户管理系统的整个系统程序; 2、管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理等。 3、用户客户端:首页、车展、新闻头条、我的 4、门店客户端:首页、车展、新闻头条、我的等相应操作; 5、基础数据管理:实现系统基本信息的添加、修改及删除等操作,并且根据需求进行交流信息的查看及回复相应操作。
现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本微信小程序医院挂号预约系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此微信小程序医院挂号预约系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的MySQL数据库进行程序开发。微信小程序医院挂号预约系统有管理员,用户两个角色。管理员功能有个人中心,用户管理,医生信息管理,医院信息管理,科室信息管理,预约信息管理,预约取消管理,留言板,系统管理。微信小程序用户可以注册登录,查看医院信息,查看医生信息,查看公告资讯,在科室信息里面进行预约,也可以取消预约。微信小程序医院挂号预约系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值