gpt4 book ai didi

java - 如何去除gradle中的重复依赖?

转载 作者:行者123 更新时间:2023-12-01 11:32:42 66 4
gpt4 key购买 nike

我在我的 gradle 脚本中使用依赖项部分,但我认为我正在脚本中创建依赖项的重复项。我在编译时和运行时都需要依赖项。我是否需要将依赖项定义为编译和运行时。因为对于运行时我的脚本具有以下逻辑

runtime.configuration 这样我就可以将所有 jar 文件放入 lib 文件夹

我可以在一个部分中完成这两件事吗?我的意思是我只需要一个依赖部分编译或运行时。

请提出建议

dependencies {
compile group: 'com.rohit.singh', name: 'common', version:'4.+'
compile group: 'com.rohit.singh', name: 'LicenseVerifier', version:'4.+'
compile group: 'com.rohit.singh', name: 'MegNativeJNI', version: '4.+', ext: 'so'
compile group: 'com.rohit.singh', name: 'NativeJNI', version: '4.+', ext: 'so'
compile(group: 'com.operasolutions', name: 'RiskAnalytics', version:'1.1') {
exclude(module: 'jyson')
}
compile group: 'org.springframework', name: 'spring-context', version:'3.2.5.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version:'3.2.5.RELEASE'
compile group: 'org.springframework', name: 'spring-core', version:'3.2.5.RELEASE'
compile group: 'org.springframework', name: 'spring-aop', version:'3.2.5.RELEASE'
compile group: 'org.springframework', name: 'spring-expression', version:'3.2.5.RELEASE'
compile group: 'org.apache.commons', name: 'commons-collections4', version:'4.0'
compile group: 'commons-io', name: 'commons-io', version:'2.4'
compile group: 'net.sf.supercsv', name: 'super-csv-dozer', version:'2.1.0'
compile group: 'net.sf.supercsv', name: 'super-csv', version:'2.1.0'
compile group: 'org.aspectj', name: 'aspectjtools', version:'1.6.2'
compile group: 'org.python', name: 'jython-standalone', version:'2.5.3'
compile group: 'com.google.code.gson', name: 'gson', version:'1.7.2'
compile group: 'log4j', name: 'log4j', version:'1.2.16'
compile group: 'com.xhaus', name: 'jyson', version:'1.0.2'
compile group: 'com.google.guava', name: 'guava', version:'17.0'
compile group: 'com.jamonapi', name: 'jamon', version:'2.4'
compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.1'
compile group: 'ch.qos.logback', name: 'logback-core', version:'1.1.1'
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.6'
compile group: 'org.codehaus.mojo', name: 'properties-maven-plugin', version:'1.0-alpha-2'
compile group: 'args4j', name: 'args4j', version:'2.0.28'
compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version:'1.9.5'
testCompile group: 'junit', name: 'junit', version:'4.11'
testCompile group: 'org.mockito', name: 'mockito-all', version:'1.9.5'
}
dependencies {
runtime group: 'com.rohit.singh', name: 'engine-common', version:'4.+'
runtime group: 'com.rohit.singh', name: 'engine-LicenseVerifier', version:'4.+'
runtime group: 'com.rohit.singh', name: 'MegNativeJNI', version: '4.+', ext: 'so'
runtime group: 'com.rohit.singh', name: 'NativeJNI', version: '4.+', ext: 'so'
runtime (group: 'com.operasolutions', name: 'RiskAnalytics', version:'1.1') {
exclude(module: 'jyson')
}
runtime group: 'org.springframework', name: 'spring-context', version:'3.2.5.RELEASE'
runtime group: 'org.springframework', name: 'spring-beans', version:'3.2.5.RELEASE'
runtime group: 'org.springframework', name: 'spring-core', version:'3.2.5.RELEASE'
runtime group: 'org.springframework', name: 'spring-aop', version:'3.2.5.RELEASE'
runtime group: 'org.springframework', name: 'spring-expression', version:'3.2.5.RELEASE'
runtime group: 'org.apache.commons', name: 'commons-collections4', version:'4.0'
runtime group: 'commons-io', name: 'commons-io', version:'2.4'
runtime group: 'net.sf.supercsv', name: 'super-csv-dozer', version:'2.1.0'
runtime group: 'net.sf.supercsv', name: 'super-csv', version:'2.1.0'
runtime group: 'org.aspectj', name: 'aspectjtools', version:'1.6.2'
runtime group: 'org.python', name: 'jython-standalone', version:'2.5.3'
runtime group: 'com.google.code.gson', name: 'gson', version:'1.7.2'
runtime group: 'log4j', name: 'log4j', version:'1.2.16'
runtime group: 'com.xhaus', name: 'jyson', version:'1.0.2'
runtime group: 'com.google.guava', name: 'guava', version:'17.0'
runtime group: 'com.jamonapi', name: 'jamon', version:'2.4'
runtime group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.1'
runtime group: 'ch.qos.logback', name: 'logback-core', version:'1.1.1'
runtime group: 'org.slf4j', name: 'slf4j-api', version:'1.7.6'
runtime group: 'org.codehaus.mojo', name: 'properties-maven-plugin', version:'1.0-alpha-2'
runtime group: 'args4j', name: 'args4j', version:'2.0.28'
runtime group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version:'1.9.5'
}

最佳答案

您已经在编译范围中定义了依赖项。无需为运行时定义它们。编译范围依赖项将在运行时自动可用。

您还可以将编译依赖项放入 lib 文件夹并排除任何不需要的依赖项。但我想知道是否有任何依赖关系需要排除,以及是否值得为其构建逻辑。

我建议让您的构建脚本尽可能简单。

关于java - 如何去除gradle中的重复依赖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30283320/

66 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com