Upload static resource to Amazon s3 server using maven plugin

I want to upload static content from my project repository to Amazon S3 (Simple Storage Service) which includes all the content enclosed inside src/main/webapp.For which i need to use maven plugin to automate such resource upload on build time.

While researching i stumble upon few such maven plugins notably :

  1. s3-upload-maven-plugin (see documentation here) - it only supports single file upload at a time
  2. s3-static-uploader (see documentation here)-an exciting prospect to look forward,however minimal functionality available
  3. aws-parent(see documentation here ) -no official maven plugin released but shares proximity with s3-static-uploader and i was unable to make it work
  4. jetS3t(see release documentation here)

I have tried all these plugins and each time i fail to achieve my goal.

The close i came to achieve my goal was while using s3-static-uploader and my pom looks like

 <plugin>
        <groupId>io.pst.mojo</groupId>
        <artifactId>s3-static-uploader-plugin</artifactId>
        <version>1.1</version>
        <configuration>
            <accessKey>${aws.accessKey}</accessKey>
            <secretKey>${aws.secretKey}</secretKey>
            <bucketName>${aws.bucketName}</bucketName>
            <refreshExpiredObjects>true</refreshExpiredObjects>
            <includes>
                <include>
                    <bind>
                        <!-- Could be path expressions or reg. expressions -->
                        <pattern>%regex[([^\s]+(\.(?i)(jpg|png|gif|bmp|tif|pdf|swf|eps))$)]</pattern>
                        <metadataId>static</metadataId>
                    </bind>
                </include>
                <include>
                    <bind>
                        <pattern>%regex[([^\s]+(\.(?i)(css|js))$)]</pattern>
                        <metadataId>volatile</metadataId>
                    </bind>
                </include>
                <include>
                    <bind>
                        <!-- Extension less files -->
                        <pattern>%regex[^[^.]+$]</pattern>
                        <metadataId>volatile-naked</metadataId>
                    </bind>
                </include>
            </includes>
            <excludes>
                <exclude>WEB-INF/.*</exclude>
            </excludes>
            <metadatas>
                <metadata>
                    <id>static</id>
                    <cacheControl>public</cacheControl>
                    <contentEncoding>plain</contentEncoding>
                    <contentType>text/html</contentType>
                    <cannedAcl>PublicRead</cannedAcl>
                </metadata>
                <metadata>
                    <id>static-longlived</id>
                    <cacheControl>public</cacheControl>
                    <contentEncoding>plain</contentEncoding>
                           <contentType>text/html</contentType>
                    <cannedAcl>PublicRead</cannedAcl>
                </metadata>
                <metadata>
                    <id>volatile</id>
                    <cacheControl>private</cacheControl>
                    <contentEncoding>plain</contentEncoding>
                    <contentType>text/html</contentType>
                    <cannedAcl>PublicRead</cannedAcl>
                </metadata>
                <metadata>
                    <id>volatile-naked</id>
                    <cacheControl>private</cacheControl>
                    <contentEncoding>plain</contentEncoding>
                    <contentType>text/html</contentType>
                    <cannedAcl>PublicRead</cannedAcl>
                </metadata>
            </metadatas>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>upload</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

But on maven install only one file is uploaded and it shows build failure with following message for next file:

Failed to execute goal io.pst.mojo:s3-static-uploader-plugin:1.1:upload (default-cli) on project sbworkbenchnavigation-portlet: cannot process file /home/pawal/sbworkbench/portlets/sbworkbenchnavigation-portlet/src/main/webapp/css/main.css: Access Denied ->

And on next maven install it shows same error for the next file.And after all files are iterated in same process the build shows success message.

Question :

  1. Am i doing anything wrong?.I have followed the plugin documentation precisely(i think).
  2. Are there any other maven plugins that i could use to upload static content to Amazion s3 server?

Answers


I was looking for a solution and decided to fork my own =)

It is based on s3-upload-maven-plugin (I use multiple executions to allow multiple files). Check it out on: https://github.com/moacyrricardo/s3-upload-maven-plugin


The same appears achievable by combination of s3-wagon extension and wagon plugin:

.m2/settings.xml

<servers>
    <server>
      <id>aws-release</id>
      <username>ASFFDSFDSFDSFDSFSFDF</username>
      <password>Hmasdflaskdjflksdjflaskdjflasjdflkasjdfl</password>
    </server>
</servers>

pom.xml

<build>
    <extensions>
        <extension>
            <groupId>org.kuali.maven.wagons</groupId>
            <artifactId>maven-s3-wagon</artifactId>
            <version>1.2.1</version>
        </extension>
    </extensions>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>wagon-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
            <execution>
                <id>deploy-release</id>
                <phase>deploy</phase>
                <goals>
                    <goal>upload</goal>
                </goals>
                <configuration>
                    <serverId>aws-release</serverId>
                    <url>s3://${bucket}/releases/</url>
                    <fromDir>${project.build.directory}</fromDir>
                    <toDir>${project.version}</toDir>
                    <includes>
                        ${project.artifactId}-${project.version}.jar,
                        ${project.artifactId}-${project.version}.dmg,
                        ${project.artifactId}-${project.version}-shaded.jar,
                    </includes>
                </configuration>
            </execution>
        </executions>
    </plugin>
</build>

Need Your Help

Recovering from zmq.error.ZMQError: Address already in use

python sockets unix zeromq amqp

I hit Ctrl-C while running a PAIR pattern (non-blocking client servers) connection with ZMQ. Later when I tried running the REQ-REP (blocking client single server connection) pattern, I keep gettin...