sedovalx / gradle-aspectj-binary

Gradle plugin for AspectJ binary weaving
16 stars 6 forks source link

how to support multiple sourcesets to weave class. #1

Open kiran4298 opened 6 years ago

kiran4298 commented 6 years ago

i see in the AspectJBinaryWeavingPlugin.kt, i see that only main sourceSet is supported, but i have project where few modules have java as a sourceset and few modules have main as a sourceSet. How could i modify your plugin to make it work for both source sets. in the below entry in your plugin code? val main = javaConvention.sourceSets.find { it.name == "main" } ?: throw GradleException("Source set 'main' is not found")

sedovalx commented 6 years ago

Hi @kiran4298! Please take a look at https://docs.gradle.org/current/userguide/custom_plugins.html#sec:getting_input_from_the_build article for how to make a plugin configurable. You may add a plugin extension with a property to specify all source set names that you want.

Feel free to contact me if you need a help on it.

sedovalx commented 4 years ago

Please see the updated README and https://github.com/sedovalx/gradle-aspectj-binary/releases/tag/1.0.41. I've added support for multiple source sets to the plugin but... honestly, I haven't tested it. So, if you still feel the need, I would appreciate getting the feedback.

qhr-nwourms commented 4 years ago

@sedovalx I tried to get multiple source sets working for a project that has aspects defined in the main source set and would weave aspects in great for the first source set as it corresponded to the outputDir. Your weaving methodology has resolved issues I've had with incremental builds for the main source set as opposed to using https://docs.freefair.io/gradle-plugins/4.1.6/reference/#_aspectj_plugins

Challenge that I am facing is that I am need to be able to weave those main source set aspects into a test source set but does not seem to be occurring.

E.g. Project +-- src | +-- main | | +-- java | | | +-- someAspect | +-- test | | +-- java | | | +-- someTestClass

My guess is that given that there is only one outputDir which had been set to the build directory of main/java is why this is not getting weaved for my tests. Would almost be nice to have a mapping for multiple source sets so that it wouldn't only just be main/test but also other kinds of tests (e.g. integration and others). Alternatively could be separate tasks for tests.

sedovalx commented 4 years ago

I'm sorry @qhr-nwourms but I don't have much time for looking into this now. Feel free to fork the repo or create a merge request with changes that you need.