我正在将 Maven 项目迁移到 Gradle。我需要管理依赖项,所以尝试了 resolutionStrategy ,如下所示:
def dependencyVersions = [
'org.slf4j:slf4j-api' : '1.7.2',
'javax.inject:javax.inject' : '1',
'com.google.code.findbugs:annotations' : '2.0.1',
'com.typesafe:config' : '1.0.0',
'ch.qos.logback:logback-classic' : '1.0.9',
'com.google.guava:guava' : '14.0',
'com.google.inject:guice' : '3.0',
'com.google.inject.extensions:guice-multibindings' : '3.0',
'com.google.code.gson:gson' : '2.2.2',
'joda-time:joda-time' : '2.1',
'com.thoughtworks.paranamer:paranamer' : '2.5.2',
'org.codehaus.groovy:groovy-all' : '2.0.6',
'commons-validator:commons-validator': '1.4.0',
'org.apache.shiro:shiro-core' : '1.2.1',
'junit:junit-dep' : '4.10',
'org.mockito:mockito-core' : '1.9.5',
'org.hamcrest:hamcrest-core': '1.3',
'org.hamcrest:hamcrest-library': '1.3',
'org.unitils:unitils-core': '3.3'
]
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
def version = dependencyVersions["$details.requested.group:$details.requested.name"]
if (version != null)
details.useVersion version
}
}
}
但是现在当我尝试 Gradle 安装(到本地 Maven 存储库)时,我收到了这个错误:
Execution failed for task ':counter-module:install'.
无法发布配置“存档”无法初始化 POM pom-default.xml:无法在 /home/workspace/counter/counter-module/build/poms/pom-default.xml 验证项目 lt.counter 的 POM