-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.latte
More file actions
123 lines (103 loc) · 4.43 KB
/
Copy pathproject.latte
File metadata and controls
123 lines (103 loc) · 4.43 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
/*
* Copyright (c) 2026 The Latte Project
* SPDX-License-Identifier: MIT
*/
project(group: "org.lattejava", name: "cli", version: "0.4.0", licenses: ["MIT"]) {
workflow {
standard()
}
publishWorkflow {
latte()
}
dependencies {
group(name: "compile") {
dependency(id: "com.googlecode.json-simple:json-simple:1.1.1")
dependency(id: "org.apache.commons:commons-compress:1.28.0")
dependency(id: "org.apache.groovy:groovy:5.0.5")
}
group(name: "test-compile", export: false) {
dependency(id: "org.easymock:easymock:5.6.0")
dependency(id: "org.testng:testng:7.12.0")
}
}
publications {
standard()
}
}
// Plugins
dependency = loadPlugin(id: "org.lattejava.plugin:dependency:0.4.0")
file = loadPlugin(id: "org.lattejava.plugin:file:0.4.3")
idea = loadPlugin(id: "org.lattejava.plugin:idea:0.4.1")
java = loadPlugin(id: "org.lattejava.plugin:java:0.4.4")
javaTestNG = loadPlugin(id: "org.lattejava.plugin:java-testng:0.4.0")
release = loadPlugin(id: "org.lattejava.plugin:release-git:0.4.0")
// Plugin settings
java.settings.javaVersion = "25"
javaTestNG.settings.javaVersion = "25"
target(name: "clean", description: "Cleans the project") {
java.clean()
}
target(name: "build", description: "Compiles the project") {
file.execute("git config core.hooksPath .githooks")
java.compile()
java.jar()
}
target(name: "doc", description: "Generate the project's JavaDoc", dependsOn: ["build"]) {
java.document()
}
target(name: "test", description: "Runs the project's tests", dependsOn: ["build"]) {
javaTestNG.test()
}
target(name: "int", description: "Releases a local integration build of the project", dependsOn: ["test"]) {
dependency.integrate()
}
target(name: "idea", description: "Updates the IntelliJ IDEA module file") {
idea.iml()
}
target(name: "format", description: "Formats the source code using IntelliJ's CLI") {
file.execute(cmd: ["${SYS["user.home"]}/Applications/IntelliJ IDEA.app/Contents/bin/format.sh", "-r", "-s", ".idea/codeStyles/Project.xml", "src/main/java/"])
file.execute(cmd: ["${SYS["user.home"]}/Applications/IntelliJ IDEA.app/Contents/bin/format.sh", "-r", "-s", ".idea/codeStyles/Project.xml", "src/test/java/"])
}
target(name: "print-dependency-tree", description: "Prints the dependency tree") {
dependency.printFull()
}
target(name: "bundle", description: "Creates a self-contained runtime bundle", dependsOn: ["build"]) {
def bundleDir = "build/bundle"
file.prune(dir: bundleDir)
file.mkdir(dir: "${bundleDir}/bin")
file.mkdir(dir: "${bundleDir}/lib")
file.mkdir(dir: "${bundleDir}/templates")
file.copyFile(file: "src/main/scripts/latte", to: "${bundleDir}/bin/latte")
file.copyFile(file: "build/jars/${project.name}-${project.version}.jar", to: "${bundleDir}/lib/${project.name}-${project.version}.jar")
dependency.copy(to: "${bundleDir}/lib") {
dependencies(group: "compile", transitive: true, fetchSource: false)
}
file.copy(to: "${bundleDir}/templates") {
fileSet(dir: "src/main/templates", includePatterns: [/.*/])
}
}
target(name: "minio", description: "Starts a local MinIO container for S3 testing") {
output.infoln("Stopping MinIO Docker container (if exists)")
file.execute(cmd: "docker rm -f latte-minio", ignoreFailures: true)
output.infoln("Starting MinIO Docker container in the background")
file.execute(cmd: "docker run -d --name latte-minio -p 9000:9000 -p 9001:9001 -e MINIO_ROOT_USER=latte-test -e MINIO_ROOT_PASSWORD=latte-test-secret minio/minio server /data --console-address :9001")
Thread.sleep(1000)
output.infoln("Initializing MinIO")
file.execute(cmd: "docker exec latte-minio mc alias set local http://localhost:9000 latte-test latte-test-secret")
file.execute(cmd: "docker exec latte-minio mc mb local/latte-test")
}
target(name: "release", description: "Releases a full version of the project", dependsOn: ["clean", "test", "bundle"]) {
release.release()
// Create a tarball of the bundle and publish it as a GitHub release
def tarball = "build/latte-${project.version}.tar.gz"
file.tar(file: tarball, compress: true) {
fileSet(dir: "build/bundle", includePatterns: [/.*/])
}
def tag = project.version.toString()
def proc = "gh release create ${tag} ${tarball} --title ${tag} --generate-notes".execute()
proc.waitFor()
if (proc.exitValue() != 0) {
fail("GitHub release creation failed [exit=${proc.exitValue()}]: ${proc.err.text}")
}
output.infoln("GitHub release created for ${tag}")
}