forked from davidmc24/gradle-avro-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
175 lines (154 loc) · 5.43 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
buildscript {
dependencies {
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.13.1"
}
}
plugins {
id "groovy"
id "checkstyle"
id "codenarc"
id "idea"
id "maven"
id "com.gradle.plugin-publish" version "0.9.4"
}
repositories {
jcenter()
}
def compileAvroVersion = "1.8.1"
dependencies {
compile gradleApi()
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"
}
sourceCompatibility = 1.6
version = "0.9.1-SNAPSHOT"
group = "com.commercehub.gradle.plugin"
pluginBundle {
website = "https://github.com/commercehub-oss/gradle-avro-plugin"
vcsUrl = "https://github.com/commercehub-oss/gradle-avro-plugin"
description = "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."
tags = ["serialization", "avro"]
plugins {
avro {
id = "com.commercehub.gradle.plugin.avro"
displayName = "Avro Plugin"
}
avroBase {
id = "com.commercehub.gradle.plugin.avro-base"
displayName = "Avro Base Plugin"
}
}
mavenCoordinates {
groupId = "com.commercehub.gradle.plugin"
artifactId = "gradle-avro-plugin"
}
}
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 << {
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 = "0.24.1"
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"
}
tasks.create("testRecentVersionCompatibility") {
description = "Tests cross-compatibility of the plugin with recent versions of Avro and Gradle"
}
test {
systemProperties = [
avroVersion: compileAvroVersion,
gradleVersion: gradle.gradleVersion,
]
}
def avroVersions = ["1.8.0", "1.8.1"]
def gradleVersions = ["2.0", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10", "2.11", "2.12", "2.13", "2.14", "2.14.1"]
if (org.gradle.api.JavaVersion.current().isJava7Compatible()) {
gradleVersions.addAll("3.0", "3.1", "3.2", "3.2.1", "3.3")
}
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"
}
if (org.gradle.api.JavaVersion.current().isJava7Compatible()) {
apply plugin: "com.github.hierynomus.license"
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
}
}