forked from GoogleCloudPlatform/cloud-code-intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
174 lines (154 loc) · 5.57 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
/*
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file 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 {
repositories {
maven { url "https://maven-central.storage.googleapis.com"}
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.13"
}
}
plugins {
id 'net.researchgate.release' version '2.6.0'
id "org.jetbrains.intellij" version "0.2.17" apply false
id "com.diffplug.gradle.spotless" version "3.6.0" apply false
}
subprojects {
repositories {
maven { url "https://maven-central.storage.googleapis.com"}
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
apply plugin: 'java'
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
group = 'com.google.cloud.tools.intellij'
task jarSources(type:Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
assemble.dependsOn jarSources
apply plugin: "net.ltgt.apt-idea"
apply plugin: "net.ltgt.errorprone"
apply plugin: 'org.jetbrains.intellij'
intellij {
type = ideaEdition
version = ideaVersion
updateSinceUntilBuild = false
downloadSources = true
intellijRepo = intellijRepoUrl
}
configurations.runtime {
resolutionStrategy {
// GCS brings in conflicting versions of this library so force the latest
force 'com.google.api:api-common:1.1.0'
failOnVersionConflict()
def provided = [["org.apache.httpcomponents", "httpclient"],
["com.google.guava", "guava"],
["com.google.api-client", "google-api-client"]]
eachDependency { DependencyResolveDetails dependency ->
if (provided.contains([dependency.requested.group, dependency.requested.name])) {
throw new GradleException('Dependency "' + dependency.requested.name +
'" should not be included in your build')
}
}
}
}
dependencies {
compile 'joda-time:joda-time:2.9.2'
testCompile ('com.google.truth:truth:0.36') {
exclude group: 'com.google.guava', module: 'guava'
}
testCompile ('com.google.truth.extensions:truth-java8-extension:0.36') {
exclude group: 'com.google.guava', module: 'guava'
}
testCompile 'junit:junit:4.+'
testCompile 'org.mockito:mockito-core:2.+'
}
apply plugin: 'jacoco'
jacocoTestReport {
reports {
xml.enabled true
}
}
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
java {
googleJavaFormat('1.5')
}
}
apply plugin: 'checkstyle'
configurations {
checkstyleConfig
}
def versions = [
checkstyle: '6.17',
]
dependencies {
checkstyleConfig ("com.puppycrawl.tools:checkstyle:${versions.checkstyle}") {
transitive = false
}
checkstyle "com.puppycrawl.tools:checkstyle:${versions.checkstyle}"
}
checkstyle {
configFile = rootProject.file('google_checks.xml')
showViolations true
sourceSets = [project.sourceSets.main]
}
// The checkstyle plugin does not provide a way to fail the build on warnings, and
// the google_checks.xml sets the severity level to "warning" for all violations. The
// following is the workaround.
tasks.withType(Checkstyle).each { checkstyleTask ->
checkstyleTask.doLast {
reports.all { report ->
if(report.name == "xml") {
def outputFile = report.destination
if (outputFile.exists() && outputFile.text.contains("<error ")) {
throw new GradleException("There were checkstyle warnings! For more info check $outputFile")
}
}
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
release {
buildTasks = ['doRelease']
// Do not change the tagTemplate value to double quotes or the version will be evaluated before
// the SNAPSHOT version is updated to the release version.
tagTemplate = 'v$version'
git {
requireBranch = /^release_v\d+.*$/
}
}
// We aren't building or doing anything interesting for release.
// We just update the version and generate the tag as CI will handle deployment.
task doRelease {
doLast {
println '===============================!!PLEASE READ!!=================================\n\n' +
'IMPORTANT: The release command will trigger the creation of a new release ' +
'in Github, the uploading of binaries to github, and the publishing of our plugin' +
'to the IntelliJ plugin repository.\n' +
'Hit CTRL+C to cancel.\n'
}
}