如何包括蚂蚁flaka罐子? [英] How to include Ant flaka jar?

查看:247
本文介绍了如何包括蚂蚁flaka罐子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写Ant脚本和使用Ant flaka罐子做一些工作。

I am writing ant scripts and using Ant flaka jar to do some work.

但flaka没有其他外部的Ant的lib工作。

But flaka doesn't work as other external Ant lib.

例如,如果我需要包括蚂蚁的contrib:

For example, if I need to include ant-contrib:

  <taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
        <pathelement location="../../lib/ant-contrib.jar"/>
  </classpath>
  </taskdef>

更重要的是,我可以指定罐的位置。

Most importantly, I can specify where the jar is located.

但对于flaka,我没有看到这样的事情。在官方网站上,他们只是告诉用户下载flaka罐子到Ant安装文件夹。

But for flaka, I don't see such thing. In the official website, they just tell user to download flaka jar to Ant installation folder.

我怎么可以指定在哪里flaka罐子时,我想使用它?

How can I specify where is the flaka jar when I want to use it?

推荐答案

都是些一般建议首先。任何外部的lib有可能成为视线的蚂蚁,意味着路径。结果
最原始的办法是把你的蚂蚁插件在$ ANT_HOME / lib目录,但'污染'你的Ant安装。结果把你的外部库在它自己的位置,F.E. / ant_xtralibs并使用通过Ant_ARGS的-lib参数。结果
Flaka手动部分2有关于一些笔记,在更多的细节 Ant手册。结果

First of all some general recommendation. Any external lib has to be in sight for ant, means on path.
The most primitive approach is to put your ant addons in $ANT_HOME/lib, but that 'pollutes' your ant installation.
Put your external libs in it's own location, f.e. /ant_xtralibs and use the -lib parameter via Ant_ARGS.
The Flaka manual section 2 has some notes about that, more details in the Ant manual.

您例如处理antcontrib通过的taskdef资源..结果现代使用传统方法的方法是使用一个XML命名空间声明,作为Flaka手册第2章前右提到结果:结果
因此显示的所有构建文件片段假定构建文件包含以下XML命名空间声明

Your example dealing with antcontrib uses the traditional approach via taskdef resource..
The modern - recommended - way is to use a XML namespace declaration, as the Flaka Manual mentions
right before section 2 :
"Thus all build file snippets shown assume that the build file contains the following XML namespace declaration"

这也可以通过使用Flaka的taskdef传统的方式:

It's also possible to use Flaka via taskdef the traditional way:

<project>
  <taskdef resource="it/haefelinger/flaka/antlib.xml">
   <classpath>
    <pathelement location="/home/rosebud/flaka/ant-flaka-1.02.02.jar"/>
   </classpath>
  </taskdef>

  <!-- when on path via -lib or ANT_ARGS it's enough to use : -->
  <taskdef resource="it/haefelinger/flaka/antlib.xml"/>

  <logo>
   Hello, #{property['ant.file'].tofile.name}
  </logo>

</project>

输出

Trying to override old definition of datatype filterset
Trying to override old definition of task fail
Trying to override old definition of task echo
[logo] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
[logo] :                               Hello, demo.xml                                :
[logo] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

请注意开始与线,试图重写。
这是因为Flaka延伸一些Ant任务

note the lines starting with "Trying to override.." That's because of Flaka extends some ant tasks

但如果你把Flaka在它自己的命名空间:

but if you put Flaka in it's own namespace :

<project name="demo" xmlns:fl="antlib:it.haefelinger.flaka">
 <fl:logo>
  Hello, #{property['ant.file'].tofile.name}
 </fl:logo>
</project>

输出

[fl:logo] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
[fl:logo] :                               Hello, demo.xml                                :
[fl:logo] ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

没有更多的试图重写......指的是蚁自己的任务,没有更多的碰撞,如Flaka驻留在它自己的命名空间中搜索

no more "Trying to override..." means no more collision with ant's own tasks, as Flaka resides in it's own namespace

因此​​,要长话短说:结果
1)使用ANT_ARGS带给你extralibs(Flaka ..等)在比赛结果
2)使用空间声明搜索结果

So to make it short :
1) use ANT_ARGS to bring your extralibs (Flaka .. etc.) in the game
2) use the modern way of Namespace declaration

