简体   繁体   English

Gradle-从依赖项中排除spring.xml

[英]Gradle - Exclude spring.xml from a dependency

Is there a way to exclude spring.xml from a gradle dependency? 有没有办法从gradle依赖项中排除spring.xml? I have enabled autoscanning for all spring.xmls but do not want spring.xml from a specific jar to considered. 我已经为所有spring.xmls启用了自动扫描,但不希望考虑特定jar中的spring.xml。

compile('com.savnet.ofm:ofm-client:16.08') {
    exclude group: "net.sf.saxon", module: "saxon-xpath"
    exclude group: 'hibernate'
}   

You mean excluding a file from a JAR you depend on? 您的意思是从您依赖的JAR中排除文件?

If so, then as far as I know there is no per-se supported way. 如果是这样,据我所知,目前还没有支持的方法。
But you can make it manually. 但是您可以手动进行。
Something like the following which is totally made up right now and not tested , so take this as a starting point that might work or might need some polishing to work. 像下面这样的东西现在已经完全组成并且没有经过测试 ,因此可以以此为出发点,它可能会起作用,或者可能需要一些技巧才能起作用。

configurations { foo }
dependencies { foo 'com.savnet.ofm:ofm-client:16.08'}
sourceSets { main.compileClasspath += configurations.foo }

task fooJar(type: Jar) {
    archiveName = 'foo.jar'
    from zipTree(configurations.foo.singleFile)
    exclude 'spring.xml'
}

And then use fooJar output as runtime library. 然后将fooJar输出用作运行时库。

请参见此处 ,以了解如何动态调整罐子并取决于调整后的版本的示例

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

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