forked from redhat-developer/intellij-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
209 lines (184 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
buildscript {
ext.ideaVersion = ideaVersion
ext.kotlinVersion = kotlinVersion
ext.java_version = "17"
}
plugins {
id "org.jetbrains.intellij" version "${intellijPluginVersion}"
id "org.jetbrains.kotlin.jvm" version "${kotlinJvmPluginVersion}"
id "idea"
}
sourceSets {
integrationTest {
java.srcDir file('src/it/java')
resources.srcDir file('src/it/resources')
compileClasspath += sourceSets.main.output + configurations.runtimeClasspath
runtimeClasspath += output + compileClasspath
}
}
task integrationTest(type: Test) {
useJUnitPlatform()
description = 'Runs the integration tests.'
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
mustRunAfter test
}
tasks.withType(Test) {
environment 'GRADLE_RELEASE_REPOSITORY','https://services.gradle.org/distributions'
}
dependencies {
implementation(
"com.redhat.devtools.intellij:intellij-common:${intellijCommonVersion}",
"io.fabric8:kubernetes-client:${kubernetesClientVersion}",
"io.fabric8:kubernetes-model:${kubernetesClientVersion}",
"io.fabric8:kubernetes-model-common:${kubernetesClientVersion}",
"io.fabric8:openshift-client:${kubernetesClientVersion}",
"io.fabric8:kubernetes-httpclient-okhttp:${kubernetesClientVersion}",
"com.fasterxml.jackson.core:jackson-core:2.17.0", /* IC-2022.3 ships 2.16.0 */
"org.apache.commons:commons-lang3:3.12.0"
)
testImplementation(
"org.assertj:assertj-core:3.22.0",
"org.mockito:mockito-inline:4.5.1",
"com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0",
"org.jetbrains.kotlin:kotlin-test-junit:${kotlinVersion}"
)
integrationTestImplementation(
"com.redhat.devtools.intellij:intellij-common:${intellijCommonVersion}",
"com.redhat.devtools.intellij:intellij-common-ui-test-library:0.3.0",
"org.junit.jupiter:junit-jupiter-engine:5.8.2",
"org.junit.jupiter:junit-jupiter-api:5.8.2",
"org.junit.jupiter:junit-jupiter:5.8.2",
"org.junit.platform:junit-platform-launcher:1.9.3",
"com.google.code.gson:gson:2.8.9"
)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(java_version)
}
}
configurations {
implementation {
exclude group: "org.slf4j", module: "slf4j-api"
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib"
}
compileOptions {
sourceCompatibility = java_version
targetCompatibility = java_version
}
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}
test {
afterSuite { desc, result ->
if (!desc.parent)
println("${result.resultType} " +
"(${result.testCount} tests, " +
"${result.successfulTestCount} successes, " +
"${result.failedTestCount} failures, " +
"${result.skippedTestCount} skipped)")
}
}
intellij {
version = ideaVersion //for a full list of Jetbrains IDEA releases please see https://www.jetbrains.com/intellij-repository/releases
pluginName = "Kubernetes by Red Hat"
plugins = ["yaml"]
updateSinceUntilBuild = false
}
runIde {
}
patchPluginXml {
sinceBuild = "${sinceIdeaBuild}"
}
runPluginVerifier {
ideVersions = [ideaVersion]
}
publishPlugin {
token = jetBrainsToken
channels = [jetBrainsChannel]
}
runIdeForUiTests {
systemProperty "robot-server.port", System.getProperty("robot-server.port")
}
task generateSchemas {
final LATEST_VERSION_SCHEMA = "v1.24.2"
final SCHEMA_BASEURL = "https://raw.githubusercontent.com/kubernetes/kubernetes"
final SCHEMA_DIR = "src/main/resources/schemas/"
final K8S_DIR = "k8s.io"
doLast {
def schemaVersion = getProjectProperty("schemaVersion", LATEST_VERSION_SCHEMA)
def url = "${SCHEMA_BASEURL}/${schemaVersion}/api/openapi-spec/swagger.json"
def destination = "${SCHEMA_DIR}/${K8S_DIR}"
file("${projectDir}/${destination}").deleteDir()
println("Generating schemas ${schemaVersion} from openapi at ${url} \ninto ${SCHEMA_DIR}")
/*
* openapi2jsonschema -o src/main/resources/schemas/k8s.io --kubernetes --expanded --stand-alone --strict https://raw.githubusercontent.com/kubernetes/kubernetes/v1.20.5/api/openapi-spec/swagger.json
*/
def process = exec {
executable "openapi2jsonschema"
args "-o", destination, "--kubernetes", "--expanded", "--stand-alone", "--strict", url
}
if (isSuccess(process.exitValue)) {
createIndexFile("${projectDir}/${destination}")
} else {
println(colorize("yellow",
"""Generating schema failed. Please make sure that you have 'openapi2jsonschema' installed.
Make sure you have python installed and then run 'pip install openapi2jsonschema'.
Further info is available at https://pypi.org/project/openapi2jsonschema/"""))
}
}
ext.createIndexFile = { destination ->
def indexFilename = "index.txt"
def index = file("${destination}/${indexFilename}")
index.createNewFile()
files { file("${destination}").listFiles() }
.filter { file ->
!file.name.endsWith(indexFilename) ||
!file.name.endsWith("all.json") ||
!file.name.endsWith("_definitions.json") ||
!file.name.contains(".v")
}
.each { file ->
index.text += "${file.name}\n"
}
return index
}
ext.isSuccess = { exitValue ->
return exitValue == 0
}
}
private def getProjectProperty(String key, String defaultValue) {
def value = defaultValue
if (project.hasProperty(key)) {
schemaVersion = project.getProperty(key)
}
return value;
}
private def colorize(String color, String message) {
final colors = [
black: 30,
red: 31,
green: 32,
yellow: 33,
blue: 34,
magenta: 35,
cyan: 36,
white: 37
]
return new String((char) 27) + "[${colors[color]}m${message}" + new String((char) 27) + "[0m"
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://repository.jboss.org"
}
maven {
url "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies"
}
}
group "com.redhat.devtools.intellij"
version projectVersion