Skip to content

Commit a0c78ba

Browse files
committed
添加pom依赖传递
1 parent 38bfc9a commit a0c78ba

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

morpher-api/build.gradle.kts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id("java")
33
id("maven-publish")
4+
id("java-library")
45
}
56

67
description = "A tool that use custom transformer for modifying java bytecode"
@@ -39,14 +40,28 @@ tasks {
3940
// }
4041
// }
4142

42-
publishing{
43-
publications{
44-
create<MavenPublication>("mavenJava"){
43+
publishing {
44+
publications {
45+
create<MavenPublication>("mavenJava") {
4546
groupId = "com.github.luiox"
4647
artifactId = "morpher-api"
4748
version = "1.6"
4849

4950
artifact(jar)
51+
// from(components["java"])
52+
pom.withXml {
53+
val dependenciesNode = asNode().appendNode("dependencies")
54+
55+
// 遍历项目依赖并添加到 POM
56+
project.configurations.implementation.get().allDependencies.forEach { dep ->
57+
if (dep.group != null) { // 过滤掉没有 group 的依赖(如本地项目)
58+
val dependencyNode = dependenciesNode.appendNode("dependency")
59+
dependencyNode.appendNode("groupId", dep.group)
60+
dependencyNode.appendNode("artifactId", dep.name)
61+
dependencyNode.appendNode("version", dep.version ?: "")
62+
}
63+
}
64+
}
5065
}
5166
}
5267
}

0 commit comments

Comments
 (0)