【发布时间】:2016-03-06 12:05:12
【问题描述】:
我正在创建一个与 spring 无关的 aspectj 项目。各个方面都是我写的。到目前为止,我一直在使用“ant”构建来编译我的代理,现在我正在尝试转向 gradle。
我的问题 - 我不希望我的类被检测,但是 ajc 也会编织我的代码,所以如果我要添加一个切入点到 "someFunction() " 函数,我的代码 com.myproject.MyClass 有一个名为 "someFunction" 的函数,它将被检测。
如何将 gradle aspectj 插件配置为不检测“com.myProject”中的类? (在运行时是 aop.xml 文件,但问题出在编译时)。
我的代码:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
ext.aspectjVersion = '1.8.8'
configurations {
ajc
aspects
aspectCompile
ajInpath
compile {
extendsFrom aspects
}
}
publishing {
publications {
mavenJava(MavenPublication) { from components.java }
}
}
repositories {
jcenter()
}
compileJava {
sourceCompatibility = "1.6"
targetCompatibility = "1.6"
doLast {
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
classpath: configurations.ajc.asPath)
ant.iajc(
source: sourceCompatibility,
target: targetCompatibility,
destDir: sourceSets.main.output.classesDir.absolutePath,
maxmem: "512m",
fork: "true",
inpath: configurations.ajInpath.asPath,
aspectPath: configurations.aspects.asPath,
Xlint: "ignore",
sourceRootCopyFilter: "**/*.java, **/*.class, **/*.aj",
classpath: "${configurations.compile.asPath};${configurations.aspectCompile.asPath}") {
sourceroots {
sourceSets.main.java.srcDirs.each {
pathelement(location: it.absolutePath)
}
}
}
}
}
dependencies {
ajc "org.aspectj:aspectjtools:1.8.8"
compile "org.aspectj:aspectjrt:1.8.8"
}
谢谢
【问题讨论】:
标签: gradle aspectj gradle-plugin