firstdarkdev / modpublisher

A dual publishing Gradle Plugin to publish mods to Modrinth, Curseforge and GitHub in one go
MIT License
19 stars 3 forks source link

Feature: upload different artifacts to each platform #3

Closed MattSturgeon closed 11 months ago

MattSturgeon commented 11 months ago

For example, Freecam produces a "normal" build as well as a "modrinth" build, as some options need to be restricted to comply with their ToS.

Could artifact be replaced with a NamedDomainObjectContainer, MapProperty, or similar?

The existing API could be maintained by having a setArtifact() input that assigns the given artifact to all (recognized) entries.

hypherionmc commented 11 months ago

Hmm makes total sense.

What I can do is, keep setArtifact, and then add a second one that takes in a string/enum matching the platform.

So for example:

setArtifact(jar) // Used for all Platforms
setArtifact("modrinth", jar) // Only uploaded to modrinth
setArtifact(Platform.Modrinth, jar) // Only uploaded to modrinth

Would something like that work?

MattSturgeon commented 11 months ago

That'd be perfect. (Merry christmas btw :santa: ).

How would it behave if setArtifact(jar) is used in tandem with setArtifact(__, jar)? Would the first invocation set the "default" and the second then overwrite the specified platform?

hypherionmc commented 11 months ago

Oh yeah, it's christmas lol. Merry christmas.

If there is no specific override for a platform, it will use the global one. If no global one, and no platform one is found, it will throw an error.

So for example:

setArtifact(jar) // Global
setArtifact("modrinth", modrinthJar) // Modrinth task will use this artifact

Then GitHub/Curseforge will use global, and modrinth will use the modrinth jar

hypherionmc commented 11 months ago

Implemented with 2.0.2

Configuration:

setArtifact(jar) // Global Artifact
setPlatformArtifact("modrinth", modrinthJar) // Override for Modrinth.
setPlatformArtifact("curseforge", curseJar) // Override for Curse
setPlatformArtifact(Platform.GitHub, githubJar) // Override GitHub jar

or Kotlin

artifact.set(tasks.jar) // Global Artifact
setPlatformArtifact("modrinth", tasks.modrinthJar) // Override for Modrinth.
setPlatformArtifact("curseforge", tasks.curseJar) // Override for Curse
setPlatformArtifact(Platform.GitHub, tasks.githubJar) // Override GitHub jar

If setPlatformArtifact is not called for a platform, artifact will be used. If neither is set, an error will be thrown

MattSturgeon commented 11 months ago

Wonderful, thank you!

hypherionmc commented 11 months ago

You're welcome. Do let me know if you have any questions or need anything else :)