juraj-hrivnak / Pakku

A multiplatform modpack manager for Minecraft: Java Edition. Create modpacks for CurseForge, Modrinth or both simultaneously.
https://juraj-hrivnak.github.io/Pakku/
European Union Public License 1.2
24 stars 4 forks source link

Rewrite exporting & implement "export rules" + "export profiles" #18

Closed juraj-hrivnak closed 3 months ago

juraj-hrivnak commented 3 months ago

Export Rules

Exporting a modpack is now controlled by a list of rules which control what should happen with the content you want to export/package.

These rules can be written in many ways and are fully extensible by extending the RuleContext class.

To create an export rule, you simply implement the functional interface like this:

fun exampleRule() = ExportRule {
    when (it)
    {
        is ExportingProject -> it.export() // (Sample function)
        else                -> it.ignore()
    }
}

Export rules must be part of an ExportProfile to be executed.

Export Profiles

An export profile is used to contain the above-mentioned list of rules. Each export profile is independent of each other and will result in one exported file.

ExportProfile(
    name = "example-profile",
    rules = listOf(
        exampleRule()
    )
)

An export profile can be exported using the ExportProfile.export() extension function. Multiple export profiles can be exported asynchronously when used as a parameter in the export() function.