简体   繁体   English

常春藤conf斗争

[英]Ivy conf struggle

I am currently struggling with apache ivy's conf settings. 我目前正在使用apache ivy的conf设置。 Maybe i'll explain what i want to achieve first: 也许我先解释一下我要实现的目标:

  1. I want two configurations: compile, runtime 我想要两种配置:编译,运行时
  2. I want for each configuration that ivy resolves, all jars including the transitive dependencies 我想要常春藤解析的每个配置,所有罐子,包括传递依赖项

Here's something i tried: 这是我尝试过的方法:

<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>  

But it cannot even be parsed: The ivy file '...\\ivy.xml' could not be parsed: 但它甚至无法解析:无法解析常春藤文件'... \\ ivy.xml':

Could please someone tell me how to declare the conf settings properly, so that i can resolve using either compile or runtime and get all jars including the transitive dependencies(in the example case only the jars of ivy). 可以请别人告诉我如何正确声明conf设置,以便我可以使用编译或运行时进行解析,并获取包括传递依赖项在内的所有jar(在本例中仅是常春藤的jar)。

Update 更新资料

Ok, thanks for the links. 好的,谢谢您的链接。 This makes it a bit clearer, but i'm still stuck. 这使它更清晰一些,但我仍然陷于困境。

I changed the dependency declaration so that it resolves the ivy jars in scope 'default': (I left out the "compile->default" declaration, as it seems there's a bug in the parsing of ivy eclipse plugin) 我更改了依赖声明,以便解析“默认”范围内的常春藤罐子(我省略了“编译->默认”声明,因为在常春藤eclipse插件的解析中似乎存在错误)

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

and retrieved the jars (using the ivy eclipse plugin) with the settings confs='*' and types='*' . 并使用设置confs='*' and types='*'检索罐子(使用ivy eclipse插件)。

All i got was a single ivy-2.4.0.jar. 我所得到的只是一个常春藤2.4.0.jar。 I expected all runtime dependencies. 我期望所有运行时依赖项。 I can't exactly tell which they are, as i don't understand the declarations in ivy's xml file like(the whole xml file is appended later): 我无法确切地说出它们是什么,因为我不理解ivy的xml文件中的声明(整个xml文件稍后会附加):

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

Here's how i understand the conf="runtime->default" declaration: 这是我理解conf =“ runtime-> default”声明的方式:

  • The ivy dependency is assigned to (local) conf 'runtime' 常春藤依赖项分配给(local)conf'runtime'
  • The ivy dependency is assigned to remote conf 'default' 常春藤依赖项分配给远程会议'默认'
  • Whenever i resolve (or retrieve) the dependency for conf 'runtime' i get all of the remote dependencies including the transitive dependencies for conf 'default', as the 'default' conf is declared as 每当我解析(或检索)conf'runtime'的依赖关系时,我都会获得所有远程依赖关系,包括conf'default'的传递依赖关系,因为'default'conf被声明为

    "The remote module's artifact and all it's runtime transitive dependencies" link “远程模块的工件及其所有运行时传递依赖项” 链接

Here's my ivy.xml: 这是我的ivy.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>

Here's the content the ivy-2.4.0.xml: 这是ivy-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>

Sounds like an XML formatting problem. 听起来像XML格式问题。

The following examples demonstrate how ivy configurations can be used to manage separate "compile", "runtime" and "test" classpaths: 以下示例演示了如何使用ivy配置来管理单独的“编译”,“运行时”和“测试”类路径:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM