forked from justsml/rest-api-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
188 lines (159 loc) · 5.77 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
181
182
183
184
185
186
187
188
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3"
classpath 'org.akhikhl.gretty:gretty:1.4.2'
}
}
apply plugin: 'io.codearte.nexus-staging'
allprojects {
apply plugin: 'maven'
apply plugin: 'java'
group = 'com.paypal.sdk'
version = '1.14.0'
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
mavenCentral()
}
// Currently disables doclint
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
// GLOBAL METHODS
def getRepositoryUsername() {
return hasProperty('sonatypeUsername') ? sonatypeUsername : ""
}
def getRepositoryPassword() {
return hasProperty('sonatypePassword') ? sonatypePassword : ""
}
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
// ## REST API SDK
project(':rest-api-sdk') {
apply plugin: 'signing'
apply from: 'lombok.gradle'
nexusStaging {
packageGroup = "com.paypal"
username = getRepositoryUsername()
password = getRepositoryPassword()
}
dependencies {
// General
compile 'com.google.code.gson:gson:2.2.2'
// Logging
testRuntime 'org.apache.logging.log4j:log4j-api:2.1'
testRuntime 'org.apache.logging.log4j:log4j-core:2.1'
testRuntime 'org.apache.logging.log4j:log4j-slf4j-impl:2.1'
compile 'org.slf4j:slf4j-api:1.7.21'
// Test
testCompile 'org.testng:testng:6.3.1'
testCompile "org.mockito:mockito-all:1.10.19"
testCompile 'org.powermock:powermock-api-mockito:1.7.3'
testCompile 'org.powermock:powermock-module-testng:1.7.3'
}
test {
// enable TestNG support (default is JUnit)
useTestNG {
suites 'src/test/resources/testng.xml'
// show standard out and standard error of the test JVM(s) on the console
testLogging.showStandardStreams = true
// This is to force the test task to execute everytime.
outputs.upToDateWhen { false }
}
}
// Run functional tests
task functionalTest(type: Test, dependsOn: 'test') {
useTestNG() {
suites 'src/test/resources/functional.xml'
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
// Using delomboked as a source
from sourceSets.main.ext.delombok
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
pom.project {
name 'rest-api-sdk'
groupId 'com.paypal.sdk'
artifactId 'rest-api-sdk'
packaging 'jar'
description 'PayPal SDK for integrating with the REST APIs'
url 'https://github.com/paypal/PayPal-Java-SDK.git'
scm {
url 'https://github.com/paypal/PayPal-Java-SDK.git'
connection 'scm:git:git://github.com/paypal/PayPal-Java-SDK.git'
}
licenses {
license {
name 'PayPal SDK License'
url 'https://github.com/paypal/PayPal-Java-SDK/blob/master/LICENSE.txt'
distribution 'repo'
}
}
developers {
developer {
id 'DL-PP-JAVA-SDK'
name 'DL-PP-JAVA-SDK'
email '[email protected]'
}
}
}
}
}
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask(tasks.uploadArchives) }
sign configurations.archives
}
}
// ## REST API SAMPLE PROJECT
project(':rest-api-sample') {
apply plugin: 'org.akhikhl.gretty'
// property name to override default Jetty port
final JETTY_RUN_HTTP_PORT = 'jettyRunHttpPort'
dependencies {
compile project(':rest-api-sdk')
compile 'javax.servlet:javax.servlet-api:3.1.0'
compile 'log4j:log4j:1.2.14'
compile 'org.apache.logging.log4j:log4j-api:2.1'
compile 'org.apache.logging.log4j:log4j-core:2.1'
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.1'
}
gretty.httpPort = Integer.valueOf(findPropertyOrDefault(JETTY_RUN_HTTP_PORT, project, 8080))
}
/**
* Try to find first significant value by {@code propertyName} in the next order:
* <ol>
* <li>If {@code propertyName} is supplied as a gradle runtime argument (<b>-D</b> option)</li>
* <li>If {@code propertyName} is set as a {@code project} property, for example in
* {@code gradle.properties} file of the project or in the gradle home directory</li>
* <li>otherwise fallback to {@code defaultValue}</li>
* </ol>
*
* @param propertyName name of the sought property
* @param project Gradle project in which try to find the value
* @param defaultValue value to use if neither runtime argument nor project property found
*
* @return String value from system, project property, or {@code defaultValue}
*/
static String findPropertyOrDefault(String propertyName, Project project, Object defaultValue) {
return System.getProperty(propertyName) ?:
project.findProperty(propertyName) ?:
defaultValue as String
}