-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbuild.gradle
133 lines (112 loc) · 4.04 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
plugins {
id "io.franzbecker.gradle-lombok" version "4.0.0"
}
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
dependencies {
implementation("org.slf4j:slf4j-api:1.7.30")
implementation("com.fasterxml.jackson.core:jackson-core:2.12.0")
implementation("com.fasterxml.jackson.core:jackson-databind:2.12.0")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.0")
implementation("com.madrobot:madrobotbeans:0.1")
implementation("io.github.classgraph:classgraph:4.8.90")
implementation("com.squareup.okhttp3:okhttp:4.9.0")
compileOnly("org.thymeleaf:thymeleaf:3.0.11.RELEASE")
testImplementation("org.thymeleaf:thymeleaf:3.0.11.RELEASE")
testImplementation("junit:junit:4.13.1")
testImplementation("org.apache.httpcomponents:httpclient:4.5.13:tests")
testImplementation("org.apache.httpcomponents:httpclient:4.5.13")
}
lombok {
version = "1.18.16"
sha256 = ""
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
}
import io.franzbecker.gradle.lombok.task.DelombokTask
import java.nio.file.Files
import java.nio.file.Paths
task delombok(type: DelombokTask, dependsOn: compileJava) {
ext.outputDir = file("$buildDir/delombok")
outputs.dir(outputDir)
sourceSets.main.java.srcDirs.each { dir ->
inputs.dir(dir)
args(dir, "-d", outputDir)
}
}
javadoc {
dependsOn delombok
source = delombok.outputDir
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
def packageSummary = 'Kontent.ai Delivery SDK client.'
def packageDescription = 'Java client around Kontent.ai Delivery REST API.'
def repoArtifactId = 'delivery-sdk'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
artifactId = repoArtifactId
groupId = repoGroupId
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom.withXml {
def root = asNode()
root.appendNode('description', packageDescription)
root.appendNode('name', packageSummary)
root.appendNode('url', 'https://kontent.ai')
root.children().last() + pomConfig
}
}
}
repositories {
maven {
if (project.getVersion().toString().endsWith('SNAPSHOT')) {
url "https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
}
credentials {
username nexusUsername
password nexusPassword
}
}
}
}
signing {
// https://docs.gradle.org/current/userguide/signing_plugin.html#using_in_memory_ascii_armored_openpgp_subkeys
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign publishing.publications.mavenJava
}
task createTrackingHeaderProperties(dependsOn: processResources) {
doLast {
def propertiesPath = "$buildDir/resources/main/kontent/ai/delivery"
Files.createDirectories(Paths.get(propertiesPath))
new File("$propertiesPath/version.properties").withWriter { w ->
Properties p = new Properties()
p['version'] = version.toString()
p['package-id'] = repoGroupId.toString() + ':' + repoArtifactId.toString()
p['repository-host'] = repositoryHost.toString()
p.store w, null
}
}
}
classes {
dependsOn createTrackingHeaderProperties
}