forked from GoogleContainerTools/jib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
173 lines (147 loc) · 4.92 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
plugins {
id 'java-gradle-plugin'
id 'checkstyle'
id 'com.github.sherter.google-java-format' version '0.7.1'
// For local install
id 'maven'
// Error-prone checker
id 'net.ltgt.apt' version '0.13'
id 'net.ltgt.errorprone' version '0.0.13'
// Prepare release
id 'net.researchgate.release' version '2.6.0'
// Gradle Plugin Portal publish
id 'com.gradle.plugin-publish' version '0.9.10'
}
group 'com.google.cloud.tools'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
// Use jcenter for gradle plugin portal releases.
jcenter()
}
sourceSets {
main {
java.srcDir file('../jib-core/src/main/java')
resources.srcDir file('../jib-core/src/main/resources')
}
test {
java.srcDir file('../jib-core/src/test/java')
resources.srcDir file('../jib-core/src/test/resources')
}
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/integration-test/java')
srcDir file('../jib-core/src/integration-test/java')
}
resources {
srcDir file('src/integration-test/resources')
srcDir file('../jib-core/src/integration-test/resources')
}
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
dependencies {
// These are copied over from jib-core and are necessary for the jib-core sourcesets.
compile 'com.google.http-client:google-http-client:1.23.0'
compile 'org.apache.commons:commons-compress:1.15'
compile 'com.google.guava:guava:23.5-jre'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.2'
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'org.javassist:javassist:3.22.0-GA'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.12.0'
compile gradleApi()
// NullAway errorprone plugin
apt 'com.uber.nullaway:nullaway:0.4.2'
errorprone 'com.google.errorprone:error_prone_core:2.2.0'
}
task wrapper(type: Wrapper) {
gradleVersion = '4.6'
}
// Integration tests must be run explicitly
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
systemProperty '_JIB_DISABLE_USER_AGENT', true
}
integrationTest.dependsOn test
test {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}
// Adds NullAway errorprone checks.
tasks.withType(JavaCompile) {
if (!name.toLowerCase().contains("test")) {
options.compilerArgs += ["-Xep:NullAway:ERROR", "-XepOpt:NullAway:AnnotatedPackages=com.google.cloud.tools"]
}
}
// Fail build on javadoc warnings
tasks.withType(Javadoc) {
options.addBooleanOption('Xwerror', true)
}
tasks.withType(Test) {
reports.html.setDestination file("${reporting.baseDir}/${name}")
}
/* GOOGLE JAVA FORMAT */
googleJavaFormat {
toolVersion = '1.6'
}
check.dependsOn verifyGoogleJavaFormat
/* GOOGLE JAVA FORMAT */
/* CHECKSTYLE */
checkstyle {
toolVersion = "7.6.1"
// get the google_checks.xml file from the checkstyle jar and take out the java checks
def googleChecks = resources.text.fromArchiveEntry(configurations.checkstyle[0], 'google_checks.xml').asString()
def fileExtensionsBefore = '<property name="fileExtensions" value="java, properties, xml"/>'
def fileExtensionsAfter = '<property name="fileExtensions" value="properties, xml"/>'
def googleChecksNoJava = googleChecks.replace(fileExtensionsBefore, fileExtensionsAfter)
assert !googleChecks.equals(googleChecksNoJava)
config = resources.text.fromString(googleChecksNoJava)
maxErrors = 0
maxWarnings = 0
}
/* CHECKSTYLE */
/* JAR */
// Necessary for adding version information into the JAR.
jar {
manifest {
attributes 'Implementation-Title': project.name,
'Implementation-Version': version,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Built-Gradle': gradle.gradleVersion
}
}
/* JAR */
/* RELEASE */
// Prepare release
release {
tagTemplate = 'v$version-gradle'
git {
requireBranch = /^gradle_release_v\d+.*$/ //regex
}
}
// Gradle Plugin Portal releases
pluginBundle {
website = 'https://github.com/GoogleContainerTools/jib/'
vcsUrl = 'https://github.com/GoogleContainerTools/jib/'
plugins {
jibPlugin {
id = 'com.google.cloud.tools.jib'
displayName = 'Jib'
description = 'Containerize your Java application'
tags = ['google', 'java', 'containers', 'docker', 'kubernetes', 'microservices']
}
}
}
tasks.publishPlugins.dependsOn integrationTest
/* RELEASE */