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

Derive4J annotations scoped "provided" produce compiler warnings in Gradle project #42

Open
dmolesUC opened this issue Dec 5, 2017 · 4 comments

Comments

@dmolesUC
Copy link

dmolesUC commented Dec 5, 2017

When I include HalBuilder 5 in a Gradle project, I get warnings like these on compilation:

warning: unknown enum constant Flavour.Vavr
  reason: class file for org.derive4j.Flavour not found
warning: unknown enum constant ArgOption.checkedNotNull
  reason: class file for org.derive4j.ArgOption not found
warning: unknown enum constant Make.constructors
  reason: class file for org.derive4j.Make not found
warning: unknown enum constant Make.getters
warning: unknown enum constant Make.casesMatching

My workaround was to include derive4j-annotation as a compile-only dependency (loosely equivalent to Maven provided scope):

  compile 'com.theoryinpractise:halbuilder5:5.1.2'
  compileOnly 'org.derive4j:derive4j-annotation:0.12.3' // avoid HalBuilder-related compile warnings

(The down side of this is I'm hypothetically passing the problem along to anybody that depends on my code, but this particular project is an application rather than a library so that's not likely. In a library, I'd probably have to just make it an explicit compile dependency.)

I don't know what happens in straight Maven, but it seems to me provided might be the wrong scope for the Derive4J libraries, since it doesn't seem likely that it's going to be literally provided by a JDK or container.

dmolesUC pushed a commit to dmolesUC/cursive that referenced this issue Dec 6, 2017
@talios
Copy link
Member

talios commented Dec 6, 2017

This is strange - that should be a compile time only dependency for myself, not anyone consuming the library - I list them as provided, I suspect derive4j's annotations may not just be source retention, and thus being picked up and warned out.

I'll see if I can address that.

@dmolesUC
Copy link
Author

dmolesUC commented Dec 6, 2017

It looks like org.derive4j.Data has no explicit retention policy, so it'll default to RetentionPolicy.CLASS.

@jbgi
Copy link

jbgi commented Dec 12, 2017

yeah, derive4j use RetentionPolicy.CLASS because the annotations of separate compilation units should potentially be accessible for when derive4j generate typeclass instances that rely on instances generated by other compilation units (to be able to locate where the instances have been generated).

I agree that, if this feature is not needed, the warning is not cool... not sure how to avoid it (apart from the mentioned solution of declaring a compile-only dependency on derive4j-annotations).
It's a shame that compile-only dependencies cannot be made transitive.

@dmolesUC
Copy link
Author

Yeah, a distinction between transitive compile dependencies and transitive runtime dependencies would be nice. In its absence, though, maybe the simplest thing is just to make it a runtime dependency.

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

3 participants