2011-11-25 115 views
0

我需要創建一個具有依賴關係的jar文件,我需要將rxtx庫作爲依賴項添加。但是當我創建jar時,我無法在jar文件中看到rxtx。請張貼正確的方式來做到這一點。使用Maven Assembly插件打包rxtx庫

這是我的POM文件

.... 
    <dependency> 
     <groupId>org.rxtx</groupId> 
     <artifactId>rxtxcomm</artifactId> 
     <version>2.0-7pre1</version> 
     <scope>run</scope> 
    </dependency> 
.... 

.... 
<plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.2.1</version> 
      <configuration> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
       <archive> 
        <manifest> 
         <mainClass>uom.elect.smeter.Output</mainClass> 
        </manifest> 
       </archive> 
      </configuration> 
      <executions> 
       <execution> 
        <id>make-assembly</id> 
        <!-- this is used for inheritance merges --> 
        <phase>package</phase> 
        <!-- bind to the packaging phase --> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 

     </plugin> 
.... 
+1

的相關部分是'rxtxcomm'一個錯字範圍'run'?如果沒有,那麼這可能是你的問題的原因。它應該是'運行時'或另一個有效範圍。 – Raghuram

+0

錯誤..我試過了。但沒有運氣。彙編插件彙編除rxtx之外的所有包。 – tiran

+0

適合我。你需要提供更多的細節。 rxtxcomm是maven中心還是本地回購的maven依賴項? – Raghuram

回答

0
 <plugin> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>copy</id> 
        <phase>process-resources</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <artifactItems> 
          <artifactItem> 
           <groupId>org.company.project</groupId> 
           <artifactId>RXTXcommJar</artifactId> 
           <version>1.0.0</version> 
           <type>jar</type> 
           <outputDirectory> 
            ${project.build.outputDirectory} 
           </outputDirectory> 
           <destFileName>RXTXcomm.jar</destFileName> 
          </artifactItem> 
          <artifactItem> 
           <groupId>org.company.project</groupId> 
           <artifactId>rxtxParalleldll</artifactId> 
           <version>1.0.0</version> 
           <type>dll</type> 
           <outputDirectory> 
            ${project.build.outputDirectory}/apps/plugin/ 
           </outputDirectory> 
           <destFileName>rxtxParallel.dll</destFileName> 
          </artifactItem> 
          <artifactItem> 
           <groupId>org.company.project</groupId> 
           <artifactId>rxtxSerialdll</artifactId> 
           <version>1.0.0</version> 
           <type>dll</type> 
           <outputDirectory> 
            ${project.build.outputDirectory}/apps/plugin/ 
           </outputDirectory> 
           <destFileName>rxtxSerial.dll</destFileName> 
          </artifactItem>     
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin>