Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Pre-defined Descriptor중 bin descriptor 를 사용하면 편리하다.편리하며 미리 정의된 포맷은 템플릿은 다음과 같다.

Expand
Code Block
languagexml
titlebin descriptor format:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  <id>bin</id>
  <formats>
    <format>tar.gz</format>
    <format>tar.bz2</format>
    <format>zip</format>
  </formats>
  <fileSets>
    <fileSet>
      <directory>${project.basedir}</directory>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>README*</include>
        <include>LICENSE*</include>
        <include>NOTICE*</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>*.jar</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}/site</directory>
      <outputDirectory>docs</outputDirectory>
    </fileSet>
  </fileSets>
</assembly>


사전 정의된 템플릿을 수정하여 다음과 같이 custom bin descriptor 를 적용할 수 있다.

  1. assembly-descriptor 작성를  작성하고 프로젝트의 root 에 저장한다.

    Code Block
    languagexml
    titleassembly-desc-bin.xml
    <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
      <id>bin</id>
      <formats>
        <format>zip</format>
      </formats>
      <fileSets>
        <fileSet>
          <directory>${project.basedir}</directory>
          <outputDirectory>/</outputDirectory>
          <includes>
            <include>README*</include>
            <include>LICENSE*</include>
            <include>NOTICE*</include>
          </includes>
        </fileSet>
        <fileSet>
          <directory>${project.build.directory}</directory>
          <outputDirectory>/</outputDirectory>
          <includes>
            <include>*.jar</include>
            <include>*.pdf</include>
          </includes>
          <excludes>
          	<exclude>pom.xml</exclude>
          </excludes>
        </fileSet>
    	<!-- 예제 소스 패키징 -->
    	<!-- 예제소스 위치: src/test/java/com/snakeoil/example !-->
    	<fileSet>
          <directory>src/test/java/com/snakeoil/example</directory>
          <outputDirectory>/com/snakeoil/example</outputDirectory>
          <excludes>
    	    <exclude>**/target/**</exclude>
    	  </excludes>
        </fileSet>
      </fileSets>
    </assembly>
  2. pom.xml 에 plugin 설정 및 descriptors 에 기술

    Code Block
    <build>
     <plugins>
      <plugin>
    	<groupId>org.apache.maven.plugins</groupId>
    	<artifactId>maven-assembly-plugin</artifactId>
    	<version>2.4</version>
    	<configuration>
    		<descriptors>
                <!-- 위에서 작성한 파일명 기술 -->
    			<descriptor>assembly-desc-bin.xml</descriptor>
    		</descriptors>
    	</configuration>
    	<executions>
    		<execution>
    			<id>bin</id>
    			<phase>package</phase>
    			<goals>
    				<goal>single</goal>
    			</goals>
    		</execution>
    	</executions>
     </plugin>
     </plugins>
    </build>
  3. mvn package 를 실행
  4. ${artifactId}-${version}-bin.zip 으로 package 가 생성된다.

...