-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
170 lines (155 loc) · 5.03 KB
/
build.gradle
File metadata and controls
170 lines (155 loc) · 5.03 KB
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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
id 'groovy'
id 'java-library'
id 'maven-publish'
id 'signing'
id 'se.alipsa.nexus-release-plugin' version '2.0.1'
id "com.github.ben-manes.versions" version "0.53.0"
}
group = 'se.alipsa.groovy'
version = '1.1.1-SNAPSHOT'
description = 'A Groovy Dependency Resolver'
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
withSourcesJar()
withJavadocJar()
}
repositories {
if (version.contains('SNAPSHOT')) {
mavenLocal()
}
mavenCentral()
}
dependencies {
def groovyVersion = "5.0.4"
implementation('se.alipsa:maven-utils:1.4.0')
implementation("org.slf4j:slf4j-api:2.0.17")
runtimeOnly("org.tinylog:slf4j-tinylog:2.7.0")
runtimeOnly("org.tinylog:tinylog-impl:2.7.0")
compileOnly("org.apache.groovy:groovy:$groovyVersion")
testImplementation("org.apache.groovy:groovy:$groovyVersion")
testImplementation(platform('org.junit:junit-bom:6.0.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation('org.junit.platform:junit-platform-launcher')
testImplementation("org.apache.groovy:groovy-jsr223:$groovyVersion")
}
test {
useJUnitPlatform {
if (!project.hasProperty("includeIntegrationTests")) {
excludeTags "integration"
}
}
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.FAILED,
//TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
showStandardStreams = true
// set options for log level DEBUG and INFO
debug {
events TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
exceptionFormat = TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}
tasks.register("integrationTest", Test) {
description = "Runs integration tests that require network and dependency downloads"
group = "verification"
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
def testMavenRepoDir = layout.buildDirectory.dir("integration-test-m2-repo").get().asFile
systemProperty "maven.repo.local", testMavenRepoDir.absolutePath
useJUnitPlatform {
includeTags "integration"
}
doFirst {
delete(testMavenRepoDir)
testMavenRepoDir.mkdirs()
}
shouldRunAfter test
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifacts = [jar, javadocJar, sourcesJar]
pom {
name = 'Dynamic Dependency Resolver'
description = "${project.description}"
url = "https://github.com/Alipsa/dependency-resolver"
licenses {
license {
name = 'MIT License'
url = 'https://raw.githubusercontent.com/Alipsa/dependency-resolver/main/LICENSE'
}
}
developers {
developer {
id = 'perNyfelt'
name = 'Per Nyfelt'
}
}
scm {
url = 'https://github.com/Alipsa/dependency-resolver/tree/main'
connection = 'scm:git:https://github.com/Alipsa/dependency-resolver.git'
developerConnection = 'scm:git:https://github.com/Alipsa/dependency-resolver.git'
}
}
}
}
}
signing {
if (project.properties['signing.keyId'] != null) {
project.logger.lifecycle("Signing artifacts...")
sign publishing.publications.maven
} else {
project.logger.lifecycle("signing.keyId is not defined, skipping signing of artifacts...")
}
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
// https://github.com/ben-manes/gradle-versions-plugin
tasks.named("dependencyUpdates").configure {
gradleReleaseChannel = "current"
resolutionStrategy {
componentSelection {
all {
if (isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)) {
reject('Release candidate')
}
}
}
}
}
nexusReleasePlugin {
userName = project.ext.properties.sonatypeUsername
password = project.ext.properties.sonatypePassword
mavenPublication = publishing.publications.maven
}