This repository has been archived by the owner on Jan 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
207 lines (178 loc) · 6.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
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
207
/*
* Copyright (c) Octopus Deploy and contributors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* these files except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
buildscript {
dependencies {
//Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
}
}
import net.ltgt.gradle.errorprone.CheckSeverity
plugins {
id 'com.diffplug.spotless' version '5.14.2'
id 'com.github.ben-manes.versions' version '0.36.0'
id 'com.github.hierynomus.license' version '0.15.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'net.ltgt.errorprone' version '1.3.0'
id "org.openapi.generator" version '5.2.0'
id "com.jfrog.artifactory" version '4.18.0'
id 'com.adarshr.test-logger' version '3.0.0'
id 'maven-publish'
id 'java-library'
id 'distribution'
}
group = "com.octopus.wrappedapi"
defaultTasks 'build', 'checkLicenses', 'javadoc'
def buildAliases = ['dev': [
'spotlessApply',
'build',
'checkLicenses',
'javadoc'
]]
subprojects {
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.ltgt.errorprone'
apply from: "${rootDir}/gradle/versions.gradle"
apply from: "${rootDir}/gradle/check-licenses.gradle"
version = rootProject.version
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
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
}
repositories {
mavenLocal()
mavenCentral()
}
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) {
doFirst {
logger.info("From Parent")
}
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()
testLogging.showStandardStreams = false
testLogging {
exceptionFormat = 'full'
}
}
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()
}
if (!Arrays.asList("acceptance-tests", "examples").contains(project.name)) {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
publishing {
publications {
mavenJava(MavenPublication) {
groupId = "com.octopus"
version = "${project.version}"
from components.java
artifact sourcesJar
artifact javadocJar
versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}
}
}
}
}
}
tasks.getByName("compileJava").dependsOn project(":octopus-openapi-wrapper").getTasksByName("openApiGenerate", false)
jar { enabled = false }
// Do not allow publishing if all tests haven't passed
artifactoryPublish.dependsOn(test)
def artifactoryUsername = System.getenv('ARTIFACTORY_USERNAME')
def artifactoryPassword = System.getenv('ARTIFACTORY_PASSWORD')
artifactory {
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'maven'
username = "${artifactoryUsername}"
password = "${artifactoryPassword}"
maven = true
}
defaults {
publications('mavenJava')
}
}
}