蚂蚁常春藤:运行罐子生产文本报告 [英] Ant Ivy: Producing text report of the runtime jars

查看:229
本文介绍了蚂蚁常春藤:运行罐子生产文本报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常情况下,当我们从常春藤下载罐子,我们设置模式来包括JAR的版本号。

 <常春藤:检索
    模式=$ {} lib.dir / [设置] / [神器] - [修改] [转]
    登录=$ {} ivy.log/>

然而,这一个项目,我们不能这样做。罐已无需版本ID对它们进行下载:

 <常春藤:检索
    模式=$ {} lib.dir / [设置] / [神器] [转]。/>

该应用由覆盖的安装了什么已经存在。如果一个特定的罐子的修订会从一个版本变为下一步,我们将结束与两个旧瓶子和罐子那的新版本,而我们不知道正在使用哪个版本。删除修订信息可以很容易地确保旧的罐子都用更新的版本替换。

但是,开发商仍然会像什么罐子的版本已下载并投入战争建成一个简单的报表,所以我怎么能产生这样的报告。我一直在寻找常春藤:报告,但它不会产生一个文字报告。有一个 <常春藤:artifactreport /&GT ; 的任务,但也产生XML报告,而不是一个文字报告

我可以解析使用Perl或Python这份报告,但我宁可不使用可执行文件作为构建过程的一部分。否则,当开发者构建,他们就必须要确保这些外部程序正确安装和配置。

有一个简单的方法来产生一个纯文本报告?


解决方案

采用ANT XSLT 任务生成CSV格式的文本文件。

示例

 ├──构建
│└──常春藤
│├──com.myspotontheweb-演示compile.html
│├──com.myspotontheweb-演示runtime.html
│├──com.myspotontheweb-演示的test.html
│├──常春藤report.css
│├──REPORT.TXT
│└──report.xml将
├──的build.xml
├──的ivy.xml
└──report.xsl

的build.xml

 <项目名称=演示默认值=解析的xmlns:常春藤=的antlib:org.apache.ivy.ant>    <目标名称=解析描述=使用常春藤解析依赖性>
        <常春藤:决心/>        <! - 报告 - >
        <常春藤:报告todir ='构建/常青藤图='假'XML ='假'/>        <常春藤:artifactreport TOFILE =建立/常春藤/ report.xml将/>
        < XSLT样式= =在建/常春藤/ report.xml将走出=建立/常春藤/ REPORT.TXT/&GTreport.xsl    < /目标与GT;< /项目>

report.xsl

 <的xsl:样式版本=1.0的xmlns:XSL =htt​​p://www.w3.org/1999/XSL/Transform>  < XSL:输出方法=TEXT/>  <的xsl:模板匹配=/>
    < XSL:申请模板选择=模块/模块/神器/>
  < / XSL:模板>  <的xsl:模板匹配=神器>
    <的xsl:value-of的选择=../@组织/>
    < XSL:文本>,< / XSL:文本>
    <的xsl:value-of的选择=../@名/​​>
    < XSL:文本>,< / XSL:文本>
    <的xsl:value-of的选择=../@转/>
    < XSL:文本>,< / XSL:文本>
    <的xsl:value-of的选择=原产地检/>
    < XSL:文本>,< / XSL:文本>
    < XSL:选择=缓存位置/&GT值的;
    < XSL:文本>
< / XSL:文本>
  < / XSL:模板>< / XSL:样式>

REPORT.TXT

<$p$p><$c$c>org.slf4j,slf4j-api,1.7.5,http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar,/home/mark/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.5.jar
org.slf4j,slf4j-log4j12,1.7.5,http://repo1.maven.org/maven2/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar,/home/mark/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.5.jar
log4j,log4j,1.2.17,http://repo1.maven.org/maven2/log4j/log4j/1.2.17/log4j-1.2.17.jar,/home/mark/.ivy2/cache/log4j/log4j/bundles/log4j-1.2.17.jar
junit,junit,4.11,http://repo1.maven.org/maven2/junit/junit/4.11/junit-4.11.jar,/home/mark/.ivy2/cache/junit/junit/jars/junit-4.11.jar
org.hamcrest,hamcrest-core,1.3,http://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar,/home/mark/.ivy2/cache/org.hamcrest/hamcrest-core/jars/hamcrest-core-1.3.jar

