2013-08-08 4 views
2

내가 자바 프로젝트를위한 항아리를 생성하기 위해 노력하고 있습니다를 사용하여 파일 및 단지를 압축 한 후 jar 파일과 받는다는 - 조립 플러그인을 사용하여 lib 디렉토리를 압축하지만 프로젝트가 포함되어 있지 않습니다 zip 파일의 항아리. 나가 시도하는 무엇 이건이 어떤 문제점 또는 다른 사람이있다. 비슷한 예가 있습니까?빌드 자바 프로젝트 항아리와는 메이븐

답변

2

의 pom.xml

... 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <version>2.4</version> 
       <configuration> 
        <archive> 
         <manifest> 
          <addClasspath>true</addClasspath> 
          <classpathPrefix>lib/</classpathPrefix> 
         </manifest> 
        </archive> 
        <descriptors> 
         <descriptor>src/assembly/assembly.xml</descriptor> 
        </descriptors> 
       </configuration> 
      </plugin> 
... 

assembly.xml에게

<assembly> 
    <id>assembly</id> 
    <formats> 
     <format>zip</format> 
    </formats> 
    <dependencySets> 
     <dependencySet> 
      <useProjectArtifact>false</useProjectArtifact> 
      <outputDirectory>/lib</outputDirectory> 
      <unpack>false</unpack> 
     </dependencySet> 
    </dependencySets> 
    <fileSets> 
     <fileSet> 
      <directory>${project.build.directory}</directory> 
      <outputDirectory></outputDirectory> 
      <includes> 
       <include>*.jar</include> 
      </includes> 
     </fileSet> 
    </fileSets> 
</assembly> 
0

나는 jar가 들어있는 eat 모듈을 만드는 예제가있다. 어쩌면 당신을 도울 수있는보세요.

<?xml version="1.0" encoding="UTF-8"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <modelVersion>4.0.0</modelVersion> 

    <parent> 
    <groupId>cat.base.gpt</groupId> 
    <artifactId>gpt</artifactId> 
    <version>0.0.1</version> 
    </parent> 

    <artifactId>gpt.ear</artifactId> 
    <name>gpt.ear</name> 
    <packaging>ear</packaging> 
    <description>Paquet de l'aplicació J2EE</description> 

    <dependencies> 
    <!-- 
    dependencies definides al pom-pare é sncessari especificar el type 
    ja que per defecte type=jar 
    --> 
     <dependency> 
      <groupId>${project.groupId}</groupId> 
      <artifactId>gpt.domini</artifactId> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>${project.groupId}</groupId> 
      <artifactId>gpt.ejb</artifactId> 
      <type>ejb</type> 
     </dependency> 
     <dependency> 
      <groupId>${project.groupId}</groupId> 
      <artifactId>gpt.logica</artifactId> 
      <type>jar</type> 
     </dependency> 
     <dependency> 
      <groupId>${project.groupId}</groupId> 
      <artifactId>gpt.ui</artifactId> 
      <type>war</type> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-ear-plugin</artifactId> 
       <configuration> 
        <description>GPT</description> 
        <displayName>Gestió posicions tributarias</displayName> 
        <encoding>${project.build.sourceEncoding}</encoding> 
        <version>1.4</version> 
        <skinnyWars>true</skinnyWars> 
        <generateApplicationXml>true</generateApplicationXml> 
        <modules> 
         <ejbModule> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>${project.parent.artifactId}.ejb</artifactId> 
          <bundleFileName>${project.parent.artifactId}-ejb.jar</bundleFileName> 
         </ejbModule> 
         <jarModule> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>gpt.logica</artifactId> 
          <includeInApplicationXml>true</includeInApplicationXml> 
         </jarModule>       
         <webModule> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>gpt.ui</artifactId> 
          <contextRoot>/gpt</contextRoot> 
         </webModule> 
        </modules> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
       <configuration> 
        <excludeScope>runtime</excludeScope> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 
+0

감사를 시도하지만 내가하려고했던 것과 매우 다르다. – user1323670

관련 문제