Add webapp.zip to release outputs and move version substitution from runtime to build-time

This commit is contained in:
Lukas Rieger (Blue) 2024-09-21 16:34:21 +02:00
parent 41bd685bfb
commit 3193912914
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6
5 changed files with 23 additions and 10 deletions

View File

@ -3,9 +3,6 @@ plugins {
id ( "io.github.goooler.shadow" )
}
val Project.releaseDirectory: File
get() = rootProject.projectDir.resolve("build/release")
tasks.shadowJar {
archiveFileName = "${project.name}-${project.version}-shadow.jar"
}

View File

@ -0,0 +1,5 @@
import org.gradle.api.Project
import java.io.File
val Project.releaseDirectory: File
get() = rootProject.projectDir.resolve("build/release")

View File

@ -43,8 +43,17 @@ tasks.register("zipWebapp", type = Zip::class) {
archiveFileName = "webapp.zip"
destinationDirectory = file("src/main/resources/de/bluecolored/bluemap/")
val replacements = mapOf(
"version" to project.version
)
inputs.properties(replacements)
inputs.dir("webapp/dist/")
outputs.file("src/main/resources/de/bluecolored/bluemap/webapp.zip")
filesMatching(listOf(
"index.html",
)) { expand(properties) }
}
tasks.processResources {
@ -55,6 +64,14 @@ tasks.getByName("sourcesJar") {
dependsOn("zipWebapp")
}
tasks.register<CopyFileTask>("release") {
group = "publishing"
dependsOn("zipWebapp")
inputFile = tasks.getByName("zipWebapp").outputs.files.singleFile
outputFile = releaseDirectory.resolve("bluemap-${project.version}-webapp.zip")
}
tasks.clean {
doFirst {
if (!file("webapp/dist/").deleteRecursively())

View File

@ -114,12 +114,6 @@ public void updateFiles() throws IOException {
// extract zip to webroot
Files.createDirectories(webRoot);
FileHelper.extractZipFile(zippedWebapp, webRoot, StandardCopyOption.REPLACE_EXISTING);
// set version in index.html
Path indexFile = webRoot.resolve("index.html");
String indexContent = Files.readString(indexFile);
indexContent = indexContent.replace("%version%", BlueMap.VERSION);
Files.writeString(indexFile, indexContent);
}
@SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal", "unused", "MismatchedQueryAndUpdateOfCollection"})

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<meta name="description"
content="BlueMap is a tool that generates 3D maps of your Minecraft worlds and displays them in your browser">
<meta name="version" content="%version%">
<meta name="version" content="${version}">
<meta name="keywords" content="bluemap, map, minecraft, minecraft map">
<meta name="theme-color" content="#006EDE">
<meta name="og:site_name" content="BlueMap">