Skip to content

Commit cbc9635

Browse files
authored
Merge pull request #367 from l3r8yJ/210
210
2 parents 85132cf + 53f7b5e commit cbc9635

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
------
2+
Weaving Java Binaries
3+
------
4+
Ivan Ivanchuk
5+
------
6+
2024-01-16
7+
------
8+
9+
~~
10+
~~ Copyright (c) 2012-2024, jcabi.com
11+
~~ All rights reserved.
12+
~~
13+
~~ Redistribution and use in source and binary forms, with or without
14+
~~ modification, are permitted provided that the following conditions
15+
~~ are met: 1) Redistributions of source code must retain the above
16+
~~ copyright notice, the list of conditions and the following
17+
~~ disclaimer. 2) Redistributions in binary form must reproduce the above
18+
~~ copyright notice, the list of conditions and the following
19+
~~ disclaimer in the documentation and/or other materials provided
20+
~~ with the distribution. 3) Neither the name of the jcabi.com, nor
21+
~~ the names of its contributors may be used to endorse or promote
22+
~~ products derived from this software without specific prior written
23+
~~ permission.
24+
~~
25+
~~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
~~ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT
27+
~~ NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
28+
~~ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
29+
~~ THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
30+
~~ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, CONSEQUENTIAL DAMAGES
31+
~~ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32+
~~ SERVICES, LOSS OF USE, DATA, PROFITS, OR BUSINESS INTERRUPTION)
33+
~~ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34+
~~ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35+
~~ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
36+
~~ OF THE POSSIBILITY OF SUCH DAMAGE.
37+
~~
38+
## @todo #210:30/DEV Add an integration test
39+
## We need to add an integration test that will
40+
## show how to work with gradle using show how to
41+
## work with Gradle project and jcabi-aspects.
42+
43+
Weaving Java Binaries
44+
45+
{{{http://en.wikipedia.org/wiki/Aspect_weaver}Aspect weaving}} is a process
46+
of modifying binary <<<.class>>> files after compilation in order
47+
to inject AOP advice at certain join points.
48+
49+
First of all, you annotate your classes and methods, and then compile. Then
50+
you run AspectJ weaver which modifies <<<.class>>> files, producing
51+
new "weaved" versions of them.
52+
53+
Luckily, these steps can be automated.
54+
All you need to do to start using our AOP aspects is
55+
add these two artifacts to your <<<build.gradle.kts>>>:
56+
57+
+--
58+
dependencies {
59+
implementation("com.jcabi:jcabi-aspects:${latestVersion}")
60+
}
61+
+--
62+
63+
Then, you use
64+
{{{https://plugins.gradle.org/plugin/io.freefair.aspectj.post-compile-weaving}post-compile-weaving}}
65+
plugin which executes AspectJ weaver to modify your <<<.class>>> files:
66+
67+
+--
68+
plugins {
69+
id("io.freefair.aspectj.post-compile-weaving") version "${latestVersion}"
70+
}
71+
72+
dependencies {
73+
implementation("com.jcabi:jcabi-aspects:${latestVersion}")
74+
aspect("com.jcabi:jcabi-aspects:${latestVersion}")
75+
}
76+
+--
77+
Also, don't forget to mark jcabi dependency as <<<aspect>>>
78+
79+
{{{./example-weaving-eclipse.html}Additional configuration for eclipse
80+
users}}.
81+
82+
That's it. {{{https://www.l3r8y.ru/2024/01/15/how-to-use-jcabi-aspects-with-gradle}Link to original post}}.

0 commit comments

Comments
 (0)