-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathbuild.gradle
More file actions
189 lines (165 loc) · 5.55 KB
/
build.gradle
File metadata and controls
189 lines (165 loc) · 5.55 KB
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
181
182
183
184
185
186
187
188
189
apply plugin: 'java'
apply plugin: 'java-library-distribution'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'io.github.goooler.shadow'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'
apply plugin: 'io.github.gradle-nexus.publish-plugin'
group 'co.omise'
version '5.3.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile).configureEach {
options.release = 8
}
repositories {
mavenCentral()
jcenter()
}
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.github.goooler.shadow:shadow-gradle-plugin:8.1.8"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.42.0'
classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882")
classpath "io.github.gradle-nexus:publish-plugin:2.0.0"
}
}
java {
withJavadocJar()
withSourcesJar()
}
distributions {
main {
archivesBaseName = 'omise-java'
}
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
jacoco {
toolVersion = "0.8.12"
}
jacocoTestReport {
reports {
xml.required = true
csv.required = true
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}
}
// REF: https://docs.gradle.org/current/userguide/publishing_maven.html
publishing {
publications {
release(MavenPublication) {
publication ->
artifact jar
artifactId = 'omise-java'
artifact sourcesJar
artifact javadocJar
pom {
name = 'Omise Java'
description = 'Java bindings for the Omise API'
packaging = 'jar'
url = 'https://www.omise.co'
scm {
connection = 'scm:git:git://git.github.com/omise/omise-java'
developerConnection = 'scm:git:git://git.github.com/omise/omise-java'
url = 'https://github.com/omise/omise-java'
}
licenses {
license {
name = 'The MIT License (MIT)'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'chakrit'
name = 'Omise'
email = 'support@omise.co'
}
}
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
if (it.group != null && (it.name != null || "unspecified" == it.name) && it.version != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
}
signing {
def signingKey = System.getenv("PGP_SIGNING_KEY")
def signingPwd = System.getenv("PGP_SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPwd)
sign publishing.publications.release
}
nexusPublishing {
repositories {
sonatype {
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
/**
* {@link Package#getImplementationVersion()} on IDE will alway return `null`
* because this method read data from `META-INF/MANIFEST.MF` that contain in `.jar`.
* If need to check it, you have to run directly to `.jar` will return correct value.
*
* Run `gradle shadowJar` and `unzip -p build/libs/omise-java-3.0.0-all.jar META-INF/MANIFEST.MF`
* will return attributes in manifest file.
*/
jar {
manifest {
attributes 'Implementation-Version': version
}
}
shadowJar {
// Include all manifest from jar to shadowJar
manifest {
inheritFrom jar.manifest
}
relocate 'okhttp3', 'co.omise.dependencies.okhttp3'
relocate 'okio', 'co.omise.dependencies.okio'
relocate 'com.fasterxml.jackson', 'co.omise.dependencies.com.fasterxml.jackson'
}
dependencies {
// persistence
implementation 'com.fasterxml.jackson.core:jackson-core:2.20.1'
// Java 8 data/time serializer
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1'
// networking
implementation 'com.squareup.okhttp3:okhttp:5.3.2'
// test
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.google.guava:guava:33.5.0-jre'
}
sonar {
properties {
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.organization', 'omise'
property 'sonar.projectName', 'omise-java'
property 'sonar.projectKey', 'omise_omise-java'
property 'sonar.coverage.jacoco.xmlReportPaths', "${project.buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"
property 'sonar.junit.reportPaths', "${project.buildDir}/test-results/testProductionDebugUnitTest"
}
}