build.gradle如下:
buildscript {
repositories {
maven { url "http://nexus.**.org/nexus/content/groups/public/" }
}
dependencies {
classpath("nl.eveoh:gradle-aspectj:1.5")
}
}
ext {
springBootVersion = '1.2.3.RELEASE'
aspectjVersion = '1.8.5'
}
apply plugin: 'aspectj'
compileAspect {
additionalAjcArgs = ['encoding': 'UTF-8', 'source': '1.8', 'target': '1.8']
}
dependencies {
compile ("com.alibaba:fastjson:1.2.5")
compile ('commons-io:commons-io:2.4')
compile ('commons-lang:commons-lang:2.6')
compile ("ch.qos.logback:logback-classic:1.1.3")
compile ("ch.qos.logback:logback-core:1.1.3")
compile ("org.springframework:spring-jms:4.1.6.RELEASE")
compile ("org.apache.kafka:kafka-clients:0.8.2.2")
compile ("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile ("org.aspectj:aspectjrt:$aspectjVersion")
compile ("org.aspectj:aspectjweaver:$aspectjVersion")
compile("com.aa.bb:bb-core:1.0")
ajInpath ("com.aa.bb:bb-core:1.0")
}
当我执行gradle build时,会输出一些编译错误:
20:35:12: Executing external task 'build'...
:myproject:compileAspect
[ant:iajc] trouble in:
[ant:iajc] public class org.springframework.http.converter.feed.AtomFeedHttpMessageConverter extends org.springframework.http.converter.feed.AbstractWireFeedHttpMessageConverter:
[ant:iajc] public void <init>():
[ant:iajc] ALOAD_0 // Lorg/springframework/http/converter/feed/AtomFeedHttpMessageConverter; this (line 38)
[ant:iajc] NEW org.springframework.http.MediaType
[ant:iajc] DUP
[ant:iajc] LDC "application"
[ant:iajc] LDC "atom+xml"
[ant:iajc] INVOKESPECIAL org.springframework.http.MediaType.<init> (Ljava/lang/String;Ljava/lang/String;)V
[ant:iajc] INVOKESPECIAL org.springframework.http.converter.feed.AbstractWireFeedHttpMessageConverter.<init> (Lorg/springframework/http/MediaType;)V
[ant:iajc] constructor-execution(void org.springframework.http.converter.feed.AtomFeedHttpMessageConverter.<init>())
[ant:iajc] | RETURN (line 39)
[ant:iajc] constructor-execution(void org.springframework.http.converter.feed.AtomFeedHttpMessageConverter.<init>())
[ant:iajc] end public void <init>()
[ant:iajc]
[ant:iajc] protected boolean supports(Class):
[ant:iajc] method-execution(boolean org.springframework.http.converter.feed.AtomFeedHttpMessageConverter.supports(java.lang.Class))
[ant:iajc] | LDC com.sun.syndication.feed.atom.Feed (line 43)
[ant:iajc] | ALOAD_1 // Ljava/lang/Class; clazz
[ant:iajc] | method-call(boolean java.lang.Class.isAssignableFrom(java.lang.Class))
[ant:iajc] | | INVOKEVIRTUAL java.lang.Class.isAssignableFrom (Ljava/lang/Class;)Z
[ant:iajc] | method-call(boolean java.lang.Class.isAssignableFrom(java.lang.Class))
[ant:iajc] | IRETURN
[ant:iajc] method-execution(boolean org.springframework.http.converter.feed.AtomFeedHttpMessageConverter.supports(java.lang.Class))
[ant:iajc] end protected boolean supports(Class)
[ant:iajc]
[ant:iajc] end public class org.springframework.http.converter.feed.AtomFeedHttpMessageConverter
[ant:iajc]
[ant:iajc]
[ant:iajc] Exception thrown from AspectJ 1.8.5
[ant:iajc]
[ant:iajc] This might be logged as a bug already -- find current bugs at
[ant:iajc] http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler
[ant:iajc]
[ant:iajc] Bugs for exceptions thrown have titles File:line from the top stack,
[ant:iajc] e.g., "SomeFile.java:243"
[ant:iajc]
[ant:iajc] If you don't find the exception below in a bug, please add a new bug
[ant:iajc] at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
[ant:iajc] To make the bug a priority, please include a test program
[ant:iajc] that can reproduce this exception.
[ant:iajc] org.aspectj.weaver.MissingResolvedTypeWithKnownSignature cannot be cast to org.aspectj.weaver.ReferenceType
[ant:iajc]
[ant:iajc] when weaving type org.springframework.http.converter.feed.AtomFeedHttpMessageConverter
[ant:iajc] when weaving classes
[ant:iajc] when weaving
[ant:iajc] when batch building BuildConfig[null] #Files=49 AopXmls=#0
[ant:iajc] org.aspectj.weaver.MissingResolvedTypeWithKnownSignature cannot be cast to org.aspectj.weaver.ReferenceType
[ant:iajc] java.lang.ClassCastException: org.aspectj.weaver.MissingResolvedTypeWithKnownSignature cannot be cast to org.aspectj.weaver.ReferenceType
[ant:iajc] at org.aspectj.weaver.BoundedReferenceType.parameterize(BoundedReferenceType.java:109)
[ant:iajc] at org.aspectj.weaver.ResolvedType.parameterize(ResolvedType.java:2489)
[ant:iajc] at org.aspectj.weaver.ResolvedMemberImpl.parameterize(ResolvedMemberImpl.java:897)
[ant:iajc] at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:794)
[ant:iajc] at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:742)
[ant:iajc] at org.aspectj.weaver.ReferenceType.getDeclaredMethods(ReferenceType.java:859)
[ant:iajc] at org.aspectj.weaver.ResolvedType$MethodGetterIncludingItds.get(ResolvedType.java:252)
[ant:iajc] at org.aspectj.weaver.ResolvedType$MethodGetterIncludingItds.get(ResolvedType.java:250)
[ant:iajc] at org.aspectj.weaver.Iterators$4$1.hasNext(Iterators.java:213)
[ant:iajc] at org.aspectj.weaver.Iterators$4.hasNext(Iterators.java:230)
[ant:iajc] at org.aspectj.weaver.ResolvedType.lookupResolvedMember(ResolvedType.java:619)
[ant:iajc] at org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:192)
[ant:iajc] at org.aspectj.weaver.JoinPointSignatureIterator.hasNext(JoinPointSignatureIterator.java:68)
[ant:iajc] at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:317)
[ant:iajc] at org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:197)
[ant:iajc] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137)
[ant:iajc] at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:56)
[ant:iajc] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137)
[ant:iajc] at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:56)
[ant:iajc] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137)
[ant:iajc] at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:113)
[ant:iajc] at org.aspectj.weaver.Advice.match(Advice.java:109)
[ant:iajc] at org.aspectj.weaver.bcel.BcelAdvice.match(BcelAdvice.java:152)
[ant:iajc] at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:3304)
[ant:iajc] at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:2692)
[ant:iajc] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:480)
[ant:iajc] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:100)
[ant:iajc] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1689)
[ant:iajc] at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1633)
[ant:iajc] at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1398)
[ant:iajc] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1184)
[ant:iajc] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514)
[ant:iajc] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueForWeaving(AjPipeliningCompilerAdapter.java:447)
[ant:iajc] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:432)
[ant:iajc] at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:103)
[ant:iajc] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:822)
[ant:iajc] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:480)
[ant:iajc] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:420)
[ant:iajc] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036)
[ant:iajc] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272)
[ant:iajc] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
[ant:iajc] at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
[ant:iajc] at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
[ant:iajc] at org.aspectj.tools.ajc.Main.run(Main.java:371)
[ant:iajc] at org.aspectj.tools.ajc.Main.runMain(Main.java:248)
[ant:iajc] at org.aspectj.tools.ajc.Main.main(Main.java:84)
[ant:iajc]
[ant:iajc] trouble in:
[ant:iajc] public class org.springframework.http.converter.feed.RssChannelHttpMessageConverter extends org.springframework.http.converter.feed.AbstractWireFeedHttpMessageConverter:
[ant:iajc] public void <init>():
[ant:iajc] ALOAD_0 // Lorg/springframework/http/converter/feed/RssChannelHttpMessageConverter; this (line 38)
[ant:iajc] NEW org.springframework.http.MediaType
[ant:iajc] DUP
[ant:iajc] LDC "application"
[ant:iajc] LDC "rss+xml"
[ant:iajc] INVOKESPECIAL org.springframework.http.MediaType.<init> (Ljava/lang/String;Ljava/lang/String;)V
[ant:iajc] INVOKESPECIAL org.springframework.http.converter.feed.AbstractWireFeedHttpMessageConverter.<init> (Lorg/springframework/http/MediaType;)V
[ant:iajc] constructor-execution(void org.springframework.http.converter.feed.RssChannelHttpMessageConverter.<init>())
[ant:iajc] | RETURN (line 39)
[ant:iajc] constructor-execution(void org.springframework.http.converter.feed.RssChannelHttpMessageConverter.<init>())
[ant:iajc] end public void <init>()
[ant:iajc]
[ant:iajc] protected boolean supports(Class):
[ant:iajc] method-execution(boolean org.springframework.http.converter.feed.RssChannelHttpMessageConverter.supports(java.lang.Class))
[ant:iajc] | LDC com.sun.syndication.feed.rss.Channel (line 43)
[ant:iajc] | ALOAD_1 // Ljava/lang/Class; clazz
[ant:iajc] | method-call(boolean java.lang.Class.isAssignableFrom(java.lang.Class))
[ant:iajc] | | INVOKEVIRTUAL java.lang.Class.isAssignableFrom (Ljava/lang/Class;)Z
[ant:iajc] | method-call(boolean java.lang.Class.isAssignableFrom(java.lang.Class))
[ant:iajc] | IRETURN
[ant:iajc] method-execution(boolean org.springframework.http.converter.feed.RssChannelHttpMessageConverter.supports(java.lang.Class))
[ant:iajc] end protected boolean supports(Class)
[ant:iajc]
[ant:iajc] end public class org.springframework.http.converter.feed.RssChannelHttpMessageConverter
[ant:iajc]
[ant:iajc]
[ant:iajc] Exception thrown from AspectJ 1.8.5
[ant:iajc]
[ant:iajc] This might be logged as a bug already -- find current bugs at
[ant:iajc] http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler
[ant:iajc]
[ant:iajc] Bugs for exceptions thrown have titles File:line from the top stack,
[ant:iajc] e.g., "SomeFile.java:243"
[ant:iajc]
[ant:iajc] If you don't find the exception below in a bug, please add a new bug
[ant:iajc] at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
[ant:iajc] To make the bug a priority, please include a test program
[ant:iajc] that can reproduce this exception.
[ant:iajc] org.aspectj.weaver.MissingResolvedTypeWithKnownSignature cannot be cast to org.aspectj.weaver.ReferenceType
[ant:iajc]
[ant:iajc] when weaving type org.springframework.http.converter.feed.RssChannelHttpMessageConverter
[ant:iajc] when weaving classes
[ant:iajc] when weaving
[ant:iajc] when batch building BuildConfig[null] #Files=49 AopXmls=#0
[ant:iajc] org.aspectj.weaver.MissingResolvedTypeWithKnownSignature cannot be cast to org.aspectj.weaver.ReferenceType
[ant:iajc] java.lang.ClassCastException: org.aspectj.weaver.MissingResolvedTypeWithKnownSignature cannot be cast to org.aspectj.weaver.ReferenceType
[ant:iajc] at org.aspectj.weaver.BoundedReferenceType.parameterize(BoundedReferenceType.java:109)
[ant:iajc] at org.aspectj.weaver.ResolvedType.parameterize(ResolvedType.java:2489)
[ant:iajc] at org.aspectj.weaver.ResolvedMemberImpl.parameterize(ResolvedMemberImpl.java:897)
[ant:iajc] at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:794)
[ant:iajc] at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:742)
[ant:iajc] at org.aspectj.weaver.ReferenceType.getDeclaredMethods(ReferenceType.java:859)
[ant:iajc] at org.aspectj.weaver.ResolvedType$MethodGetterIncludingItds.get(ResolvedType.java:252)
[ant:iajc] at org.aspectj.weaver.ResolvedType$MethodGetterIncludingItds.get(ResolvedType.java:250)
[ant:iajc] at org.aspectj.weaver.Iterators$4$1.hasNext(Iterators.java:213)
[ant:iajc] at org.aspectj.weaver.Iterators$4.hasNext(Iterators.java:230)
[ant:iajc] at org.aspectj.weaver.ResolvedType.lookupResolvedMember(ResolvedType.java:619)
[ant:iajc] at org.aspectj.weaver.JoinPointSignatureIterator.findSignaturesFromSupertypes(JoinPointSignatureIterator.java:192)
[ant:iajc] at org.aspectj.weaver.JoinPointSignatureIterator.hasNext(JoinPointSignatureIterator.java:68)
[ant:iajc] at org.aspectj.weaver.patterns.SignaturePattern.matches(SignaturePattern.java:317)
[ant:iajc] at org.aspectj.weaver.patterns.KindedPointcut.matchInternal(KindedPointcut.java:197)
[ant:iajc] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137)
[ant:iajc] at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:56)
[ant:iajc] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137)
[ant:iajc] at org.aspectj.weaver.patterns.AndPointcut.matchInternal(AndPointcut.java:56)
[ant:iajc] at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:137)
[ant:iajc] at org.aspectj.weaver.ShadowMunger.match(ShadowMunger.java:113)
[ant:iajc] at org.aspectj.weaver.Advice.match(Advice.java:109)
[ant:iajc] at org.aspectj.weaver.bcel.BcelAdvice.match(BcelAdvice.java:152)
[ant:iajc] at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:3304)
[ant:iajc] at org.aspectj.weaver.bcel.BcelClassWeaver.match(BcelClassWeaver.java:2692)
[ant:iajc] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:480)
[ant:iajc] at org.aspectj.weaver.bcel.BcelClassWeaver.weave(BcelClassWeaver.java:100)
[ant:iajc] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1689)
[ant:iajc] at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump(BcelWeaver.java:1633)
[ant:iajc] at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify(BcelWeaver.java:1398)
[ant:iajc] at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1184)
[ant:iajc] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514)
[ant:iajc] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.queueForWeaving(AjPipeliningCompilerAdapter.java:447)
[ant:iajc] at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:432)
[ant:iajc] at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$after$org_aspectj_ajdt_internal_compiler_CompilerAdapter$5$6b855184(CompilerAdapter.aj:103)
[ant:iajc] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:822)
[ant:iajc] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:480)
[ant:iajc] at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:420)
[ant:iajc] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1036)
[ant:iajc] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272)
[ant:iajc] at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
[ant:iajc] at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
[ant:iajc] at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
[ant:iajc] at org.aspectj.tools.ajc.Main.run(Main.java:371)
[ant:iajc] at org.aspectj.tools.ajc.Main.runMain(Main.java:248)
[ant:iajc] at org.aspectj.tools.ajc.Main.main(Main.java:84)
[ant:iajc]
[ant:iajc] 九月 08, 2016 8:35:41 下午 org.aspectj.weaver.tools.Jdk14Trace info
[ant:iajc] 信息: Dumping to D:\***\.\ajcore.20160908.203541.662.txt
[ant:iajc]
[ant:iajc] 2 fail|aborts
:myproject-common:compileAspect FAILED
如果我删除脚本
ajInpath ("com.aa.bb:bb-core:1.0")
gradle构建将成功,但我需要编织外部jar。
我的项目基于intellij idea(16)+ gradle(2.12)+ spring boot(1.2.3)
任何帮助将不胜感激。
===============================================
更新
在我添加spring-framework进行排除之后,没有编译错误,但外部jar仍未编织。
ajInpath ("com.aa.bb:bb-core:1.0"){
exclude(group: "org.springframework")
}
答案 0 :(得分:0)
我最终解决了^ _ ^。 由于我的项目有多模块,所以我将aspectj配置文件移动到根模块。最后的gradle脚本是:
buildscript {
repositories {
maven { url "http://nexus.**.org/nexus/content/groups/public/" }
}
dependencies {
classpath("nl.eveoh:gradle-aspectj:1.5")
}
}
ext {
springBootVersion = '1.2.3.RELEASE'
aspectjVersion = '1.8.5'
}
apply plugin: 'aspectj'
dependencies {
def appBizPath = project(':my-app-business').projectDir
def webBizPath = project(':my-web-business').projectDir
def baseBizPath = project(':my-base-business').projectDir
def comBizPath = project(':my-common').projectDir
compile project(':my-app-business')
compile project(':my-web-business')
compile project(':my-base-business')
compile project(':my-common')
compileAspect {
additionalAjcArgs = ['encoding': 'UTF-8', 'showWeaveInfo': true, 'srcdir' : "${appBizPath}/src/main;${webBizPath}/src/main;${baseBizPath}/src/main;${comBizPath}/src/main"]
}
ajInpath ("com.aa.bb:bb-core:1.0"){
exclude(group: "org.springframework")
}
}