如何设置"-aspectpath" FreeFair AspectJ Gradle插件? [英] How to set "-aspectpath" for the FreeFair AspectJ Gradle Plugin?

查看:466
本文介绍了如何设置"-aspectpath" FreeFair AspectJ Gradle插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用库中的AspectJ批注,这是我正在进入的项目.我的项目使用Gradle,因此我尝试使用 FreeFair AspectJ Gradle插件.

我需要能够将AspectJ -aspectpath 参数设置为Gradle引入的库依赖项.

FreeFair,似乎没有很多文档 a>,主要是示例代码.. >

在他们的示例代码中,我看到可以使用它来将 -aspectpath 设置为本地项目":

aspect project(":aspectj:aspect")

有人知道如何将 -aspectpath 设置为外部库依赖项吗?

我创建了一个示例项目,并将其放在GitHub上: freefair-aspectpath-external-库.

  • 注意:我正在使用 io.freefair.gradle:aspectj-plugin 版本 2.9.5 ,因为我的项目使用了Gradle版本 4.10.3 .


更新:我为此创建了一个错误: https://github.com/freefair/gradle-plugins/issues/46

解决方案

感谢 @larsgrefer ,他提供了答案在GitHub发行版( 46 )中.

对于 io.freefair.aspectj.compile-time-weaving 插件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"
}

I am trying to use an AspectJ Annotation that is in a Library, that I am pulling into my project. My project uses Gradle, so I am attempting to use FreeFair AspectJ Gradle Plugin.

I need to be able to set the AspectJ -aspectpath argument, to the Library Dependency that Gradle is pulling in.

FreeFair, does not seem to have much Documentation, mainly just Sample Code.

In their sample code, I see that I can use this to set the -aspectpath to a local "project":

aspect project(":aspectj:aspect")

Does anyone know how to set the -aspectpath to an external library dependency?

I created an example Project and put it on GitHub: freefair-aspectpath-external-library.

  • Note: I am using io.freefair.gradle:aspectj-plugin version 2.9.5 because my project is stuck using Gradle version 4.10.3.


Update: I have created a bug for this: https://github.com/freefair/gradle-plugins/issues/46

解决方案

Thanks to @larsgrefer, who provided the answer in the GitHub Issue (46).

For the io.freefair.aspectj.compile-time-weaving plugin 2.9.5 the configuration is named "aspects" instead of "aspect".

The following fixed the issue:

aspects project(":aspectj:aspect")

The full build file resembles:

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

这篇关于如何设置"-aspectpath" FreeFair AspectJ Gradle插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