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

Use the 'io.freefair.aspectj' gradle plugin #7183

Merged
merged 1 commit into from
Aug 12, 2019

Conversation

larsgrefer
Copy link
Contributor

After I've migrated (or removed) the other gradle plugins in #7077 #7173 and #7174 the AspectJ plugin was the last remaining one. Instead of migrating the current groovy based plugin to java, I just used the AspectJ gradle plugin I've already written last year.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 5, 2019
@rwinch
Copy link
Member

rwinch commented Aug 5, 2019

Thanks for the PR @larsgrefer! We'd love to rely on proper AspectJ Gradle plugin. However, it appears this PR broke the build. Can you take a look at that?

@rwinch rwinch added status: waiting-for-feedback We need additional information before we can continue in: build An issue in the build type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 5, 2019
@larsgrefer larsgrefer force-pushed the feature/aspectJPlugin branch 2 times, most recently from 5c61639 to df413db Compare August 5, 2019 22:01
@larsgrefer
Copy link
Contributor Author

@rwinch The build is fixed now.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 5, 2019
@rwinch
Copy link
Member

rwinch commented Aug 6, 2019

Is there a reason that we need to move the source code into a different source folder? I'd prefer to keep the code in the src/main/java folder.

@rwinch rwinch added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Aug 6, 2019
@larsgrefer
Copy link
Contributor Author

The io.freefair.aspectj plugin uses src/main/aspectj as source root for the code to be compiled by ajc by default. (The same way like src/main/groovy would contain code for groovyc and src/main/kotlin would contain the code compiled by kotlinc).

If you like, this can be changed in the build script:

sourceSets.main.aspectj.srcDir "src/main/java"

Another option would be the io.freefair.aspectj.post-compile-weaving plugin.
This plugin leaves the actual compilation to javac (or groovyc, kotlinc, ...) and only performs the weaving as bytecode-to-bytecode transformation (by passing the compiler output into ajc's --inpath)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 6, 2019
@rwinch
Copy link
Member

rwinch commented Aug 9, 2019

I think I'd like to use sourceSets.main.aspectj.srcDir "src/main/java". My reasoning is that while it makes sense from a Gradle plugin perspective that aspectj code is place in it's own source folder it feels a bit invasive.

Spring allows switching between proxy and compile time aspects with just configuration. It is a bit disruptive to switch the folder that the annotated Java code is in.

@larsgrefer larsgrefer force-pushed the feature/aspectJPlugin branch from df413db to df4d564 Compare August 9, 2019 17:18
@larsgrefer larsgrefer force-pushed the feature/aspectJPlugin branch from df4d564 to 974e3c1 Compare August 9, 2019 17:25
@larsgrefer
Copy link
Contributor Author

I think I'd like to use sourceSets.main.aspectj.srcDir "src/main/java". My reasoning is that while it makes sense from a Gradle plugin perspective that aspectj code is place in it's own source folder it feels a bit invasive.

For the aspects project this is actually the only option because its aspect is an *.aj file, which has to be compiled by ajc.

For samples/javaconfig/aspectj and samples/xml/aspectj I've chosen the post-compile-weaving approach because it's even less invasive and provides better integration:

  • The post-compile-weaving plugin can also weave groovy, scala and kotlin classes
  • Since the acutal compilation is perfomed by javac, additional tooling like lombok could be used without problems.

@rwinch rwinch removed the status: feedback-provided Feedback has been provided label Aug 12, 2019
@rwinch rwinch self-assigned this Aug 12, 2019
@rwinch rwinch added this to the 5.2.0.RC1 milestone Aug 12, 2019
@rwinch rwinch merged commit a51318e into spring-projects:master Aug 12, 2019
@rwinch
Copy link
Member

rwinch commented Aug 12, 2019

Thanks for the PR @larsgrefer! This is now merged into master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: build An issue in the build type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants