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

allow multiple interfacePackages or simply scan recursively from a wildcarded package path #8

Open
SingingBush opened this issue Jun 29, 2023 · 3 comments

Comments

@SingingBush
Copy link

Hi, I've setup interfacer to process some generated java files that are output by the gradle-avro-plugin

plugins {
    id 'java-library'
    id 'maven-publish'
    id "com.github.davidmc24.gradle.plugin.avro-base" version "1.7.1"
    id "io.github.tunguski.interfacer" version "0.0.7"
}

...

tasks.register("avroInterfacer", pl.matsuo.interfacer.gradle.InterfacerTask) {
    dependsOn generate
    interfacePackage = 'com.company.schema.core'
    interfacesDirectory = file('src/main/java')
    scanDirectory = file("build/generated/java")
}

so far this is working fine but within my project I have interfaces in different packages based on areas of concern. It would be good if instead of having interfacePackage that I could either specify something like interfacePackages = 'com.company.schema.*' or perhaps interfacePackages = ['com.company.schema.core', 'com.company.schema.users', 'com.company.schema.products']

@SingingBush
Copy link
Author

perhaps another option would be for the annotation to support full package path:

@java-interface("com.company.schema.users.EndUser")

@tunguski
Copy link
Owner

tunguski commented Jul 1, 2023

I am not sure I understand - what would be the difference between interfacePackages = 'com.company.schema.*' and interfacePackage = 'com.company.schema'? If you need recursive scan of interfaces in subpackages, then I believe it is done by default.

But if you need to explicitly list multiple packages, I think it may be possible through undocumented feature - https://github.com/tunguski/interfacer/blob/master/interfacer-core/src/main/java/pl/matsuo/interfacer/core/ClasspathInterfacesScanner.java#L36.

@SingingBush
Copy link
Author

I'll give this another go then. When I was trying to use it a few days ago I seemed to need to specify the full package path to a single package where I had some interfaces and in the annotation just pit the interface name. I have a few other packages that I want to use interfaces for so I'll give interfacePackage = 'com.company.schema' a go and confirm if all ok.

I like being verbose though so if interfacePackage = 'com.company.schema.core,com.company.schema.users,com.company.schema.products' is already a working feature I'm happy.

Potentially this is just a case of making the documentation more clear that interfacePackage can be comma separated values.

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

No branches or pull requests

2 participants