Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for Gradle multi-module repo: Cannot set the value of task nativeTestBuild property 'server' of type #70

Closed
xmlking opened this issue Jun 23, 2021 · 9 comments · Fixed by #80
Labels
gradle-bug Bug in Gradle itself

Comments

@xmlking
Copy link

xmlking commented Jun 23, 2021

when I use

plugins {
    id("org.graalvm.buildtools.native")
}

in multiple modules in Gradle multi-module repo, I have got following error

* What went wrong:
An exception occurred applying plugin request [id: 'org.graalvm.buildtools.native', version: '0.9.0']
> Failed to apply plugin 'org.graalvm.buildtools.native'.
   > Could not create task ':apps:linking-service:nativeTestBuild'.
      > Cannot set the value of task ':apps:linking-service:nativeTestBuild' property 'server' of type org.graalvm.buildtools.gradle.NativeImageService using a provider of type org.graalvm.buildtools.gradle.NativeImageService.

To reproduce : https://github.com/xmlking/micro-apps

@lazar-mitrovic
Copy link
Collaborator

lazar-mitrovic commented Jun 23, 2021

I might be missing something but I cannot reproduce this locally.

I tried invoking ./gradlew nativeBuild in the root project, and it crashes with:

> Task :apps:account-service:nativeBuild FAILED
Warning: Ignoring server-mode native-image argument --no-server.
Error: Found invalid image builder Java VM argument: flag

FAILURE: Build failed with an exception.

This originates from wrong configuration in apps/account-service/build.gradle.kts:78, and removing it leads to crash due to build time initialization of slf4j.

I tried invoking ./gradlew -Pagent -DpersistConfig nativeTest in the root project as well and it also fails with a bunch of build time initialized classes - so, due to the missing configuration.

At the end I tried running ./gradlew :apps:linking-service:nativeTest and it resulted with a crash in the compileKotlin task, which is again unrelated to this plugin:

> Task :apps:linking-service:compileTestKotlin FAILED
e: micro-apps/apps/linking-service/src/test/kotlin/micro/apps/service/domain/echo/KeyingServiceTest.kt: (15, 27): Unresolved reference: KeyingService
e: micro-apps/apps/linking-service/src/test/kotlin/micro/apps/service/domain/echo/KeyingServiceTest.kt: (25, 89): Unresolved reference: KeyingService

Aforementioned native-image errors originate from native-image executable itself, and that invocation happens lot after the phase that would throw the stack trace like yours.

So I would need more pointers about the command line invocation you were using in order to try to reproduce this.

@xmlking
Copy link
Author

xmlking commented Jun 25, 2021

I fixed above broken test cases...
please try this

  1. uncomment \\ id("org.graalvm.buildtools.native")
    https://github.com/xmlking/micro-apps/blob/develop/apps/account-service/build.gradle.kts#L3
  2. uncomment nativeBuild block
    https://github.com/xmlking/micro-apps/blob/develop/apps/account-service/build.gradle.kts#L73-L88

then run gradle :apps:account-service:nativeBuild in the project root, to reproduce the error.

@lazar-mitrovic lazar-mitrovic added the bug Something isn't working label Jun 26, 2021
@lazar-mitrovic
Copy link
Collaborator

@melix would you mind taking a look into this? It fails for me on 0.9.1-SNAPSHOT with the error mentioned above, as well as using PR #71 with:

org.gradle.jvm.toolchain.internal.NoToolchainAvailableException: No compatible toolchains found for request filter: {languageVersion=11, vendor=matching('GraalVM'), implementation=vendor-specific} (auto-detect true, auto-download true)

@melix
Copy link
Collaborator

melix commented Jun 28, 2021

This is actually a bug in Gradle, see gradle/gradle#17559

@lazar-mitrovic lazar-mitrovic linked a pull request Jun 28, 2021 that will close this issue
xmlking added a commit to xmlking/micro-apps that referenced this issue Jun 30, 2021
@Azbesciak
Copy link

Maybe some workaround for this? This is still an issue, I have a similar error, but I suppose the reason is the same

Could not create task ':my-project:collectReachabilityMetadata'.
   > Cannot set the value of task ':my-project:collectReachabilityMetadata' property 'metadataService' of type org.graalvm.buildtools.gradle.internal.GraalVMReachabilityMet
adataService using a provider of type org.graalvm.buildtools.gradle.internal.GraalVMReachabilityMetadataService.

@Azbesciak
Copy link

Azbesciak commented Jan 26, 2023

Stack trace from above in the file
reachability_metadata.txt

I noticed that it occurs when there are multiple projects which use that, but there is some dependency between them, and at the same time maybe others' plugins' versions differ

@camwardy
Copy link

camwardy commented Jun 1, 2023

@Azbesciak did you ever find a solution to this? I'm experiencing the same error you were. Thanks

@Azbesciak
Copy link

Azbesciak commented Jun 3, 2023

@w4rdy I suppose it was because of different versions of pluggins (as mentioned); I have monorepo with multiple spring apps with shared build.gradle as a base, and then each has its own extension (which is optional, same to libs inside that project).
The project which is in the log was different, it was based on the spring cloud - had its own BOM, different deps.
When I made that bom shared (it was anyway adviced and common in a spring projects on initializr), also made other deps, which could have conflicts, the same, it has gone - as I remember, but it was quite a long time ago and I had a maraton of bugs and solutions to integrate spring boot native

tcibinan added a commit to tcibinan/microservices-intro that referenced this issue Aug 24, 2023
@bpstelios10
Copy link

@camwardy i just faced the same issue. i had to extract the apply plugin to the root build.gradle, in subprojects and this error was resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle-bug Bug in Gradle itself
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants