-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
179 lines (154 loc) · 5.17 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
plugins {
id 'java-gradle-plugin'
id 'jacoco'
id 'signing'
id 'com.gradle.plugin-publish' version '1.2.2'
id 'org.sonarqube' version '5.1.0.4882'
id 'pl.droidsonroids.jacoco.testkit' version '1.0.12'
id 'com.github.ben-manes.versions' version '0.51.0'
id 'org.sonatype.gradle.plugins.scan' version '2.8.3'
}
repositories {
mavenCentral()
}
apply from: 'gradle/workAroundJacocoGradleTestKitIssueOnWindows.gradle'
version = '3.0.1'
group = 'org.itsallcode'
ext {
gradlePluginId = 'org.itsallcode.openfasttrace'
oftVersion = '4.1.0'
junitVersion = '5.11.0'
if (project.hasProperty('oftSourceDir')) {
oftSourceDir = file(project.oftSourceDir)
useOftSources = oftSourceDir.exists()
if (!useOftSources) {
logger.warn "OFT source directory $oftSourceDir does not exist"
}
} else {
oftSourceDir = 'oft-dir-not-found'
useOftSources = false
}
}
def compiledClassesFolders(File dir) {
def classDirs = new HashSet()
file(dir).eachFileRecurse(groovy.io.FileType.DIRECTORIES) {
String normalizedName = it.toString().replace('\\', '/')
if (normalizedName.endsWith('/target/classes') && !normalizedName.contains('testutil')) {
classDirs.add(it)
}
}
return classDirs
}
dependencies {
if (useOftSources) {
logger.lifecycle "Including OpenFastTrace sources from Maven target dir $oftSourceDir"
implementation files(compiledClassesFolders(oftSourceDir)) {
builtBy "compileOft"
}
} else {
implementation "org.itsallcode.openfasttrace:openfasttrace-api:$oftVersion"
implementation "org.itsallcode.openfasttrace:openfasttrace-core:$oftVersion"
implementation "org.itsallcode.openfasttrace:openfasttrace-exporter-specobject:$oftVersion"
runtimeOnly "org.itsallcode.openfasttrace:openfasttrace:$oftVersion"
}
}
def getJavaVersion = {
return project.hasProperty('javaVersion') ? project.getProperty('javaVersion') : 17
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(getJavaVersion())
}
modularity.inferModulePath = false
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:all'
options.compilerArgs << '-Werror'
options.encoding = 'UTF-8'
}
javadoc {
failOnError = true
options.addBooleanOption('html5', true)
//options.addStringOption('Xwerror', '-quiet')
}
task compileOft(type: Exec) {
workingDir oftSourceDir
def mavenCommand = 'mvn'
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
mavenCommand = 'mvn.cmd'
}
commandLine mavenCommand, '-T', '1C', 'package', '-DskipTests', '-Dmaven.test.skip=true',
'-Dmaven.site.skip=true', '-Dmaven.javadoc.skip=true', '-Dmaven.source.skip=true', '-Dossindex.skip=true',
'-Djava.version=' + getJavaVersion()
}
clean {
def exampleProjects = rootProject.file('example-projects').listFiles()
def propertyFiles = exampleProjects.collect { new File(it, 'gradle.properties') }
propertyFiles.each { delete it }
}
gradlePlugin {
website = 'https://github.com/itsallcode/openfasttrace-gradle'
vcsUrl = 'https://github.com/itsallcode/openfasttrace-gradle.git'
plugins {
openFastTracePlugin {
id = gradlePluginId
implementationClass = 'org.itsallcode.openfasttrace.gradle.OpenFastTracePlugin'
displayName = 'OpenFastTrace requirements tracing plugin'
description = 'Gradle plugin for tracing requirements using OpenFastTrace'
tags.addAll(['requirementstracing', 'requirements', 'tracing', 'reqtracing', 'openfasttrace', 'oft'])
}
}
}
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
}
testing {
suites {
test {
useJUnitJupiter(junitVersion)
dependencies {
implementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
implementation "org.hamcrest:hamcrest-core:3.0"
implementation "com.jparams:to-string-verifier:1.4.8"
}
}
}
}
test.onlyIf { rootProject.name == 'openfasttrace-gradle' }
jacocoTestReport {
dependsOn test
reports {
xml.required = true
}
}
test {
finalizedBy jacocoTestReport
}
project.tasks["sonar"].dependsOn jacocoTestReport
sonarqube {
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.organization", "itsallcode"
}
}
publishPlugins.dependsOn check
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)
}
tasks.named("dependencyUpdates").configure {
gradleReleaseChannel = "current"
rejectVersionIf {
isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)
}
}
ossIndexAudit {
allConfigurations = false
useCache = true
excludeVulnerabilityIds = []
printBanner = false
}
rootProject.tasks["build"].dependsOn(tasks["ossIndexAudit"])