-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
181 lines (152 loc) · 4.63 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
plugins {
id 'java-library'
id 'maven-publish'
id 'io.github.gradle-nexus.publish-plugin' version "1.3.0"
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'signing'
}
import org.apache.tools.ant.filters.ReplaceTokens
def versionObj = new Version(major: 2, minor: 7, revision: 0)
group 'io.github.kodehawa'
version "$versionObj"
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation 'com.fasterxml.jackson.core:jackson-core:2.16.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'org.slf4j:slf4j-api:2.0.9'
testImplementation 'ch.qos.logback:logback-classic:1.4.14'
testImplementation 'junit:junit:4.13.2'
}
task sourcesForRelease(type: Copy) {
from 'src/main/java'
into 'build/filteredSrc'
}
//Task for the versioning system
task prepareSource(type: Copy) {
from 'src/main/java'
into 'build/prepared-src'
filter(ReplaceTokens, tokens: [
version: versionObj.toString()
])
dependsOn clean
}
prepareSource.dependsOn clean
// Maven Central requirement
java {
withJavadocJar()
withSourcesJar()
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
javadoc {
failOnError = true
options.memberLevel = JavadocMemberLevel.PUBLIC
options.author()
options.encoding = 'UTF-8'
}
compileJava {
source = sourcesForRelease.destinationDir
classpath = sourceSets.main.compileClasspath
options.encoding = 'UTF-8'
dependsOn sourcesForRelease
}
jar {
archiveBaseName = project.name
manifest {
attributes 'Implementation-Version': archiveVersion
}
}
shadowJar {
classifier("withDependencies")
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = System.getenv("SONATYPE_USER")
password = System.getenv("SONATYPE_PASS")
}
}
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/kodehawa/imageboard-api")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
from(components.java)
}
mavenJava(MavenPublication) {
from(components.java)
pom {
name.set("imageboard-api")
description.set(" Simple asynchronous Java API wrapper around the most popular danbooru-compatible (Konachan, Yande.re, Danbooru, Gelbooru, etc) booru APIs. ")
url.set("https://github.com/Kodehawa/imageboard-api")
licenses {
license {
name.set("Apache-2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set("1")
name.set("Kodehawa")
email.set("contact@mantaro.site")
}
}
scm {
connection.set("scm:git:git://github.com/Kodehawa/imageboard-api.git")
developerConnection.set("scm:git:ssh://github.com/Kodehawa/imageboard-api.git")
url.set("https://github.com/Kodehawa/imageboard-api")
}
}
}
}
}
signing {
def signingKey = base64Decode(System.getenv("SIGN_KEY"))
def signingPassword = System.getenv("SIGN_PW")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
static def base64Decode(encodedString){
if(encodedString != null) {
byte[] decoded = encodedString.decodeBase64()
String decode = new String(decoded)
return decode
}
return null;
}
build {
dependsOn clean
dependsOn jar
dependsOn javadocJar
dependsOn sourcesJar
dependsOn shadowJar
dependsOn test
jar.mustRunAfter clean
javadocJar.mustRunAfter jar
sourcesJar.mustRunAfter javadocJar
shadowJar.mustRunAfter sourcesJar
}
class Version {
String major, minor, revision
String toString() {
"${major}.${minor}" + (revision == "0" ? "" : ".${revision}")
}
}