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

Import AutoValue via Gradle: why api and not implementation? #620

Closed
mr746866 opened this issue Apr 1, 2018 · 4 comments
Closed

Import AutoValue via Gradle: why api and not implementation? #620

mr746866 opened this issue Apr 1, 2018 · 4 comments
Labels

Comments

@mr746866
Copy link

mr746866 commented Apr 1, 2018

In the user guide here, the instruction to import AutoValue states following.

dependencies {
  // Use 'api' rather than 'compile' for Android or java-library projects.
  compile             "com.google.auto.value:auto-value-annotations:1.6"
  annotationProcessor "com.google.auto.value:auto-value:1.6"
}

Is there any specific reason to use api instead of implementation? (In general, use of implementation is preferred over api)

@tbroyer
Copy link
Contributor

tbroyer commented Apr 1, 2018

See discussion in #606. If compileOnly works for you, then use it, but if you're building a library shared with others (publicly) you'd better use api.

@mr746866
Copy link
Author

mr746866 commented Apr 1, 2018

@tbroyer Can you please explain the consequence of using implementation? I am using it in my Android project and don't see any problem with it.

@tbroyer
Copy link
Contributor

tbroyer commented Apr 1, 2018

Any annotation with retention class or runtime can cause issues in downstream modules (at compile time, during static analysis, etc.) under some conditions.

Using api on the other hand is mostly harmless. Worst thing is triggering rebuilds (when updating auto-value).

So without going into details in the doc, best status quo is to suggest api.

@eamonnmcmanus
Copy link
Member

With Gradle ≥6.7, it's actually best to use compileOnlyApi. We've updated the documentation to reflect that.

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

No branches or pull requests

4 participants