2012-07-24 25 views
2

我使用Maven 3.0.4以及Jython 2.5.2和Pygments 1.5(通過一個雞蛋)。我已經配置了Jython的編譯Maven的插件作爲,Maven版本的區別:使用jython時準備並安裝jar

<plugin> 
<groupId>net.sf.mavenjython</groupId> 
<artifactId>jython-compile-maven-plugin</artifactId> 
<version>1.2</version> 
<executions> 
    <execution> 
     <phase>package</phase> 
     <goals> 
      <goal>jython</goal> 
     </goals> 
    </execution> 
</executions> 
<configuration> 
    <libraries> 
     <!-- Install the latest pygments library --> 
     <param>Pygments</param> 
    </libraries> 
</configuration> 

運行MVN安裝創建的JAR包含Pygments來做庫在文件嵌入到。這確保我所有的代碼都能正常工作。

當我運行mvn發行版時,該問題開始:準備命令。在這種情況下,只有我的代碼進入JAR內部,並且庫被忽略。如果我看看目標/類文件夾,它包含我的代碼和所需的pygments庫。

關於我可能會失蹤或做錯的任何想法?

回答

0

我能夠在大量的碰撞和試運行後自行解決問題。該解決方案使用配置maven-jar-plugin來包含目標/類文件夾內的所有文件。這樣,安裝版本:準備目標構建完全相同的二進制文件。

,我用我的項目
<plugin> 
<artifactId>maven-jar-plugin</artifactId> 
<configuration> 
    <includes> 
     <include>**</include> 
    </includes> 
</configuration> 
<executions> 
    <execution> 
     <phase>package</phase> 
     <goals> 
      <goal>jar</goal> 
     </goals> 
    </execution> 
</executions> 
</plugin> 

整個構建分錄下:

<build> 
<plugins> 
    <!-- set compilation properties --> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>2.3.2</version> 
     <configuration> 
      <source>1.6</source> 
      <target>1.6</target> 
     </configuration> 
    </plugin> 

    <!-- Generate the project-javadoc.jar for OSS repository --> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-javadoc-plugin</artifactId> 
     <version>2.8.1</version> 
    </plugin> 

    <!-- Generate the project-sources.jar for OSS repository --> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-source-plugin</artifactId> 
     <version>2.1.2</version> 
    </plugin> 

    <!-- Install Jython and Pygments library --> 
    <plugin> 
     <groupId>net.sf.mavenjython</groupId> 
     <artifactId>jython-compile-maven-plugin</artifactId> 
     <version>1.2</version> 
     <executions> 
      <execution> 
       <phase>package</phase> 
       <goals> 
        <goal>jython</goal> 
       </goals> 
      </execution> 
     </executions> 
     <configuration> 
      <libraries> 
       <!-- Install the latest pygments library --> 
       <param>Pygments</param> 
      </libraries> 
     </configuration> 
    </plugin>  

    <plugin> 
     <artifactId>maven-jar-plugin</artifactId> 
     <configuration> 
      <includes> 
       <include>**</include> 
      </includes> 
     </configuration> 
     <executions> 
      <execution> 
       <phase>package</phase> 
       <goals> 
        <goal>jar</goal> 
       </goals> 
      </execution> 
     </executions> 
    </plugin> 
</plugins> 
</build> 

希望這有助於。

相關問題