Skip to content

Commit 5ba9cf4

Browse files
authored
docs: update documentation for aspectJ (#1273)
* Update documentation for aspectJ * update README
1 parent ba8075f commit 5ba9cf4

12 files changed

+1142
-127
lines changed

README.md

+92-4
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,32 @@ Powertools for AWS Lambda (Java) is a developer toolkit to implement Serverless
1313

1414
Powertools for AWS Lambda (Java) is available in Maven Central. You can use your favourite dependency management tool to install it
1515

16-
* [maven](https://maven.apache.org/):
16+
#### Maven:
1717
```xml
1818
<dependencies>
1919
...
2020
<dependency>
2121
<groupId>software.amazon.lambda</groupId>
2222
<artifactId>powertools-tracing</artifactId>
23-
<version>1.17.0-SNAPSHOT</version>
23+
<version>1.16.0</version>
2424
</dependency>
2525
<dependency>
2626
<groupId>software.amazon.lambda</groupId>
2727
<artifactId>powertools-logging</artifactId>
28-
<version>1.17.0-SNAPSHOT</version>
28+
<version>1.16.0</version>
2929
</dependency>
3030
<dependency>
3131
<groupId>software.amazon.lambda</groupId>
3232
<artifactId>powertools-metrics</artifactId>
33-
<version>1.17.0-SNAPSHOT</version>
33+
<version>1.16.0</version>
3434
</dependency>
3535
...
3636
</dependencies>
3737
```
3838

3939
And configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project:
4040

41+
For Java 11+, use the following:
4142
```xml
4243
<build>
4344
<plugins>
@@ -78,6 +79,93 @@ And configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambd
7879
</build>
7980
```
8081

82+
For Java 8, use the following:
83+
```xml
84+
<build>
85+
<plugins>
86+
...
87+
<plugin>
88+
<groupId>org.codehaus.mojo</groupId>
89+
<artifactId>aspectj-maven-plugin</artifactId>
90+
<version>1.14.0</version>
91+
<configuration>
92+
<source>1.8</source>
93+
<target>1.8</target>
94+
<complianceLevel>1.8</complianceLevel>
95+
<aspectLibraries>
96+
<aspectLibrary>
97+
<groupId>software.amazon.lambda</groupId>
98+
<artifactId>powertools-logging</artifactId>
99+
</aspectLibrary>
100+
<aspectLibrary>
101+
<groupId>software.amazon.lambda</groupId>
102+
<artifactId>powertools-tracing</artifactId>
103+
</aspectLibrary>
104+
<aspectLibrary>
105+
<groupId>software.amazon.lambda</groupId>
106+
<artifactId>powertools-metrics</artifactId>
107+
</aspectLibrary>
108+
</aspectLibraries>
109+
</configuration>
110+
<executions>
111+
<execution>
112+
<goals>
113+
<goal>compile</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
</plugin>
118+
...
119+
</plugins>
120+
</build>
121+
```
122+
#### gradle
123+
124+
For Java 11+:
125+
126+
```groovy
127+
plugins {
128+
id 'java'
129+
id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
130+
}
131+
132+
repositories {
133+
mavenCentral()
134+
}
135+
136+
dependencies {
137+
aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
138+
aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}'
139+
aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}'
140+
}
141+
142+
sourceCompatibility = 11
143+
targetCompatibility = 11
144+
```
145+
146+
For Java8:
147+
148+
```groovy
149+
plugins {
150+
id 'java'
151+
id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
152+
}
153+
154+
repositories {
155+
mavenCentral()
156+
}
157+
158+
dependencies {
159+
aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
160+
aspect 'software.amazon.lambda:powertools-tracing:{{ powertools.version }}'
161+
aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}'
162+
}
163+
164+
sourceCompatibility = 1.8
165+
targetCompatibility = 1.8
166+
```
167+
168+
81169
## Example
82170

83171
See the **[examples](examples)** directory for example projects showcasing usage of different utilities.

docs/core/logging.md

+135
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,141 @@ Logging provides an opinionated logger with output structured as JSON.
1111
* Log Lambda event when instructed, disabled by default, can be enabled explicitly via annotation param
1212
* Append additional keys to structured log at any point in time
1313

14+
## Install
15+
16+
Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes.
17+
18+
=== "Maven Java 11+"
19+
20+
```xml hl_lines="3-7 16 18 24-27"
21+
<dependencies>
22+
...
23+
<dependency>
24+
<groupId>software.amazon.lambda</groupId>
25+
<artifactId>powertools-logging</artifactId>
26+
<version>{{ powertools.version }}</version>
27+
</dependency>
28+
...
29+
</dependencies>
30+
...
31+
<!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
32+
<build>
33+
<plugins>
34+
...
35+
<plugin>
36+
<groupId>dev.aspectj</groupId>
37+
<artifactId>aspectj-maven-plugin</artifactId>
38+
<version>1.13.1</version>
39+
<configuration>
40+
<source>11</source> <!-- or higher -->
41+
<target>11</target> <!-- or higher -->
42+
<complianceLevel>11</complianceLevel> <!-- or higher -->
43+
<aspectLibraries>
44+
<aspectLibrary>
45+
<groupId>software.amazon.lambda</groupId>
46+
<artifactId>powertools-logging</artifactId>
47+
</aspectLibrary>
48+
</aspectLibraries>
49+
</configuration>
50+
<executions>
51+
<execution>
52+
<goals>
53+
<goal>compile</goal>
54+
</goals>
55+
</execution>
56+
</executions>
57+
</plugin>
58+
...
59+
</plugins>
60+
</build>
61+
```
62+
63+
=== "Maven Java 1.8"
64+
65+
```xml hl_lines="3-7 16 18 24-27"
66+
<dependencies>
67+
...
68+
<dependency>
69+
<groupId>software.amazon.lambda</groupId>
70+
<artifactId>powertools-logging</artifactId>
71+
<version>{{ powertools.version }}</version>
72+
</dependency>
73+
...
74+
</dependencies>
75+
...
76+
<!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
77+
<build>
78+
<plugins>
79+
...
80+
<plugin>
81+
<groupId>org.codehaus.mojo</groupId>
82+
<artifactId>aspectj-maven-plugin</artifactId>
83+
<version>1.14.0</version>
84+
<configuration>
85+
<source>1.8</source>
86+
<target>1.8</target>
87+
<complianceLevel>1.8</complianceLevel>
88+
<aspectLibraries>
89+
<aspectLibrary>
90+
<groupId>software.amazon.lambda</groupId>
91+
<artifactId>powertools-logging</artifactId>
92+
</aspectLibrary>
93+
</aspectLibraries>
94+
</configuration>
95+
<executions>
96+
<execution>
97+
<goals>
98+
<goal>compile</goal>
99+
</goals>
100+
</execution>
101+
</executions>
102+
</plugin>
103+
...
104+
</plugins>
105+
</build>
106+
```
107+
108+
=== "Gradle Java 11+"
109+
110+
```groovy hl_lines="3 11"
111+
plugins {
112+
id 'java'
113+
id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0'
114+
}
115+
116+
repositories {
117+
mavenCentral()
118+
}
119+
120+
dependencies {
121+
aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
122+
}
123+
124+
sourceCompatibility = 11
125+
targetCompatibility = 11
126+
```
127+
128+
=== "Gradle Java 1.8"
129+
130+
```groovy hl_lines="3 11"
131+
plugins {
132+
id 'java'
133+
id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
134+
}
135+
136+
repositories {
137+
mavenCentral()
138+
}
139+
140+
dependencies {
141+
aspect 'software.amazon.lambda:powertools-logging:{{ powertools.version }}'
142+
}
143+
144+
sourceCompatibility = 1.8
145+
targetCompatibility = 1.8
146+
```
147+
148+
14149
## Initialization
15150

16151
Powertools for AWS Lambda (Java) extends the functionality of Log4J. Below is an example `#!xml log4j2.xml` file, with the `JsonTemplateLayout` using `#!json LambdaJsonLayout.json` configured.

0 commit comments

Comments
 (0)