2013-12-18 67 views
2

我想從我的項目庫中的靜態內容上傳到亞馬遜S3(簡單存儲服務),其中包括封閉內部的src/main/webapp的。對於所有內容亞馬遜S3服務器到我需要使用maven插件在構建時自動執行此類資源上載。上傳靜態資源使用Maven插件

雖然研究我偶然發現了一些這樣的Maven插件值得注意的是:

  1. S3-上載了Maven插件(見文檔here) - 它僅支持在同一時間
  2. 單文件上傳s3-static-uploader(請參閱文檔here) - 令人振奮的前景展望未來,但功能最少
  3. aws -parent(見文檔here) - 沒有官方Maven插件釋放,但股S3-靜態上傳接近,我無法使它工作
  4. 的JetS3t(參見發行文檔here

我已經嘗試過所有這些插件,每次都無法實現我的目標。

我來實現我的目標,同時利用S3-靜載是密切和我的聚甲醛看起來像

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

但在行家安裝只有一個文件上傳,它顯示了構建失敗與下一個文件下面的消息:

未能執行目標 io.pst.mojo:S3-靜態上傳者插件:1.1:上傳(默認CLI)上 項目sbworkbenchnavigation的portlet:無法處理文件 /home/pawal/sbworkbench/portlets/sbworkbenchnavigation-portlet/src/main/webapp/css/main.css: 訪問被拒絕 - >

而且旁邊Maven的安裝它爲下一個文件顯示相同的錯誤。並且在所有文件在同一進程中迭代後,構建將顯示成功消息。

問:

  1. 難道我做錯了什麼。我也跟着插件文檔 精確(我認爲)。
  2. 是否有任何其他的maven插件可以用來將靜態內容上傳到Amazion s3服務器?

回答

3

同樣由S3-車皮擴展和車皮插件組合似乎可實現的:

.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> 
+0

完美工作 – rrhartjr