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

Failure on releasing jni projects #385

Open
abelavusau opened this issue Dec 5, 2023 · 1 comment
Open

Failure on releasing jni projects #385

abelavusau opened this issue Dec 5, 2023 · 1 comment

Comments

@abelavusau
Copy link

abelavusau commented Dec 5, 2023

We have a build consisting of cpp projects and some of those are jni shared libraries with the following build configuration:

release {
    with(git) {
        requireBranch.set("master")
        failOnCommitNeeded.set(false)
        commitVersionFileOnly.set(true)
        tagTemplate.set(project.ext["release.tagTemplate"].toString())
        preTagCommitMessage.set(project.ext["release.preTagCommitMessage"].toString())
        newVersionCommitMessage.set(project.ext["release.newVersionCommitMessage"].toString())
    }
}

val beforeReleaseBuild by tasks.getting
val afterReleaseBuild by tasks.getting

if (tasks.withType(Test::class).isNotEmpty()) {
    beforeReleaseBuild.dependsOn(tasks.test)
}

afterReleaseBuild.dependsOn(tasks.publish)

library {
    source.from("src/main/c++")
    publicHeaders.from("src/main/include")

    binaries.configureEach {
        compileTask.get().compilerArgs.addAll(
            listOf(
                "-I", "${org.gradle.internal.jvm.Jvm.current().javaHome}/include",
                "-I", "${org.gradle.internal.jvm.Jvm.current().javaHome}/include/linux"
            )
        )
    }
}

Running gradle release on the jni project i got:

Failed to notify project evaluation listener.
   > Failed to query the value of property 'compileTask'.
      > Could not create task ':commons-io-jni-release:commons-io-jni:compileTestCpp'.
         > Could not create task of type 'CppCompile'.
            > Could not create service of type DefaultCompilationStateCacheFactory.
               > Cache 'nativeCompile' couldn't be reused because of the following mismatch:
                  * Requested value serializer type (org.gradle.language.nativeplatform.internal.incremental.CompilationStateSerializer) doesn't match current cache type (org.gradle.language.nativeplatform.internal.incremental.CompilationStateSerializer)
   > Failed to query the value of property 'compileTask'.
      > Could not create task ':commons-io-jni-release:commons-io-jni:compileDebugCpp'.
         > Could not create task of type 'CppCompile'.
            > Could not create service of type DefaultCompilationStateCacheFactory.
               > Cache 'nativeCompile' couldn't be reused because of the following mismatch:
                  * Requested value serializer type (org.gradle.language.nativeplatform.internal.incremental.CompilationStateSerializer) doesn't match current cache type (org.gradle.language.nativeplatform.internal.incremental.CompilationStateSerializer)

After this all projects in the build are affected by this issue unless native-build/.gradle cache is deleted and the build is reconfigured again.

@abelavusau abelavusau changed the title Error releasing jni projects Failure on releasing jni projects Dec 5, 2023
@Hillkorn
Copy link
Collaborator

Hillkorn commented Jul 8, 2024

To get an idea what the issue could be here I would need some example project. And some information like gradle & java version that are used here.
What might be an issue that I see is that you use org.gradle.internal.jvm.Jvm.current().javaHome but there is the java toolchain that should be used instead. See https://docs.gradle.org/current/userguide/toolchains.html
It might be that you already use the java toolchain for the java projects which might be a different JDK than what you get by the internal gradle JVM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants