2013-07-01 114 views
1

幾個星期前我剛開始學習maven。目前試圖在我的腦海中實現結構。一切都知道是完美的,但我有一個關於部署的問題。Maven:更改遠程目錄結構

的問題是:

當我執行mvn release:perform文物被部署到我的FTP服務器ftp://centos-release/maven/linuxapp/releases/com/gmail/baturman/linuxapp/linuxapp/0.0.5/路徑。

,當我執行mvn deploy當前快照被部署到FTP服務器ftp://centos-gitlab/maven/linuxapp/snapshots/com/gmail/baturman/linuxapp/linuxapp/0.0.6-SNAPSHOT/

一切都很酷,但是,這不是我想要的結構。我想有這樣的目錄結構:

對於版本:ftp://centos-release/maven/linuxapp/releases/0.0.5/

對於快照:ftp://centos-release/maven/linuxapp/snapshots/0.0.6-SNAPSHOT/

能否請指教?

這是我的pom文件。

<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>com.gmail.baturman.linuxapp</groupId> 
<artifactId>linuxapp</artifactId> 
<version>0.0.5-SNAPSHOT</version> 
<description>Linux App - Powered by git and maven :)</description> 
<name>Linux App</name> 

<!-- PROPERTIES --> 
<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<!-- DEPENDENCIES --> 
<dependencies> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.17</version> 
    </dependency> 
</dependencies> 



<!-- RELEASE INFORMATION --> 
<scm> 
    <connection>scm:git:[email protected]:maven/linuxapp.git</connection> 
    <developerConnection>scm:git:[email protected]:maven/linuxapp.git</developerConnection> 
    <url>http://centos-gitlab/maven/linuxapp</url> 
    <tag>v0.0.3</tag> 
</scm> 

<distributionManagement> 
    <repository> 
     <id>release-server</id> 
     <name>Release Repository</name> 
     <url>ftp://centos-gitlab/maven/${project.artifactId}/releases</url> 
    </repository> 
    <snapshotRepository> 
     <id>release-server</id> 
     <name>Snapshot Repository</name> 
     <url>ftp://centos-gitlab/maven/${project.artifactId}/snapshots</url> 
     <uniqueVersion>false</uniqueVersion> 
    </snapshotRepository> 
</distributionManagement> 



<!-- BUILD --> 
<build> 
    <finalName>${project.artifactId}</finalName> 

    <!-- EXTENSIONS --> 
    <extensions> 
     <extension> 
      <groupId>org.apache.maven.wagon</groupId> 
      <artifactId>wagon-ftp</artifactId> 
      <version>2.4</version> 
     </extension> 
    </extensions> 

    <!-- RESOURCES --> 
    <resources> 
     <resource> 
      <directory>src/main/resources</directory> 
     </resource> 
     <resource> 
      <directory>src/main/conf</directory> 
      <excludes> 
       <exclude>*.properties</exclude> 
      </excludes> 
     </resource> 
    </resources> 

    <!-- PLUGINS --> 
    <plugins> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>2.4</version> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.4</version> 
      <configuration> 
       <descriptor>src/main/assembly/assembly.xml</descriptor> 
       <useJvmChmod>true</useJvmChmod> 
      </configuration> 
      <executions> 
       <execution> 
        <id>release-server</id> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-release-plugin</artifactId> 
      <version>2.4.1</version> 
      <configuration> 
       <tagNameFormat>[email protected]{project.version}</tagNameFormat> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

+0

爲什麼你需要它部署的方式?它匹配你在你的pom.xml中定義的'groupId',即你告訴它做的事情。通過這種方式部署,你會獲得什麼?即你是否有一個現有的腳本/應用程序(它不使用Maven依賴關係解析庫)需要它以「你的」方式部署? – noahlz

+0

嗨,感謝您的回答,我正在部署的FTP服務器不打算用作Maven存儲庫。這就像發佈內部網絡中的所有東西。 – WhiteScars

+0

在這種情況下,您需要創建一個自定義插件或Maven ant運行任務,將工件複製到您選擇的目錄格式。 – noahlz

回答

1

首先,我會建議開始使用一個倉庫管理像NexusArtifactoryArchiva比ftp服務器更好的解決方案。除此之外,你必須改變你的定義:

<distributionManagement> 
    <repository> 
     <id>release-server</id> 
     <name>Release Repository</name> 
     <url>ftp://centos-gitlab/maven/releases/</url> 
    </repository> 
    <snapshotRepository> 
     <id>release-server</id> 
     <name>Snapshot Repository</name> 
     <url>ftp://centos-gitlab/maven/snapshots/</url> 
     <uniqueVersion>false</uniqueVersion> 
    </snapshotRepository> 
</distributionManagement> 
+0

感謝您的建議,但正如我在我的評論中所述,我想使用此FTP服務器發佈內部使用的所有內容(工件,文檔等)。 – WhiteScars

+0

使用存儲庫不會阻止發佈所有內容以供內部使用。我沒有看到FTP服務器相對於可通過簡單http訪問的Repository服務器的優勢。 – khmarbaise

+0

嗨,感謝您的建議。起初我以爲版本庫管理員是在線服務,但顯然看起來,我可以在我的服務器上安裝Archiva。感謝您的提示。 – WhiteScars