当前位置: 首页 > 知识库问答 >
问题:

常春藤

秦承允
2023-03-14

我目前正在与apache ivy的conf设置作斗争。也许我会先解释我想实现的目标:

  1. 我需要两种配置:编译、运行时

这是我试过的:

<configurations>
    <conf name="compile" visibility="public"/>
    <conf name="runtime" visibility="public" extends="compile"/>
</configurations>
<dependencies>
    <dependency org="org.apache.ivy" name="ivy" rev="2.4.0" conf="runtime->runtime, compile->compile"/>
</dependencies>  

但它甚至无法被解析:无法解析ivy文件'...\ivy.xml':

有人能告诉我如何正确地声明conf设置,这样我就可以使用compile或runtime来解析,并获得所有jar,包括可传递的依赖项(在这个示例中,只有ivy的jar)。

使现代化

好的,谢谢你的链接。这让事情变得更清楚了一点,但我还是被卡住了。

我更改了依赖项声明,以便它解析作用域“default”中的常春藤jar:(我省略了“compile”-

<dependency org="org.apache.ivy" name="ivy" rev="2.4.0" conf="runtime->default"/>

并使用设置confs='*'和type='*'检索JAR(使用ivy eclipse插件)。

我只得到一棵常春藤2.4.0。罐子我期望所有的运行时依赖性。我不能确切地说出它们是什么,因为我不理解ivy的xml文件中的声明,比如(整个xml文件将在后面追加):

<dependency org="org.apache.ant" name="ant" rev="1.7.1" force="true" conf="optional->compile(*),master(*)"/>

以下是我对conf=“runtime”的理解-

>

  • ivy依赖项分配给(本地)conf'runtime'
  • ivy依赖项分配给远程conf'default'
  • 每当我解析(或检索)conf'runtime'的依赖项时,我都会得到所有的远程依赖项,包括conf'default'的传递依赖项,因为'default'conf被声明为

    “远程模块的工件及其所有运行时传递依赖项”链接

    这是我的常春藤。xml:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <ivy-module version="2.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
        <info organisation="My Name" module="jaculon.ivy" status="integration">
        </info>
    
        <configurations>
            <conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
            <conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
            <conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
            <conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
            <conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath." extends="compile"/>
            <conf name="test" visibility="public" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends="runtime"/>
            <conf name="system" visibility="public" description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository."/>
            <conf name="sources" visibility="public" description="this configuration contains the source artifact of this module, if any."/>
            <conf name="javadoc" visibility="public" description="this configuration contains the javadoc artifact of this module, if any."/>
            <conf name="optional" visibility="public" description="contains all optional dependencies"/>
        </configurations>
        <dependencies>
            <!-- Need ivy to resolve the jars. -->
            <dependency org="org.apache.ivy" name="ivy" rev="2.4.0" conf="runtime->default"/>
        </dependencies>
    
    </ivy-module>
    

    以下是常春藤2.4.0的内容。xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
        <info organisation="org.apache.ivy"
            module="ivy"
            revision="2.4.0"
            status="release"
            publication="20141222174010"
        >
            <description homepage="http://ant.apache.org/ivy/" />
            <m:properties__project.build.sourceEncoding>UTF-8</m:properties__project.build.sourceEncoding>
            <m:properties__organization.logo>http://www.apache.org/images/asf_logo_wide.gif</m:properties__organization.logo>
            <m:properties__distMgmtSnapshotsName>Apache Development Snapshot Repository</m:properties__distMgmtSnapshotsName>
            <m:properties__distMgmtSnapshotsUrl>https://repository.apache.org/content/repositories/snapshots</m:properties__distMgmtSnapshotsUrl>
            <m:maven.plugins>org.apache.maven.plugins__maven-remote-resources-plugin__null|org.apache.maven.plugins__maven-remote-resources-plugin__null</m:maven.plugins>
            <m:properties__sourceReleaseAssemblyDescriptor>source-release</m:properties__sourceReleaseAssemblyDescriptor>
        </info>
        <configurations>
            <conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
            <conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
            <conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
            <conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
            <conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath." extends="compile"/>
            <conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends="runtime"/>
            <conf name="system" visibility="public" description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository."/>
            <conf name="sources" visibility="public" description="this configuration contains the source artifact of this module, if any."/>
            <conf name="javadoc" visibility="public" description="this configuration contains the javadoc artifact of this module, if any."/>
            <conf name="optional" visibility="public" description="contains all optional dependencies"/>
        </configurations>
        <publications>
            <artifact name="ivy" type="jar" ext="jar" conf="master"/>
            <artifact name="ivy" type="source" ext="jar" conf="sources" m:classifier="sources"/>
            <artifact name="ivy" type="javadoc" ext="jar" conf="javadoc" m:classifier="javadoc"/>
        </publications>
        <dependencies>
            <dependency org="org.apache.ant" name="ant" rev="1.7.1" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="org.apache.ant" name="ant-nodeps" rev="1.7.1" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="org.apache.ant" name="ant-trax" rev="1.7.1" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="commons-httpclient" name="commons-httpclient" rev="3.0" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="oro" name="oro" rev="2.0.8" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="commons-vfs" name="commons-vfs" rev="1.0" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="com.jcraft" name="jsch" rev="0.1.50" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="com.jcraft" name="jsch.agentproxy" rev="0.0.6" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="com.jcraft" name="jsch.agentproxy.connector-factory" rev="0.0.6" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="com.jcraft" name="jsch.agentproxy.jsch" rev="0.0.6" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="org.bouncycastle" name="bcpg-jdk14" rev="1.45" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="org.bouncycastle" name="bcprov-jdk14" rev="1.45" force="true" conf="optional->compile(*),master(*)"/>
            <dependency org="junit" name="junit" rev="3.8.2" force="true" conf="test->runtime(*),master(*)"/>
            <dependency org="commons-lang" name="commons-lang" rev="2.6" force="true" conf="test->runtime(*),master(*)"/>
            <dependency org="org.apache.ant" name="ant-testutil" rev="1.7.0" force="true" conf="test->runtime(*),master(*)">
                <exclude org="*" module="*" name="*" type="*" ext="*" conf="" matcher="exact"/>
            </dependency>
            <dependency org="ant" name="ant-launcher" rev="1.6.2" force="true" conf="test->runtime(*),master(*)">
                <exclude org="*" module="*" name="*" type="*" ext="*" conf="" matcher="exact"/>
            </dependency>
            <dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" force="true" conf="test->runtime(*),master(*)">
                <exclude org="*" module="*" name="*" type="*" ext="*" conf="" matcher="exact"/>
            </dependency>
            <dependency org="xerces" name="xercesImpl" rev="2.6.2" force="true" conf="test->runtime(*),master(*)"/>
            <dependency org="xerces" name="xmlParserAPIs" rev="2.6.2" force="true" conf="test->runtime(*),master(*)"/>
        </dependencies>
    </ivy-module>
    
  • 共有1个答案

    董凡
    2023-03-14

    听起来像是XML格式问题。

    以下示例演示了如何使用ivy配置来管理单独的“编译”、“运行时”和“测试”类路径:

    • Ivy,主配置是什么?为什么不拉jvyaml
     类似资料:
    • 我正在尝试使用IVY,并且我已经在springsource工具套件中设置了我的IVY-de。 在尝试构建我的工作空间时,我得到了以下错误。 说明资源路径位置类型类路径发布/导出依赖项C:/Users/user1/.ivy2/cache/jstl/jstl.jars/jstl-1.2.jar无效。项目包含另一个具有相同存档名称的依赖项。Web P/Web类路径依赖关系验证器消息 在这方面,我们非常感

    • 我是艾薇的新手,所以这可能已经被报道过了,但是我知道的还不够多。我的搜索结果是空的,没有找到类似的经历。 因此,当我第一次下拉整个项目并且更新库引用时,我有时会收到未解决的依赖项警告。它似乎在随机库上。 例如,我刚刚在某个项目中添加了Commons-codec-1.9,而工作集中的其他项目使用1.6和1.7。当运行盛大的构建脚本时,突然对于1.6和1.7“配置[is]未找到”: 现在,我不完全确定

    • 我有一个简单的文件: 其中是我的配置名称,是映射的Maven类型。这被正确解析并给我这些文件: 现在,我必须添加这个依赖项: 它将< code>validation-api作为其依赖项,与我在顶部指定的相同。 艾薇解决了这个问题,给了我这些文件: 但这次没有检索到文件。为什么?我认为这个文件没有冲突……我应该怎么做才能拥有和jar(二进制和源代码)?

    • 我正在使用RabbitMQ的spring cloud stream。我试图通过在运行时删除队列并将消息发送到删除的队列来进行否定测试。 我正在侦听来自队列1的消息,并将消息发送到队列2(已删除的一个)。我原以为上面的代码会抛出异常,但事实并非如此。甚至从队列1读取的消息也已被确认。我在队列1和队列2上有一个死信队列,但消息没有进入DLQ。

    • 我正在尝试解决Ant/Ivy系统中的一些技术债务,我目前的任务之一是解决我们目前的一些检索后行为。默认情况下,我们的构建系统检索Ivy依赖项,然后将压缩工件(tar、tar.bz2、gzip、zip)提取到依赖文件夹,以便我们的项目具有一致的依赖位置: 提取发生在中,因此我们可以受益于一些元数据(路径、名称、类型等),所有这些都以'dep'为前缀。 我们目前有一个属性,可以设置为关闭 ivy.xm

    • 问题内容: 我将Ivy用作我的持续集成构建系统的一部分,但是我需要覆盖Ivy的本地缓存区域的默认位置。 问题答案: 尽管上面来自skaffman的答案是正确的,但我发现它比我预期的要多得多的工作! 当我将ivysettings.xml文件添加到项目时,然后我需要重新定义几乎所有内容,因为在此之前默认值一直可以正常工作。 因此,我发现了如何在NAnt脚本中将新的缓存目录添加到嵌入式命令行中… (我的