如何为FreeFair AspectJ Gradle插件设置“-aspectpath”?

xvw2m8pv  于 2023-01-13  发布在  其他
关注(0)|答案(2)|浏览(220)

我正在尝试使用库中的AspectJ Annotation,并将其拉入我的项目。我的项目使用Gradle,因此我尝试使用FreeFair AspectJ Gradle Plugin
我需要能够将AspectJ *-aspectpath * 参数设置为Gradle正在拉入的库依赖项。
FreeFair,似乎没有太多的Documentation,主要只是Sample Code
在他们的示例代码中,我看到我可以使用它来将 *-aspectpath * 设置为一个本地"项目":

aspect project(":aspectj:aspect")

有人知道如何将 *-aspectpath * 设置为外部库依赖项吗?
我创建了一个示例项目,并将其放在GitHub上:freefair-aspectpath-external-library.

ijxebb2r

ijxebb2r1#

感谢@larsgrefer,他在GitHub问题(46)中提供了答案。
对于 io.freefair.aspectj.compile-time-weaving 插件2.9.5,配置被命名为“aspects”而不是“aspect”。
以下操作修复了该问题:

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"
}
pxiryf3j

pxiryf3j2#

aspect是一种普通的老式gradle配置。
这意味着您可以使用这里描述的所有表示法:

dependencies {
    aspect project(":my-aspect")
    aspect "com.example.foo:bar-aspect:1.0.0"
    aspect file("foo.jar")
}

相关问题