-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
143 lines (130 loc) · 4.09 KB
/
build.gradle
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
plugins {
id 'java-library'
id 'idea'
id 'signing'
id 'maven-publish'
}
group projGroupId
version = projVersion
repositories {
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/central' }
// temporary maven repositories
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/releases' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
compileOnly "org.jetbrains:annotations:24.0.1"
}
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
}
}
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
}
archivesBaseName = projArtifactId
withJavadocJar()
withSourcesJar()
}
javadoc {
failOnError = false
options.encoding 'UTF-8'
options.charSet 'UTF-8'
options.author true
options.locale 'en_US'
options.links "https://docs.oracle.com/en/java/javase/$sourceCompatibility/docs/api/"
options.windowTitle "$projName $projVersion Javadoc"
}
jar {
manifestContentCharset 'utf-8'
metadataCharset 'utf-8'
from 'LICENSE'
manifest.attributes(
'Specification-Title': projName,
'Specification-Vendor': orgName,
'Specification-Version': '0',
'Implementation-Title': projName,
'Implementation-Vendor': orgName,
'Implementation-Version': archiveVersion
)
}
sourcesJar {
dependsOn classes
archiveClassifier.set 'sources'
from sourceSets.main.allSource, 'LICENSE'
}
javadocJar {
dependsOn javadoc
archiveClassifier.set 'javadoc'
from javadoc, 'LICENSE'
}
artifacts {
archives javadocJar, sourcesJar
}
publishing.publications {
register('mavenJava', MavenPublication) {
groupId = projGroupId
artifactId = projArtifactId
version = projVersion
description = projDesc
from components.java
pom {
name = projName
description = projDesc
url.set "https://github.com/$projVcs"
licenses {
license {
name.set 'MIT'
url.set "https://raw.githubusercontent.com/$projVcs/$projBranch/LICENSE"
}
}
organization {
name = orgName
url = orgUrl
}
developers {
String[] prop = (project.developers as String).split(',')
for (String s : prop) {
String[] dev = s.split(':', 3)
developer {
id.set dev[0]
name.set dev[1]
email.set dev[2]
}
}
}
scm {
connection.set "scm:git:https://github.com/${projVcs}.git"
developerConnection.set "scm:git:https://github.com/${projVcs}.git"
url.set "https://github.com/${projVcs}.git"
}
}
}
}
// You have to add 'OSSRH_USERNAME', 'OSSRH_PASSWORD', 'signing.keyId',
// 'signing.password' and 'signing.secretKeyRingFile' to
// GRADLE_USER_HOME/gradle.properties
publishing.repositories {
maven {
name = "OSSRH"
credentials {
username = project.findProperty("OSSRH_USERNAME") ?: "null"
password = project.findProperty("OSSRH_PASSWORD") ?: "null"
}
url = version.endsWith('-SNAPSHOT')
? "https://s01.oss.sonatype.org/content/repositories/snapshots/"
: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
}
}
signing {
if (!version.endsWith('-SNAPSHOT') && Boolean.parseBoolean(System.getProperty("gpg.signing", "true")))
sign publishing.publications.mavenJava
}
idea.module.inheritOutputDirs = true