-
Notifications
You must be signed in to change notification settings - Fork 883
Expand file tree
/
Copy pathmain.dang
More file actions
208 lines (187 loc) · 4.83 KB
/
main.dang
File metadata and controls
208 lines (187 loc) · 4.83 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
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
pub description = "Toolchain to develop the Dagger Java SDK (experimental)"
type JavaSdkDev {
"""
Base image to create a dev container for the Java SDK
"""
let mavenImage: Container! {
workspace.directory("sdk/java/runtime/images/maven").dockerBuild
}
"""
Workspace with all the files needed to develop the SDK.
"""
pub workspace: Directory! @defaultPath(path: "/") @ignorePatterns(patterns: [
"*",
"!sdk/java/dagger-codegen-maven-plugin/",
"!sdk/java/dagger-java-annotation-processor/",
"!sdk/java/dagger-java-sdk/",
"!sdk/java/dagger-java-samples/pom.xml",
"!sdk/java/runtime/template/",
"!sdk/java/runtime/images/",
"!sdk/java/LICENSE",
"!sdk/java/README.md",
"!sdk/java/pom.xml",
"sdk/java/**/src/test",
"sdk/java/**/target",
])
"""
The path of the SDK in the workspace
"""
pub sourcePath: String! = "sdk/java"
"""
Workspace path in the dev container
"""
let workspacePath: String! = "/src"
"""
Build a container to run the java toolchain
"""
let devContainer: Container! {
daggerEngine
.installClient(
mavenImage
.withDirectory(workspacePath, workspace)
.withWorkdir(workspacePath + "/" + sourcePath),
)
}
pub name: String! {
"java"
}
pub source: Directory! {
workspace.directory(sourcePath)
}
"""
Test the Java SDK
"""
pub test: Void @check {
devContainer
.withExec(["mvn", "clean", "verify", "-Ddaggerengine.version=local"])
.sync
null
}
"""
Lint the Java SDK
"""
pub lint: Void @check {
devContainer
.withExec(["mvn", "fmt:check"])
.sync
null
}
"""
Format the Java SDK
"""
pub fmt: Changeset {
devContainer
.withExec(["mvn", "com.spotify.fmt:fmt-maven-plugin:format"])
.directory(workspacePath)
.changes(devContainer.directory(workspacePath))
}
"""
Check that releasing works, without actually releasing
"""
pub releaseDryRun(
"""
Git tag to fake-release
"""
sourceTag: String! = "HEAD",
): Void @check {
let version = sourceTag.trimPrefix(sourcePath + "/v")
devContainer
.withExec(["apk", "add", "--no-cache", "gpg"])
.withExec(["mvn", "versions:set", "-DnewVersion=" + version])
.withExec(["mvn", "clean", "deploy", "-Prelease", "-Dmaven.deploy.skip=true"])
.withExec(["find", ".", "-name", "*.jar"])
.sync
null
}
"""
Publish the Java SDK
Java release not yet available, call dry run release
"""
pub release(
"""
Source git tag to release
"""
sourceTag: String!,
): Void {
releaseDryRun(sourceTag)
}
"""
Bump the Java SDK's Engine dependency
"""
pub bump(version: String!): Changeset {
let v = version.trimPrefix("v")
# TODO: handle snapshot versions
# if (!v.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) {
# v = v + "-SNAPSHOT"
# }
let bumpCtr = devContainer
.withExec([
"mvn",
"versions:set",
"-DgenerateBackupPoms=false",
"-DnewVersion=" + v,
])
.withExec([
"mvn",
"versions:set-property",
"-DgenerateBackupPoms=false",
"-Dproperty=daggerengine.version",
"-DnewVersion=" + v,
])
.withWorkdir("runtime/template")
.withExec([
"mvn",
"versions:set-property",
"-DgenerateBackupPoms=false",
"-Dproperty=dagger.module.deps",
"-DnewVersion=" + v + "-template-module",
])
let initialState = directory
let bumped = directory
[
sourcePath + "/dagger-codegen-maven-plugin/pom.xml",
sourcePath + "/dagger-java-annotation-processor/pom.xml",
sourcePath + "/dagger-java-sdk/pom.xml",
sourcePath + "/dagger-java-samples/pom.xml",
sourcePath + "/pom.xml",
sourcePath + "/runtime/template/pom.xml",
].each { pom =>
initialState = initialState.withFile(pom, workspace.file(pom))
bumped = bumped.withFile(pom, bumpCtr.file(workspacePath + "/" + pom))
}
bumped
.changes(initialState)
}
"""
Check dependencies in the Java SDK
"""
pub checkDeps: Void {
let changes = bumpDeps
.asPatch
.contents
if (changes != "") {
container.withError("Updates available for Java dependencies:\n\n" + changes).sync
}
null
}
"""
Bump dependencies in the Java SDK
"""
pub bumpDeps: Changeset! {
let ctr = devContainer
[
sourcePath + "/dagger-codegen-maven-plugin/",
sourcePath + "/dagger-java-annotation-processor",
sourcePath + "/dagger-java-sdk",
sourcePath + "/dagger-java-samples",
sourcePath,
].each { modPath =>
ctr = ctr
.withWorkdir(workspacePath + "/" + modPath)
.withExec(["mvn", "versions:update-properties"])
}
ctr
.directory(workspacePath)
.changes(devContainer.directory(workspacePath))
}
}