From 222d2b163999b7d16055185bdf77e7ea98d4ef97 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 20 Oct 2014 17:39:11 +0200 Subject: [PATCH] Fix unnecessary required spring-context-support dep Prior to this commit, a project using compile time weaving upgrading to 4.1 was forced to add spring-context-support and the jcache API in order to build. This problem is not new really: spring-aspects holds all aspects provided by the framework and they all are evaluated when compiling. 4.1 just happens to define a new aspect that requires extra dependencies. This commit uses a new annotation of AspectJ 1.8.3. When @RequiredTypes is added on an aspect, it is evaluated only if the classes defined on the annotation are actually present. If they are not, the aspect is disabled and does not break the build. Issue: SPR-12163 --- build.gradle | 2 +- .../java/org/springframework/cache/aspectj/JCacheCacheAspect.aj | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7cbcb095b6..8cf26a4391 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ configure(allprojects) { project -> group = "org.springframework" version = qualifyVersionIfNecessary(version) - ext.aspectjVersion = "1.8.2" + ext.aspectjVersion = "1.8.3" ext.eclipseLinkVersion = "2.4.2" ext.ehcacheVersion = "2.9.0" ext.ehcacheJCacheVersion = "1.0.0" diff --git a/spring-aspects/src/main/java/org/springframework/cache/aspectj/JCacheCacheAspect.aj b/spring-aspects/src/main/java/org/springframework/cache/aspectj/JCacheCacheAspect.aj index 505035e71c..3aeeefbd0e 100644 --- a/spring-aspects/src/main/java/org/springframework/cache/aspectj/JCacheCacheAspect.aj +++ b/spring-aspects/src/main/java/org/springframework/cache/aspectj/JCacheCacheAspect.aj @@ -22,6 +22,7 @@ import javax.cache.annotation.CacheRemove; import javax.cache.annotation.CacheRemoveAll; import javax.cache.annotation.CacheResult; +import org.aspectj.lang.annotation.RequiredTypes; import org.aspectj.lang.annotation.SuppressAjWarnings; import org.aspectj.lang.reflect.MethodSignature; @@ -43,6 +44,7 @@ import org.springframework.cache.jcache.interceptor.JCacheAspectSupport; * @author Stephane Nicoll * @since 4.1 */ +@RequiredTypes({"org.springframework.cache.jcache.interceptor.JCacheAspectSupport", "javax.cache.annotation.CacheResult"}) public aspect JCacheCacheAspect extends JCacheAspectSupport { @SuppressAjWarnings("adviceDidNotMatch")