我在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'
}
答案 0 :(得分:1)
您已在编译范围中定义了依赖项。也没有必要为运行时定义它们。编译范围依赖项将在运行时自动提供。
您还可以将编译依赖项放到lib文件夹中,并排除您不需要的任何依赖项。但是我想知道是否有任何依赖要排除,是否值得为它构建逻辑。
我建议你的构建脚本尽可能简单。