-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.gradle
206 lines (166 loc) · 5.6 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
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
import net.ltgt.gradle.errorprone.CheckSeverity
plugins {
id 'com.diffplug.spotless' version '5.15.0'
id 'com.github.ben-manes.versions' version '0.36.0'
id 'com.github.hierynomus.license' version '0.16.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'net.ltgt.errorprone' version '2.0.0'
id 'maven-publish'
id 'java'
id 'distribution'
}
group = "com.octopus.teamcity"
defaultTasks 'build', 'checkLicenses', 'javadoc'
ext {
teamcity_version = 10.0
teamcity_distribution = "C:\\TeamCity"
build_timestamp_format = "yyyyMMddHHmm"
}
allprojects {
apply plugin: 'java-library'
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.ltgt.errorprone'
apply from: "${rootDir}/gradle/versions.gradle"
apply from: "${rootDir}/gradle/check-licenses.gradle"
// Provided configuration allows compile-time only dependencies to NOT
// be included in the final distributions.
configurations {
provided
}
// this ensures SNAPSHOT versions are always pulled from maven repo (rather than using past
// cached version)
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
sourceSets {
main { compileClasspath += configurations.provided }
}
version = rootProject.version
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set("javadoc")
from javadoc.destinationDir
}
sourceCompatibility = 8
targetCompatibility = 8
repositories {
mavenCentral()
maven { url "https://download.jetbrains.com/teamcity-repository" }
maven { url "https://packages.octopushq.com/artifactory/maven" }
}
dependencies {
errorprone "com.google.errorprone:error_prone_core"
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
}
apply plugin: 'com.diffplug.spotless'
spotless {
java {
// This path needs to be relative to each project
target '**/src/*/java/**/*.java'
removeUnusedImports()
googleJavaFormat('1.7')
importOrder 'com.octopus', 'java', ''
trimTrailingWhitespace()
endWithNewline()
}
groovyGradle {
target '*.gradle'
greclipse().configFile(rootProject.file('gradle/formatter.properties'))
endWithNewline()
}
// Below this line are currently only license header tasks
format 'groovy', { target '**/src/*/grovy/**/*.groovy' }
}
tasks.withType(JavaCompile) {
options.compilerArgs += [
'-Xlint:unchecked',
'-Xlint:cast',
'-Xlint:rawtypes',
'-Xlint:overloads',
'-Xlint:divzero',
'-Xlint:finally',
'-Xlint:static',
'-Werror',
]
options.errorprone {
excludedPaths = '.*generated/*.*'
// Our equals need to be symmetric, this checker doesn't respect that.
check('EqualsGetClass', CheckSeverity.OFF)
// We like to use futures with no return values.
check('FutureReturnValueIgnored', CheckSeverity.OFF)
// We use the JSR-305 annotations instead of the Google annotations.
check('ImmutableEnumChecker', CheckSeverity.OFF)
// This is a style check instead of an error-prone pattern.
check('UnnecessaryParentheses', CheckSeverity.OFF)
// This check is broken in Java 12. See https://github.com/google/error-prone/issues/1257
if (JavaVersion.current() == JavaVersion.VERSION_12) {
check('Finally', CheckSeverity.OFF)
}
// This check is broken after Java 12. See https://github.com/google/error-prone/issues/1352
if (JavaVersion.current() > JavaVersion.VERSION_12) {
check('TypeParameterUnusedInFormals', CheckSeverity.OFF)
}
check('FieldCanBeFinal', CheckSeverity.WARN)
check('InsecureCryptoUsage', CheckSeverity.WARN)
check('WildcardImport', CheckSeverity.WARN)
}
options.encoding = 'UTF-8'
}
test {
useJUnitPlatform()
}
tasks.withType(Test) {
// If GRADLE_MAX_TEST_FORKS is not set, use half the available processors
maxParallelForks = (System.getenv('GRADLE_MAX_TEST_FORKS') ?: (Runtime.runtime.availableProcessors().intdiv(2) ?: 1)).toInteger()
}
}
apply plugin: "distribution"
distZip {
archiveFileName = "Octopus.TeamCity." + rootProject.version + ".zip"
}
distributions {
main {
contents {
from file("teamcity-plugin.xml"), {
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens:[version: rootProject.version])
}
into('agent/') {
//from tasks.findByPath(":octopus-agent:distZip").outputs.files
from tasks.findByPath(":octopus-agent:distZip")
}
into('server/') {
from tasks.findByPath(":octopus-server:installDist")
}
into '/'
}
}
}
task packageName {
doFirst {
println tasks.findByPath(":distZip").outputs.files.singleFile
}
}
task deployLocal(type: Copy) {
def teamCityDataDir = System.getenv("TEAMCITY_DATA_DIR") ?: System.getenv("HOME") + "/.BuildServer"
into(teamCityDataDir + "/plugins")
from tasks.findByPath(":distZip")
}
task updateJsp(type: Copy) {
outputs.upToDateWhen { false }
def teamCityDataDir = System.getenv("TEAMCITY_INSTALL_DIR")
def subPath = "/webapps/ROOT/plugins/Octopus.TeamCity"
def fullPath = teamCityDataDir + subPath
doFirst() {
if(teamCityDataDir == null) {
throw new GradleException("TEAMCITY_INSTALL_DIR env var not set, unable to copy jsps")
}
logger.info("Copying files to ${fullPath}")
}
outputs.upToDateWhen { false }
into(fullPath)
from fileTree("octopus-server/src/main/resources/buildServerResources")
}