This message was deleted.
# native
s
This message was deleted.
d
Do you have a project example. The error points to the fact that Nokee expect a configuration named
compileOnly
as a declarable bucket (
canBeConsumed == false && canBeResolved == false
) but it found an existing configuration with the same name as resolvable bucket. It seems there is something else configuring the project.
p
It's a subproject
also the reason I wanted to use this plugin is it seems to allow me to target a specific os. I wanna build a c library on my mac or on any computer running gradle but have it be able to run on a 64bit linux machine or in this case debian linux docker image. However I just can't get the plugin to build and even when I create a whole new project, I can't add this to my build.gradle.kts file:
Copy code
library {
    targetMachines.set(listOf(machines.linux.x86_64,
        machines.windows.x86, machines.windows.x86_64,
        machines.macOS.x86_64))
}
d
You are right and it should work as described. When you say it doesn't work with Gradle enterprise, you mean when you don't apply
com.gradle.enterprise
or not using
--scan
it work fine?
p
nah it's got nothing to do with gradle enterprise
or at least I dont think it does
maybe it's just casue I'm using it in a subproject
where I've already declared some java plugins
d
I'm more curious about which plugins get applied to the project to know who else may be creating compileOnly configuration.
p
applicatoin java base kotlin("jvm") version "1.5.31" java id("io.gitlab.arturbosch.detekt") version "1.17.1" idea
there's a few of them
also when I changed to version 0.4.0, the error was about
implementation
configuraton
hang on leme get ya the logs
d
If you apply the Java plugin together with c-library (in the same project). It would be normal to see this failure.
p
ah well that makes sense so what can I do?
d
If you want to build a JNI libray with c native code use jni-library and c-language
p
it's not a JNI library
it's just a shared library that will be used as a plugin inside a docker container
I was just hoping to build it with gradle as opposed to using gcc inside the container
d
Then just make sure you don't apply two plugins with different entrypoint (see https://docs.nokee.dev/manual/plugin-anatomy.html)
If I remember correctly compileOnly was added after 0.4.
p
yeah not really trying to do anything complex here, just need to build a c library and copy the .so file into a docker container
I tried the c plugin from gradle but that won't let me target a specific OS
d
The c plugin is a bit different.
p
also do you guys have any full samples that use the library { } field
cause even in a completely separate project, that's not working
That is definitely unexpected. If you can reproduce the error in a project, I can have a look.
p
yeah that's the one I tested with, can't seem to add this:
Copy code
libary {
	targetMachines.set(listOf(machines.linux.x86_64, machines.macOS.x86_64))
}
to the build.gradle.kts
Copy code
plugins {
	id("dev.nokee.c-library")
	id("dev.nokee.xcode-ide")
}

libary {
	targetMachines.set(listOf(machines.linux.x86_64, machines.macOS.x86_64))
}
that's the build.gradle.kts file I'm trying to use, it's the same project as the sample you pasted above
d
I will give it a try as soon as I'm back to my computer.
p
aight feel free to DM me, thanks
d
(in about 30-ish minutes)
👍 1
p
I gotta take a break from looking at this shit
d
I tried it locally and it works as expected: https://scans.gradle.com/s/7sbak5obchqmc
So there is potentially some various things to look at to figure out what is the difference.
The first one that jump to me would be if there is any
~/.gradle/init.d
scripts that would automatically apply any plugins which may be incompatible with Nokee. A quick way to check is to use different home directory. With the sample, you can try
./gradlew build -g user-home
This will effectively ignore any configuration or cache under
~/.gradle
If that doesn’t work then we can start looking at the environment you are using via
./gradlew --version
Mine is:
Copy code
------------------------------------------------------------
Gradle 6.2.1
------------------------------------------------------------

Build time:   2020-02-24 20:24:10 UTC
Revision:     aacbcb7e587faa6a8e7851751a76183b6187b164

Kotlin:       1.3.61
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          1.8.0_292 (AdoptOpenJDK 25.292-b10)
OS:           Mac OS X 10.16 x86_64
I tried with Gradle 7.4 and it work as well: https://gradle.com/s/ckmae7qcod4bu
Copy code
------------------------------------------------------------
Gradle 7.4
------------------------------------------------------------

Build time:   2022-02-08 09:58:38 UTC
Revision:     f0d9291c04b90b59445041eaa75b2ee744162586

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          1.8.0_292 (AdoptOpenJDK 25.292-b10)
OS:           Mac OS X 10.16 x86_64
p
@daniel it just doesnt work for me:
Copy code
* What went wrong:
Script compilation errors:

  Line 5: libary {
          ^ Unresolved reference: libary

  Line 6:     targetMachines.set(listOf(machines.linux.x86_64, machines.macOS.x86_64))
              ^ Unresolved reference: targetMachines

  Line 6:     targetMachines.set(listOf(machines.linux.x86_64, machines.macOS.x86_64))
                                        ^ Unresolved reference: machines

  Line 6:     targetMachines.set(listOf(machines.linux.x86_64, machines.macOS.x86_64))
                                                               ^ Unresolved reference: machines
Copy code
plugins {
    id("dev.nokee.c-library")
}

libary {
    targetMachines.set(listOf(machines.linux.x86_64, machines.macOS.x86_64))
}
this is my build.gradle.kts file
Copy code
pluginManagement {
    repositories {
        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}")
            }
        }
    }
}
settings.gradle.kts file
d
I can see a typo in the extension name
libary
instead of
library
. The current error is most likely that typo. IntelliJ should auto-complete or at least underline the extension block as error, assuming the project was synced with IntelliJ. In cases, like this, commenting the configuration (the extension block) and leaving just the plugin apply can help move pass the syntax error and allow IntelliJ to finish the sync. Not convenient when there is a lot of configuration or on a new project.
p
fuck me, yeah for some reason intelliJ highlighting isn't working for me right now on these build.gradle files. Anyway you were right, the problem was using the nokee plugin as a subproject in a multi-project build, once I separated it out completely, it built. 🤞 the binary works in a linux docker container
actually it jsut doesn't work, it won't let me build a native c library on my mac that targets a linux machine, should've known there was no way it would work. thanks for all your help @daniel, really appreciate the time
d
Cross-compilation require toolchain configuration which is a bit more evolved as they aren’t always as straight forward. One solution I often use is just execute the build in a target docker with the toolchain, jvm, and all. You can mount the working directory into the build container so the resulting binary will be cross-built.
👍 1