Skip to content

Commit b9d26ef

Browse files
committed
Add GraalVM Native Image compilation support
Add archetype-app-quickstart archetype
1 parent 5774a10 commit b9d26ef

File tree

95 files changed

+2967
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2967
-37
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"contributor": "",
4+
"type": "feature",
5+
"description": "Created a new archetype, `archetype-app-quickstart`, which allows you to create a simple application with SDK dependencies"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"contributor": "",
4+
"type": "feature",
5+
"description": "Add GraalVM Native Image configurations for SDK classes"
6+
}

archetypes/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ This module contains maven archetypes for AWS Java SDK 2.x.
55

66
## Archetypes
77

8-
- [archetype-lambda](archetype-lambda/README.md) - a lambda function template using AWS Java SDK 2.x
8+
- [archetype-app-quickstart](archetype-app-quickstart/README.md) - a simple client application
9+
template using the AWS SDK for Java 2.x
10+
- [archetype-lambda](archetype-lambda/README.md) - an AWS Lambda function
11+
template using the AWS SDK for Java 2.x
12+
913

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Maven Archetype for client applications using the AWS SDK for Java 2.x
2+
3+
## Description
4+
This is an Apache Maven Archetype to create a client application with
5+
a dependency of [AWS Java SDK 2.x][aws-java-sdk-v2].
6+
7+
### Features
8+
9+
The generated application has the following features:
10+
11+
- Uses [Bill of Materials](BOM) to manage SDK dependencies
12+
- Contains the code to create the SDK client
13+
- Out-of-box support of GraalVM Native Image when `nativeImage` is enabled
14+
15+
## Usage
16+
17+
You can use `mvn archetype:generate` to generate a project using this archetype. See [maven archetype usage guidance][maven-archetype-usage] for more information.
18+
19+
- Interactive mode
20+
21+
```
22+
mvn archetype:generate \
23+
-DarchetypeGroupId=software.amazon.awssdk \
24+
-DarchetypeArtifactId=archetype-app-quickstart \
25+
-DarchetypeVersion=2.x
26+
```
27+
28+
- Batch mode
29+
30+
```
31+
mvn archetype:generate \
32+
-DarchetypeGroupId=software.amazon.awssdk \
33+
-DarchetypeArtifactId=archetype-app-quickstart \
34+
-DarchetypeVersion=2.x \
35+
-DgroupId=com.test \
36+
-DnativeImage=true \
37+
-DhttpClient=apache-client \
38+
-DartifactId=sample-project \
39+
-Dservice=s3 \
40+
-DinteractiveMode=false
41+
```
42+
43+
### Parameters
44+
45+
Parameter Name | Default Value | Description
46+
---|---|---
47+
`service` (required) | n/a | Specifies the service client to be used in the application, eg: s3, dynamodb. Only one service should be provided. You can find available services [here][java-sdk-v2-services].
48+
`groupId`(required) | n/a | Specifies the group ID of the project
49+
`artifactId`(required) | n/a | Specifies the artifact ID of the project
50+
`nativeImage`(required) | n/a | Specifies whether GraalVM Native Image configuration should be included
51+
`httpClient`(required) | n/a | Specifies the http client to be used by the SDK client. Available options are `url-connection-client` (sync), `apache-client` (sync), `netty-nio-client` (async). See [http clients][sdk-http-clients]
52+
`javaSdkVersion` | Same version as the archetype version | Specifies the version of the AWS Java SDK 2.x to be used
53+
`version` | 1.0-SNAPSHOT | Specifies the version of the project
54+
`package` | ${groupId} | Specifies the package name for the classes
55+
56+
57+
[aws-java-sdk-v2]: https://github.com/aws/aws-sdk-java-v2
58+
[java-sdk-v2-services]: https://github.com/aws/aws-sdk-java-v2/tree/master/services
59+
[sdk-http-clients]: https://github.com/aws/aws-sdk-java-v2/tree/master/http-clients
60+
[maven-archetype-usage]: https://maven.apache.org/archetype/maven-archetype-plugin/usage.html
61+
[graalvm]: https://www.graalvm.org/docs/getting-started/#native-images
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License").
6+
~ You may not use this file except in compliance with the License.
7+
~ A copy of the License is located at
8+
~
9+
~ http://aws.amazon.com/apache2.0
10+
~
11+
~ or in the "license" file accompanying this file. This file is distributed
12+
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
~ express or implied. See the License for the specific language governing
14+
~ permissions and limitations under the License.
15+
-->
16+
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<parent>
21+
<artifactId>archetypes</artifactId>
22+
<groupId>software.amazon.awssdk</groupId>
23+
<version>2.16.1-SNAPSHOT</version>
24+
</parent>
25+
<modelVersion>4.0.0</modelVersion>
26+
27+
<artifactId>archetype-app-quickstart</artifactId>
28+
<packaging>maven-archetype</packaging>
29+
<name>AWS Java SDK :: Archetype App</name>
30+
<description>
31+
The AWS SDK for Java - Maven archetype for a sample application using AWS Java SDK 2.x
32+
</description>
33+
34+
<properties>
35+
<maven.archetype.version>3.2.0</maven.archetype.version>
36+
<maven.resource.plugin.version>3.2.0</maven.resource.plugin.version>
37+
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
38+
</properties>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>software.amazon.awssdk</groupId>
43+
<artifactId>archetype-tools</artifactId>
44+
<version>${awsjavasdk.version}</version>
45+
<scope>provided</scope>
46+
</dependency>
47+
</dependencies>
48+
<build>
49+
<!-- Filtering the resource properties to get ${project.version} from archetype metadata.
50+
See https://stackoverflow.com/a/22300149 -->
51+
<resources>
52+
<resource>
53+
<directory>src/main/resources</directory>
54+
<filtering>true</filtering>
55+
<includes>
56+
<include>META-INF/maven/archetype-metadata.xml</include>
57+
</includes>
58+
</resource>
59+
<resource>
60+
<directory>src/main/resources</directory>
61+
<filtering>false</filtering>
62+
<excludes>
63+
<exclude>META-INF/maven/archetype-metadata.xml</exclude>
64+
</excludes>
65+
</resource>
66+
</resources>
67+
<extensions>
68+
<extension>
69+
<groupId>org.apache.maven.archetype</groupId>
70+
<artifactId>archetype-packaging</artifactId>
71+
<version>${maven.archetype.version}</version>
72+
</extension>
73+
</extensions>
74+
75+
<plugins>
76+
<plugin>
77+
<artifactId>maven-archetype-plugin</artifactId>
78+
<version>${maven.archetype.version}</version>
79+
<configuration>
80+
<noLog>true</noLog>
81+
<ignoreEOLStyle>true</ignoreEOLStyle>
82+
<skip>${skip.unit.tests}</skip>
83+
</configuration>
84+
<executions>
85+
<execution>
86+
<id>integration-test</id>
87+
<phase>verify</phase>
88+
<goals>
89+
<goal>integration-test</goal>
90+
</goals>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
95+
<!-- Copy the global.vm and serviceMapping.vm from archetype-tools -->
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-dependency-plugin</artifactId>
99+
<version>${maven-dependency-plugin.version}</version>
100+
<executions>
101+
<execution>
102+
<id>unpack-archetype-tools</id>
103+
<phase>process-classes</phase>
104+
<goals>
105+
<goal>unpack</goal>
106+
</goals>
107+
<configuration>
108+
<artifactItems>
109+
<artifactItem>
110+
<groupId>software.amazon.awssdk</groupId>
111+
<artifactId>archetype-tools</artifactId>
112+
<version>${project.version}</version>
113+
<outputDirectory>${basedir}/target/classes/archetype-resources</outputDirectory>
114+
<includes>**/*.vm</includes>
115+
</artifactItem>
116+
</artifactItems>
117+
</configuration>
118+
</execution>
119+
</executions>
120+
</plugin>
121+
122+
<!-- workaround to copy the global.vm and serviceMapping.vm to the sub folders
123+
because global.vm is not so global any more
124+
see https://github.com/aws/aws-sdk-java-v2/issues/1981 -->
125+
<plugin>
126+
<artifactId>maven-resources-plugin</artifactId>
127+
<version>${maven.resource.plugin.version}</version>
128+
<executions>
129+
<execution>
130+
<id>copy-resources-to-sub-folder</id>
131+
<phase>process-classes</phase>
132+
<goals>
133+
<goal>copy-resources</goal>
134+
</goals>
135+
<configuration>
136+
<outputDirectory>${basedir}/target/classes/archetype-resources/src/main/java</outputDirectory>
137+
<encoding>UTF-8</encoding>
138+
<resources>
139+
<resource>
140+
<directory>${basedir}/target/classes/archetype-resources</directory>
141+
<includes>
142+
<include>global.vm</include>
143+
<include>serviceMapping.vm</include>
144+
</includes>
145+
</resource>
146+
</resources>
147+
</configuration>
148+
</execution>
149+
<execution>
150+
<id>copy-resources-to-sub-folder-2</id>
151+
<phase>process-classes</phase>
152+
<goals>
153+
<goal>copy-resources</goal>
154+
</goals>
155+
<configuration>
156+
<outputDirectory>${basedir}/target/classes</outputDirectory>
157+
<encoding>UTF-8</encoding>
158+
<resources>
159+
<resource>
160+
<directory>${basedir}/target/classes/archetype-resources</directory>
161+
<includes>
162+
<include>global.vm</include>
163+
<include>serviceMapping.vm</include>
164+
</includes>
165+
</resource>
166+
</resources>
167+
</configuration>
168+
</execution>
169+
</executions>
170+
</plugin>
171+
</plugins>
172+
</build>
173+
174+
</project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="archetype-app-quickstart"
3+
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<fileSets>
6+
<fileSet filtered="true" packaged="true" encoding="UTF-8">
7+
<directory>src/main/java</directory>
8+
<includes>
9+
<include>**/*.java</include>
10+
</includes>
11+
</fileSet>
12+
<fileSet filtered="true" packaged="true" encoding="UTF-8">
13+
<directory>src/test/java</directory>
14+
<includes>
15+
<include>**/*.java</include>
16+
</includes>
17+
</fileSet>
18+
<fileSet filtered="true" packaged="false" encoding="UTF-8">
19+
<directory>src/main/resources</directory>
20+
<includes>
21+
<include>simplelogger.properties</include>
22+
</includes>
23+
</fileSet>
24+
<fileSet filtered="true" encoding="UTF-8">
25+
<directory/>
26+
<includes>
27+
<include>.gitignore</include>
28+
<include>README.md</include>
29+
</includes>
30+
</fileSet>
31+
</fileSets>
32+
<requiredProperties>
33+
<requiredProperty key="javaSdkVersion">
34+
<defaultValue>${project.version}</defaultValue>
35+
<validationRegex>\d+\.\d+.\d+</validationRegex>
36+
</requiredProperty>
37+
<requiredProperty key="service">
38+
</requiredProperty>
39+
<requiredProperty key="httpClient">
40+
<validationRegex>(url-connection-client|apache-client|netty-nio-client)</validationRegex>
41+
</requiredProperty>
42+
<requiredProperty key="nativeImage">
43+
<validationRegex>(true|false)</validationRegex>
44+
</requiredProperty>
45+
</requiredProperties>
46+
</archetype-descriptor>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Eclipse
2+
.classpath
3+
.project
4+
.settings/
5+
6+
# Intellij
7+
.idea/
8+
*.iml
9+
*.iws
10+
11+
# Mac
12+
.DS_Store
13+
14+
# Maven
15+
target/
16+
17+
**/dependency-reduced-pom.xml
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#[[#]]# App
2+
3+
This project contains a maven application with [AWS Java SDK 2.x](https://github.com/aws/aws-sdk-java-v2) dependencies.
4+
5+
#[[##]]# Prerequisites
6+
- Java 1.8+
7+
- Apache Maven
8+
- GraalVM Native Image (optional)
9+
10+
#[[##]]# Development
11+
12+
Below is the structure of the generated project.
13+
14+
```
15+
├── src
16+
│   ├── main
17+
│   │   ├── java
18+
│   │   │   └── package
19+
│   │   │   ├── App.java
20+
│   │   │   ├── DependencyFactory.java
21+
│   │   │   └── Handler.java
22+
│   │   └── resources
23+
│   │   └── simplelogger.properties
24+
│   └── test
25+
│   └── java
26+
│   └── package
27+
│   └── HandlerTest.java
28+
```
29+
30+
- `App.java`: main entry of the application
31+
- `DependencyFactory.java`: creates the SDK client
32+
- `Handler.java`: you can invoke the api calls using the SDK client here.
33+
34+
#[[####]]# Building the project
35+
```
36+
mvn clean package
37+
```
38+
39+
#if( $nativeImage == 'true')
40+
#[[####]]# Building the native image
41+
42+
Note that it requires `native-image` installed in your environment
43+
44+
```
45+
mvn clean package -P native-image
46+
```
47+
After it finishes, you can find the generated native image in the `target
48+
` folder.
49+
50+
You can run the following command to execute it.
51+
52+
```
53+
target/${artifactId}
54+
```
55+
#end

0 commit comments

Comments
 (0)