2009-09-30 80 views
2

我正在使用Maven的exec:java爲我的項目之一運行jline(下面附帶的當前POM)。該項目曾經是一個單一的組件,所以所有的依賴都與exec:java插件定義在同一個POM中。這工作得很好,所有的依賴關係都被拾起,並在運行'mvn exec:java'時放在類路徑中。然而,我現在已經將項目分成幾個模塊,並希望在exec:java運行時從每個模塊獲取依賴關係,但我無法弄清楚如何配置它。建議將不勝感激!獲取Maven exec:使用項目模塊依賴關係的java插件

感謝, 尼克


<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <name>Lensfield</name> 
    <groupId>org.lensfield</groupId> 
    <artifactId>lensfield-pom</artifactId> 
    <version>0.1-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>1.5</source> 
        <target>1.5</target> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>1.1</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>java</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <includeProjectDependencies>true</includeProjectDependencies> 
        <includePluginDependencies>true</includePluginDependencies> 
        <executableDependency> 
         <groupId>jline</groupId> 
         <artifactId>jline</artifactId> 
        </executableDependency> 
        <mainClass>jline.ConsoleRunner</mainClass> 
        <arguments> 
         <argument>clojure.lang.Repl</argument> 
        </arguments> 
       </configuration> 
       <dependencies> 
        <dependency> 
         <groupId>jline</groupId> 
         <artifactId>jline</artifactId> 
         <version>0.9.94</version> 
        </dependency> 
       </dependencies> 
      </plugin> 
     </plugins> 
    </build> 
    <modules> 
     <module>lensfield-share</module> 
     <module>lensfield-build</module> 
     <module>lensfield-webapp</module> 
    </modules> 
</project> 

回答

2

您可以指定該項目的parent POM,並在父母的pluginManagement部分中定義的EXEC的插件。這意味着插件配置將可用於聲明最小插件配置的任何子POM。以下就足夠了。

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>exec-maven-plugin</artifactId> 
</plugin> 

當孩子被處理完畢,就會從父繼承的配置,以及EXEC-插件將與當前項目的依賴執行。

+0

輝煌 - 非常感謝! – eldoctoro 2009-09-30 12:21:50