[TOC] # 建立存儲桶 Create A Bucket # 請求簽發公有證書 Request A Public Certificate # 創建全球內容分發網絡分配 Create An Amazon CloudFront Distribution # 使用 Amazon CloudFront 全球內容分發網絡分配為靜態網站提供服務 Use an Amazon CloudFront Distribution To Serve A Static Website # 添加用戶 Add User ## 基於資源的策略 Resource-Based Policies ## 以編程方式訪問的 AWS 安全憑證 AWS Security Credentials w/ Programmatic Access ### 管理 IAM 用戶的訪問密鑰 Managing Access Key For IAM User # 編輯 `$M2_HOME/settings.xml` 編輯 Apache Maven 的設定檔。 ```xml <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- other fragments omitted for brevity --> <servers> <server> <id>DISTRIBUTION_REPOSITORY_ID</id> <username>AWS_ACCESS_KEY_ID</username> <password>AWS_SECRET_ACCESS_KEY</password> </server> </servers> <!-- other fragments omitted for brevity --> </settings> ``` - **`DISTRIBUTION_REPOSITORY_ID`** 將用於開發項目中的 **`pom.xml`** 裡。 - 將前一節的 **`AWS_ACCESS_KEY_ID`** 代入。 - 將前一節的 **`AWS_SECRET_ACCESS_KEY`** 代入。 # 編輯 Maven 專案/項目的 `pom.xml` ```xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <!-- other fragments omitted for brevity --> <distributionManagement> <repository> <id>DISTRIBUTION_REPOSITORY_ID</id> <url>s3://BUCKET_NAME</url> </repository> <snapshotRepository> <id>DISTRIBUTION_REPOSITORY_ID</id> <url>s3://BUCKET_NAME</url> </snapshotRepository> </distributionManagement> <build> <extensions> <extension> <groupId>com.gkatzioura.maven.cloud</groupId> <artifactId>s3-storage-wagon</artifactId> <version>2.3</version> </extension> </extensions> <plugins> <plugin> <!-- explicitly define maven-deploy-plugin after other to force exec order --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>3.1.1</version> <executions> <execution> <id>deploy</id> <phase>deploy</phase> <goals> <goal>deploy</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.6.3</version> <executions> <execution> <id>attach-javadocs</id> <phase>deploy</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> <configuration> <doclint>all,-missing</doclint> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.3.0</version> <executions> <execution> <id>attach-sources</id> <phase>deploy</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <!-- other fragments omitted for brevity --> </project> ``` - 將前一節的 **`DISTRIBUTION_REPOSITORY_ID`** 代入。 ## `/project/build/extensions/extension` ### `com.gkatzioura.maven.cloud:s3-storage-wagon` - [GitHub](https://github.com/gkatzioura/CloudStorageMaven) :::warning This repository [has been archived by the owner on Apr 16, 2021](https://github.com/seahen/maven-s3-wagon/commit/7a1ee124a2bc97499eca82dbd3beec6cad5b62e9 "@seahen committed on 2021-03-27T14:43Z [maven-release-plugin] prepare for next development iteration"). It is now read-only. ::: - [Maven Repository](https://mvnrepository.com/artifact/com.gkatzioura.maven.cloud/s3-storage-wagon) - [sonatype | Maven Central](https://central.sonatype.com/artifact/com.gkatzioura.maven.cloud/s3-storage-wagon) ### `com.github.seahen:maven-s3-wagon` - [GitHub](https://github.com/seahen/maven-s3-wagon) - [Maven](https://central.sonatype.com/artifact/com.github.seahen/maven-s3-wagon) ## `/project/build/plugins/plugin` ### `org.apache.maven.plugins:maven-deploy-plugin` - [GitHub](https://github.com/apache/maven-deploy-plugin) - [Home](https://maven.apache.org/plugins/maven-deploy-plugin/) - [Maven Repository](https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-deploy-plugin) - [sonatype | Maven Central](https://central.sonatype.com/artifact/org.apache.maven.plugins/maven-deploy-plugin) ### `org.apache.maven.plugins:maven-javadoc-plugin` - [GitHub](https://github.com/apache/maven-javadoc-plugin) - [Home](https://maven.apache.org/plugins/maven-javadoc-plugin/) - [Maven Repository](https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin) - [sonatype | Maven Central](https://central.sonatype.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin) ### 解決討人厭的 JavaDoc 檢查 - [Stack Overflow: **How to disable Javadoc warnings in Maven Javadoc Plugin?**](https://stackoverflow.com/questions/39616344/how-to-disable-javadoc-warnings-in-maven-javadoc-plugin) - [Apache &#187; Maven &#187; Plugins &#187; Apache Maven Javadoc Plugin &#187; **Usage**](https://maven.apache.org/plugins/maven-javadoc-plugin/usage.html) - [Apache &#187; Maven &#187; Plugins &#187; Apache Maven Javadoc Plugin &#187; **javadoc:javadoc**](https://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html) - [The javadoc Command &#187; **Additional Options Provided by the Standard Doclet**](https://docs.oracle.com/en/java/javase/17/docs/specs/man/javadoc.html#additional-options-provided-by-the-standard-doclet) ### `org.apache.maven.plugins:maven-source-plugin` - [GitHub](https://github.com/apache/maven-source-plugin) - [Home](https://maven.apache.org/plugins/maven-source-plugin/) - [Maven Repository](https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-source-plugin) - [sonatype | Maven Central](https://central.sonatype.com/artifact/org.apache.maven.plugins/maven-source-plugin) # 將 JavaDoc、Source 及 Artifact 一起部署到自訂/私有 Maven Repository :::info 此操作會將 artifact 安裝到 `~/.m2/repository/` 並部署到 remote。 ::: ```shell mvn clean deploy ``` # 將 JavaDoc、Source 及 Artifact 一起安裝到本地 Maven Repository :::info 此操作僅將 artifact 安裝到 `~/.m2/repository/` 不會部署到 remote。 ::: ```shell mvn clean install ```