-
Notifications
You must be signed in to change notification settings - Fork 273
/
build.gradle
207 lines (181 loc) · 6.63 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
plugins {
id 'codenarc'
id 'idea'
id 'eclipse'
id 'groovy'
id 'maven'
id 'maven-publish'
id 'signing'
id "com.github.ben-manes.versions" version "0.12.0"
id "com.gradle.plugin-publish" version "0.11.0"
id "org.gradle.kotlin.kotlin-dsl" version "1.4.9"
}
group = 'com.google.protobuf'
version = '0.9.5-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
repositories {
gradlePluginPortal()
google()
}
configurations {
// Test projects may have runtime dependencies such as the kotlin plugin
testProjectRuntime
}
dependencies {
compileOnly "com.android.tools.build:gradle:4.1.0"
compileOnly "org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.7.22"
implementation 'com.google.gradle:osdetector-gradle-plugin:1.7.3'
testImplementation 'junit:junit:4.12'
testImplementation('org.spockframework:spock-core:1.0-groovy-2.4') {
exclude module: 'groovy-all'
}
testImplementation 'commons-io:commons-io:2.5'
}
java {
withJavadocJar()
withSourcesJar()
}
tasks.register('groovydocJar', Jar) {
dependsOn groovydoc
classifier = 'groovydoc'
from groovydoc.destinationDir
}
codenarc {
toolVersion = "1.4"
if (System.env.CI == 'true') {
// Normally html output is more user friendly,
// but we want a console printable file for CI logs
reportFormat = 'text'
}
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
File testRepoUrl = layout.buildDirectory.dir('testRepo').get().asFile
publishing {
publications {
pluginMaven(MavenPublication) {
artifact groovydocJar
pom {
name = project.name
description = "Gradle build plugin to handle Protocol Buffers automated code generation and compilation"
url = "https://github.com/google/protobuf-gradle-plugin"
licenses {
license {
name = "BSD 3-Clause"
url = "http://opensource.org/licenses/BSD-3-Clause"
}
}
developers {
developer {
id = "zhangkun83"
name = "Kun Zhang"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/google/protobuf-gradle-plugin.git"
developerConnection = "scm:git:[email protected]:google/protobuf-gradle-plugin.git"
url = "https://github.com/google/protobuf-gradle-plugin"
}
}
}
}
repositories {
maven {
url = testRepoUrl
name = "test"
}
maven {
String releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
String snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotUrl : releaseUrl
credentials {
if (rootProject.hasProperty("ossrhUsername") && rootProject.hasProperty("ossrhPassword")) {
username = rootProject.ossrhUsername
password = rootProject.ossrhPassword
}
}
}
}
}
// The Gradle plugin portal doesn't allow signature files.
if (!gradle.startParameter.taskNames.intersect(['publishPlugins'])) {
signing {
required { isReleaseVersion }
sign publishing.publications.pluginMaven
}
}
gradlePlugin {
plugins {
protobufPlugin {
id = "com.google.protobuf"
implementationClass = "com.google.protobuf.gradle.ProtobufPlugin"
description = "The Protobuf plugin provides protobuf compilation to your project."
}
}
}
pluginBundle {
website = 'https://github.com/google/protobuf-gradle-plugin'
vcsUrl = 'https://github.com/google/protobuf-gradle-plugin'
description = 'The Protobuf plugin provides protobuf compilation to your project.'
plugins {
protobufPlugin {
id = 'com.google.protobuf'
displayName = 'Protobuf Plugin for Gradle'
tags = ['protobuf', 'protocol-buffers', 'protoc']
}
}
}
// Required in order to support building a mixed kotlin/groovy project. With out this,
// we would get a cyclic dependency error, since both compileKotlin and compileGroovy
// depend on compileJava.
// See https://github.com/gradle/gradle/pull/11513 and https://discuss.gradle.org/t/kotlin-groovy-and-java-compilation/14903/10
tasks.named('compileGroovy') {
classpath = sourceSets.main.compileClasspath
}
tasks.named('compileKotlin') {
compileKotlin.classpath += files(compileGroovy.destinationDirectory)
}
tasks.named('test') {
inputs.files fileTree("$projectDir/testProject")
inputs.files fileTree("$projectDir/testProjectAndroid")
inputs.files fileTree("$projectDir/testProjectAndroidBare")
inputs.files fileTree("$projectDir/testProjectAndroidBase")
inputs.files fileTree("$projectDir/testProjectAndroidDependentBase")
inputs.files fileTree("$projectDir/testProjectAndroidKotlin")
inputs.files fileTree("$projectDir/testProjectAndroidKotlinDsl")
inputs.files fileTree("$projectDir/testProjectAndroidLibrary")
inputs.files fileTree("$projectDir/testProjectBase")
inputs.files fileTree("$projectDir/testProjectBuildTimeProto")
inputs.files fileTree("$projectDir/testProjectConfigureJavaExecutable")
inputs.files fileTree("$projectDir/testProjectCustomProtoDir")
inputs.files fileTree("$projectDir/testProjectDependent")
inputs.files fileTree("$projectDir/testProjectDependentApp")
inputs.files fileTree("$projectDir/testProjectJavaAndKotlin")
inputs.files fileTree("$projectDir/testProjectJavaLibrary")
inputs.files fileTree("$projectDir/testProjectKotlin")
inputs.files fileTree("$projectDir/testProjectKotlinDslBase")
inputs.files fileTree("$projectDir/testProjectKotlinDslCopySpec")
inputs.files fileTree("$projectDir/testProjectLite")
testLogging {
events = ["standard_out", "standard_error", "started", "passed", "failed", "skipped"]
}
// Hack for gradle runner test classloader.
//
// GradleRunner.withPluginClasspath method loads a plugin under test to the classloader_1.
// When the test project is executed, it will load plugins to a project classloader_2.
// The classloader_1 doesn't known about classloader_2. When the plugin under test will use classes which
// was loaded to project with the classloader_2, ClassNotFoundException will be thrown.
//
// To fix this problem, don't use the withPluginClasspath method.
// Provide a plugin under test with the maven local repository.
systemProperty("protobufPluginVersion", version)
systemProperty("testRepoUrl", testRepoUrl.absolutePath)
dependsOn(
"publishProtobufPluginPluginMarkerMavenPublicationToTestRepository",
"publishPluginMavenPublicationToTestRepository"
)
}