- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有关 Apache Ivy 的三个简单问题:
(1) 在我们的项目中,我们使用了 100 多个“通用”JAR(log4j、junit、commons-cli 等)。我们是否必须为所有这些文件编写 ivy.xml(“模块描述符”)文件,或者我可以在 ibiblio(或其他)存储库中找到通用文件吗?强制你的用户为每个依赖项编写他们自己的 ivy 文件对我来说听起来非常残酷和不寻常。
(2) 特定 JAR 是否需要 ivy 文件,或者当 Ivy 在存储库中查找没有相应 ivy 文件的依赖项时是否有默认值?
(3) 是否可以将所有依赖项放在一个文件夹(repo)中,并定义 1 个 ivy.xml 文件来配置其中的所有依赖项?
感谢您的帮助!
最佳答案
(1) Ivy 文件不必列出每个 jar。有些 jar 是其他 jar 的依赖项,由 ivy 自动从存储库中提取。没有可用的默认值。对于新项目,我通常会生成第一个 ivy 文件(请参阅随附的 ant2ivy 脚本)
(2) 仅当 jar 具有依赖项时,ivy 存储库中才需要 ivy 文件。话虽如此,拥有一个是很好的做法。就我个人而言,我作弊并使用 Maven 存储库管理器,如 Nexus存放我的 jar 。
(3) 您可以在设置文件中使用文件系统解析器创建本地存储库,如下所示:
<ivysettings>
<settings defaultResolver='maven-repos' />
<resolvers>
<chain name='maven-repos'>
<ibiblio name='central' m2compatible='true' />
<ibiblio name='spring-external' m2compatible='true' root='http://repository.springsource.com/maven/bundles/external' />
</chain>
<filesystem name='local'>
<artifact pattern='/home/mark/tmp/petclinic/build/jars/[artifact]' />
</filesystem>
</resolvers>
<modules>
<module organisation='NA' name='mylibrary1.jar' resolver='local' />
<module organisation='NA' name='mylibrary2.jar' resolver='local' />
..
</modules>
</ivysettings>
当与模块声明结合使用时,这使得您的 ivy.xml 文件中的以下内容成为可能:
<dependency org='NA' name='mylibrary1.jar' rev='NA' />
<dependency org='NA' name='mylibrary2.jar' rev='NA' />
所有其他依赖项均从 Maven 存储库检索。
如果您遵循我附加的 ant2ivy 脚本的逻辑,您会看到我将此策略与我无法使用 Sonatype 的存储库 REST API 识别的 jar 一起使用
这是一个粗略且现成的 groovy 脚本,它执行 Sonatypes 存储库的查找以识别指定目录中的 jar
//
// Dependencies
// ============
import groovy.xml.MarkupBuilder
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Grapes([
@Grab(group='org.slf4j', module='slf4j-simple', version='1.6.2')
])
//
// Classes
// =======
class Ant2Ivy {
Logger log = LoggerFactory.getLogger(this.class.name);
String groupId
String artifactId
String repoUrl
Ant2Ivy(groupId, artifactId) {
this(groupId, artifactId, "http://repository.sonatype.org")
}
Ant2Ivy(groupId, artifactId, repoUrl) {
this.groupId = groupId
this.artifactId = artifactId
this.repoUrl = repoUrl
log.debug "groupId: {}, artifactId: {}", groupId, artifactId
}
//
// Given a directory, find all jar and search Nexus
// based on the file's checksum
//
// Return a data structure containing the GAV coordinates of each jar
//
def search(File inputDir) {
def results = [:]
results["found"] = []
results["missing"] = []
log.info "Searching: {} ...", repoUrl
def ant = new AntBuilder()
ant.fileset(id:"jars", dir:inputDir.absolutePath, includes:"**/*.jar")
ant.project.references.jars.each {
def jar = new File(inputDir, it.name)
// Checksum URL
ant.checksum(file:jar.absolutePath, algorithm:"SHA1", property:jar.name)
def searchUrl = "${repoUrl}/service/local/data_index?sha1=${ant.project.properties[jar.name]}"
log.debug "SearchUrl: {}, File: {}", searchUrl, jar.name
// Search for the first result
def searchResults = new XmlParser().parseText(searchUrl.toURL().text)
def artifact = searchResults.data.artifact[0]
if (artifact) {
log.debug "Found: {}", jar.name
results["found"].add([file:jar.name, groupId:artifact.groupId.text(), artifactId:artifact.artifactId.text(), version:artifact.version.text()])
}
else {
log.warn "Not Found: {}", jar.name
results["missing"].add([file:jar.name, fileObj:jar])
}
}
return results
}
//
// Given an input direcory, search for the GAV coordinates
// and use this information to write two XML files:
//
// ivy.xml Contains the ivy dependency declarations
// ivysettings.xml Resolver configuration
//
def generate(File inputDir, File outputDir) {
outputDir.mkdir()
def antFile = new File(outputDir, "build.xml")
def ivyFile = new File(outputDir, "ivy.xml")
def ivySettingsFile = new File(outputDir, "ivysettings.xml")
def localRepo = new File(outputDir, "jars")
def results = search(inputDir)
//
// Generate the ant build file
//
log.info "Generating ant file: {} ...", antFile.absolutePath
def antContent = new MarkupBuilder(antFile.newPrintWriter())
antContent.project(name: "Sample ivy builde", default:"resolve", "xmlns:ivy":"antlib:org.apache.ivy.ant" ) {
target(name:"resolve") {
"ivy:resolve"()
}
target(name:"clean") {
"ivy:cleancache"()
}
}
//
// Generate the ivy file
//
log.info "Generating ivy file: {} ...", ivyFile.absolutePath
def ivyConfig = new MarkupBuilder(ivyFile.newPrintWriter())
ivyConfig."ivy-module"(version:"2.0") {
info(organisation:this.groupId, module:this.artifactId)
configurations(defaultconfmapping:"default")
dependencies() {
results.found.each {
dependency(org:it.groupId, name:it.artifactId, rev:it.version, conf:"default->master")
}
results.missing.each {
dependency(org:"NA", name:it.file, rev:"NA")
}
}
}
//
// Generate the ivy settings file
//
log.info "Generating ivy settings file: {} ...", ivySettingsFile.absolutePath
def ivySettings = new MarkupBuilder(ivySettingsFile.newPrintWriter())
def ant = new AntBuilder()
ivySettings.ivysettings() {
settings(defaultResolver:"maven-repos")
resolvers() {
chain(name:"maven-repos") {
// TODO: Make this list of Maven repos configurable
ibiblio(name:"central", m2compatible:"true")
ibiblio(name:"spring-external", m2compatible:"true", root:"http://repository.springsource.com/maven/bundles/external")
}
if (results.missing.size() > 0) {
filesystem(name:"local") {
artifact(pattern:"${localRepo.absolutePath}/[artifact]")
}
}
}
if (results.missing.size() > 0) {
modules() {
results.missing.each {
module(organisation:"NA", name:it.file, resolver:"local")
ant.copy(file:it.fileObj.absolutePath, tofile:"${localRepo.absolutePath}/${it.file}")
}
}
}
}
}
}
//
// Main program
// ============
def cli = new CliBuilder(usage: 'ant2ivy')
cli.with {
h longOpt: 'help', 'Show usage information'
g longOpt: 'groupid', args: 1, 'Module groupid', required: true
a longOpt: 'artifactid', args: 1, 'Module artifactid', required: true
s longOpt: 'sourcedir', args: 1, 'Source directory containing jars', required: true
t longOpt: 'targetdir', args: 1, 'Target directory where write ivy build files', required: true
}
def options = cli.parse(args)
if (!options) {
return
}
if (options.help) {
cli.usage()
}
//
// Generate ivy configuration
//
def ant2ivy = new Ant2Ivy(options.groupid, options.artifactid)
ant2ivy.generate(new File(options.sourcedir), new File(options.targetdir))
脚本运行如下:
groovy ant2ivy.groovy -g com.hello -a test -s targetdir/WEB-INF/lib -t build
当针对 petclinic 运行时样本生成了以下文件
build/build.xml
build/ivy.xml
build/ivysettings.xml
build/jars/..
..
jars 目录包含那些在 Maven 存储库中找不到的库。
关于 Apache Ivy : Dependency Ivy FIles,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7363580/
如果我有一个包含 debian/control 和 Build-Depends 条目的 Depends 文件。 如何安装两组依赖项? 目前我正在使用以下命令创建一个依赖于 Build-Depends
我一直在查看衬底节点模板的Cargo.toml文件,并注意到,对于大多数 crate 而言,其依赖性如下所示: [dependencies.grandpa] package = 'sc-finalit
我在 Netbeans 7.1 IDE 中有一个 Maven 项目。 我想为 Dependencies 添加相同的依赖项和 Test Dependencies . 添加到一个中会将其从另一个中删除。
我正在尝试解决此处描述的问题: http://www.jayway.com/2013/04/12/solving-asm-conflicts-after-upgrading-to-groovy-2-1
我研究过这个问题,但找不到共识。如果“A 依赖于 B”,术语“依赖性”指的是: 一个 B A和B的关系 这个术语在计算机技术的不同子领域中是否有不同的含义? 最佳答案 B 将是依赖项。您可能会以“B
WebLogic 10.3.6Java 1.6 所以我在使用 Eclipse 时遇到了 XML 问题。 7天前我去度假之前,这一切运行良好。事实上,在我离开之前,我恢复到了旧版本,因为我在一些不太重要
在问这个问题之前,我想说 this stackoverflow 中的问题与我的问题非常相似,但概念仍然不清楚,非常困惑。 我想了解依赖倒置原则,但我无法完全理解它? 下面是DIP说的两点 A. Hig
很难说出这里问的是什么。这个问题是模棱两可的、模糊的、不完整的、过于宽泛的或修辞的,无法以目前的形式得到合理的回答。如需帮助澄清这个问题以便重新打开它,visit the help center .
我正在尝试使用 apache maven 创建一个包。当我运行 mvn clean install 命令时,出现以下错误: dependencies.dependency.version' is mi
在 Real World Ocaml Chapter 9这是关于仿函数的: Dependency injection Makes the implementations of some compone
我已经构建了类似用于创建网站的基本模板/工作流的东西,主要使用 Grunt。 该模板的一部分是 Modernizr 特征检测库,我的一项 Grunt 任务依赖于它。 目前我只是将该依赖项存储在我的 b
我有固定依赖项的 python 项目。由于第三方依赖项中的错误,在我的包中发现了错误。该依赖项已发布修复该错误的补丁。然而,根据 semantic versioning ,是否为固定依赖项的每个补丁版
使用插件io.spring.dependency-management ,我的依赖的一些版本是从其他依赖中扣除的 id("io.spring.dependency-management") versi
我有这两个表“员工表,从属表” 员工表有“ID, employee_id, employee_name” 从属表有“ID, employee_id, dependent_name, relations
我正在使用 Eclipse 中的一个 mavenised java 项目,其中有几个模块无法构建并从 pom 文件中抛出错误: Project build error: 'dependencies.d
我有一个包含多个模块的 maven 项目。在 Eclipse(Juno,带有 m2e)中,它似乎编译得很好。但是当我在其中一个模块上进行 maven 安装时,构建会立即失败。 父 pom: com
我使用 eclipse juno 创建了一个 maven 项目并编辑了 pom 文件。当我通过“mvn clean install”使用命令提示符运行 pom 文件时,出现此错误。 [ERROR] T
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 6 年前。 Improv
似乎包括与 provided 的直接依赖关系范围很好理解。似乎还包括带有 runtime 的传递依赖项。范围也很容易实现。 但是我如何才能包含两个间接级别的依赖项? 例子: A --> B --> C
我有以下情况: 我想在我的另一个项目中使用我的一个项目(托管在 bintray.com 上)。 我设置了一个 Maven 存储库,上传了 Artifact 和 pom 文件,然后能够使用上传到 bin
我是一名优秀的程序员,十分优秀!