我想重用在此pom.xml file中定义的依赖关系这是相当长的依赖关系列表。我想重用它以方便。如何重用在gradle中的pom.xml中定义的依赖关系
所以我在的build.gradle文件中加入这样一行。:
dependencies {
// unfortunately, Gradle seems just ignore this line.
compile("org.activiti:activiti-ui-root:6.0.0")
}
但似乎刚刚的gradle这个则会忽略行。如果我不想重写一长串依赖关系,那么重用pom文件的最佳方法是什么?
请给我一些建议,非常感谢。
==============================
感谢,所有你们。最后我发现“io.spring.gradle:dependency-management-plugin”有助于解决我的问题。
@madhead是对的。 pom.xml只提供了jar版本,但不会将任何文件导入到我的项目中。
pom.xml实际上并未定义任何依赖关系,它仅定义了dependencyManagement块中的工件版本。因此,根据Gradle中的这个工件不会在你的项目中带来任何传递依赖(这在Maven中也不会)。
但是没关系。版本信息就够了。
这部分是我用来解决我的问题。
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
} }
.......
项目( ':编辑图像发生器'){
dependencyManagement {
imports {
// import the pom.xml from outside.
mavenBom "org.activiti:activiti-ui-root:6.0.0"
}
}
dependencies {
// It's good to see that, you don't need to specify the version here.
// with the mavenBom imported above, you can always get the right version.
compile("org.activiti:activiti-bpmn-model")
testCompile("org.activiti:activiti-bpmn-converter")
compile("org.activiti:activiti-image-generator")
compile("org.imgscalr:imgscalr-lib:4.2")
compile("org.slf4j:slf4j-api")
testCompile("commons-io:commons-io")
testCompile("junit:junit")
}
}
https://docs.gradle.org/current/userguide/artifact_dependencies_tutorial.html – nullpointer
我没有尝试,但我认为你可以实现它。在Gradle设置文件中,您可以实现函数来读取xml pom文件,获取所有依赖关系,然后将它们作为Gradle依赖关系加载。这只是一个想法。 –
你为什么认为Gradle忽略这条线?你的'build.gradle'其余部分是怎么样的? –