Correct way of setting group/version for multi-module project? (failure to build KMM: compileKotlinIosArm64 / compileKotlinIosSimulatorArm64)

(I decided to extract this from another topic to avoid keeping off-topic there)

Finally managed to get back to it (had to dig more into gradle and do “a little bit” of refactoring of our project :slight_smile: ).

Now I have better understanding of how gradle works and your point about allprojects { … } was very helpful.

Now the plugin/extension works quite nicely but I have a question about allprojects {} and setting of group/version. You said it would be best to set it in gradle.properties and it seems reasonable but when I set it like that one of the modules (kotlin multi platform for iOS) fails with “can’t find group”:

> Task :common:service:compileKotlinIosSimulatorArm64 FAILED
Caching disabled for task ':common:service:compileKotlinIosSimulatorArm64' because:
  Build cache is disabled
Task ':common:service:compileKotlinIosSimulatorArm64' is not up-to-date because:
  Task has failed previously.
file or directory '/Users/wojtek/dev/myproject/common/service/src/iosSimulatorArm64Main/kotlin', not found
file or directory '/Users/wojtek/dev/myproject/common/service/src/appleMain/kotlin', not found
file or directory '/Users/wojtek/dev/myproject/common/service/src/nativeMain/kotlin', not found
file or directory '/Users/wojtek/dev/myproject/common/service/src/iosSimulatorArm64Main/kotlin', not found
file or directory '/Users/wojtek/dev/myproject/common/service/src/appleMain/kotlin', not found
file or directory '/Users/wojtek/dev/myproject/common/service/src/nativeMain/kotlin', not found
file or directory '/Users/wojtek/dev/myproject/common/service/src/iosSimulatorArm64Main/kotlin', not found
file or directory '/Users/wojtek/dev/myproject/common/service/src/appleMain/kotlin', not found
file or directory '/Users/wojtek/dev/myproject/common/service/src/nativeMain/kotlin', not found
Starting process 'command '/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java''. Working directory: /Users/wojtek/dev/myproject/common/service Command: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java -Dfile.separator=/ -Dftp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16 -Dhttp.nonProxyHosts=local|*.local|169.254/16|*.169.254/16 -Djava.awt.headless=true -Djava.class.path=/Users/wojtek/.gradle/wrapper/dists/gradle-8.10.2-bin/a04bxjujx95o3nb99gddekhwo/gradle-8.10.2/lib/gradle-daemon-main-8.10.2.jar -Djava.class.version=61.0 -Djava.home=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home -Djava.library.path=/Users/wojtek/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. -Djava.runtime.name=OpenJDK Runtime Environment -Djava.runtime.version=17.0.14+7 -Djava.specification.maintenance.version=1 -Djava.specification.name=Java Platform API Specification -Djava.specification.vendor=Oracle Corporation -Djava.specification.version=17 -Djava.vendor=Eclipse Adoptium -Djava.vendor.url=https://adoptium.net/ -Djava.vendor.url.bug=https://github.com/adoptium/adoptium-support/issues -Djava.vendor.version=Temurin-17.0.14+7 -Djava.version=17.0.14 -Djava.version.date=2025-01-21 -Djava.vm.compressedOopsMode=Zero based -Djava.vm.info=mixed mode, sharing -Djava.vm.name=OpenJDK 64-Bit Server VM -Djava.vm.specification.name=Java Virtual Machine Specification -Djava.vm.specification.vendor=Oracle Corporation -Djava.vm.specification.version=17 -Djava.vm.vendor=Eclipse Adoptium -Djava.vm.version=17.0.14+7 -Djdk.debug=release -Dkotlin.daemon.jvm.options=-Xmx5g -Dlibrary.jansi.path=/Users/wojtek/.gradle/native/jansi/1.18/osx -Dline.separator=
 -Dnative.encoding=UTF-8 -Dorg.gradle.appname=gradlew -Dorg.gradle.daemon=false -Dorg.jetbrains.kotlin.cliMessageRenderer=GradleStyle -Dos.arch=aarch64 -Dos.name=Mac OS X -Dos.version=15.2 -Dpath.separator=: -DsocksNonProxyHosts=local|*.local|169.254/16|*.169.254/16 -Dsun.arch.data.model=64 -Dsun.boot.library.path=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/lib -Dsun.cpu.endian=little -Dsun.io.unicode.encoding=UnicodeBig -Dsun.java.command=org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.10.2 -Dsun.java.launcher=SUN_STANDARD -Dsun.jnu.encoding=UTF-8 -Dsun.management.compiler=HotSpot 64-Bit Tiered Compilers -Duser.home=/Users/wojtek -Duser.name=wojtek -Duser.timezone=Europe/Madrid -Xmx3G -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/var/folders/5p/f8dxkg916dqbrqb9v0lm18sm0000gn/T/ -Duser.country=PL -Duser.language=es -Duser.variant -ea -cp /Users/wojtek/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.21/konan/lib/kotlin-native-compiler-embeddable.jar:/Users/wojtek/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.21/konan/lib/trove4j.jar org.jetbrains.kotlin.cli.utilities.MainKt konanc @/var/folders/5p/f8dxkg916dqbrqb9v0lm18sm0000gn/T/kotlinc-native-args1778648734368371337.lst
Successfully started process 'command '/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java''
Failed to load native library:libjansi.jnilib. The native library file at /Users/wojtek/.gradle/native/jansi/1.18/osx/libjansi.jnilib is not executable, make sure that the directory is mounted on a partition without the noexec flag, or set the jansi.tmpdir system property to point to a proper location.  osinfo: Mac/arm64
java.lang.UnsatisfiedLinkError: /Users/wojtek/.gradle/native/jansi/1.18/osx/libjansi.jnilib: dlopen(/Users/wojtek/.gradle/native/jansi/1.18/osx/libjansi.jnilib, 0x0001): tried: '/Users/wojtek/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/wojtek/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (no such file), '/Users/wojtek/.gradle/native/jansi/1.18/osx/libjansi.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
e: KLIB resolver: Could not find "org.group.myproject" in [/Users/wojtek/dev/myproject/common/service, /Users/wojtek/.konan/klib, /Users/wojtek/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.21/klib/common, /Users/wojtek/.konan/kotlin-native-prebuilt-macos-aarch64-2.0.21/klib/platform/ios_simulator_arm64]

> Task :common:service:compileKotlinIosArm64 FAILED

If I put group = "org.group.myproject" in every submodule build.gradle.kts then it builds.

Considering that allprojects { ... } is discouraged and setting group/version in gradle.properties results in above error what would be the best way to configure group/version globally?

Imho, if it does not work from the properties file this should be reported to somewhere, because that sounds like a bug to me.

The alternative is to set it in a convention plugin that you apply to all projects.
For group and version it just usually is much easier to just do it in the properties file if they are static values.

Maybe this project helps as a blueprint: GitHub - prof18/RSS-Parser: A Kotlin Multiplatform library to parse a RSS Feed

Probably not a good idea to use that as blueprint, as I see after 2 seconds in its readme and in its own build script the discouraged bad-practice cross-project configuration that you should avoid.

1 Like

Thank you for the clarification. I picked that one because it is successfully published.

Sure, but the whole purpose of the thread is to avoid cross-project configuration. :wink: