gradle - how to declare a dependency of a jar in a jar

帅比萌擦擦* 提交于 2019-11-29 16:26:33

Resolving a dependency inside a dependency would require the use of the ivy packager resolver.

I've never configured the package resolver from within Gradle, but I think it would work something like the following (Referencing webpage)

repositories {
    add(new org.apache.ivy.plugins.resolver.packager.PackagerResolver()) {
        name = 'local Ivy packagers'

        buildRoot = file("${gradle.gradleUserHomeDir}/packager/build")
        resourceCache = file("${gradle.gradleUserHomeDir}/packager/cache")

        addIvyPattern      "file:///${project.rootDir}/ivy/[organisation]/[module]/[revision]/ivy.xml"
        addArtifactPattern "file:///${project.rootDir}/ivy/[organisation]/[module]/[revision]/packager.xml"
    }
}

dependencies {
    compile group: 'org.myorg', name: 'jms', version: '1.1.0.200810061358'
}

The resolver requires the following files for the declared dependency:

ivy/org.myorg/jms/1.1.0.200810061358/ivy.xml
ivy/org.myorg/jms/1.1.0.200810061358/packager.xml

ivy.xml

Describes the module and in this case declares what artifacts are published:

<ivy-module version="2.0">
    <info organisation="org.myorg" module="jms" revision="1.1.0.200810061358" status="release"/>

    <publications>
        <artifact name="jms" type="jar"/>
    </publications>

</ivy-module>

packager.xml

Describes where the enclosing archive is located and instructions on how to extract jms.jar:

<packager-module version="1.0">

    <resource dest="archive" url="http://archivaserver:8080/archiva/repository/??/javax.jms_1.1.0.200810061358.jar" sha1="????"/>

    <build>
        <move file="archive/jms.jar" tofile="artifacts/jars/jms.jar"/>
    </build>

</packager-module>

The content under the build tag is used to generate an ANT script. For more details read the "Packaging instructions" section of the ivy documentation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!