-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
206 lines (176 loc) · 6.29 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//file:noinspection GroovyAssignabilityCheck
import java.text.SimpleDateFormat
apply plugin: 'wrapper'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'jacoco'
apply plugin: 'java-library'
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
version = '3.0-SNAPSHOT'
group = 'com.needhamsoftware'
ext.isSnapshot = version.endsWith('-SNAPSHOT')
ext.isLocal = version.endsWith('-LOCAL')
ext.isRelease = !(isLocal || isSnapshot)
ext.releaseRepo = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
ext.snapshotRepo = 'https://oss.sonatype.org/content/repositories/snapshots'
ext.testingRepo = 'file:///tmp/myRepo/'
ext.uploadRepo = isRelease ? releaseRepo : (isSnapshot ? snapshotRepo : testingRepo)
repositories {
mavenCentral()
}
// A little idiot proofing...
task(checkUploadDest) {
doLast {
if (gradle.taskGraph.hasTask(':uploadRelease')) {
if (isSnapshot) {
ant.fail('Release should not have suffix of -SNAPSHOT')
}
if (isLocal) {
ant.fail('Release should not have suffix of -LOCAL')
}
} else if (gradle.taskGraph.hasTask(':uploadSnapshot')) {
if (!isSnapshot) {
ant.fail('Snapshot should have suffix of SNAPSHOT')
}
} else {
if (!isLocal) {
ant.fail('This is not a local version, ' +
'please use either uploadRelease or uploadSnapshot, or change the version suffix to -LOCAL')
}
}
}
}
ext.isLocalVersion = !version.endsWith("LOCAL")
publishing {
publications {
maven(MavenPublication) {
groupId = group
artifactId = 'easier-mock'
version = version
from components.java
}
}
}
// Uncomment this to do sonatype uploads (fails on all other machines looking for gpg key otherwise
//
//signing {
// required { !isLocalVersion && gradle.taskGraph.hasTask('uploadArchives') }
// sign configurations.archives
//}
//
//uploadArchives {
// it.dependsOn checkUploadDest
// repositories {
// mavenDeployer {
// beforeDeployment { deployment -> signing.signPom(deployment) }
// repository(url: project.uploadRepo) {
// authentication(userName: sonatypeUsername, password: sonatypePassword)
// }
// pom.project {
// parent {
// groupId 'org.sonatype.oss'
// artifactId 'oss-parent'
// //noinspection GroovyAssignabilityCheck
// version '7'
// }
// name 'easier-mock'
// description 'An add on to EasyMock to make EasyMock even Easier'
// url 'https://github.com/fsparv/EasierMock'
// licenses {
// license {
// name 'The Apache Software License, Version 2.0'
// url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
// distribution 'repo'
// }
// }
// scm {
// connection 'scm:git:[email protected]:fsparv/EasierMock.git'
// developerConnection 'scm:git:[email protected]:fsparv/EasierMock.git'
// url '[email protected]:fsparv/EasierMock.git'
// }
// developers {
// developer {
// id 'nsoft'
// name 'Patrick Heck'
// email '[email protected]'
// }
// }
// }
// pom.withXml { root ->
// def children = root.asNode().children()
// def versionIndex = children.indexOf(children.find { it.name().localPart == 'version' })
// // Stuff that sonatype wants... there may be a way to make these appear automatically but...
// // http://issues.gradle.org/browse/GRADLE-1285
// children.add(versionIndex + 1, new Node(null, 'packaging', 'jar'))
// }
// }
// }
//}
dependencies {
implementation 'net.bytebuddy:byte-buddy:1.12.6'
api 'org.easymock:easymock:4.3' // Not technically ABI but always should be present to use this lib in test code.
implementation 'net.bytebuddy:byte-buddy:1.12.6'
implementation 'junit:junit-dep:4.11' // req as implementation by BeanTester only.
testImplementation 'org.testng:testng:7.4.0'
testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
testImplementation 'org.powermock:powermock-api-easymock:2.0.9'
testImplementation 'com.google.guava:guava:31.0.1-jre'
}
jacocoTestReport.dependsOn += test
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
additionalSourceDirs.from = files(sourceSets.main.allJava.srcDirs)
}
task sourcesJar(type: Jar) {
archiveClassifier.set 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
archiveClassifier.set 'javadoc'
from javadoc
}
artifacts {
archives sourcesJar
archives javadocJar
}
jar {
from 'LICENSE.txt'
rename '(LICENSE.txt)', 'META-INF/$1'
}
sourcesJar {
from 'LICENSE.txt'
rename '(LICENSE.txt)', 'META-INF/$1'
}
javadocJar {
from 'LICENSE.txt'
rename '(LICENSE.txt)', 'META-INF/$1'
}
jar.manifest.attributes getManifestAttributes()
sourcesJar.manifest.attributes getManifestAttributes()
javadocJar.manifest.attributes getManifestAttributes()
@SuppressWarnings("GroovyAssignabilityCheck")
def getManifestAttributes() {
Map<String, String> attrs = new LinkedHashMap<>()
attrs.put('Implementation-Title', project.name)
attrs.put('Implementation-Version', version)
attrs.put('Build-Timestamp', getTimestamp())
attrs.put('Build-Jdk', getJdk())
attrs.put('Build-Tool', GradleVersion.current())
return attrs
}
static def getTimestamp() {
def dt = new Date()
def df = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss', Locale.ENGLISH)
df.format(dt)
}
static def getJdk() {
"${System.getProperty('java.version')} (${System.getProperty('java.vm.vendor')} ${System.getProperty('java.vm.version')})"
}
task testng(type: Test)
testng.useTestNG()
test.dependsOn 'testng'