Giter VIP home page Giter VIP logo

Comments (6)

StephanSchuster avatar StephanSchuster commented on May 14, 2024 2

Okay, the above is obviously stupid in terms of source sets.
This here seems to work. Is this correct?

app/build.gradle:

kotlin {
    sourceSets {
        debug {
            kotlin.srcDir("build/generated/ksp/debug/kotlin")
        }
        release {
            kotlin.srcDir("build/generated/ksp/release/kotlin")
        }
    }
}

from compose-destinations.

StephanSchuster avatar StephanSchuster commented on May 14, 2024 1

Glad this helped. I you prefer, you can close this issue. On the other hand it would be nice to keep it open until the root cause in KSP is fixed or to track your current status in terms of better solutions (e.g. same location for debug and release).

from compose-destinations.

raamcosta avatar raamcosta commented on May 14, 2024

Is that working? To be honest I have not setup this for multiple variants. But this seems related with the KSP issue and not directly with this library.
Have you looked here?

I'd love to ear from you when you get this to work, it will help me understand this for the next time someone is struggling with the same thing.

from compose-destinations.

StephanSchuster avatar StephanSchuster commented on May 14, 2024

Upfront: I am using Groovy, not kts. I am neither a Gradle expert, nor do I now anything about KSP.

Yes it is working. Actually it is the only setup that I found working for me. But I don't know if this is good or if there are better ways. I would be happy if someone could confirm this.

Yes I had a look at the link you provided.
I wasn't able to transfer the answer from keyboardr to Groovy and my setup.
I tried the answer from Seoung transferred to Groovy without success. Same problem.

android {
    buildTypes {  // not working for me
        debug {
            sourceSets {
                main {
                    kotlin.srcDir("build/generated/ksp/debug/kotlin")
                }
            }
        }
        release {
           ...
            sourceSets {
                main {
                    kotlin.srcDir("build/generated/ksp/release/kotlin")
                }
            }
        }
    }
    ...
}

From my understanding and my tests I can tell the following:

  • when I build with build variant "debug" your code is generated under build/generated/ksp/**debug**/kotlin
  • when I build with build variant "release" your code is generated under build/generated/ksp/**release**/kotlin
  • with any other setup than the one I mentioned is working for me, I cannot get debug AND release to work
  • either because classes are not found for the build variant (because I did not yet build this variant)
  • or because I get the "Redeclaration" error mentioned above (because then both variants are built)

I think it is crucial that debug AND release is working and not just once.

In your readme you are mentioning under setup (3): "main" and ".../debug/..." which I think is wrong or rather only working as long as you only build the debug variant.
In fact I just tried to build your project with debug and release and got the same "Redeclaration" error. Try it yourself.

When I compare the stuff "you" generate under build/generated/ksp/**debug**/kotlin and build/generated/ksp/**release**/kotlin, everything is binary identical. As said, I know nothing about KSP and I don't know if you can/should influence this. But as both folders are identical, it might make sense to ALWAYS generate to e.g. "main" (???) and ALWAYS have this included in the source set independent of the build variant.

from compose-destinations.

raamcosta avatar raamcosta commented on May 14, 2024

Thanks for the elaborate response 👍
I was actually trying myself and I observed the same behaviour you're describing.
I believe your solution appears to be exactly what we want. I'll update my README.md, thank you so much for this 🙂

As far as changing the location to be the same for debug and release, I'll investigate it further, but it seems to me that this is related with this issue that soon should be solved, hopefully. For now, it seems expected, as we see a similar approach done here

Once again, thanks so much for taking the time. If there is anything else I can help with, I'd be glad :)

from compose-destinations.

raamcosta avatar raamcosta commented on May 14, 2024

Closing this issue, since this shouldn't bother anyone now that I updated the Readme. Thank you!

from compose-destinations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.