bytedeco / gradle-javacpp

Gradle plugins to automate the build process of JavaCPP and JavaCV
Other
56 stars 20 forks source link

How can I change javacppPlatform at runtime? #24

Open zxdposter opened 2 years ago

zxdposter commented 2 years ago

I want use macosx-x86_64 on run application, but use linux-x86_64 when package.

These way seems not working.

    parent?.ext?.set("javacppPlatform", "linux-x86_64")
    println(parent?.ext?.get("javacppPlatform"))
    implementation(group = "org.bytedeco", name = "javacpp")
    implementation(group = "org.bytedeco", name = "ffmpeg-platform")
    implementation(group = "org.bytedeco", name = "javacv")

or

tasks {
    "war"(War::class) {
        first {
            parent?.ext?.set("javacppPlatform", "linux-x86_64")
            println(parent?.ext?.get("javacppPlatform"))
            true
        }
        enabled = true
    }
}
saudet commented 2 years ago

Setting the extra property as shown in the README.md file doesn't work?? https://github.com/bytedeco/gradle-javacpp#the-platform-plugin

zxdposter commented 2 years ago

@saudet yes it work, I already used with macosx-x86_64, but I want change when some task run such as package task.

saudet commented 2 years ago

It won't work if you set it after Gradle has resolved the dependencies. You need to make sure to set it before that happens.

zxdposter commented 2 years ago

yes, I noticed that, so I want find a way to solve, have any suggestions?

saudet commented 2 years ago

One way to do that kind thing would be to split your project into multiple subprojects. Then we can do anything we need in the parent project, and only call the subproject for that package task, where we can set javacppPlatform early before it resolves its dependencies.