forked from telekom-mms/cmcc-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
171 lines (143 loc) · 5.38 KB
/
Copy pathbuild.gradle
File metadata and controls
171 lines (143 loc) · 5.38 KB
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
import io.fabric8.crdv2.generator.CRDGenerator
import io.fabric8.crd.generator.collector.CustomResourceCollector
import java.nio.file.Files
import org.gradle.api.internal.tasks.JvmConstants;
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("io.fabric8:crd-generator-api-v2:7.1.0")
classpath("io.fabric8:crd-generator-collector:7.1.0")
}
}
plugins {
id 'org.springframework.boot' version '3.4.4'
id 'io.spring.dependency-management' version '1.1.7'
id 'java'
id 'com.google.cloud.tools.jib' version '3.4.5'
}
group = 'com.tsystemsmms'
version = '0.0.1-SNAPSHOT'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
}
compileJava {
options.deprecation = true
}
dependencies {
// developmentOnly 'org.springframework.boot:spring-boot-devtools:3.2.0'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.javaoperatorsdk:operator-framework-spring-boot-starter:6.0.1'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.80'
// required for the fabric8 k8s client to grok k3d certificates
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
// Lombok + CRD Generation
compileOnly 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
compileOnly 'io.fabric8:crd-generator-apt:7.1.0'
// Test
testImplementation 'org.hamcrest:hamcrest'
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.12.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'io.javaoperatorsdk:operator-framework-spring-boot-starter-test:6.0.1'
}
tasks.named('test') {
useJUnitPlatform()
}
def crdToCopy = copySpec {
from('build/resources/main/coremediacontentclouds.cmcc.tsystemsmms.com-v1.yml') {
rename '.*', 'cmcc-crd.yaml'
}
}
// The following is a workaround for the missing gradle plugin in CRD generator V2
// see https://github.com/fabric8io/kubernetes-client/blob/main/doc/CRD-generator.md
// and https://github.com/fabric8io/kubernetes-client/blob/main/crd-generator/gradle/README.md
tasks.register("generateCrds") {
description = "Generate CRDs from compiled custom resource classes"
group = "crd"
var sourceSet = project.sourceSets["main"]
var compileClasspathElements = sourceSet.compileClasspath.collect { it.absolutePath }
var outputClassesDirs = sourceSet.output.classesDirs
var classpathElements = outputClassesDirs.collect { it.absolutePath }
classpathElements.addAll(compileClasspathElements)
var filesToScan = (outputClassesDirs.toList()).flatten()
var outputDir = sourceSet.output.resourcesDir
doLast {
Files.createDirectories(outputDir.toPath())
var collector = new CustomResourceCollector()
.withParentClassLoader(Thread.currentThread().contextClassLoader)
.withClasspathElements(classpathElements)
.withFilesToScan(filesToScan)
var crdGenerator = new CRDGenerator()
.customResourceClasses(collector.findCustomResourceClasses())
.inOutputDir(outputDir)
var crdGenerationInfo = crdGenerator.detailedGenerate()
crdGenerationInfo.getCRDDetailsPerNameAndVersion()
.entrySet()
.forEach {
println("Generated CRD $it.key:")
it.value.entrySet().forEach { println(" $it.key -> ${it.value.filePath}") }
}
}
}
tasks.register("copyCrd") {
['k8s', 'charts/cmcc-operator/crds', 'src/test/resources'].each { dest ->
copy {
with crdToCopy
into dest
}
}
}
tasks.named(JvmConstants.CLASSES_TASK_NAME) {
finalizedBy("generateCrds")
}
copyCrd.dependsOn(generateCrds)
build.finalizedBy(copyCrd)
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
jib {
from {
image = "docker.io/library/amazoncorretto:17"
platforms {
platform {
architecture = 'amd64'
os = 'linux'
}
platform {
architecture = 'arm64'
os = 'linux'
}
}
}
to {}
container {
labels = [
"org.opencontainers.image.description" : "A Kubernetes operator that installs and configures a CoreMedia Content Cloud installation in a cluster.",
"org.opencontainers.image.documentation": "https://github.com/Telekom-MMS/cmcc-operator",
"org.opencontainers.image.licenses" : "Apache-2.0",
"org.opencontainers.image.source" : "https://github.com/Telekom-MMS/cmcc-operator",
"org.opencontainers.image.title" : "CoreMedia Content Cloud Kubernetes Operator",
"org.opencontainers.image.url" : "https://github.com/Telekom-MMS/cmcc-operator",
"org.opencontainers.image.vendor" : "T-Systems Multimedia Solutions GmbH"
]
user = 1000
}
}