forked from checkout/checkout-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
166 lines (147 loc) · 5.32 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
plugins {
id 'java-library'
id 'signing'
id 'de.marcphilipp.nexus-publish' version '0.4.0'
id 'io.codearte.nexus-staging' version '0.21.2'
id 'com.gradle.build-scan' version '2.3'
id 'io.freefair.lombok' version '3.8.1'
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
implementation 'com.google.guava:guava:30.0-jre'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.slf4j:slf4j-api:1.7.26'
implementation 'org.apache.httpcomponents:httpclient:4.5.12'
implementation 'org.apache.commons:commons-lang3:3.11'
implementation 'javax.validation:validation-api:2.0.1.Final'
implementation 'org.apache.httpcomponents:httpmime:4.5.13'
testImplementation(platform('org.junit:junit-bom:5.7.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation("org.junit.jupiter:junit-jupiter-params")
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-inline:3.11.2'
testImplementation 'org.mockito:mockito-junit-jupiter:3.11.2'
testImplementation 'org.slf4j:slf4j-simple:1.7.26'
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
test {
environment "CHECKOUT_PUBLIC_KEY", System.getenv("CHECKOUT_PUBLIC_KEY")
environment "CHECKOUT_SECRET_KEY", System.getenv("CHECKOUT_SECRET_KEY")
environment "CHECKOUT_FOUR_PUBLIC_KEY", System.getenv("CHECKOUT_FOUR_PUBLIC_KEY")
environment "CHECKOUT_FOUR_SECRET_KEY", System.getenv("CHECKOUT_FOUR_SECRET_KEY")
systemProperty "org.slf4j.simpleLogger.defaultLogLevel", "INFO"
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
showStandardStreams = true
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
artifact sourcesJar
artifact javadocJar
pom {
name = project_name
packaging = 'jar'
description = project_description
url = project_url
scm {
connection = project_scm
developerConnection = project_scm
url = project_url
}
licenses {
license {
name = project_license_slug
url = project_license_url
}
}
developers {
developer {
id = project_developer
name = project_developer
}
}
}
}
}
}
nexusStaging {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
stagingProfileId = "57cde3b2433ed7"
packageGroup = "com.checkout"
numberOfRetries = 100
delayBetweenRetriesInMillis = 5000
}
nexusPublishing {
connectTimeout = Duration.ofMinutes(15)
clientTimeout = Duration.ofMinutes(15)
repositories {
sonatype {
packageGroup = rootProject.nexusStaging.packageGroup
stagingProfileId = rootProject.nexusStaging.stagingProfileId
username = rootProject.nexusStaging.username
password = rootProject.nexusStaging.password
}
}
}
signing {
sign publishing.publications.mavenJava
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
jar {
manifest {
attributes 'Implementation-Title': 'checkout-sdk-java',
'Implementation-Version': archiveVersion.get()
}
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign }) {
allprojects {
ext."signing.keyId" = System.getenv('GPG_KEY_ID')
ext."signing.secretKeyRingFile" = System.getenv('GPG_KEY_LOCATION')
ext."signing.password" = System.getenv('GPG_PASSPHRASE')
}
}
// Do not sign archives by default (a local build without gpg keyring should succeed)
if (taskGraph.allTasks.any { it.name == 'build' || it.name == 'assemble' }) {
tasks.findAll {
it.name == 'signArchives' || it.name == 'signDocsJar' || it.name == 'signTestJar'
}.each { task ->
task.enabled = false
}
}
if (taskGraph.hasTask(test)
&& (System.getenv('CHECKOUT_PUBLIC_KEY') == null || System.getenv('CHECKOUT_SECRET_KEY') == null)
&& (System.getenv('CHECKOUT_FOUR_PUBLIC_KEY') == null || System.getenv('CHECKOUT_FOUR_SECRET_KEY') == null)) {
// @TODO: This just blocks testing locally without proper credentials. But it would be better to have different
// tests that anyone can run with mocks or just unit tests and a different test phase run optionally for proper
// integration tests.
// throw new GradleException("Please ensure both the CHECKOUT_PUBLIC_KEY and CHECKOUT_SECRET_KEY environment variables are set in order to run the tests against the Checkout Sandbox.")
}
}