forked from davidmc24/gradle-avro-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
214 lines (189 loc) · 6.91 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
208
209
210
211
212
213
214
plugins {
id "groovy"
id "checkstyle"
id "codenarc"
id "idea"
id "maven-publish"
id "java-gradle-plugin"
id "com.jfrog.bintray" version "1.7.3"
id "com.github.hierynomus.license" version "0.14.0"
}
repositories {
jcenter()
}
def compileAvroVersion = "1.8.2"
dependencies {
compile localGroovy()
compile "org.apache.avro:avro-compiler:${compileAvroVersion}"
testCompile("org.spockframework:spock-core:1.0-groovy-2.4") {
exclude module: "groovy-all"
}
testCompile gradleTestKit()
}
tasks.withType(AbstractCompile) {
options.encoding = "UTF-8"
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all" << "-Xlint:-options" << "-Werror"
}
sourceCompatibility = 1.7
version = "0.14.2-SNAPSHOT"
group = "com.commercehub.gradle.plugin"
task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
classifier "sources"
extension "jar"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier "javadoc"
extension "jar"
}
publishing {
publications {
mainMaven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
}
bintray {
// dryRun = true
// publish = true
user = project.hasProperty("bintrayUserName") ? bintrayUserName : null
key = project.hasProperty("bintrayApiKey") ? bintrayApiKey : null
publications = ["mainMaven", "avroBasePluginMarkerMaven", "avroPluginMarkerMaven"]
pkg {
repo = "main"
name = project.name
userOrg = "commercehub-oss"
licenses = ["Apache-2.0"]
desc = "A Gradle plugin to allow easily performing Java code generation for Apache Avro. It supports JSON schema declaration files, JSON protocol declaration files, and Avro IDL files."
websiteUrl = "https://github.com/commercehub-oss/gradle-avro-plugin"
issueTrackerUrl = 'https://github.com/commercehub-oss/gradle-avro-plugin/issues'
vcsUrl = "https://github.com/commercehub-oss/gradle-avro-plugin"
labels = ["serialization", "avro"]
githubRepo = "commercehub-oss/gradle-avro-plugin"
version {
name = project.version
vcsTag = project.version
}
}
}
bintrayUpload.dependsOn build, { generatePomFileForAvroBasePluginMarkerMavenPublication }, { generatePomFileForAvroPluginMarkerMavenPublication }
gradlePlugin {
plugins {
avro {
id = "com.commercehub.gradle.plugin.avro"
implementationClass = "com.commercehub.gradle.plugin.avro.AvroPlugin"
}
avroBase {
id = "com.commercehub.gradle.plugin.avro-base"
implementationClass = "com.commercehub.gradle.plugin.avro.AvroBasePlugin"
}
}
}
idea {
project {
vcs = "Git"
ipr {
withXml { provider ->
def node = provider.asNode()
node.append(new XmlParser().parseText("""
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="LINE_SEPARATOR" value=" "/>
<option name="RIGHT_MARGIN" value="140"/>
</value>
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true"/>
</component>
""".stripIndent()))
}
}
}
}
// Write the plugin's classpath to a file to share with the tests
task createClasspathManifest {
def outputDir = file("$buildDir/$name")
inputs.files sourceSets.main.runtimeClasspath
outputs.dir outputDir
doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n")
}
}
// Add the classpath file to the test runtime classpath
dependencies {
testRuntime files(createClasspathManifest)
}
checkstyle {
toolVersion = "6.1.1" // Last version of checkstyle to support Java 6
}
// Nasty workaround for https://issues.gradle.org/browse/GRADLE-2888
def checkstyleWarningsFile = "build/reports/checkstyle/main.xml"
checkstyleMain.doLast {
File warningsFile = file(checkstyleWarningsFile)
if (warningsFile.exists() && warningsFile.text.contains("<error ")) {
throw new GradleException("There were checkstyle warnings! For more info check ${warningsFile}")
}
}
codenarc {
toolVersion = "1.0"
config = project.resources.text.fromFile("config/codenarc/codenarc.groovy")
}
tasks.create("testVersionCompatibility") {
description = "Tests cross-compatibility of the plugin with different versions of Avro and Gradle."
group = "Verification"
}
tasks.create("testRecentVersionCompatibility") {
description = "Tests cross-compatibility of the plugin with recent versions of Avro and Gradle."
group = "Verification"
}
test {
systemProperties = [
avroVersion: compileAvroVersion,
gradleVersion: gradle.gradleVersion,
]
}
def avroVersions = ["1.8.2"]
def gradleVersions = []
if (!org.gradle.api.JavaVersion.current().isJava9Compatible()) { // Gradle 4.2.1 is the first version that supports modern Java 9, as per https://discuss.gradle.org/t/could-not-determine-java-version-from-9-0-1/24457
gradleVersions.addAll("3.0", "3.1", "3.2", "3.2.1", "3.3", "3.4", "3.4.1", "3.5", "3.5.1", "4.0", "4.0.1", "4.0.2", "4.1", "4.2")
}
gradleVersions.addAll("4.2.1", "4.3", "4.3.1", "4.4", "4.4.1", "4.5", "4.5.1", "4.6")
// Support for running Gradle on Java 7 is deprecated and will be removed in Gradle 5, as per https://docs.gradle.org/4.2.1/release-notes.html
avroVersions.each { def avroVersion ->
gradleVersions.each { def gradleVersion ->
def newTask = tasks.create(name: "testAvro${avroVersion}Gradle${gradleVersion}", type: Test) {
description = "Test cross-compatibility of the plugin with Avro ${avroVersion} and Gradle ${gradleVersion}"
systemProperties = [
avroVersion: avroVersion,
gradleVersion: gradleVersion,
]
reports {
html.destination = file("$buildDir/reports/tests-${avroVersion}-${gradleVersion}")
junitXml.destination = file("$buildDir/reports/tests-${avroVersion}-${gradleVersion}")
}
}
testVersionCompatibility.dependsOn newTask
if (gradleVersions.indexOf(gradleVersion) >= gradleVersions.size() - 5) {
testRecentVersionCompatibility.dependsOn newTask
}
}
}
tasks.withType(Test) {
jvmArgs "-Xss320k"
minHeapSize "120m"
maxHeapSize "280m"
}
license {
header = file("gradle/DEFAULT_LICENSE_NOTICE")
skipExistingHeaders = true
mapping("avdl", "JAVADOC_STYLE")
excludes(["**/*.avsc", "**/*.avpr"]) // JSON doesn't allow comments
exclude("**/record.vm") // Existing header in different style
// dryRun = true
}