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

Scala and required CDI dependency #378

Open
ben-manes opened this issue May 3, 2017 · 6 comments
Open

Scala and required CDI dependency #378

ben-manes opened this issue May 3, 2017 · 6 comments
Milestone

Comments

@ben-manes
Copy link

Unlike Java, Scala fully resolves all annotations and requires them to be on the classpath when loading a class. This means that Scala JCache users in a non-CDI environment, such as Guice, must include the provided scoped dependency. The pom.xml states that this dependency could be removed with CDI 1.1, which was released 4 years ago. This quirk of Scala surprised a user and, if the comment is accurate, it would be nice to remove the requirement.

<!--This is only needed if you are using a CDI based implementation of the annotations support.
    In CDI 1.1. we should be able to remove this dependency completely. -->
<dependency>
  <groupId>javax.enterprise</groupId>
  <artifactId>cdi-api</artifactId>
  <version>1.0-SP4</version>
  <scope>provided</scope>
  <optional>true</optional>
</dependency>
@cruftex
Copy link
Member

cruftex commented May 3, 2017

I did a quick check. The dependency provides the javax.enterprise.util.Nonbinding annotation, which is used in the following JCache annotations: CacheRemove, CacheResult, CacheRemoveAll, CacheDefaults, CachePut, CacheRemove.

For example:

public @interface CacheDefaults {

  /**
   * The default name of the cache for the annotated class
   * <p>
   * If not specified defaults to:
   * package.name.ClassName.methodName(package.ParameterType,package.ParameterType)
   * <p>
   * Applicable for {@link CacheResult}, {@link CachePut}, {@link CacheRemove},
   * and {@link CacheRemoveAll}
   */
  @Nonbinding String cacheName() default "";
  . . . 

I don't think we can drop @Nonbinding to get rid of the dependency, especially in an MR which needs to be 100% API compatible.

@ben-manes
Copy link
Author

ben-manes commented May 3, 2017

Yes, that is the annotation causing the required dependency. I am unfamiliar with CDI, so to me the comment implied that the annotation may not be necessary anymore. However, we would need someone who uses CDI to clarify.

@cruftex
Copy link
Member

cruftex commented May 3, 2017

The description is here:
http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#performing_typesafe_resolution

I am unfamiliar with CDI, so to me comment implied that the annotation may not be necessary anymore. However, we would need someone who uses CDI to clarify.

Me too. However, it obviously has some intended semantic. We cannot change here any more after the JCache Spec was released.

@cruftex cruftex added this to the 2.0 milestone May 3, 2017
@cruftex
Copy link
Member

cruftex commented May 3, 2017

Tagged with 2.0 for now. Any comments whether we can rid of the dependency, at least for Version 2, are much appreciated.

@ben-manes
Copy link
Author

I think the comment was alluding to adding bean-discovery-mode, set to none in the jar's beans.xml.

@cruftex cruftex modified the milestones: 2.0, 1.2 Aug 6, 2019
@cruftex
Copy link
Member

cruftex commented Aug 6, 2019

Possible other solution:

Split the API jar into two jars and separate the annotations. I just tagged this with milestone 1.2, maybe its worth to talk about another MR.

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