File: build.gradle

package info (click to toggle)
opentest4j 1.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 300 kB
  • sloc: java: 562; xml: 295; makefile: 2
file content (211 lines) | stat: -rw-r--r-- 5,514 bytes parent folder | download | duplicates (4)
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
207
208
209
210
211
import java.text.SimpleDateFormat

plugins {
	id 'java'
	id 'osgi'
	id 'eclipse'
	id 'idea'
	id 'maven'
	id 'signing'
}

// https://reproducible-builds.org/docs/source-date-epoch/
String source_date_epoch = System.getenv("SOURCE_DATE_EPOCH");
if (source_date_epoch != null) {
   TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
}
Date buildTimeAndDate = source_date_epoch == null ?
    new Date() :
    new Date(1000 * Long.parseLong(source_date_epoch))
ext {
	buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
	buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
	builtByValue = project.hasProperty('builtBy') ? project.builtBy : project.defaultBuiltBy
}

description = 'Open Test Alliance for the JVM'
def moduleName = 'org.opentest4j'

repositories {
	mavenCentral()
}

compileJava {
	options.compilerArgs = ['--release', '8']
}

task compileModule(type: JavaCompile) {
	def moduleSrcDir = file('src/module/java')
	source(moduleSrcDir)
	destinationDir = file("$buildDir/classes/java/modules")
	classpath = compileJava.classpath
	inputs.property("moduleName", moduleName)
	inputs.property("moduleVersion", project.version)
	options.compilerArgs = [
			'--release', '9',
			'--module-version', project.version as String,
			'--module-source-path', moduleSrcDir.toString(),
			'--patch-module', "$moduleName=${sourceSets.main.allJava.srcDirs.join(':')}",
			'--module', moduleName
	]
}

dependencies {
	testCompile("junit:junit:${junit4Version}")
}

test {
	testLogging {
		exceptionFormat = 'full'
	}
}

def normalizeVersion = { versionLiteral ->
	try {
		(versionLiteral =~ /(\d+)\.(\d+)\.(\d+).*/)[0][1..3].join('.')
	} catch (e) {
		throw new GradleException("Version '$versionLiteral' does not match version pattern, e.g. 1.0.0-QUALIFIER", e)
	}
}

jar {
	manifest {
		attributes(
			'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(),
			'Built-By': builtByValue,
			'Build-Date': buildDate,
			'Build-Time': buildTime,
			'Specification-Title': project.name,
			'Specification-Version': normalizeVersion(project.version),
			'Specification-Vendor': 'opentest4j.org',
			'Implementation-Title': project.name,
			'Implementation-Version': project.version,
			'Implementation-Vendor': 'opentest4j.org'
		)
		license = 'The Apache License, Version 2.0'
		vendor = 'opentest4j.org'
	}
	from(files("${compileModule.destinationDir}/$moduleName").builtBy(compileModule)) {
		include('module-info.class')
	}
}

javadoc {
	options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
	options.author = true
	options.header = 'Open Test Alliance for the JVM'
	options.addStringOption('Xdoclint:html,syntax,reference', '-quiet')
	options.links 'https://docs.oracle.com/en/java/javase/11/docs/api/'
}

task sourcesJar(type: Jar, dependsOn: classes) {
	classifier = 'sources'
	from sourceSets.main.allSource
}

task javadocJar(type: Jar) {
	classifier = 'javadoc'
	from javadoc
}

artifacts {
	archives sourcesJar
	archives javadocJar
}

def signArtifacts = !project.version.contains('SNAPSHOT')

if (signArtifacts) {
	signing {
		sign configurations.archives
	}
}

uploadArchives {

	dependsOn check

	repositories {
		mavenDeployer {

			if (signArtifacts) {
				beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
			}

			def ossrhUsername = rootProject.hasProperty('ossrhUsername') ? rootProject.ossrhUsername : ''
			def ossrhPassword = rootProject.hasProperty('ossrhPassword') ? rootProject.ossrhPassword : ''

			repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
				authentication(userName: ossrhUsername, password: ossrhPassword)
			}

			snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
				authentication(userName: ossrhUsername, password: ossrhPassword)
			}

			pom.project {
				name "${project.group}:${project.name}"
				packaging 'jar'
				description "Open Test Alliance for the JVM"
				url 'https://github.com/ota4j-team/opentest4j'

				scm {
					connection 'scm:git:git://github.com/ota4j-team/opentest4j.git'
					developerConnection 'scm:git:git://github.com/ota4j-team/opentest4j.git'
					url 'https://github.com/ota4j-team/opentest4j'
				}

				licenses {
					license {
						name 'The Apache License, Version 2.0'
						url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
					}
				}

				developers {
					developer {
						id 'bechte'
						name 'Stefan Bechtold'
						email 'stefan.bechtold@me.com'
					}
					developer {
						id 'jlink'
						name 'Johannes Link'
						email 'business@johanneslink.net'
					}
					developer {
						id 'marcphilipp'
						name 'Marc Philipp'
						email 'mail@marcphilipp.de'
					}
					developer {
						id 'mmerdes'
						name 'Matthias Merdes'
						email 'Matthias.Merdes@heidelberg-mobil.com'
					}
					developer {
						id 'sbrannen'
						name 'Sam Brannen'
						email 'sam@sambrannen.com'
					}
				}
			}

			pom.whenConfigured { p ->
				p.dependencies = p.dependencies.findAll { dep -> dep.scope != 'test' }
			}
		}
	}
}

def docsVersion = project.version.contains('SNAPSHOT') ? 'snapshot' : project.version
def docsDir = new File(buildDir, 'ghpages-docs')

task createCurrentDocsFolder(type: Copy) {
	outputs.dir "${docsDir}/current"

	from "${docsDir}/${docsVersion}"
	into "${docsDir}/current"
}

createCurrentDocsFolder.onlyIf { project.hasProperty('replaceCurrentDocs') }