Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Produce on test sources #962

Open
charbgr opened this issue Apr 20, 2022 · 4 comments
Open

Question: Produce on test sources #962

charbgr opened this issue Apr 20, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@charbgr
Copy link

charbgr commented Apr 20, 2022

Hello folks!

Is there a way to produce classes from main sources to test sources?

A usecase for this is to create helper classes for testing base on the main sources e.g. fixture creation

Thanks!

@neetopia
Copy link
Collaborator

How about adding the generated folder into your test source set in build script?

@charbgr
Copy link
Author

charbgr commented May 25, 2022

@neetopia this is not what I want! The drawback of this solution is that these generated classes can be used from main sources and this is not the expected behavior! I want these classes to be used only from test sources!

@neetopia
Copy link
Collaborator

neetopia commented Jun 9, 2022

I've got a similar request on slack as well. Will try to prioritize this in near future.

@neetopia neetopia added the enhancement New feature or request label Jun 9, 2022
@OliverO2
Copy link

Looks like if #1021 would be accepted (and later enhanced to cover Android builds), it would provide the configuration infrastructure to specify an output source set per compilation. Then, the configuration for main could contain something like this:

sourceSets {
    val main by getting {
        ksp {
            processor(project(":test-processor"))
            outputSourceSet = "debugUnitTest"
        }
    }
}

But maybe we'll even see use cases where multiple output source sets are required. In this case, the KSP Gradle plugin could set up proper dependencies, and pass the configured output source sets to the compiler plugin and processor. The processor could then decide which output source set to use for each piece of code to generate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants