yshrsmz / buildkonfig Goto Github PK
View Code? Open in Web Editor NEWBuildConfig for Kotlin Multiplatform Project
License: Apache License 2.0
BuildConfig for Kotlin Multiplatform Project
License: Apache License 2.0
Currently, if we need to use BuildKonfig from different module, it is not visible since BuildKonfig
is generated internal, maybe we can make this optional, since it causes repeated setups in different modules
Hi
How can I do the buildkonfig
in the Gradle Kotlinscript variant ?
buildkonfig { }
gives me a syntax error obviously
Hi, it would be great to add nullable support. Any thoughts about this? If help is needed I could try.
Thanks for BuildKonfig, it continues to be an essential tool for KMP App Development! โค๏ธ
I was happy to see continued maintenance with a 0.10.0
release:
Unfortunately, this new version has a bug for my project.
Gradle Sync fails with the error:
Duplicate content roots detected:
Path [/Users/me/project/client/build/buildkonfig/commonMain] of module
[project.client.commonMain] was removed from modules [project.client.materialComposeMain]
(I've redacted my actual username and project name but the pattern is preserved)
This prevents working with the project.
If I change only the BuildKonfig dependency back to 0.9.0
, everything works as expected.
My project has quite a nested module structure; perhaps you've changed some code related to adding source-set paths to modules that has caused it to add to multiple source-sets unnecessarily?
Not sure the DSL below is possible, but something like this
buildKonfig {
defaultConfigs {
// load all values as string
fromProperties file('./secrets.properties') {
// specify type
propertyAs type: 'INT', key: 'KEY_OF_PROPERTY'
// also specify different name
propertyAs type: 'LONG', key: 'key.of.other', name: 'DIFFERENT_NAME'
}
// you can also add other stuff as usual
buildKonfigField('STRING', 'FOO', 'bar')
}
}
Hello ๐
I had a KMP module which has only JVM target enabled, but since BuildKonfig is generating the class in commonMain
I had to add
val commonMain by getting
val commonTest by getting
val jvmMain by getting {
dependsOn(commonMain)
...
}
val jvmTest by getting {
dependsOn(commonTest)
...
}
Maybe we can configure the place that BuildKonfig
is generated ?
Currently the multiplatform plugin is required to use BuildKonfig. It would be nice to be able to use BuildKonfig in non-multiplatform projects as well, namely in standalone JVM, JS, or Native projects that use the other respective Kotlin plugins.
It turned out that I haven't registered this plugin to there:P
Hey,
Thanks for your effort and great tool. I tried to add to my compose playgrond project JS MPP target, using latest version 0.11.0 of BuildKonfig got this error during project sync:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':common' Caused by: java.lang.IllegalStateException: non-flavored defaultConfigs must be provided. at com.codingfeline.buildkonfig.gradle.BuildKonfigSpecKt.mergeConfigs(BuildKonfigSpec.kt:29)
Reproducible on this branch in my project:
https://github.com/mariuszmarzec/todo/tree/feature/js_support
Because editing gradle.properties
is error-prone.
It is intended to be version-controlled, so avoid editing it if possible.
First of all, thanks so much for an awesome library!
I have a KMM project that was upgraded to Kotlin v1.5.31 recently. With that release came support for generating an XCFramework that can be consumed from the iOS app, which is awesome since it lets you bundle up different app variants like one for the simulator and one for physical devices.
Previously I would use BuildKonfig and its targetConfigs
option to create fields for different platforms, ios
among them. This worked fine on Kotlin v1.5.10. After upgrading to v1.5.31, the fields in the defaultConfigs
are found, but not the ones in targetConfigs
.
Hi,
I'm trying to setup BuildKonfig in our app, but the generated file is not being updated running the generator command.
Below is my setup and would be kind to know if my setup is wrong.
Thanks in advance.
// build.gradle.ktx
...
buildkonfig {
packageName = "com.foo.bar"
// default config is required
defaultConfigs {
buildConfigField(Type.STRING, "OAUTH_CLIENT_ID", "")
buildConfigField(Type.STRING, "OAUTH_CLIENT_SECRET", "")
}
}
# gradle.properties
OAUTH_CLIENT_ID=foo
OAUTH_CLIENT_SECRET=bar
// Generated file
import kotlin.String
internal object BuildKonfig {
val OAUTH_CLIENT_ID: String = ""
val OAUTH_CLIENT_SECRET: String = ""
}
Ran into issue now that we have switched to KMM hierarchical project support and I see in the change log that you supposedly support it. However the readme was never updated explaining how to do it and in fact it says that it is not supported.
Some thing like Android's product flavor could be useful.
But since Kotlin MPP does not support it, we need to come up with some workaround.
buildkonfig {
targetConfigs {
android {
flavor = "dev"
}
android {
flavor = "release"
}
ios {
flavor = "dev"
}
ios {
flavor = "release"
}
}
}
copied from #61 (comment), by @TobiasPr
Why did you decide that the hierarchical higher source set always has precedence? I think this is counter intuitive. I think about as inheritance in which lower hierarchical source set inherits the props from the higher source set, but it should still be able to set a more specific value
right now we have a sourceset hierarchy like this:
commonMain/
โโ jvmMain/
โโโ androidMain/
โโ iosMain/
for androidMain the buildkonfig is not generated - only for the jvmMain
Hi,
Our buildkonfig
configuration has grown to 115 lines of code (with formatting), so we extract it to another gradle file.
However, applying this plug-in to our shared/build.gradle
fails our build with an exception.
buildkonfig
to a separate gradle file, e.i. buildkonfig.gradle
in our case.apply(from = "$rootDir/gradle/buildkonfig.gradle")
in shared/build.gradle file
./gradlew build
should produce the error below:FAILURE: Build failed with an exception.
* Where:
Build file '/Users/kamara/sandbox/kmm-app/app/shared/build.gradle.kts' line: 133
* What went wrong:
A problem occurred evaluating script.
> No signature of method: buildkonfig_bpv4u8f025ackfhk6ga5bwbu6.buildkonfig() is applicable for argument types: (buildkonfig_bpv4u8f025ackfhk6ga5bwbu6$_run_closure1) values: [buildkonfig_bpv4u8f025ackfhk6ga5bwbu6$_run_closure1@5dd086a8]
It's not possible to enable Gradle configuration Cache in projects using BuildKonfig
.
When i have in root gradle.properties
file:
org.gradle.unsafe.configuration-cache=true
I get these errors during build
Configuration cache problems found in this build.
86 problems were found storing the configuration cache.
- Task `:shared:accountNavigation:generateBuildKonfig` of type `com.codingfeline.buildkonfig.gradle.BuildKonfigTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
See https://docs.gradle.org/7.4.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:shared:action:generateBuildKonfig` of type `com.codingfeline.buildkonfig.gradle.BuildKonfigTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
...
See https://docs.gradle.org/7.4.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
plus 71 more problems. Please see the report for details.
It'd seem that since 0.10.1
the java compatibility has been broken.
Kotlin: 1.5.30
Gradle: 7.2
BuildKonfig: since 0.10.1
Gradle JVM : 1.8
As soon as I enable the Config file generation, even with no fields defined, the task compileProductionExecutableKotlinBrowser
yields error:
java.lang.AssertionError: Unexpected field without property myapp.MyConfig.$stable
at org.jetbrains.kotlin.ir.backend.js.export.ExportModelGenerator.exportClass(ExportModelGenerator.kt:177)
at org.jetbrains.kotlin.ir.backend.js.export.ExportModelGenerator.exportDeclaration(ExportModelGenerator.kt:58)
at org.jetbrains.kotlin.ir.backend.js.export.ExportModelGenerator.generateExport(ExportModelGenerator.kt:34)
at org.jetbrains.kotlin.ir.backend.js.export.ExportModelGenerator.generateExport(ExportModelGenerator.kt:47)
at org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformer.generateModule(IrModuleToJsTransformer.kt:46)
at org.jetbrains.kotlin.ir.backend.js.CompilerKt.compile(compiler.kt:123)
at org.jetbrains.kotlin.ir.backend.js.CompilerKt.compile$default(compiler.kt:36)
at org.jetbrains.kotlin.cli.js.K2JsIrCompiler.doExecute(K2JsIrCompiler.kt:256)
at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:182)
at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:75)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:90)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1575)
at jdk.internal.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
sometimes it requires two sync until it recognize directories as source sets
For iOS, we have to create a target for the simulator (iosX64) and the device (iosArm64/iosArm32). I'm merging them through:
val iosX64 = iosX64()
val iosArm64 = iosArm64("ios")
android()
configure(listOf(iosX64, iosArm64)) {
binaries {
framework(frameworkName) {
baseName = frameworkName
}
}
}
val commonMain by sourceSets.getting {
dependencies {
...
}
}
val iosX64Main by sourceSets.getting
val iosMain by sourceSets.getting {
iosX64Main.dependsOn(this)
dependencies {
...
}
}
Problem is, buildkonfig generates for both the targets but since iosX64 is dependent on iosArm64, it produces an redeclaration error. Is there any way we can ignore some of the targets?
For example :
internal object BuildKonfig {
val FOOD_API_KEY: String = "1234"
}
why value not const?
plugins {
// ..
id("com.codingfeline.buildkonfig") version "0.7.0"
}
buildkonfig {
packageName = "app.mobius.feature"
defaultConfigs { }
targetConfigs { // ERROR
android{ }
}
}
kotlin {
android()
}
DefaultConfigs
is working but targetConfigs
generate the following error:
* What went wrong:
Script compilation errors:
Line 42: targetConfigs {
^ Type mismatch: inferred type is () -> Unit but Closure<*> was expected
* Exception is:
ScriptCompilationException(errors=[ScriptCompilationError(message=Type mismatch: inferred type is () -> Unit but Closure<*> was expected, location=/tmp/gradle-kotlin-dsl-2843013171482525738.tmp/build.gradle.kts (42:19)), ScriptCompilationError(message=Type mismatch: inferred type is () -> Unit but Closure<*> was expected, location=/tmp/gradle-kotlin-dsl-2843013171482525738.tmp/build.gradle.kts (59:19))])
at org.gradle.kotlin.dsl.support.KotlinCompilerKt.compileKotlinScriptModuleTo(KotlinCompiler.kt:177)
.....
Hi, maybe you can use const for generated config objects? Otherwise, you will not be able to make other constants. Constants will allow you to discard chunks of test code that should not be build for a production code.
internal object BuildKonfig {
val FLAVOR: String = "dev"
}
->
internal object BuildKonfig {
const val FLAVOR: String = "dev"
}
This is a pretty niche use case, but with Kotlin 1.4's generated TypeScript definitions only top level declarations marked with @JsExport
will be included.
In my case, I am building a web client in TypeScript (rather than use Kotlin/JS) that makes use of a shared multiplatform module that depends on some API keys that are set through a BuildKonfig object.
Naturally, this would depend on #31.
Dear Sir
as README Product Flavor session
the plugin can set BuildType & ProductFlavor
if want modify sourceSets ?
like this older plugin https://github.com/turnsk/gradle-java-flavours
let we set different sourceSets at java/kotlin ( like at spring boot !!)
if this plugin can do it
have any demo ?
THX
Dear Sir
as this project - https://github.com/bennyhuo/hello-kni
can use kotlin native to JNI ( kotlin --> c --> JNI --->Android/JVM)
when call JNI System.loadLibrary is "knlib" , that define at sharedLib in build.gradle.kts
if use BuildKonfig to define a String buildConfigField like "JNI_NAME_PREFIX" value is "knlib"
we will get buildConfigField at app
but it can not work
THX
Hi. During first build, plugin generates expect object BuildKonfig (commonMain) and actual object BuildKonfig (androidMain+jvmMain) and everything works fine. But during second build (without any changes) it regenerates expect object in commonMain to actual object so build fails due to missing expect object and redeclaration of actual objects.
Below is part of my build.gradle file.
apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'com.android.library'
apply plugin: 'com.codingfeline.buildkonfig'
kotlin {
android {
compilations.all {
kotlinOptions.jvmTarget = rootProject.ext.javaVersion
}
}
jvm()
sourceSets {
all {
languageSettings {
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
optIn("kotlin.RequiresOptIn")
}
}
commonMain {}
jvmMain {}
androidMain {}
androidRc {}
androidRelease {}
}
}
buildkonfig {
packageName = project.PACKAGE
defaultConfigs {
buildConfigField "BOOLEAN", "ABC", "true", const: true
}
targetConfigs {
android {
buildConfigField "BOOLEAN", "ABC", "true", const: true
}
jvm {
buildConfigField "BOOLEAN", "ABC", "false", const: true
}
}
}
we need to delete buildkonfig
dir before generating objects
In Android, BuildConfig
holds a DEBUG
variable we can use to check the build type.
Can we have this? Would be useful for some cases like enabling Ktor's Logging on debug build but not on release builds.
When adding a js(IR)
target
plugins {
kotlin("multiplatform")
id("com.android.library")
id("com.codingfeline.buildkonfig")
}
kotlin {
android()
...
iosTarget("ios") { ... }
js(IR) {
browser()
}
sourceSets {
val commonMain by getting
val androidMain by getting
val iosMain by getting
val jsMain by getting
}
}
configure<com.codingfeline.buildkonfig.gradle.BuildKonfigExtension> {
packageName = "com.sample.buildkonfig.issues"
defaultConfigs {
buildConfigField(STRING, "VERSION", "mysupersecretpassword")
}
}
throws during sync
Caused by: java.lang.IllegalArgumentException: packageName must be provided
even when the packageName
is provided
Minimal working example here: https://github.com/xxfast/BuildKonfig-Issues
Or download here:
BuildKonfig-Issues-master.zip
full sync stacktrace:
org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':shared:generateBuildKonfig'.
at org.gradle.api.internal.tasks.DefaultTaskContainer.taskCreationException(DefaultTaskContainer.java:719)
at org.gradle.api.internal.tasks.DefaultTaskContainer.access$600(DefaultTaskContainer.java:77)
at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreatingProvider.domainObjectCreationException(DefaultTaskContainer.java:711)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection$AbstractDomainObjectCreatingProvider.tryCreate(DefaultNamedDomainObjectCollection.java:948)
at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreatingProvider.access$1401(DefaultTaskContainer.java:658)
at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreatingProvider$1.run(DefaultTaskContainer.java:684)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
at org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreatingProvider.tryCreate(DefaultTaskContainer.java:680)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection$AbstractDomainObjectCreatingProvider.calculateOwnValue(DefaultNamedDomainObjectCollection.java:929)
at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateValue(AbstractMinimalProvider.java:103)
at org.gradle.api.internal.provider.Collectors$ElementFromProvider.collectEntries(Collectors.java:98)
at org.gradle.api.internal.provider.Collectors$TypedCollector.collectEntries(Collectors.java:329)
at org.gradle.api.internal.provider.Collectors$TypedCollector.collectInto(Collectors.java:324)
at org.gradle.api.internal.collections.DefaultPendingSource.realize(DefaultPendingSource.java:61)
at org.gradle.api.internal.collections.DefaultPendingSource.realizePending(DefaultPendingSource.java:39)
at org.gradle.api.internal.collections.SortedSetElementSource.iterator(SortedSetElementSource.java:63)
at org.gradle.api.internal.DefaultDomainObjectCollection.iterator(DefaultDomainObjectCollection.java:130)
at org.gradle.api.internal.tasks.DefaultTaskContainer.iterator(DefaultTaskContainer.java:624)
at org.jetbrains.kotlin.gradle.KotlinMPPGradleModelBuilder.buildTestRunTasks(KotlinMPPGradleModelBuilder.kt:1114)
at org.jetbrains.kotlin.gradle.KotlinMPPGradleModelBuilder.buildTarget(KotlinMPPGradleModelBuilder.kt:340)
at org.jetbrains.kotlin.gradle.KotlinMPPGradleModelBuilder.buildTargets(KotlinMPPGradleModelBuilder.kt:258)
at org.jetbrains.kotlin.gradle.KotlinMPPGradleModelBuilder.buildAll(KotlinMPPGradleModelBuilder.kt:59)
at org.jetbrains.plugins.gradle.tooling.internal.ExtraModelBuilder.buildAll(ExtraModelBuilder.java:115)
at org.jetbrains.plugins.gradle.tooling.internal.ExtraModelBuilder.buildAll(ExtraModelBuilder.java:80)
at org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry$BuilderWithParameter.build(DefaultToolingModelBuilderRegistry.java:192)
at org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry$LockSingleProjectBuilder.lambda$build$0(DefaultToolingModelBuilderRegistry.java:211)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$withProjectLock$3(DefaultProjectStateRegistry.java:310)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:213)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:310)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.fromMutableState(DefaultProjectStateRegistry.java:291)
at org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry$LockSingleProjectBuilder.build(DefaultToolingModelBuilderRegistry.java:211)
at org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry$BuildOperationWrappingBuilder$1.call(DefaultToolingModelBuilderRegistry.java:246)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
at org.gradle.tooling.provider.model.internal.DefaultToolingModelBuilderRegistry$BuildOperationWrappingBuilder.build(DefaultToolingModelBuilderRegistry.java:243)
at org.gradle.tooling.internal.provider.runner.DefaultBuildController.getModel(DefaultBuildController.java:102)
at org.gradle.tooling.internal.consumer.connection.ParameterAwareBuildControllerAdapter.getModel(ParameterAwareBuildControllerAdapter.java:39)
at org.gradle.tooling.internal.consumer.connection.UnparameterizedBuildController.getModel(UnparameterizedBuildController.java:113)
at org.gradle.tooling.internal.consumer.connection.NestedActionAwareBuildControllerAdapter.getModel(NestedActionAwareBuildControllerAdapter.java:31)
at org.gradle.tooling.internal.consumer.connection.UnparameterizedBuildController.findModel(UnparameterizedBuildController.java:97)
at org.gradle.tooling.internal.consumer.connection.NestedActionAwareBuildControllerAdapter.findModel(NestedActionAwareBuildControllerAdapter.java:31)
at org.gradle.tooling.internal.consumer.connection.UnparameterizedBuildController.findModel(UnparameterizedBuildController.java:81)
at org.gradle.tooling.internal.consumer.connection.NestedActionAwareBuildControllerAdapter.findModel(NestedActionAwareBuildControllerAdapter.java:31)
at org.jetbrains.plugins.gradle.model.ProjectImportAction$MyBuildController.findModel(ProjectImportAction.java:542)
at org.jetbrains.plugins.gradle.model.ClassSetProjectImportModelProvider.populateProjectModels(ClassSetProjectImportModelProvider.java:31)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.addProjectModels(ProjectImportAction.java:201)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:114)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:41)
at org.gradle.tooling.internal.consumer.connection.InternalBuildActionAdapter.execute(InternalBuildActionAdapter.java:64)
at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner$ActionRunningListener.runAction(AbstractClientProvidedBuildActionRunner.java:134)
at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner$ActionRunningListener.buildFinished(AbstractClientProvidedBuildActionRunner.java:119)
at jdk.internal.reflect.GeneratedMethodAccessor324.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:398)
at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:380)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:61)
at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:368)
at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:355)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:43)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:245)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:157)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:61)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:346)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:249)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:141)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at com.sun.proxy.$Proxy18.buildFinished(Unknown Source)
at org.gradle.initialization.DefaultGradleLauncher.finishBuild(DefaultGradleLauncher.java:196)
at org.gradle.initialization.DefaultGradleLauncher.finishBuild(DefaultGradleLauncher.java:132)
at org.gradle.internal.invocation.GradleBuildController$1.create(GradleBuildController.java:72)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:213)
at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:67)
at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:56)
at org.gradle.tooling.internal.provider.runner.AbstractClientProvidedBuildActionRunner.runClientAction(AbstractClientProvidedBuildActionRunner.java:53)
at org.gradle.tooling.internal.provider.runner.ClientProvidedPhasedActionRunner.run(ClientProvidedPhasedActionRunner.java:47)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:66)
at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at org.gradle.tooling.internal.provider.FileSystemWatchingBuildActionRunner.run(FileSystemWatchingBuildActionRunner.java:90)
at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:41)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:49)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:44)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:44)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.lambda$execute$0(InProcessBuildActionExecuter.java:59)
at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:86)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:58)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.lambda$execute$0(BuildTreeScopeLifecycleBuildActionExecuter.java:34)
at org.gradle.internal.buildtree.BuildTreeState.run(BuildTreeState.java:53)
at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.execute(BuildTreeScopeLifecycleBuildActionExecuter.java:33)
at org.gradle.launcher.exec.BuildTreeScopeLifecycleBuildActionExecuter.execute(BuildTreeScopeLifecycleBuildActionExecuter.java:28)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:104)
at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:55)
at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:64)
at org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:37)
at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildActionExecuter.lambda$execute$0(SessionScopeLifecycleBuildActionExecuter.java:54)
at org.gradle.internal.session.BuildSessionState.run(BuildSessionState.java:67)
at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildActionExecuter.execute(SessionScopeLifecycleBuildActionExecuter.java:50)
at org.gradle.tooling.internal.provider.SessionScopeLifecycleBuildActionExecuter.execute(SessionScopeLifecycleBuildActionExecuter.java:36)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:59)
at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:31)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:58)
at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:47)
at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:31)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:65)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:29)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:84)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalArgumentException: packageName must be provided
at com.codingfeline.buildkonfig.gradle.BuildKonfigPlugin$configure$3$task$1.execute(BuildKonfigPlugin.kt:68)
at com.codingfeline.buildkonfig.gradle.BuildKonfigPlugin$configure$3$task$1.execute(BuildKonfigPlugin.kt:16)
at org.gradle.api.internal.DefaultMutationGuard$2.execute(DefaultMutationGuard.java:44)
at org.gradle.api.internal.DefaultMutationGuard$2.execute(DefaultMutationGuard.java:44)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:100)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:95)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:92)
at org.gradle.internal.ImmutableActionSet$SetWithManyActions.execute(ImmutableActionSet.java:329)
at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:264)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection.doAdd(DefaultNamedDomainObjectCollection.java:113)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:258)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection$AbstractDomainObjectCreatingProvider.tryCreate(DefaultNamedDomainObjectCollection.java:944)
... 165 more
I think it isn't
The readme shows the old way to configure the plugin using classpath inside buildscript, but since you are publishing in the gradle plugin portal there is no reason to so it that way. The readme should reflect the prefered way using the new plugin syntax.
When using Multiple KMM Modules in one Project like
And one of those modules use BuildKonfig
then there is a build\generated\resource\buildConfig\debug\packagename\BuilConfig.kt
file foreach Module which results in :androidApp:mergeLibDexDebug FAILED
it's much cleaner
Object is generated as internal. To use it from the iOS or Android app requires adding another layer to expose the values. Add an option to generate it as public.
blocked by #36
related: #56
Kotlin 1.4.0 adds support for the hierarchical project structure.
So how can we support this?
kotlin {
jvm()
ios()
}
buildkonfig {
defaultConfigs {
buildConfigField 'STRING', 'commonField', 'commonValue'
}
targetConfigs {
ios {
buildConfigField 'STRING', 'iosField', 'iosValue'
}
}
}
Say I have a configuration above.
Currently, BuildKonfig does not generate an object for iosMain
, simply ignore it as there's no target named ios
. We need to declare iosX64
and iosArm64
in targetConfigs
.
To generate objects for intermediate SourceSets, we need to check SourceSets' dependencies.
In BuildKonfigPlugin
,
targets.filter { it.name != "metadata" }.forEach { target ->
val name = "${target.name}Main"
val sourceSetMain = sourceSets.getByName(name)
// !!!!
val dependentSourceSets = sourceSetMain.dependsOn.filter { it.name != "commonMain" }
println(dependentSourceSets)
val outDirMain = File(outputDirectory, name).also { it.mkdirs() }
sourceSetMain.kotlin.srcDirs(outDirMain.toRelativeString(project.projectDir))
outputDirectoryMap[TargetName(target.name, target.platformType.toKgqlPlatformType())] = outDirMain
}
If target is iosX64
and that is defined via ios()
, this dependentSourceSets
should have a iosMain
SourceSets.
Currently, everything that is generated is added into a single object. That sounds reasonable but we may want to group certain things and seperate from eachother, maybe we can introduce a name
into config and use this name to name generated objects
like this
configure<BuildKonfigExtension> {
packageName = "${ProjectSettings.PROJECT_ID}.common"
name = "VersionBuildKonfig"
defaultConfigs {
buildConfigField(STRING, "VERSION", project.getVersion(), const = true)
}
}
configure<BuildKonfigExtension> {
packageName = "${ProjectSettings.PROJECT_ID}.common"
name = "ApiBuildKonfig"
defaultConfigs {
buildConfigField(STRING, "BASE_URL", "www.asd.com", const = true)
}
}
Additionally, this request will also make sense after we implement: #74 Since we may want to make some Konfigs internal while some public
I'm converting this issue to a generic discussion, as it becomes out of control as a feature-tracking issue.
to implement #31, we first need to add an option to change the name the generated object.
API could be
buildkonfig {
packageName = 'com.example.app'
objectName = 'AwesomeConfig' // defaults to 'BuildKonfig'
defaultConfigs {
buildConfigField 'STRING', 'name', 'value'
}
}
๐ค
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.