修改注释要求命名空间的类路径结合后的修改结果

EDIT after comment asking for namespace combined with classpath EDIT

是这样的作品,请参见 Ant手册,详细了解的antlib ,尤其是部分结果
从构建文件里面装载的antlib,为Flaka你会使用这样的:结果

yes that works, see Ant manual for details about antlib, especially the section
"Load antlib from inside of the buildfile", for Flaka you would use something like :

<project xmlns:fl="antlib:it.haefelinger.flaka">
 <taskdef uri="antlib:it.haefelinger.flaka"
  resource="it/haefelinger/flaka/antlib.xml"
  classpath="path/to/flaka.jar"/>

但我相信你依然没有获得使用$ ANT_ARGS结果的优点
简单地使用一些脚本,开始您的Ant脚本,F.E. :结果

but i believe you still didn't get the advantages of using $ANT_ARGS
simply use some script to start your ant scripts, f.e. :

对于Windows结果
设置JAVA_HOME = C:\\ java的\\ JDK \\ 1.6.0_26结果
设置ANT_HOME = C:\\蚂蚁结果
设置ANT_ARGS -lib = C:\\ ant_xtralibs; C:\\ ant_testlibs结果
设置PATH =%PATH%;%JAVA_HOME%\\ BIN;%ANT_HOME%\\ bin中; C:\\ CVSNT结果

for Windows
set JAVA_HOME=C:\java\jdk\1.6.0_26
set ANT_HOME=C:\ant
set ANT_ARGS=-lib C:\ant_xtralibs;C:\ant_testlibs
set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin;C:\cvsnt

::默认搜索
调用Ant -f%1

:: default
call ant -f %1

::调试结果
::调用Ant -debug -f%1结果
...等结果

:: debug
::call ant -debug -f %1
... etc.

Linux / Unix版 - 不要忘记上ANT_ARGS行quotationmarks结果!
...结果
ANT_ARGS = - lib目录的/ usr /本地/ ant_xtralibs:在/ usr /本地/ ant_testlibs结果
出口ANT_ARGS结果
...结果

for Linux/Unix - don't forget the quotationmarks on the ANT_ARGS line !
...
ANT_ARGS="-lib /usr/local/ant_xtralibs:/usr/local/ant_testlibs"
export ANT_ARGS
...

您不需要使用classpath中不再使用的taskdef!结果
使用-lib选项加载额外的库还有另一个好处。结果
有必须蚂蚁指标(如BSF,JS,XML)结果之前加载一些库
开始分析构建文件。结果

You don't need to use taskdef with classpath anymore !!
Using the -lib option to load additional libraries has another benefit.
There are some libs which must be loaded before Ant (f.e. BSF, js, xml)
starts parsing the buildfile.

ANT_ARGS是一个特殊的环境变量。其内容是自动
添加到Ant的调用。

ANT_ARGS is a special environment variable. Its content is automatically added to the invocation of Ant.

- 其他的可能性 - 结果

-- Other possibilities --

1)搜索
把那些设置ANT_ARGS ...'的东西变成=结果

1)
put those 'set ANT_ARGS ...' stuff into =

的Linux / Unix结果
$ ANT_HOME /斌/蚂蚁结果

Linux/Unix
$ANT_HOME/bin/ant

视窗结果
%ANT_HOME%/斌/ ant.bat结果

Windows
%ANT_HOME%/bin/ant.bat

缺点=改变了蚂蚁核心安装,请记住结果
更改之前,您复制蚂蚁安装结果
另一台机器和奇怪的事情发生了!结果

disadvantage = changes the ant core installation, remember
your changes before you copy your ant installation to
another machine and strange things happen !

2)结果
把你的extralibs在$ {}的user.home /。蚂蚁/ lib目录结果
优势=每个用户可以使用他自己的一套库搜索

2)
put your extralibs in ${user.home}/.ant/lib
advantage = every user may use his own set of libraries

细节请查阅Ant手册:结果
http://ant.apache.org/manual/running.html#commandline 结果
http://ant.apache.org/manual/running.html#libs

consult the Ant manual for details :
http://ant.apache.org/manual/running.html#commandline
http://ant.apache.org/manual/running.html#libs

这篇关于如何包括蚂蚁flaka罐子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