nokeedev / gradle-native

The home of anything about Gradle support for natively compiled languages

Home Page:https://nokee.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dev.nokee.jni-library build fails on M1

dosier opened this issue · comments

commented

Hey, I am trying to build a JNI library, and stumbled upon this plugin, looks pretty cool :).
However, when I try to import dev.nokee.jni-library, I am receiving the following exception:

Could not initialize class dev.nokee.runtime.nativebase.internal.DefaultMachineArchitecture
> Exception java.lang.UnsupportedOperationException: Unsupported architecture of name 'aarch64' [in thread "Daemon worker Thread 6"]

Importing id("dev.nokee.cpp-language") seems to work fine though.

I am using a M1 MBP.

My build.gradle.kts contains:

plugins {
    id("dev.nokee.jni-library")
}

With my settings.gradle.kts looking like:

pluginManagement {
    repositories {
        mavenCentral()
        gradlePluginPortal()

        maven { url = uri("https://repo.nokee.dev/release") }
        maven { url = uri("https://repo.nokee.dev/snapshot") }
    }
    val nokeeVersion = "0.5.0-930919a0"
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id.startsWith("dev.nokee.")) {
                useModule("${requested.id.id}:${requested.id.id}.gradle.plugin:${nokeeVersion}")
            }
        }
    }
}
rootProject.name = "kotlin-jni"

I will have a look at this soon. I'm a bit more offline than usual this past month. However, try the latest version from here: https://services.nokee.dev/versions/latest-snapshot.json There's a newer snapshot but that one should have support for aarch64.

I can confirm that the following resolved the architecture issue on my M1:

// settings.gradle
pluginManagement {
  repositories {
    gradlePluginPortal()
    maven { url = uri('https://repo.nokee.dev/release') }
    maven { url = uri('https://repo.nokee.dev/snapshot') }
  }
  resolutionStrategy {
    eachPlugin {
      if (requested.id.id.startsWith('dev.nokee.')) {
        useModule "${requested.id.id}:${requested.id.id}.gradle.plugin:0.4.3129-202303171612.d413fb13"
      }
    }
  }
}
// build.gradle
plugins {
  id 'dev.nokee.c-application' // or whatever
}

Still get the error message with version 0.4.3129-202303171612.d413fb13
A problem occurred configuring project ':plugin:objc-jni'

Caused by: java.lang.IllegalArgumentException: The following target machines are not know by the defined tool chains:
 macos aarch64
	at dev.nokee.platform.nativebase.internal.TargetMachinesPropertyRegistrationRule.assertTargetMachinesAreKnown(TargetMachinesPropertyRegistrationRule.java:66)
	at dev.nokee.platform.nativebase.internal.TargetMachinesPropertyRegistrationRule.lambda$execute$0(TargetMachinesPropertyRegistrationRule.java:58)
	at dev.nokee.platform.base.internal.DimensionPropertyRegistrationFactory$Builder.lambda$validateUsing$0(DimensionPropertyRegistrationFactory.java:88)
	at dev.nokee.platform.base.internal.BuildVariants$ToCoordinateSet.lambda$asCoordinateSet$0(BuildVariants.java:118)
	at dev.nokee.util.internal.PeekTransformer.transform(PeekTransformer.java:34)
	at dev.nokee.utils.internal.WrappedTransformer.transform(WrappedTransformer.java:33)
	at dev.nokee.utils.TransformerUtils$ComposeTransformer.transform(TransformerUtils.java:276)
	at dev.nokee.utils.TransformerUtils$ComposeTransformer.transform(TransformerUtils.java:276)