我正在尝试使用库中的 AspectJ 注释,并将其拉入我的项目中。我的项目使用 Gradle,所以我尝试使用FreeFair AspectJ Gradle 插件 https://plugins.gradle.org/search?term=freefair+aspectj.
我需要能够设置 AspectJ-方面路径参数,到 Gradle 引入的库依赖项。
FreeFair,好像没有太多文档 https://github.com/freefair/gradle-plugins/tree/3.5.1/aspectj-plugin,主要只是示例代码 https://github.com/freefair/gradle-plugins/blob/3.5.1/examples/aspectj.
在他们的示例代码中,我看到我可以使用它来设置-方面路径到本地“项目”:
aspect project(":aspectj:aspect")
有谁知道如何设置-方面路径到外部库依赖项?
我创建了一个示例项目并将其放在 GitHub 上:freefair-aspectpath-外部库 https://github.com/BrandonDudek/freefair-aspectpath-external-library.
-
Note:我在用io.freefair.gradle:aspectj-插件版本2.9.5因为我的项目使用 Gradle 版本卡住了4.10.3.
Update:我为此创建了一个错误:https://github.com/freefair/gradle-plugins/issues/46 https://github.com/freefair/gradle-plugins/issues/46
谢谢@larsgrefer https://stackoverflow.com/users/3574494/larsgrefer,谁在 GitHub Issue 中提供了答案(46 https://github.com/freefair/gradle-plugins/issues/46).
For the io.freefair.aspectj.编译时编织插件 2.9.5 配置名为“aspects”而不是“方面”。
以下修复了该问题:
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"
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)