| commit | 12d907eb537d8f0b8956c4ee9de110d4a7a4f1fa | [log] [tgz] |
|---|---|---|
| author | Dengke Tang <[email protected]> | Thu May 25 16:56:51 2023 -0700 |
| committer | GitHub <[email protected]> | Thu May 25 16:56:51 2023 -0700 |
| tree | 3345d2a7ed756a533e5a0dd808495d77cb6470c4 | |
| parent | 9ec1e1207bc11b635dfe4ffb620354116ebda580 [diff] |
S3 upload with unknown content-length (#628)
Java Bindings for the AWS Common Runtime
This library is licensed under the Apache 2.0 License.
Requirements:
JAVA_HOME is setBuilding:
apt-get install cmake3 maven openjdk-8-jdk-headless -ygit clone https://github.com/awslabs/aws-crt-java.gitcd aws-crt-javagit submodule update --init --recursivemvn compileRequirements:
JAVA_HOME is setbrew install maven cmake (if you have homebrew installed, otherwise install these manually)git clone https://github.com/awslabs/aws-crt-java.gitcd aws-crt-javagit submodule update --init --recursivemvn compileRequirements:
JAVA_HOME is setchoco install maven (if you have chocolatey installed), otherwise install maven and the JDK manuallygit clone https://github.com/awslabs/aws-crt-java.gitcd aws-crt-javagit submodule update --init --recursivemvn compileNOTE: Make sure you run this from a VS Command Prompt or have run VCVARSALL.BAT in your current shell so CMake can find Visual Studio.
From the aws-crt-java directory: mvn install From maven: (https://search.maven.org/artifact/software.amazon.awssdk.crt/aws-crt/)
The aws-crt JAR in Maven Central is a large “uber” jar that contains compiled C libraries for many different platforms (Windows, Linux, etc). If size is an issue, you can pick a smaller platform-specific JAR by setting the <classifier>.
<!-- Platform-specific Linux x86_64 JAR --> <dependency> <groupId>software.amazon.awssdk.crt</groupId> <artifactId>aws-crt</artifactId> <version>0.20.5</version> <classifier>linux-x86_64</classifier> </dependency>
<!-- "Uber" JAR that works on all platforms --> <dependency> <groupId>software.amazon.awssdk.crt</groupId> <artifactId>aws-crt</artifactId> <version>0.20.5</version> </dependency>
The os-maven-plugin can automatically detect your platform's classifier at build time.
NOTES: The auto-detected linux-arm_32 platform classifier is not supported, you must specify linux-armv6 or linux-armv7.
<build> <extensions> <!-- Generate os.detected.classifier property --> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.7.0</version> </extension> </extensions> </build> <dependencies> <dependency> <groupId>software.amazon.awssdk.crt</groupId> <artifactId>aws-crt</artifactId> <version>0.20.5</version> <classifier>${os.detected.classifier}</classifier> </dependency> <dependencies>
Please note that on Mac, once a private key is used with a certificate, that certificate-key pair is imported into the Mac Keychain. All subsequent uses of that certificate will use the stored private key and ignore anything passed in programmatically. Beginning in v0.6.6, when a stored private key from the Keychain is used, the following will be logged at the “info” log level:
static: certificate has an existing certificate-key pair that was previously imported into the Keychain. Using key from Keychain instead of the one provided.
Many tests require custom arguments. These tests will be quietly skipped if their arguments are not set. Arguments can be passed like so:
mvn test -Dcertificate=path/to/cert -Dprivatekey=path/to/key ...
Many tests require that you have set up an AWS IoT Thing.
Full list of test arguments:
endpoint: AWS IoT service endpoint hostnamecertificate: Path to the IoT thing certificateprivatekey: Path to the IoT thing private keyprivatekey_p8: Path to the IoT thing private key in PKCS#8 formatecc_certificate: Path to the IoT thing with EC-based certificateecc_privatekey: Path to the IoT thing with ECC private key (The ECC key file should only contains the ECC Private Key section to working on MacOS.)rootca: Path to the root certificateproxyhost: Hostname of proxyproxyport: Port of proxyNETWORK_TESTS_DISABLED: Set this if tests are running in a constrained environment where network access is not guaranteed/allowed.These can be set persistently via Maven settings (usually in ~/.m2/settings.xml):
<settings> ... <profiles> <profile> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <crt.test.endpoint>XXXXXXXXXX-ats.iot.us-east-1.amazonaws.com</crt.test.endpoint> <crt.test.certificate>/path/to/XXXXXXXX-certificate.pem.crt</crt.test.certificate> <crt.test.privatekey>/path/to/XXXXXXXX-private.pem.key</crt.test.privatekey> <crt.test.rootca>/path/to/AmazonRootCA1.pem</crt.test.rootca> ... etc ... </properties> </profile> </profiles> </settings>%
Tests can be debugged in Java/Kotlin via the built-in tooling in VSCode and IntelliJ. If you need to debug the native code, it's a bit trickier.
To debug native code with VSCode or CLion or any other IDE:
Find your mvn launch script(e.g. realpath $(which mvn)) and pull the command line at the bottom from it. This changes between versions of maven, so it is difficult to give consistent directions.
As an example, for Maven 3.6.0 on Linux: /path/to/java -classpath /usr/share/java/plexus-classworlds-2.5.2.jar -Dclassworlds.conf=/usr/share/maven/bin/m2.conf -Dmaven.home=/usr/share/maven -Dlibrary.jansi.path=/usr/share/maven/lib/jansi-native -Dmaven.multiModuleProjectDirectory=. org.codehaus.plexus.classworlds.launcher.Launcher test -DforkCount=0 -Ddebug.native -Dtest=HttpClientConnectionManager#testMaxParallelConnections
The important parts are:
-DforkCount=0 - prevents the Maven process from forking to run tests, so your debugger will be attached to the right process. You can ignore this if you configure your debugger to attach to child processes.-Ddebug.native - Makes CMake compile the JNI bindings and core libraries in debug. By default, we compile in release with symbols, which will help for call stacks, but less so for live debugging.Set the executable to launch to be your java binary (e.g. /usr/bin/java)
Set the parameters to be the ones used by the mvn script, as per above
Set the working directory to the aws-crt-java directory
On windows, you will need to manually load the PDB via the Modules window in Visual Studio, as it is not embedded in the JAR. It will be in the target/cmake-build/lib/windows/<arch> folder.