diff --git a/buildSrc/src/main/kotlin/bluemap.implementation.gradle.kts b/buildSrc/src/main/kotlin/bluemap.implementation.gradle.kts index 5994b076..be2c7846 100644 --- a/buildSrc/src/main/kotlin/bluemap.implementation.gradle.kts +++ b/buildSrc/src/main/kotlin/bluemap.implementation.gradle.kts @@ -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" } diff --git a/buildSrc/src/main/kotlin/release.kt b/buildSrc/src/main/kotlin/release.kt new file mode 100644 index 00000000..d7030503 --- /dev/null +++ b/buildSrc/src/main/kotlin/release.kt @@ -0,0 +1,5 @@ +import org.gradle.api.Project +import java.io.File + +val Project.releaseDirectory: File + get() = rootProject.projectDir.resolve("build/release") diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 187d6c18..640d18c1 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -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("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()) diff --git a/common/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java b/common/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java index 59b9064e..9680d21d 100644 --- a/common/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java +++ b/common/src/main/java/de/bluecolored/bluemap/common/WebFilesManager.java @@ -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"}) diff --git a/common/webapp/index.html b/common/webapp/index.html index 39c8140c..7c60a2f1 100644 --- a/common/webapp/index.html +++ b/common/webapp/index.html @@ -5,7 +5,7 @@ - +