Publish native artifact with id embedding platform information

I’m trying to publish a C++ library to a maven repository using the maven nar artifact naming convention, something like mylib-amd64-windows-msvc.zip. I tried to access targetPlatform from the publishing block but it is not accessible from the block.

publishing {
publications {
maven(MavenPublication) {
group = ‘com.mycom.myproj’
artifactId “myproj-${targetPlatform.architecture}-${targetPlatform.operatingSystem}”
version ‘1.0’
}
}
}

I get the following error:

  • What went wrong:
    A problem occurred configuring root project ‘list’.

Exception thrown while executing model rule: PublishingPluginRules#publishing(ExtensionContainer)
Could not get unknown property ‘targetPlatform’ for object of type org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication.