【问题标题】:Ivy - get a flat list of modules and their revisions across multiple projects常春藤 - 在多个项目中获取模块及其修订的平面列表
【发布时间】:2012-07-30 18:23:39
【问题描述】:
我们使用 Ivy 来管理我们的库依赖项,我们需要创建所有模块及其在某些配置中的修订的报告,并将其组合到大约 30 个项目中。只是一个简单的列表,其中没有依赖项。
“某些配置”是指我们,例如在 ivy.xml 文件中使用配置“compile”、“runtime”、“test”,我们只想包含“compile”和“runtime”,因为我们只对产品实际附带的库列表感兴趣。
我熟悉 任务,我们使用它为每个项目生成 HTML 报告。当然,可以选择使用此输出并对其进行解析,或者使用 XSLT 来实现所需的报告格式。但是,我想知道是否有更简单的方法?
谢谢!
【问题讨论】:
标签:
dependencies
report
ivy
dependency-management
【解决方案1】:
artifactreport 任务可用于生成 XML 文件,详细说明配置中的工件:
<ivy:artifactreport tofile="build/runtime.xml" conf="runtime"/>
这是一个稍微不同的解决方案,它结合了 groovy 和 ivy cachefileset 任务,根据编译依赖项生成 Eclipse“.classpath”文件
<macrodef name="eclipse">
<attribute name="srcdir"/>
<attribute name="outputdir"/>
<attribute name="classpathref" default="build.path"/>
<attribute name="conf" default="compile"/>
<sequential>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="@{classpathref}"/>
<ivy:cachefileset setid="libfiles" conf="@{conf}"/>
<groovy>
<arg value="@{srcdir}"/>
<arg value="@{outputdir}"/>
import groovy.xml.MarkupBuilder
//
// Generate the classpath file
//
// The "lib" classpathentry fields are populated using the ivy artifact report
//
project.log("Creating .classpath")
new File(".classpath").withWriter { writer ->
def xml = new MarkupBuilder(writer)
xml.classpath() {
classpathentry(kind:"src", path:args[0])
classpathentry(kind:"output", path:args[1])
classpathentry(kind:"con", path:"org.eclipse.jdt.launching.JRE_CONTAINER")
project.references.libfiles.each {
classpathentry(kind:"lib", path:it)
}
}
}
</groovy>
</sequential>
</macrodef>