gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
91 stars 8 forks source link

Error while publishing cmake-library build to local repo. #1054

Closed HarrisDePerceptron closed 4 years ago

HarrisDePerceptron commented 4 years ago

Trying to publish the sample cmake-library project to local repo. tried both with maven-publish plugin and org.gradle.samples.custom-publication but both failed.

Expected Behavior

Was expecting the cmake specific library (list) to publish to local directory repo successfully.

Current Behavior

`Execution failed for task ':list:generateMetadataFileForMainPublication'.

Invalid publication 'main':

  • Variants 'debugLink' and 'releaseLink' have the same attributes and capabilities. Please make sure either attributes or capabilities are different.
  • Variants 'debugRuntime' and 'releaseRuntime' have the same attributes and capabilities. Please make sure either attributes or capabilities are different. `

    Context

    The thing i am trying to do is publish our current c++ 3rd party dependencies (which mostly uses cmake) to any gradle compatible repo so that it can be consumed by our main c++ project or any other project for that matter.

    Steps to Reproduce (for bugs)

    Just launch the publish command in cmake-library root ./gradlew publish

    Your Environment

  • Build scan URL: Build scan url : https://scans.gradle.com/s/2ot6auxbnq4qy
lacasseio commented 4 years ago

Thanks for reporting the issue with the sample. Could you give it another try? There were broken, it should work now.

HarrisDePerceptron commented 4 years ago

Thanks @lacasseio for your swift response. what you are doing here is truly revolutionary. I tried the updated plugin and now there is no build variant issue anymore. It builds and publishes just fine. I have question, don't know if i should ask it here or not, i am going to ask anyway:

Q1: How can can you pass cmake plugin build arguments: -DBUILD_WHATEVER=< value > my guess is something like this :

cmake {
  ....
  arguments.set("-DBUILD_WHATEVER=<value>")
}

Q2: How do you handle multiple binaries (.so or .a) that the cmake produces? I am trying to build opencv with gradle cmake plugin, it produces many .so files, how do you define those here:

cmake {
    binary.set("libopencv_core.so") //one of the .so file
   ...    
}

these binary lib files definitions are needed by the publishing plugin