-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
170 lines (134 loc) · 4.69 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
// .\gradlew clean build publishToSonatype closeAndReleaseSonatypeStagingRepository
// to see staged builds login and go to https://oss.sonatype.org/#stagingRepositories
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
}
dependencies {
// check maven central for the latest release
classpath("com.portingle:classpathHell:1.7.0")
}
}
plugins {
id("io.github.gradle-nexus.publish-plugin").version("1.0.0")
id 'java-library'
}
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
repositories {
mavenCentral()
}
group 'com.portingle'
version '1.2.0'
archivesBaseName = "slf4jtesting"
dependencies {
implementation 'org.slf4j:slf4j-api:1.7.32'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.13'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
}
java {
withJavadocJar()
withSourcesJar()
}
//https://sasbury.github.io/notes/2019/gradle_travis_sonatype.html
artifacts {
archives jar, javadocJar, sourcesJar
}
if (project.properties.containsKey("sonatypeUsername")) {
tasks {
signing {
sign configurations.archives
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = 'slf4jtesting'
packaging = 'jar'
description = 'SLF4JTesting is a library that provides facilities for log testing that are simple to use and optimised for use in environments with concurrent test execution and/or where console logging is desired.'
url = 'https://github.com/portingle/slf4jtesting'
scm {
connection = 'scm:[email protected]:portingle/slf4jtesting.git'
developerConnection = 'scm:[email protected]:portingle/slf4jtesting.git'
url = 'scm:[email protected]:portingle/slf4jtesting.git'
}
licenses {
license {
name = 'The MIT Licence (MIT)'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'Johnlon'
name = 'John Lonergan'
}
}
}
// create the signed artifacts
project.tasks.signArchives.signatureFiles.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
if (matcher.find()) {
classifier = matcher.group(1)
} else {
classifier = null
}
extension = 'jar.asc'
}
}
pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
}
}
}
}
nexusPublishing {
repositories {
// relies on sonatypeUsername/sonatypePassword being defined in "{gradle_home}/gradle.properties"
sonatype()
}
}
}
/* Avoid this issue when publishing by NOT sending a geadle "module" file
Missing Signature: '/com/portingle/slf4jtesting/1.2.0/slf4jtesting-1.2.0.module.asc' does not exist for 'slf4jtesting-1.2.0.module'
Would be better to figure out how to sign it.
*/
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
test {
testLogging.showStandardStreams = true
testLogging {
exceptionFormat = 'full'
events "started", "passed", "skipped", "failed"
}
}
apply plugin: 'com.portingle.classpathHell'
classpathHell {
suppressExactDupes = true
configurationsToScan = [ configurations.testRuntimeClasspath ]
resourceExclusions = [
"LICENSE.txt",
"^META-INF/.*",
".*/\$"
]
}
build.dependsOn(['checkClasspath'])