forked from jruyi/thrift-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle
110 lines (95 loc) · 3.44 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
/*
* Based on jruyi/thrift-gradle-plugin/../build.gradle
* Modified 2023 LINE Corporation
*
* Copyright 2023 LINE Corporation
*
* LINE Corporation licenses this file to you 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:
*
* https://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.
*/
plugins {
id 'checkstyle'
id 'com.gradle.plugin-publish' version '1.2.0'
id 'java-gradle-plugin'
}
group = 'com.linecorp.thrift-gradle-plugin'
version = System.getenv("PLUGIN_VERSION") ?: "0.6.2-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation "org.assertj:assertj-core:3.24.2"
testImplementation "org.junit.jupiter:junit-jupiter:5.9.3"
testImplementation "org.mockito:mockito-junit-jupiter:5.4.0"
testImplementation "org.mockito.kotlin:mockito-kotlin:5.0.0"
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
def checkstyleConfigDir = rootProject.file('settings/checkstyle/')
checkstyle {
configFile = new File(checkstyleConfigDir, 'checkstyle.xml')
configProperties = ['checkstyleConfigDir': "$checkstyleConfigDir"]
reportsDir = project.file('build/checkstyle')
toolVersion = '10.12.1'
}
tasks.withType(Checkstyle).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
// Test on multiple LTS versions to check if any API is removed in newer JDK.
def javaVersions = [11, 17]
javaVersions.each { version ->
def testOnSpecificVersion = tasks.register("testsOn$version", Test) {
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(version)
}
}
tasks.named('check').configure {
dependsOn(testOnSpecificVersion)
}
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
def setupPluginUpload = tasks.register("setupPluginUpload") {
doLast {
def key = System.getenv("GRADLE_PUBLISH_KEY")
def secret = System.getenv("GRADLE_PUBLISH_SECRET")
if (key == null || secret == null) {
throw new RuntimeException("PublishKey or PublishSecret are not defined from environment variables")
}
System.setProperty("gradle.publish.key", key)
System.setProperty("gradle.publish.secret", secret)
}
}
tasks.named("publishPlugins").configure {
dependsOn setupPluginUpload
}
gradlePlugin {
website = 'https://github.com/line/thrift-gradle-plugin'
vcsUrl = 'https://github.com/line/thrift-gradle-plugin'
plugins {
thriftGradlePlugin {
id = 'com.linecorp.thrift-gradle-plugin'
implementationClass = 'com.linecorp.thrift.plugin.ThriftPlugin'
displayName = 'Gradle plugin for compiling Thrift IDL files'
description = 'A gradle plugin for compiling Thrift IDL files using thrift compiler'
tags.set(['thrift', 'code-generation'])
}
}
}