java - Weaving production classes with AspectJ aspects in Maven for tests execution only -


I have a project with Maven Build and methods are required to add some basic display tracing. Decided to use the aspect, the main requirement is to detect the aspect in production classes in but only in unit test execution stage .

I was able to configure knitting in Maven, but after the execution of the tests was prepared for the war packed with the preparedness aspects.

This case looks very common, yet I was not able to find a solution for it in the web.

I will do this in a dedicated module, under the "use the Maven dependency plugin to open the artwork" "during the generated-trial-sources phase, then the classes Weave and finally run the test.


Let me know what I mean. Imagine the plan structure:

 | - pom.xml `- ​​some modules // this is the module we want to weave. - pom.xml // But for testing purposes only `- ... 

So my suggestion is to do something like this:

 | - pom.xml | - some-module | | - pom.xml |` - ... ` - Exam-modules // We are going to weave classes here because we do not want- pom.xml / / tracing aspect "production" jar `- ... 

An additional consideration of this idea "Test-module" to be, jah A. We will open the artwork that we so want to test we can woven their classes without affecting the "real" production issue. .

To do this, declare dependence on the module in the examination and before using the dependency: unpack to open the classes in the target / classes


Comments