hyperxpro / Brotli4j

Brotli4j provides Brotli compression and decompression for Java.
Apache License 2.0
110 stars 36 forks source link

Groovy scripts in ReadMe not works #142

Open GrapeBaBa opened 5 months ago

GrapeBaBa commented 5 months ago

Describe the bug Groovy gradle script not works. No methods for architectures.

To Reproduce Steps to reproduce the behavior:

  1. Copy the Groovy script from the ReadMe file.
  2. Run gradle build.
  3. Error like this https://github.com/optimism-java/hildr/actions/runs/9465053552

Expected behavior No errors when building.

Logs https://github.com/optimism-java/hildr/actions/runs/9465053552

Platform (please complete the following information):

Additional context

hyperxpro commented 4 months ago

Would you like to make a PR?

SrBrahma commented 2 months ago

I have the same error on GitLab CI. Doesn't happen locally.

hyperxpro commented 2 months ago

I have the same error on GitLab CI. Doesn't happen locally.

Can you help me with a reproducer?

SrBrahma commented 2 months ago

Kotlin/Java isn't my strong language so I am afraid I can't help much. But, you should be able to reproduce it by using OP's repo: https://github.com/optimism-java/hildr/pull/167/commits.

Note that he fixed his CI by changing the check at: https://github.com/optimism-java/hildr/pull/167/commits/9d42023f7a4f2c005367b8d3425b1dd24d0f6b37

SrBrahma commented 2 months ago

Further info: I am using gradle 8.10, and I found out this when I went to the definitions of the isXYZ:

image

Maybe it didn't fail locally as I am using MacOS.

SrBrahma commented 2 months ago

I have updated mine to be

def brotliVersion = "1.17.0"
def operatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()
def currentArchitecture = DefaultNativePlatform.getCurrentArchitecture()

repositories {
    mavenCentral()
}

dependencies {
    implementation "com.aayushatharva.brotli4j:brotli4j:$brotliVersion"
    runtimeOnly("""com.aayushatharva.brotli4j:native-${
        if (operatingSystem.isWindows())
            if (currentArchitecture.isAmd64()) "windows-x86_64"
            else if (currentArchitecture.isArm64()) "windows-aarch64"
            else
                throw new IllegalStateException("Unsupported architecture: ${currentArchitecture.getName()}");
        else if (operatingSystem.isMacOsX())
            if (currentArchitecture.isArm64()) "osx-aarch64"
            else "osx-x86_64"
        else if (operatingSystem.isLinux())
            if (currentArchitecture.isArm64()) "linux-aarch64"
            else if (currentArchitecture.isAmd64()) "linux-x86_64"
            else if (currentArchitecture.isArm32()) "linux-armv7"
            else if (currentArchitecture.isI386()) "linux-x86_64"  // Assuming I386 should also use linux-x86_64 as there is no linux-i386 folder
            else
                throw new IllegalStateException("Unsupported architecture: ${currentArchitecture.getName()}");
        else
            throw new IllegalStateException("Unsupported operating system: $operatingSystem");
    }:$brotliVersion""")
}

I don't know where this difference in methods comes from, though. I can do a PR, but I can't say if we are a minority that has this issue.