Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groovy Test Project Config #422

Open
moeniebdavids opened this issue Nov 14, 2021 · 4 comments
Open

Groovy Test Project Config #422

moeniebdavids opened this issue Nov 14, 2021 · 4 comments

Comments

@moeniebdavids
Copy link

moeniebdavids commented Nov 14, 2021

Hi,

Is there any special config required to have groovy gradle test projects work with AspectJ plugin?
When I run my tests, I keep getting the below
[AppClassLoader@73d16e93] error aspect 'MYASPECT' (contained in a dependancy jar which is added via gradle dependancy) woven into 'xxxxxxxxx' must be defined to the weaver (placed on the aspectpath, or defined in an aop.xml file if using LTW).

When I add a test to my main (src\main\groovy) I can execute perfectly.
Its just with the test task that my aspects do not seem to apply

In terms of my build,gradle, I add

in plugin:

	id "io.freefair.aspectj.post-compile-weaving" version "5.1.0"

in dependancy:

	compile group: 'com.xxx', name: 'aspectStuff', version: '2.1'
	aspect 'com.xxx:aspectStuff:2.1'
	testCompile group: 'com.xxx', name: 'aspectStuff', version: '2.1'
	testAspect 'com.xxx:aspectStuff:2.1'
@moeniebdavids moeniebdavids changed the title Test Project Config Groovy Test Project Config Nov 14, 2021
@moeniebdavids
Copy link
Author

@larsgrefer Apologies for the direct tagging, but any chance I can get your expertise on this?

@larsgrefer
Copy link
Member

Have you tried this:?

compileTestJava.ajc.options.aspectpath.from sourceSets.main.output

@moeniebdavids
Copy link
Author

moeniebdavids commented Nov 16, 2021

Hi @larsgrefer
Should this work if the aspects are contained in a dependancy jar?
Also, this is a test project with no main sourceset.
I am still getting
[AppClassLoader@73d16e93] error aspect 'com.xxx.aspects.xxxxxxx.xxxAspect' woven into 'com.xx.repo.Control' must be defined to the weaver (placed on the aspectpath, or defined in an aop.xml file if using LTW).

plugins {
    id 'java'
    id 'groovy'
    id 'io.qameta.allure' version '2.8.1'
    id "io.freefair.aspectj.post-compile-weaving" version "5.1.0"
}

group 'com.example'
version '1.0-SNAPSHOT'

repositories {

    mavenLocal()
    mavenCentral()
}

ext {
    allureVersion = '2.14.0'
    junitVersion = '5.7.1'
}

sourceCompatibility = '8'
targetCompatibility = '8'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

dependencies {
    implementation('org.codehaus.groovy:groovy:3.0.8')
    testImplementation('org.seleniumhq.selenium:selenium-java:4.0.0')
    testImplementation('org.slf4j:slf4j-simple:1.7.30')

    testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")

    testImplementation group: 'com.xx', name: 'xxxxxx', version: '2.2'
    testAspect 'com.xx:xxxxxx:2.2'
    testImplementation "org.aspectj:aspectjrt:1.9.5"
}

compileTestJava.ajc.options.aspectpath.from sourceSets.main.output
compileTestGroovy.ajc.options.aspectpath.from sourceSets.main.output

test {
    useJUnitPlatform()
}
allure {
    autoconfigure = true
    version = "${allureVersion}"

    useJUnit5 {
        version = "${allureVersion}"
    }
}

@moeniebdavids
Copy link
Author

moeniebdavids commented Nov 16, 2021

Please note this is a groovy project

-aspectpath contains
/home/xxx/.gradle/caches/modules-2/files-2.1/com.xx/xxxx/2.2/e6e6fc4ecdac081573d279e6e2365ed7c016b096/testBuddy-2.2.jar:
/home/xxx/.gradle/caches/modules-2/files-2.1/org.aspectj/aspectjrt/1.9.5/dc063f2557f6734ccb529b4c1d97132e4c8c739/aspectjrt-1.9.5.jar:
and a few other jars

-inpath
/home/xxx/Downloads/demo2/build/classes/groovy/test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants