SpongePowered / SpongeGradle

Handy gradle utilities for the various gradle projects of SpongePowered
MIT License
21 stars 16 forks source link

Download 1.15.2-8.0.0-SNAPSHOT when api version targeting `8.1.0-SNPSHOT` #37

Closed SettingDust closed 2 years ago

SettingDust commented 2 years ago

SG: 2.0.1 Error: Failed to find Premain-Class manifest attribute in C:\Users\setti\.gradle\caches\modules-2\files-2.1\org.spongepowered\spongevanilla\1.15.2-8.0.0-SNAPSHOT\9c0fa653fdab9b3e9af951086effcbbd485acbf2\spongevanilla-1.15.2-8.0.0-SNAPSHOT-universal.jar

zml2008 commented 2 years ago

This seems to be an issue with Sponge, where Sponge is publishing 8.1.0-SNAPSHOT versions under 8.0.0.

The logic in generateApiReleasedVersion seems to do this intentionally on the Sponge side. Should we match this in SG, or modify sponge to just strip the -SNAPSHOT off API versions?

    private static String generateApiReleasedVersion(final String apiVersion) {
        final String[] apiSplit = apiVersion.replace("-SNAPSHOT", "").split("\\.");
        final boolean isSnapshot = apiVersion.contains("-SNAPSHOT");

        // This is to determine if the split api version has at the least a minimum version.
        final String apiMajor = apiSplit[0];
        final String minorVersion;
        if (apiSplit.length > 1) {
            minorVersion = apiSplit[1];
        } else {
            minorVersion = "0";
        }
        final int latestReleasedVersion = Math.max(Integer.parseInt(minorVersion) - 1, 0);
        // And then here, we determine if the api version still has a patch version, to just ignore it.
        final String latestReleasedApiMinor = isSnapshot ? String.valueOf(latestReleasedVersion) : minorVersion;
        return apiMajor + "." + latestReleasedApiMinor;
    }

thoughts @gabizou?

gabizou commented 2 years ago

Should we match this in SG

In short, yes.

zml2008 commented 2 years ago

Fixed in e0176ccdab98e1c7dc1e5bdd34148ecd5cc28765