-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
145 lines (131 loc) · 4.66 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
import java.time.Instant
import java.time.temporal.ChronoUnit
plugins {
id 'java'
id 'maven-publish'
id 'signing'
id "com.tdder.gradle.build-number"
}
ext.pomName = "JUnit Teardown extension"
description = "JUnit Jupiter extension. Provides Automated Teardown mechanism."
repositories {
mavenCentral()
}
dependencies {
implementation platform(libs.junit.bom)
implementation libs.junit.jupiter.api
testImplementation libs.hamcrest
testImplementation libs.junit.platform.launcher
testRuntimeOnly libs.junit.jupiter.engine
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
withSourcesJar()
withJavadocJar()
}
tasks.withType(SourceTask)
.findAll { t -> t.hasProperty('options') }
.findAll { t -> t.options.hasProperty('encoding') }
.each { t -> t.options.encoding = 'UTF-8' }
tasks.withType(Javadoc).configureEach {
options {
charSet 'UTF-8'
locale 'en'
}
}
tasks.withType(Test).configureEach {
useJUnitPlatform() {
excludeTags("used-from-test")
}
}
tasks.withType(Jar).configureEach {
dependsOn buildNumber
from(rootDir) {
include "LICENSE"
into "META-INF"
}
doFirst {
manifest {
attributes["Archiver-Version"] = "Gradle ${gradle.gradleVersion}"
attributes["Created-By"] = "Gradle"
attributes["Built-By"] = "${System.getProperty("user.name")}"
attributes["Build-Jdk"] = "${System.getProperty("java.version")} (${System.getProperty("java.vm.vendor")} ${System.getProperty("java.vm.version")})"
attributes["Specification-Title"] = project.name
attributes["Specification-Version"] = project.version
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
attributes["Implementation-Vendor"] = project.group
attributes["Built-Timestamp"] = (rootProject.ext.builtTimestamp as Instant).truncatedTo(ChronoUnit.SECONDS).toString()
attributes["SCM-Revision"] = rootProject.ext.buildNumberValue
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = project.ext.pomName
description = project.description
url = "https://github.com/manhole/junit-teardown-extension"
inceptionYear = "2023"
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
developers {
developer {
id = "manhole"
name = "HONMA Hirotaka"
email = "manholex@gmail.com"
}
}
scm {
connection = "https://github.com/manhole/junit-teardown-extension.git"
developerConnection = "https://github.com/manhole/junit-teardown-extension.git"
url = "https://github.com/manhole/junit-teardown-extension"
}
issueManagement {
system = "GitHub"
url = "https://github.com/manhole/junit-teardown-extension/issues"
}
}
}
}
repositories {
maven {
name "ProjectLocal"
url project.layout.buildDirectory.dir('maven-repo').get().asFile.toURI().toURL()
}
maven {
name = "sonatype"
if (project.version.endsWith("-SNAPSHOT")) {
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
}
credentials {
username = project.findProperty("ossrh.username")
password = project.findProperty("ossrh.password")
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
// https://qiita.com/cypher256/items/f3db6bba86692c3c7733
// @see org.gradle.api.tasks.wrapper.Wrapper, org.gradle.util.DistributionLocator
tasks.withType(Wrapper).configureEach {
distributionType = Wrapper.DistributionType.ALL
doFirst {
def versionService = new URL('https://services.gradle.org/versions/current')
gradleVersion = new groovy.json.JsonSlurper().parseText(versionService.text).version
println "gradleVersion: ${gradleVersion}"
}
}