问题标签 [ant]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
822 浏览

java - 如何更改 Ant 的 XMLValidate 任务提供的验证“级别”?

我正在尝试使用 Ant 的 XMLValidate 任务来根据 DTD 验证 XML 文档。问题不在于它不工作,而在于它工作得太好了。我的 DTD 包含一个具有 IDREF 类型的“@linkend”属性的外部参照元素。大多数这些参考 ID 在当前文档之外。因此,我的构建失败,因为解析器抱怨 IDREF 引用的 ID 不存在。那么,有什么方法可以根据 DTD 验证我的 XML 文档,但忽略这种类型的错误?

我尝试过的一些事情: 在 XMLValidate 上设置“宽松”选项使任务只检查文档的格式正确,而不是针对 DTD 的有效性。 Ant 手册中的 XMLValidate 任务列出了一些您可以设置的 JAXP 和 SAX 选项,但似乎没有一个适用。

这是我的代码:

如您所见,我使用 ResolvingXMLReader 来根据公共标识符目录解析 DTD。但是,如果我直接使用嵌套的 xmlcatalog 元素指定 DTD,我会得到相同的行为。

0 投票
9 回答
6058 浏览

java - How best to store Subversion version information in EAR's?

When receiving a bug report or an it-doesnt-work message one of my initials questions is always what version? With a different builds being at many stages of testing, planning and deploying this is often a non-trivial question.

I the case of releasing Java JAR (ear, jar, rar, war) files I would like to be able to look in/at the JAR and switch to the same branch, version or tag that was the source of the released JAR.

How can I best adjust the ant build process so that the version information in the svn checkout remains in the created build?

I was thinking along the lines of:

  • adding a VERSION file, but with what content?
  • storing information in the META-INF file, but under what property with which content?
  • copying sources into the result archive
  • added svn:properties to all sources with keywords in places the compiler leaves them be

I ended up using the svnversion approach (the accepted anwser), because it scans the entire subtree as opposed to svn info which just looks at the current file / directory. For this I defined the SVN task in the ant file to make it more portable.

Not all builds result in webservices. The ear file before deployment must remain the same name because of updating in the application server. Making the file executable is still an option, but until then I just include a version information file.

Refs:
svnrevision: http://svnbook.red-bean.com/en/1.1/re57.html
svn info http://svnbook.red-bean.com/en/1.1/re13.html
subclipse svn task: http://subclipse.tigris.org/svnant/svn.html
svn client: http://svnkit.com/

0 投票
3 回答
4087 浏览

ant - 如何对自定义 ant 任务进行单元测试?

我正在编写一个扩展 Task 的自定义 ant 任务。我在任务中使用 log() 方法。我想要做的是在开发任务时使用单元测试,但我不知道如何为要运行的任务设置上下文来初始化任务,就好像它在 ant 中运行一样。

这是自定义任务:

这是单元测试代码:

当代码作为测试运行时,它会在调用 log 时给出 NullPointerException。

有人知道提供上下文或存根或类似于任务的东西的方法吗?

谢谢,

抢。

接受 Abarax 的回答。我能够调用 task.setProject(new Project()); 代码现在执行正常(除了控制台中没有出现日志记录 - 至少我可以练习代码:-))。

0 投票
7 回答
1271 浏览

java - 正则表达式:替换 XML 文件中的版本号

好的,我放弃了,我一直在尝试在 ant 中编写一个正则表达式来替换我在属性文件中的版本号。我有以下内容:

我想要实现的是仅替换功能标记的版本号,而不更改 xml 的版本或文件中插件 miriad 的版本。

我遇到的问题是我匹配太多或太少。明确匹配“版本”是不够的,因为一切都会改变

考虑到“0.0.0”可以是任何数字,是否有任何简单的方法可以匹配标签内的版本?

0 投票
2 回答
857 浏览

eclipse - 需要帮助编写自定义 BuildListener

我想在构建 Eclipse 产品的无头构建过程中添加一个 BuildListener。关于如何做到这一点的文档,容我们说,有点少。我想我需要将我的自定义 jar 放入插件中,然后使用 org.eclipse.ant.core.extraClasspathEntries 扩展点使该 jar 对 Ant 可见。但是我尝试过的所有结果

p>

我的类实现了 BuildListener 接口。各种帖子似乎表明这意味着我的类是由插件类加载器而不是 Ant 类加载器可见/加载的。但我认为扩展点的全部意义在于让 Ant 可以看到罐子......

谁能阐明我做错了什么?附加信息:我目前正在尝试使用 AntRunner 应用程序从 Eclipse IDE 运行此构建。

0 投票
4 回答
23408 浏览

xml - 用 xsl:text 解释换行符?

我有一个 XSL 样式表,其xsl:text节点中的内容如下:

样式表本身是一个带有“unix 风格”换行符的文本文件。我在 Windows 和类 unix 平台上调用这个样式表。如果输出符合调用它的平台的约定,那就太好了。

当我在 Windows 上运行这个样式表时,除了xsl:text节点的内容之外,输出都有回车/换行对。

xsl:text我可以指示 XSLT 处理器将节点内容中的换行符转换为特定于平台的行尾吗?

更多上下文:我正在从Apache Ant 1.7.1 XSLT 任务中调用样式表,如下所示:

样式表标题当前如下所示:

0 投票
1 回答
2804 浏览

java - 您使用 Ant / JDK 1.4.x 生成 Websphere 6 EJB 的方法是什么?

几年前,我发现的唯一工作方法是:

  1. 使用 XDoclet(ejbdoclet 任务)为每个会话 bean 生成 ibm-ejb-jar-bnd.xmi 和 ibm-ejb-jar-ext.xmi
  2. 用任务 jar 制作一个 jar(没有存根);;
  3. 使用此 jar 调用二进制 EJBDEPLOY,而没有参数中的存根。

但我觉得必须有一个更清洁的方法。哪个是你的?

0 投票
1 回答
1952 浏览

ant - 如何从 TeamCity 中提取工件?

我想从 teamcity 中提取工件。

我一直在尝试使用 c# 和 HtmlAgilityPack 来访问该网站并找到最新版本及其工件。我目前卡在登录状态,我想我只需要发送会话 Cookie 即可。

我是否朝着正确的方向前进,有其他人尝试过吗?

我意识到使用构建脚本推出文件很容易,但我想尽量减少对 Ant、NAnt 文件的更改,因为我正在考虑将其扩展到 100 个应用程序。

编辑:这个问题看起来很有前景Getting HTML from a page behind a login

编辑:现在可以了,我只需要编写一些代码来解析它

0 投票
1 回答
373 浏览

java - 蚂蚁在财产上的错误目录

我是 Ant 的新手,所以我决定在这里发布,而不是在官方错误列表上发布(因为它可能不是错误):

当我运行我的 Ant build.xml 文件时,除了构建目录之外,一切都运行良好,而不是将属性 ${classes.dir} 转换为 build/ver_2.0.0/classes 它创建一个文件 ${cv.build.dir} /类

这是蚂蚁代码的一部分:

0 投票
9 回答
6763 浏览

java - Ant 仍然是 Java 构建工具的最佳选择吗?

根据我的少量经验,我只使用 Ant 作为构建工具。还有其他更好的项目吗,为什么?