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

Add a way to exclude generated classes implementing an annotated interface #332

Open
NinoDLC opened this issue Mar 31, 2023 · 4 comments
Open
Assignees
Labels
Feature Feature request issue type Implement in KGP

Comments

@NinoDLC
Copy link
Contributor

NinoDLC commented Mar 31, 2023

What is your use-case and why do you need this feature?
On Android, Room uses DAO interfaces to generate SQL related code at compile time. Example:

ProjectDao.kt (source code)

package fr.delcey.todok.data.dao

// imports...

@Dao
interface ProjectDao {
    // code
}

ProjectDao_Impl.java (generated)

package fr.delcey.todok.data.dao;

// imports...

@SuppressWarnings({"unchecked", "deprecation"})
public final class ProjectDao_Impl implements ProjectDao {
  // generated code...
}

Describe the solution you'd like
I don't really know, maybe add a way to exclude classes that implement an annotated interface (@Dao in this case) ?

Another solution would be to be able to ignore every class in the generated folder but I guess Kover doesn't have this kind of information available. Another solution would be to update Room in order to annotate their generated classes with @Generated, but I don't know if it's common for this kind of lib.

@NinoDLC NinoDLC added Feature Feature request issue type S: untriaged Status: issue reported but unprocessed labels Mar 31, 2023
@shanshin
Copy link
Collaborator

Hi,
is it acceptable for you to add an exclusion filter like *Dao_Impl?

An exception by inheritance can be added, but this will require a more flexible way of writing filters, which may be added sometime in the future.

@shanshin shanshin added S: waiting for clarification Status: additional information required to proceed and removed S: untriaged Status: issue reported but unprocessed labels Apr 11, 2023
@NinoDLC
Copy link
Contributor Author

NinoDLC commented Apr 12, 2023

Yes I was mainly basing my excludes with suffixes but it's not 100% resilient (typo, rename, new architecture convention, etc).

This is not a huge issue ATM, and if the DSL to configure is too hard to maintain / configure, this may be a bad idea.

But would a more flexible way to add filters be considered, I hope "filtering by heritance of annotated interface" will make it.

@shanshin shanshin added Design needed S: postponed Status: work on the issue is not in the short term plans and removed S: waiting for clarification Status: additional information required to proceed labels Apr 21, 2023
@shanshin
Copy link
Collaborator

shanshin commented Sep 20, 2023

Relates #454

@shanshin
Copy link
Collaborator

shanshin commented Jan 3, 2025

This task will be taken into account when migrating to Kotlin Gradle Plugin.

In the future, it will be moved to the Kotlin task tracker, or closed if it loses relevance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature request issue type Implement in KGP
Projects
None yet
Development

No branches or pull requests

3 participants
@shanshin @NinoDLC and others