2012-04-14 10 views

Antwort

6

Diese Art von Bereitstellung Verzeichnisstruktur ist sehr beliebt und haben von vielen brillante Anwendungen wie Apache Maven und Ant übernommen.

Ja, wir können dies erreichen, indem wir maven-assembly-plugin bei maven package phase verwenden.

Beispiel pom.xml:

<!-- Pack executable jar, dependencies and other resource into tar.gz --> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <version>2.2-beta-5</version> 
    <executions> 
     <execution> 
     <phase>package</phase> 
     <goals><goal>attached</goal></goals> 
     </execution> 
    </executions> 
    <configuration> 
     <descriptors> 
     <descriptor>src/main/assembly/binary-deployment.xml</descriptor> 
     </descriptors> 
    </configuration> 
    </plugin> 

Beispiel binär deployment.xml:

<!-- 
    release package directory structure: 
    *.tar.gz 
     conf 
     *.xml 
     *.properties 
     lib 
     application jar 
     third party jar dependencies 
     run.sh 
     run.bat 
--> 
<assembly> 
    <id>bin</id> 
    <formats> 
    <format>tar.gz</format> 
    </formats> 
    <includeBaseDirectory>true</includeBaseDirectory> 
    <fileSets> 
    <fileSet> 
     <directory>src/main/java</directory> 
     <outputDirectory>conf</outputDirectory> 
     <includes> 
     <include>*.xml</include> 
     <include>*.properties</include> 
     </includes> 
    </fileSet> 
    <fileSet> 
     <directory>src/main/bin</directory> 
     <outputDirectory></outputDirectory> 
     <filtered>true</filtered> 
     <fileMode>755</fileMode> 
    </fileSet> 
    <fileSet> 
     <directory>src/main/doc</directory> 
     <outputDirectory>doc</outputDirectory> 
     <filtered>true</filtered> 
    </fileSet> 
    </fileSets> 
    <dependencySets> 
    <dependencySet> 
     <outputDirectory>lib</outputDirectory> 
     <useProjectArtifact>true</useProjectArtifact> 
     <unpack>false</unpack> 
     <scope>runtime</scope> 
    </dependencySet> 
    </dependencySets> 
</assembly> 
+0

sieht gut aus, danke – mibutec

Verwandte Themen