2012-03-09 80 views
0

我有一個包含一些地圖縮減代碼和幾個命令行工具的jar。mvn依賴插件和Hadoop

要分發我依賴我使用Maven的依賴插件封裝我所有的依賴在一個lib directoy我的罐子內:

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.3</version> 
      <executions> 
       <execution> 
        <id>copy-dependencies</id> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>copy-dependencies</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${project.build.directory}/classes/lib</outputDirectory> 
         <overWriteReleases>false</overWriteReleases> 
         <overWriteSnapshots>false</overWriteSnapshots> 
         <overWriteIfNewer>true</overWriteIfNewer> 
         <excludeScope>provided</excludeScope> 
        </configuration> 
       </execution> 
       <execution> 
        <id>build-classpath</id> 
        <phase>generate-sources</phase> 
        <goals> 
         <goal>build-classpath</goal> 
        </goals> 
        <configuration> 
         configure the plugin here 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

我希望有我的罐子使用lib目錄當我運行各種在命令行的java類-cp myJar.jar org.mycompany.MyClass

然而,這並不能看到,儘管操縱MANIFEST.MF

<configuration> 
       <archive> 
        <manifest> 
         <addClasspath>true</addClasspath> 
         <classpathPrefix>./lib/</classpathPrefix> 
         <mainClass>com.mycompany.MainClass</mainClass> 
        </manifest> 
       </archive> 
      </configuration> 
我最大的努力工作

有沒有辦法做到這一點,而不使用maven-assembly-plugin?

+0

爲什麼「不使用maven-assembly-plugin」? – 2012-03-11 06:52:26

+0

我已經知道如何使用程序集插件來做到這一點。我只是好奇,想知道是否有我缺少的替代品。 – 2012-03-12 16:53:39

回答

2

我假設你正在討論在map/reduce作業中使用這些依賴關係。如果是這樣,請看看來自Pere Ferrera Bertran的this article,它解釋瞭如何使用hadoop的分佈式緩存(以及其他兩種方式)來實現這一點。