如何使用Maven将jar部署到S3?

问题描述 投票:15回答:1

我有一个正在使用Maven构建的项目,我需要将其发布到私有S3存储库。

我找到了AWS Maven Wagon,但是当我尝试进行部署时,出现了身份验证错误:

[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)。我完整的pom.xml文件如下所示:

<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>
    <artifactId>custom-file-extension-windows-bundler</artifactId>
    <version>1.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <developers>
        <developer>
            <name>Danny Althoff</name>
            <email>[email protected]</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>
                <artifactId>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>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                        <manifestEntries>
                            <display_version>${display_version}</display_version>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
        <extensions>
            <extension>
                <groupId>org.springframework.build</groupId>
                <artifactId>aws-maven</artifactId>
                <version>5.0.0.RELEASE</version>
            </extension>
        </extensions>
    </build>

    <dependencies>
        <dependency>
            <groupId>javafx-packager</groupId>
            <artifactId>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很老,并且使用了过时的身份验证机制:

所以,我也尝试过:

<groupId>org.zalando.org.springframework.build</groupId>
<artifactId>aws-maven</artifactId>
<version>5.0.0.RELEASE-zal-2</version>

但是我得到相同的结果。

我的凭据在C:\ Users \ pupeno.m2 \ settings.xml中进行配置,如下所示:

<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>

我的相关政策如下:

{
    "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": "*"
        }
    ]
}
java maven amazon-web-services amazon-s3
1个回答
0
投票

有帮助吗?

  <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>
© www.soinside.com 2019 - 2024. All rights reserved.