How do I deploy jars to S3 with maven?
我有一个正在使用Maven构建的项目,我需要将其发布到私有S3存储库中。
我找到了AWS Maven Wagon,但是当我尝试进行部署时,出现了身份验证错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ custom-file-extension-windows-bundler --- Downloading from aws-snapshot: s3://project-x-support/maven2/de/dynamicfiles/projects/javafx/bundler/custom-file-extension-windows-bundler/1.0.1-SNAPSHOT/maven-metadata.xml Uploading to aws-snapshot: s3://project-x-support/maven2/de/dynamicfiles/projects/javafx/bundler/custom-file-extension-windows-bundler/1.0.1-SNAPSHOT/custom-file-extension-windows-bundler-1.0.1-20180119.133946-1.jar Uploading to aws-snapshot: s3://project-x-support/maven2/de/dynamicfiles/projects/javafx/bundler/custom-file-extension-windows-bundler/1.0.1-SNAPSHOT/custom-file-extension-windows-bundler-1.0.1-20180119.133946-1.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 5.773 s [INFO] Finished at: 2018-01-19T13:39:46Z [INFO] Final Memory: 23M/254M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project custom-file-extension-windows-bundler: Failed to deploy artifacts: Could not transfer artifact de.dynamicfiles.projects.javafx.bundler:custom-file-extension-windows-bundler:jar:1.0.1-20180119.133946-1 from/to aws-snapshot (s3://project-x-su pport/maven2): Cannot write directory 'maven2/': Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: CE401778F4180C1E) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException |
我非常确定凭据和权限是正确的,因为我正在使用它们来使用Gradle部署jar(我从.aws / credentials复制到.m2 / settings.xml)。我完整的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <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"> <modelVersion>4.0.0</modelVersion> <groupId>de.dynamicfiles.projects.javafx.bundler</groupId> custom-file-extension-windows-bundler</artifactId> <version>1.0.1-SNAPSHOT</version> <packaging>jar</packaging> <developers> <developer> <name>Danny Althoff</name> fibrefox@dynamicfiles.de</email> <url>https://www.dynamicfiles.de</url> </developer> </developers> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <version.java.source>1.8</version.java.source> <version.java.target>1.8</version.java.target> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>${version.java.source}</source> <target>${version.java.target}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> maven-jar-plugin</artifactId> <version>3.0.1</version> <configuration> <manifest> true</addDefaultImplementationEntries> true</addDefaultSpecificationEntries> </manifest> <manifestEntries> <display_version>${display_version}</display_version> </manifestEntries> </archive> </configuration> </plugin> </plugins> <extensions> <extension> <groupId>org.springframework.build</groupId> aws-maven</artifactId> <version>5.0.0.RELEASE</version> </extension> </extensions> </build> <dependencies> <dependency> <groupId>javafx-packager</groupId> javafx-packager</artifactId> <version>1.8.0_40</version> <scope>system</scope> <systemPath>${java.home}/../lib/ant-javafx.jar</systemPath> </dependency> </dependencies> <distributionManagement> <repository> <id>aws-release</id> <name>AWS Release Repository</name> <url>s3://project-x-support/maven2</url> </repository> <snapshotRepository> <id>aws-snapshot</id> <name>AWS Snapshot Repository</name> <url>s3://project-x-support/maven2</url> </snapshotRepository> </distributionManagement> </project> |
我已经注意到,AWS Maven Wagon很老,并且使用了过时的身份验证机制:
- https://github.com/spring-projects/aws-maven/issues/48
- https://github.com/spring-projects/aws-maven/issues/44
- https://github.com/spring-projects/aws-maven/issues/50
所以,我也尝试了:
1 2 3 | <groupId>org.zalando.org.springframework.build</groupId> aws-maven</artifactId> <version>5.0.0.RELEASE-zal-2</version> |
但是我得到相同的结果。
我的凭据在C:\\\\\\\\ Users \\\\\\\\ pupeno.m2 \\\\\\\\ settings.xml中进行配置,如下所示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <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"> <servers> <server> <id>aws-release</id> <username>BLAHBLAH</username> <password>SECRETBLAHBLAH</password> </server> <server> <id>aws-snapshot</id> <username>BLAHBLAH</username> <password>SECRETBLAHBLAH</password> </server> </servers> </settings> |
我的相关政策如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | { "Version":"2012-10-17", "Statement": [ { "Sid":"VisualEditor0", "Effect":"Allow", "Action": [ "s3:PutAnalyticsConfiguration", "s3:GetObjectVersionTagging", "s3:CreateBucket", "s3:ReplicateObject", "s3:GetObjectAcl", "s3:DeleteBucketWebsite", "s3:PutLifecycleConfiguration", "s3:GetObjectVersionAcl", "s3:PutObjectTagging", "s3:DeleteObject", "s3:GetIpConfiguration", "s3:DeleteObjectTagging", "s3:GetBucketWebsite", "s3:PutReplicationConfiguration", "s3:DeleteObjectVersionTagging", "s3:GetBucketNotification", "s3:PutBucketCORS", "s3:GetReplicationConfiguration", "s3:ListMultipartUploadParts", "s3:PutObject", "s3:GetObject", "s3:PutBucketNotification", "s3:PutBucketLogging", "s3:GetAnalyticsConfiguration", "s3:GetObjectVersionForReplication", "s3:GetLifecycleConfiguration", "s3:ListBucketByTags", "s3:GetInventoryConfiguration", "s3:GetBucketTagging", "s3:PutAccelerateConfiguration", "s3:DeleteObjectVersion", "s3:GetBucketLogging", "s3:ListBucketVersions", "s3:ReplicateTags", "s3:RestoreObject", "s3:ListBucket", "s3:GetAccelerateConfiguration", "s3:GetBucketPolicy", "s3:GetObjectVersionTorrent", "s3:AbortMultipartUpload", "s3:PutBucketTagging", "s3:GetBucketRequestPayment", "s3:GetObjectTagging", "s3:GetMetricsConfiguration", "s3:DeleteBucket", "s3:PutBucketVersioning", "s3:ListBucketMultipartUploads", "s3:PutMetricsConfiguration", "s3:PutObjectVersionTagging", "s3:GetBucketVersioning", "s3:GetBucketAcl", "s3:PutInventoryConfiguration", "s3:PutIpConfiguration", "s3:GetObjectTorrent", "s3:PutBucketWebsite", "s3:PutBucketRequestPayment", "s3:GetBucketCORS", "s3:GetBucketLocation", "s3:ReplicateDelete", "s3:GetObjectVersion" ], "Resource": [ "arn:aws:s3:::project-x-support/*", "arn:aws:s3:::project-x-support" ] }, { "Sid":"VisualEditor1", "Effect":"Allow", "Action": [ "s3:ListAllMyBuckets", "s3:HeadBucket", "s3:ListObjects" ], "Resource":"*" } ] } { "Version":"2012-10-17", "Statement": [ { "Sid":"VisualEditor0", "Effect":"Allow", "Action":"s3:GetBucketLocation", "Resource":"*" }, { "Sid":"VisualEditor1", "Effect":"Allow", "Action":"s3:ListAllMyBuckets", "Resource":"*" } ] } |
这有帮助吗?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <servers> <server> <id>BUCKET_NAME.release</id> <username>ACCESSKEYID</username> <password>SECRETACCESSKEY</password> <filePermissions>BucketOwnerFullControl</filePermissions> </server> <server> <id>BUCKET_NAME.snapshot</id> <username>ACCESSKEYID</username> <password>SECRETACCESSKEY</password> <filePermissions>BucketOwnerFullControl</filePermissions> </server> </servers> |