11plugins {
22 id(" java" )
3+ id(" maven-publish" )
34}
45
56description = " some generic passes"
6- group = " com.github.luiox"
7- version = " 1.0-SNAPSHOT"
87
98repositories {
109 mavenCentral()
@@ -15,8 +14,20 @@ dependencies {
1514 testImplementation(platform(" org.junit:junit-bom:${properties[" junit_version" ] as String } " ))
1615 testImplementation(" org.junit.jupiter:junit-jupiter" )
1716
18- implementation(" com.github.luiox:morpher-api:v1.6" )
19- // implementation(project(":morpher-api"))
17+ implementation(" org.ow2.asm:asm:${properties[" asm_version" ] as String } " )
18+ implementation(" org.ow2.asm:asm-tree:${properties[" asm_version" ] as String } " )
19+ implementation(" org.ow2.asm:asm-commons:${properties[" asm_version" ] as String } " )
20+ implementation(" org.ow2.asm:asm-analysis:${properties[" asm_version" ] as String } " )
21+ implementation(" org.ow2.asm:asm-util:${properties[" asm_version" ] as String } " )
22+
23+ implementation(" ch.qos.logback:logback-classic:${properties[" logback_version" ] as String } " )
24+ implementation(" ch.qos.logback:logback-core:${properties[" logback_version" ] as String } " )
25+
26+ implementation(" org.jetbrains:annotations:${properties[" jetbrains_annotations_version" ] as String } " )
27+
28+ // implementation("com.github.luiox:morpher-api:v1.6")
29+ implementation(project(" :morpher-api" ))
30+
2031}
2132
2233tasks{
@@ -26,7 +37,37 @@ tasks{
2637 }
2738 }
2839
40+ jar {
41+ duplicatesStrategy = DuplicatesStrategy .EXCLUDE
42+ }
43+
2944 test {
3045 useJUnitPlatform()
3146 }
47+
48+ publishing {
49+ publications {
50+ create<MavenPublication >(" mavenJava" ) {
51+ artifactId = " morpher-passes"
52+ groupId = project.group.toString()
53+ version = project.version.toString()
54+
55+ artifact(jar)
56+
57+ pom.withXml {
58+ val dependenciesNode = asNode().appendNode(" dependencies" )
59+
60+ // 遍历项目依赖并添加到 POM
61+ project.configurations.implementation.get().allDependencies.forEach { dep ->
62+ if (dep.group != null ) { // 过滤掉没有 group 的依赖(如本地项目)
63+ val dependencyNode = dependenciesNode.appendNode(" dependency" )
64+ dependencyNode.appendNode(" groupId" , dep.group)
65+ dependencyNode.appendNode(" artifactId" , dep.name)
66+ dependencyNode.appendNode(" version" , dep.version ? : " " )
67+ }
68+ }
69+ }
70+ }
71+ }
72+ }
3273}
0 commit comments