forked from google/protobuf-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
224 lines (192 loc) · 6.75 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
215
216
217
218
219
220
221
222
223
224
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" } // Mirrors jcenter() and mavenCentral()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath "com.gradle.publish:plugin-publish-plugin:0.11.0"
classpath "com.github.ben-manes:gradle-versions-plugin:0.12.0"
}
}
plugins {
id "org.gradle.kotlin.kotlin-dsl" version "1.4.9"
}
println """\
Welcome to Gradle $gradle.gradleVersion - http://www.gradle.org
Gradle home is set to: $gradle.gradleHomeDir
Gradle user directory is set to: $gradle.gradleUserHomeDir
Base directory: $projectDir
Running script ${relativePath(buildFile)}
"""
apply plugin: 'codenarc'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.gradle.plugin-publish'
apply plugin: 'com.github.ben-manes.versions'
group = 'com.google.protobuf'
version = '0.9.2-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://repo.gradle.org/gradle/libs-releases-local/" }
google()
// Needed for resolving 'kotlinx-metadata-jvm'
// A transitive dependency of gradle Kotlin DSL
maven { url "https://kotlin.bintray.com/kotlinx/" }
}
configurations {
// Test projects may have runtime dependencies such as the kotlin plugin
testProjectRuntime
}
dependencies {
compileOnly "com.android.tools.build:gradle:4.1.0"
implementation 'com.google.gradle:osdetector-gradle-plugin:1.7.1'
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'
}
test.inputs.files fileTree("$projectDir/testProject")
test.inputs.files fileTree("$projectDir/testProjectLite")
test.inputs.files fileTree("$projectDir/testProjectCustomProtoDir")
test.inputs.files fileTree("$projectDir/testProjectDependent")
test.inputs.files fileTree("$projectDir/testProjectAndroid")
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task groovydocJar(type: Jar, dependsOn:groovydoc) {
classifier = 'groovydoc'
from groovydoc.destinationDir
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
codenarc {
toolVersion = "1.4"
}
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 sourcesJar
artifact groovydocJar
artifact javadocJar
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']
}
}
}
if (System.env.CI == 'true') {
// Normally html output is more user friendly,
// but we want a console printable file for CI logs
project.codenarc.reportFormat = 'text'
}
// 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') {
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"
)
}