Normally, when we download jars from Ivy, we set pattern to include the version number of the jar.

<ivy:retrieve
    pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]"
    log="${ivy.log}"/>

However, for this one project, we can't do that. Jars have to be downloaded without version ID on them:

<ivy:retrieve
    pattern="${lib.dir}/[conf]/[artifact].[ext]"/>

This app is installed by overwriting what is already there. If a revision of a particular jar gets changed from one release to the next, we would end up with both the older jar and the newer version of that jar, and we would not know which version was being used. Removing the revision information makes it easy to make sure that older jars are replaced with the newer version.

However, the developer would still like a simple report on what versions of the jars were downloaded and put into the built war, so how can I generate such a report. I was looking at ivy:report but it doesn't produce a text report. There's a <ivy:artifactreport/> task, but that also produces an XML report and not a text report.

I could parse this report using Perl or Python, but I'd rather not use an executable as part of the build process. Otherwise, when a developer does a build, they'll have to make sure these external programs are correctly installed and configured.

Is there an easy way to produce a plain text report?

解决方案

Uses the ANT xslt task to generate a CSV formatted text file

Example

├── build
│   └── ivy
│       ├── com.myspotontheweb-demo-compile.html
│       ├── com.myspotontheweb-demo-runtime.html
│       ├── com.myspotontheweb-demo-test.html
│       ├── ivy-report.css
│       ├── report.txt
│       └── report.xml
├── build.xml
├── ivy.xml
└── report.xsl

build.xml

<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">

    <target name="resolve" description="Use ivy to resolve dependencies">
        <ivy:resolve/>

        <!-- Reports -->
        <ivy:report todir='build/ivy' graph='false' xml='false'/>

        <ivy:artifactreport tofile="build/ivy/report.xml"/>
        <xslt style="report.xsl" in="build/ivy/report.xml" out="build/ivy/report.txt"/>

    </target>

</project>

report.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:apply-templates select="modules/module/artifact"/>
  </xsl:template>

  <xsl:template match="artifact">
    <xsl:value-of select="../@organisation"/>
    <xsl:text>,</xsl:text>
    <xsl:value-of select="../@name"/>
    <xsl:text>,</xsl:text>
    <xsl:value-of select="../@rev"/>
    <xsl:text>,</xsl:text>
    <xsl:value-of select="origin-location"/>
    <xsl:text>,</xsl:text>
    <xsl:value-of select="cache-location"/>
    <xsl:text>
</xsl:text>
  </xsl:template>

</xsl:stylesheet>

report.txt

org.slf4j,slf4j-api,1.7.5,http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar,/home/mark/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.7.5.jar
org.slf4j,slf4j-log4j12,1.7.5,http://repo1.maven.org/maven2/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar,/home/mark/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.5.jar
log4j,log4j,1.2.17,http://repo1.maven.org/maven2/log4j/log4j/1.2.17/log4j-1.2.17.jar,/home/mark/.ivy2/cache/log4j/log4j/bundles/log4j-1.2.17.jar
junit,junit,4.11,http://repo1.maven.org/maven2/junit/junit/4.11/junit-4.11.jar,/home/mark/.ivy2/cache/junit/junit/jars/junit-4.11.jar
org.hamcrest,hamcrest-core,1.3,http://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar,/home/mark/.ivy2/cache/org.hamcrest/hamcrest-core/jars/hamcrest-core-1.3.jar

这篇关于蚂蚁常春藤:运行罐子生产文本报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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