-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
152 lines (133 loc) · 4.03 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import java.io.RandomAccessFile
import java.util.Properties
plugins {
java
signing
`maven-publish`
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}
group = "org.glavo"
version = "1.0.0"
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.compileJava {
options.release.set(9)
modularity.inferModulePath.set(true)
options.isWarnings = false
doLast {
val tree = fileTree(destinationDirectory)
tree.include("**/*.class")
tree.exclude("module-info.class")
tree.forEach {
RandomAccessFile(it, "rw").use { rf ->
rf.seek(7) // major version
rf.write(52) // java 8
rf.close()
}
}
}
}
tasks.javadoc {
options.encoding = "UTF-8"
(options as StandardJavadocDocletOptions).apply {
encoding = "UTF-8"
tags = listOf(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
addStringOption("Xdoclint:none", "-quiet")
}
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
tasks.withType<GenerateModuleMetadata>().configureEach {
enabled = false
}
configure<PublishingExtension> {
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
version = project.version.toString()
artifactId = project.name
from(components["java"])
pom {
name.set(project.name)
description.set("Public distribution of jdk.internal.jimage")
url.set("https://github.com/Glavo/jimage")
licenses {
license {
name.set("GPL v2 with Classpath Exception")
url.set("https://openjdk.java.net/legal/gplv2+ce.html")
}
}
developers {
developer {
id.set("glavo")
name.set("Glavo")
email.set("zjx001202@gmail.com")
}
}
scm {
url.set("https://github.com/Glavo/jimage")
}
}
}
}
}
var secretPropsFile = project.rootProject.file("gradle/maven-central-publish.properties")
if (!secretPropsFile.exists()) {
secretPropsFile = file(System.getProperty("user.home")).resolve(".gradle").resolve("maven-central-publish.properties")
}
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
val p = Properties()
secretPropsFile.reader().use {
p.load(it)
}
p.forEach { (name, value) ->
rootProject.ext[name.toString()] = value
}
}
listOf(
"sonatypeUsername" to "OSSRH_USERNAME",
"sonatypePassword" to "OSSRH_PASSWORD",
"sonatypeStagingProfileId" to "SONATYPE_STAGING_PROFILE_ID",
"signing.keyId" to "SIGNING_KEY_ID",
"signing.password" to "SIGNING_PASSWORD",
"signing.key" to "SIGNING_KEY"
).forEach { (p, e) ->
if (!rootProject.ext.has(p)) {
rootProject.ext[p] = System.getenv(e)
}
}
signing {
if (rootProject.ext.has("signing.key")) {
useInMemoryPgpKeys(
rootProject.ext["signing.keyId"].toString(),
rootProject.ext["signing.key"].toString(),
rootProject.ext["signing.password"].toString(),
)
}
sign(publishing.publications["maven"])
}
nexusPublishing {
repositories {
sonatype {
stagingProfileId.set(rootProject.ext["sonatypeStagingProfileId"].toString())
username.set(rootProject.ext["sonatypeUsername"].toString())
password.set(rootProject.ext["sonatypePassword"].toString())
}
}
}