@@ -6,6 +6,8 @@ import org.jackhuang.hmcl.gradle.l10n.CreateLanguageList
66import org.jackhuang.hmcl.gradle.l10n.CreateLocaleNamesResourceBundle
77import org.jackhuang.hmcl.gradle.l10n.UpsideDownTranslate
88import org.jackhuang.hmcl.gradle.mod.ParseModDataTask
9+ import org.jackhuang.hmcl.gradle.pack.CreateDeb
10+ import org.jackhuang.hmcl.gradle.pack.ReleaseType
911import org.jackhuang.hmcl.gradle.utils.PropertiesUtils
1012import java.net.URI
1113import java.nio.file.FileSystems
@@ -251,20 +253,22 @@ tasks.processResources {
251253 }
252254}
253255
256+ fun artifactFile (ext : String ) = jarPath.resolveSibling(jarPath.nameWithoutExtension + ' .' + ext)
257+
254258val makeExecutables by tasks.registering {
255259 val extensions = listOf (" exe" , " sh" )
256260
257261 dependsOn(tasks.jar)
258262
259263 inputs.file(jarPath)
260- outputs.files(extensions.map { File (jarPath.parentFile, jarPath.nameWithoutExtension + ' . ' + it) })
264+ outputs.files(extensions.map { artifactFile( it) })
261265
262266 doLast {
263267 val jarContent = jarPath.readBytes()
264268
265269 ZipFile (jarPath).use { zipFile ->
266270 for (extension in extensions) {
267- val output = File (jarPath.parentFile, jarPath.nameWithoutExtension + ' . ' + extension)
271+ val output = artifactFile( extension)
268272 val entry = zipFile.getEntry(" assets/HMCLauncher.$extension " )
269273 ? : throw GradleException (" HMCLauncher.$extension not found" )
270274
@@ -279,8 +283,31 @@ val makeExecutables by tasks.registering {
279283 }
280284}
281285
286+ val makeDeb by tasks.registering(CreateDeb ::class ) {
287+ dependsOn(makeExecutables)
288+
289+ val debFile = layout.file(provider { artifactFile(" deb" ) })
290+
291+ val debChannel = when (versionType) {
292+ " stable" -> ReleaseType .STABLE
293+ " dev" -> ReleaseType .DEVELOPMENT
294+ else -> ReleaseType .NIGHTLY
295+ }
296+
297+ version.set(project.version.toString())
298+ releaseType.set(debChannel)
299+ appShFile.set(layout.file(provider { artifactFile(" sh" ) }))
300+ iconFile.set(layout.projectDirectory.file(" image/hmcl.png" ))
301+ outputFile.set(debFile)
302+
303+ doLast {
304+ createChecksum(debFile.get().asFile)
305+ }
306+ }
307+
282308tasks.build {
283309 dependsOn(makeExecutables)
310+ dependsOn(makeDeb)
284311}
285312
286313fun parseToolOptions (options : String? ): MutableList <String > {
@@ -377,12 +404,14 @@ val upgradeTerracottaConfig = tasks.register<TerracottaConfigUpgradeTask>("upgra
377404 val destination = layout.projectDirectory.file(" src/main/resources/assets/terracotta.json" )
378405 val source = layout.projectDirectory.file(" terracotta-template.json" );
379406
380- classifiers.set(listOf (
381- " windows-x86_64" , " windows-arm64" ,
382- " macos-x86_64" , " macos-arm64" ,
383- " linux-x86_64" , " linux-arm64" , " linux-loongarch64" , " linux-riscv64" ,
384- " freebsd-x86_64"
385- ))
407+ classifiers.set(
408+ listOf (
409+ " windows-x86_64" , " windows-arm64" ,
410+ " macos-x86_64" , " macos-arm64" ,
411+ " linux-x86_64" , " linux-arm64" , " linux-loongarch64" , " linux-riscv64" ,
412+ " freebsd-x86_64"
413+ )
414+ )
386415
387416 version.set(libs.versions.terracotta)
388417 downloadURL.set($$" https://github.com/burningtnt/Terracotta/releases/download/v${version} /terracotta-${version} -${classifier} -pkg.tar.gz" )
0 commit comments