我正在尝试使用一个库中的AspectJ注释,这是我正在进行的项目。我的项目使用Gradle,所以我尝试使用FreeFair AspectJ级插件。
我需要能够将AspectJ -aspectpath参数设置为Gradle正在使用的库依赖项。
在它们的示例代码中,我看到可以使用它将-aspectpath设置为本地“项目”:
aspect project(":aspectj:aspect")有人知道如何将-aspectpath设置为外部库依赖项吗?
我创建了一个示例项目,并将其放在GitHub:freefair-aspectpath-外部库上。
更新:我为此创建了一个bug:https://github.com/freefair/gradle-plugins/issues/46
发布于 2019-05-29 13:51:24
感谢@larsgrefer,他在GitHub问题(46)中给出了答案。
对于io.freefair.aspectj.编译时编织插件2.9.5,配置名为“方面”,而不是“方面”。
以下是该问题的解决办法:
aspects project(":aspectj:aspect")完整的构建文件类似于:
buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        // 2.9.5 for use with Gradle 4.10.3.
        classpath "io.freefair.gradle:aspectj-plugin:2.9.5"
    }
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "io.freefair.aspectj.compile-time-weaving"
aspectj.version = '1.9.3'
group 'xyz.swatt'
version '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
    mavenCentral()
}
dependencies {
    ///// SWATT ///// https://mvnrepository.com/artifact/xyz.swatt/swatt
    compile group: 'xyz.swatt', name: 'swatt', version: '1.12.0'
    aspect "xyz.swatt:swatt:1.12.0"
}发布于 2019-05-23 13:43:42
aspect是一个简单的旧的gradle配置。
这意味着您可以使用这里描述的所有符号:
dependencies {
    aspect project(":my-aspect")
    aspect "com.example.foo:bar-aspect:1.0.0"
    aspect file("foo.jar")
}https://stackoverflow.com/questions/56221848
复制相似问题