2

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

kriegaex
  • 63,017
  • 15
  • 111
  • 202
Brandon Dudek
  • 849
  • 1
  • 8
  • 18
  • Have you tried raising an issue at the GitHub site and asking the author directly? – kriegaex May 21 '19 at 01:16
  • 1
    GitHub tickets are not just about bugs, they can be about documentation issues too. And that plugin definitely has some serious documentation issues. ;-) – kriegaex May 21 '19 at 12:51

2 Answers2

2

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"
}
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
Brandon Dudek
  • 849
  • 1
  • 8
  • 18
0

aspect is a plain old gradle configuration.

This means you can use all the notations described here:

dependencies {
    aspect project(":my-aspect")
    aspect "com.example.foo:bar-aspect:1.0.0"
    aspect file("foo.jar")
}
larsgrefer
  • 2,735
  • 19
  • 36