1
+ import groovy.util.Node
2
+ import groovy.util.NodeList
3
+
4
+ plugins {
5
+ `maven- publish`
6
+ `java- library`
7
+ id(" net.kyori.indra" )
8
+ id(" net.kyori.indra.publishing" )
9
+ id(" cl.franciscosolis.sonatype-central-upload" )
10
+ }
11
+
12
+ indra {
13
+ github(" SNWCreations" , " JKook" ) {
14
+ ci(true )
15
+ }
16
+ apache2License()
17
+
18
+ javaVersions {
19
+ target(8 )
20
+ minimumToolchain(17 )
21
+ }
22
+
23
+ configurePublications {
24
+ pom {
25
+ url = " https://github.com/SNWCreations/JKook"
26
+ description = " The Kook (https://kookapp.cn) Bot's Plugin framework for Java."
27
+ developers {
28
+ developer {
29
+ id = " SNWCreations"
30
+ name = " SNWCreations"
31
+ email = " snwcreations@qq.com"
32
+ roles = listOf (" contributor" )
33
+ }
34
+ developer {
35
+ id = " huanmeng-qwq"
36
+ name = " huanmeng_qwq"
37
+ email = " huanmeng@huanmeng-qwq.com"
38
+ roles = listOf (" contributor" )
39
+ }
40
+ developer {
41
+ id = " xiaoACE6716"
42
+ name = " xiaoACE"
43
+ roles = listOf (" contributor" )
44
+ }
45
+ developer {
46
+ id = " RealSeek"
47
+ name = " RealSeek"
48
+ roles = listOf (" contributor" )
49
+ }
50
+ developer {
51
+ id = " gehongyan"
52
+ name = " Ge"
53
+ roles = listOf (" contributor" )
54
+ }
55
+ developer {
56
+ id = " DeeChael"
57
+ name = " Deerio Chaelingo"
58
+ roles = listOf (" contributor" )
59
+ }
60
+ developer {
61
+ id = " natholdallas"
62
+ name = " natholdallas"
63
+ roles = listOf (" contributor" )
64
+ }
65
+ }
66
+ withXml {
67
+ project.configurations.compileOnly.get().allDependencies.forEach { dep ->
68
+ ((asNode().get(" dependencies" ) as NodeList )[0 ] as Node ).appendNode(" dependency" ).apply {
69
+ appendNode(" groupId" , dep.group)
70
+ appendNode(" artifactId" , dep.name)
71
+ appendNode(" version" , dep.version)
72
+ appendNode(" scope" , " provided" )
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+ tasks.withType<JavaCompile >().configureEach {
81
+ options.compilerArgs = mutableListOf (" -Xlint:-deprecation,-unchecked" )
82
+ }
83
+
84
+ val cleanUpload by tasks.creating(Delete ::class ) {
85
+ setDelete(project.files(project.layout.buildDirectory.dir(" sonatype-central-upload" )))
86
+ }
87
+
88
+ tasks.sonatypeCentralUpload {
89
+ // gradle sonatypeCentralUpload -PCENTRAL_USERNAME=<username> -PCENTRAL_PASSWORD=<password> -PCENTRAL_PRIVATE_KEY=<privateKey> -PCENTRAL_PRIVATE_KEY_PWD=<privateKeyPwd> -PCENTRAL_PUBLIC_KEY=<publicKey>
90
+ val centralUsername = System .getenv(" CENTRAL_USERNAME" ) ? : findProperty(" CENTRAL_USERNAME" )?.toString()
91
+ val centralPassword = System .getenv(" CENTRAL_PASSWORD" ) ? : findProperty(" CENTRAL_PASSWORD" )?.toString()
92
+ val privateKey = System .getenv(" CENTRAL_PRIVATE_KEY" ) ? : findProperty(" CENTRAL_PRIVATE_KEY" )?.toString()
93
+ val privateKeyPwd = System .getenv(" CENTRAL_PRIVATE_KEY_PWD" ) ? : findProperty(" CENTRAL_PRIVATE_KEY_PWD" )?.toString()
94
+ val publicKey = System .getenv(" CENTRAL_PUBLIC_KEY" ) ? : findProperty(" CENTRAL_PUBLIC_KEY" )?.toString()
95
+ dependsOn(tasks.build, tasks.generatePomFileForMavenPublication, cleanUpload)
96
+ // this.username = centralUsername
97
+ // this.password = centralPassword
98
+ this .publishingType = " AUTOMATIC" // MANUAL
99
+ this .signingKey = privateKey
100
+ this .signingKeyPassphrase = privateKeyPwd
101
+ this .publicKey = publicKey
102
+ archives = project.layout.buildDirectory.dir(" libs" ).get().asFileTree
103
+ pom = file(project.layout.buildDirectory.file(" publications/maven/pom-default.xml" ))
104
+ }
105
+
106
+ tasks.test {
107
+ onlyIf { ! gradle.startParameter.taskNames.contains(" sonatypeCentralUpload" ) }
108
+ }
109
+
110
+ project.afterEvaluate {
111
+ tasks.findByName(" shadowJar" )?.apply {
112
+ onlyIf { ! gradle.startParameter.taskNames.contains(" sonatypeCentralUpload" ) }
113
+ }
114
+ }
0 commit comments