mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 00:37:03 +05:30
refactor(build): fix debug builds and groups to collection tasks
This commit is contained in:
parent
19412cc963
commit
b0ffbcd07d
2 changed files with 46 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright © 2022 Harsh Shandilya.
|
* Copyright © 2022-2023 Harsh Shandilya.
|
||||||
* Use of this source code is governed by an MIT-style
|
* Use of this source code is governed by an MIT-style
|
||||||
* license that can be found in the LICENSE file or at
|
* license that can be found in the LICENSE file or at
|
||||||
* https://opensource.org/licenses/MIT.
|
* https://opensource.org/licenses/MIT.
|
||||||
|
@ -12,6 +12,7 @@ import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
||||||
|
import kotlin.io.path.createDirectory
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.file.DirectoryProperty
|
import org.gradle.api.file.DirectoryProperty
|
||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
@ -21,6 +22,7 @@ import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.InputFile
|
import org.gradle.api.tasks.InputFile
|
||||||
import org.gradle.api.tasks.InputFiles
|
import org.gradle.api.tasks.InputFiles
|
||||||
import org.gradle.api.tasks.Internal
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.Optional
|
||||||
import org.gradle.api.tasks.OutputDirectory
|
import org.gradle.api.tasks.OutputDirectory
|
||||||
import org.gradle.api.tasks.PathSensitive
|
import org.gradle.api.tasks.PathSensitive
|
||||||
import org.gradle.api.tasks.PathSensitivity
|
import org.gradle.api.tasks.PathSensitivity
|
||||||
|
@ -33,6 +35,7 @@ abstract class CollectApksTask : DefaultTask() {
|
||||||
|
|
||||||
@get:InputFile
|
@get:InputFile
|
||||||
@get:PathSensitive(PathSensitivity.NONE)
|
@get:PathSensitive(PathSensitivity.NONE)
|
||||||
|
@get:Optional
|
||||||
abstract val mappingFile: RegularFileProperty
|
abstract val mappingFile: RegularFileProperty
|
||||||
|
|
||||||
@get:Input abstract val variantName: Property<String>
|
@get:Input abstract val variantName: Property<String>
|
||||||
|
@ -41,27 +44,30 @@ abstract class CollectApksTask : DefaultTask() {
|
||||||
|
|
||||||
@get:OutputDirectory abstract val outputDirectory: DirectoryProperty
|
@get:OutputDirectory abstract val outputDirectory: DirectoryProperty
|
||||||
|
|
||||||
|
override fun getGroup(): String {
|
||||||
|
return "artifact collection"
|
||||||
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun run() {
|
fun run() {
|
||||||
val outputDir = outputDirectory.asFile.get()
|
val outputDir = outputDirectory.asFile.get().toPath()
|
||||||
val outputDirStream =
|
Files.walk(outputDir).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete)
|
||||||
Files.walk(outputDir.toPath()).sorted(Comparator.reverseOrder()).map(Path::toFile)
|
outputDir.createDirectory()
|
||||||
outputDirStream.forEach(File::delete)
|
|
||||||
outputDirStream.close()
|
|
||||||
outputDir.mkdirs()
|
|
||||||
val builtArtifacts =
|
val builtArtifacts =
|
||||||
builtArtifactsLoader.get().load(apkFolder.get()) ?: error("Cannot load APKs")
|
builtArtifactsLoader.get().load(apkFolder.get()) ?: error("Cannot load APKs")
|
||||||
builtArtifacts.elements.forEach { artifact ->
|
builtArtifacts.elements.forEach { artifact ->
|
||||||
Files.copy(
|
Files.copy(
|
||||||
Paths.get(artifact.outputFile),
|
Paths.get(artifact.outputFile),
|
||||||
outputDir.resolve("Claw-${variantName.get()}-${artifact.versionName}.apk").toPath(),
|
outputDir.resolve("Claw-${variantName.get()}-${artifact.versionName}.apk"),
|
||||||
|
StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
mappingFile.orNull?.apply {
|
||||||
|
Files.copy(
|
||||||
|
asFile.toPath(),
|
||||||
|
outputDir.resolve("mapping.txt"),
|
||||||
StandardCopyOption.REPLACE_EXISTING,
|
StandardCopyOption.REPLACE_EXISTING,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Files.copy(
|
|
||||||
mappingFile.get().asFile.toPath(),
|
|
||||||
outputDir.resolve("mapping.txt").toPath(),
|
|
||||||
StandardCopyOption.REPLACE_EXISTING,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright © 2022 Harsh Shandilya.
|
* Copyright © 2022-2023 Harsh Shandilya.
|
||||||
* Use of this source code is governed by an MIT-style
|
* Use of this source code is governed by an MIT-style
|
||||||
* license that can be found in the LICENSE file or at
|
* license that can be found in the LICENSE file or at
|
||||||
* https://opensource.org/licenses/MIT.
|
* https://opensource.org/licenses/MIT.
|
||||||
|
@ -10,19 +10,28 @@ import java.io.File
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
||||||
|
import kotlin.io.path.createDirectory
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.file.DirectoryProperty
|
import org.gradle.api.file.DirectoryProperty
|
||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.InputFile
|
import org.gradle.api.tasks.InputFile
|
||||||
|
import org.gradle.api.tasks.Optional
|
||||||
import org.gradle.api.tasks.OutputDirectory
|
import org.gradle.api.tasks.OutputDirectory
|
||||||
|
import org.gradle.api.tasks.PathSensitive
|
||||||
|
import org.gradle.api.tasks.PathSensitivity
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
abstract class CollectBundleTask : DefaultTask() {
|
abstract class CollectBundleTask : DefaultTask() {
|
||||||
@get:InputFile abstract val bundleFile: RegularFileProperty
|
@get:InputFile
|
||||||
|
@get:PathSensitive(PathSensitivity.NONE)
|
||||||
|
abstract val bundleFile: RegularFileProperty
|
||||||
|
|
||||||
@get:InputFile abstract val mappingFile: RegularFileProperty
|
@get:InputFile
|
||||||
|
@get:PathSensitive(PathSensitivity.NONE)
|
||||||
|
@get:Optional
|
||||||
|
abstract val mappingFile: RegularFileProperty
|
||||||
|
|
||||||
@get:Input abstract val variantName: Property<String>
|
@get:Input abstract val variantName: Property<String>
|
||||||
|
|
||||||
|
@ -30,23 +39,26 @@ abstract class CollectBundleTask : DefaultTask() {
|
||||||
|
|
||||||
@get:OutputDirectory abstract val outputDirectory: DirectoryProperty
|
@get:OutputDirectory abstract val outputDirectory: DirectoryProperty
|
||||||
|
|
||||||
|
override fun getGroup(): String {
|
||||||
|
return "artifact collection"
|
||||||
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun taskAction() {
|
fun taskAction() {
|
||||||
val outputDir = outputDirectory.asFile.get()
|
val outputDir = outputDirectory.asFile.get().toPath()
|
||||||
val outputDirStream =
|
Files.walk(outputDir).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete)
|
||||||
Files.walk(outputDir.toPath()).sorted(Comparator.reverseOrder()).map(Path::toFile)
|
outputDir.createDirectory()
|
||||||
outputDirStream.forEach(File::delete)
|
|
||||||
outputDirStream.close()
|
|
||||||
outputDir.mkdirs()
|
|
||||||
Files.copy(
|
Files.copy(
|
||||||
bundleFile.get().asFile.toPath(),
|
bundleFile.get().asFile.toPath(),
|
||||||
outputDir.resolve("Claw-${variantName.get()}-${versionName.get()}.aab").toPath(),
|
outputDir.resolve("Claw-${variantName.get()}-${versionName.get()}.aab"),
|
||||||
StandardCopyOption.REPLACE_EXISTING,
|
|
||||||
)
|
|
||||||
Files.copy(
|
|
||||||
mappingFile.get().asFile.toPath(),
|
|
||||||
outputDir.resolve("mapping.txt").toPath(),
|
|
||||||
StandardCopyOption.REPLACE_EXISTING,
|
StandardCopyOption.REPLACE_EXISTING,
|
||||||
)
|
)
|
||||||
|
mappingFile.orNull?.apply {
|
||||||
|
Files.copy(
|
||||||
|
asFile.toPath(),
|
||||||
|
outputDir.resolve("mapping.txt"),
|
||||||
|
StandardCopyOption.REPLACE_EXISTING,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue