Is there a way to run ksp on all targets when I cl...
# ksp
d
Is there a way to run ksp on all targets when I click the build button in Android Studio? Say I wrote this code in iosMain:
Copy code
@Component
abstract class Foo {
  companion object
}

@KmpComponentCreate
expect fun Foo.Companion.createComponent(): Foo
This is using kotlin-inject KSP to generate through
KmpComponentCreate
actuals for that function. This code complains that the actual function do not exist until I manually build the whole project. I tried with
gradle build
task but it takes a really long time due to tasks like the
linkReleaseFrameworkIosArm64
. Questions: • Is there any task I could run to build those parts for every module in my project? • Is there any way to do that when I press Android Studio build button?
e
I'm not at my computer so I can't check, but I'm pretty sure you can run a gradle command as part of your run configuration. If you could, then you can run the
kspKotlin<target>
tasks.
d
Hi @eygraber thank you for your answer and sorry for the late reply. Yes, I can run command in configuration. I was hoping I could kinda configure it somewhere to make it transparent to my current run configuration. Kinda like the default Gradle-Aware-Make knows what to do. I’m trying to bring my iOS coworkers into KMP and any additional annoyance that requires more stuff to learn is annoying.
e
Not sure if there's any other way, but you could check in a run configuration via
.idea
that is set up to do this automatically.
d
Sorry, where would I check that in .idea? the runConfiguration.xml doesn’t contain much:
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="RunConfigurationProducerService">
    <option name="ignoredProducers">
      <set>
        <option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
        <option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
        <option value="com.intellij.execution.junit.PatternConfigurationProducer" />
        <option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
        <option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
        <option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
        <option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
        <option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
      </set>
    </option>
  </component>
</project>
e
Hmm I thought there was a way to describe the configuration there 🤔
d
I just think that if the IDE has support for KMP it should do what makes sense for KMP. If the code show me an error (in this case multiplatform code in iOS) due to missing compilation it should go away when I hit the “build” button on the top of the IDE. Maybe I should create a bug report for Intellij itself
but I’m using Android Studio so I’m not sure if this issue is specific to AS