2011-09-06 84 views
1

我有一個maven項目,它保存配置信息並將它打包在一個zip文件中。我使用maven依賴項插件將內容解壓縮到$ {project.build.directory}/unpacked,然後運行資源插件來過濾內容並直接將它們轉儲到$ {project.build.directory}。maven exec插件 - logback不起作用

當我運行maven exec時,我的logback.xml沒有被拾取。它看起來類路徑設置爲$ {basedir},但我希望它有$ {project.build.directory},那個和測試類,和類。

任何時候我嘗試添加一個類路徑元素,我得到一個配置錯誤。

我應該如何配置我的pom.xml來支持它,這甚至有可能嗎?

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

        <executions> 
         <execution> 
          <id>run</id> 
          <phase>package</phase> 
          <goals> 
           <goal>java</goal> 
          </goals> 
         </execution> 
        </executions> 

        <configuration> 
         <workingDirectory>${project.build.directory}</workingDirectory> 

         <mainClass>${jar.mainClass}</mainClass> 
        </configuration> 
       </plugin> 
+0

你如何調用maven exec以及它現在是如何配置的? – Cephalopod

+0

我通過將它附加到我相信的包生命週期來調用它。我把它放在一個特定的配置文件中,可執行文件,這樣我就可以通過簡單地說mvn clean package -Pexecutable來運行它。 – Walter

+0

默認情況下,構建目錄應該是類路徑的一部分。 exec如何配置,以及您的logback.xml位於何處? – Cephalopod

回答

0

這應該可以解決問題。

 <plugin> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>2.3.1</version> 
      <configuration> 
       <archive> 
        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> 
        <manifest> 
         <addClasspath>true</addClasspath> 
         <!-- <classpathPrefix></classpathPrefix> --> 
         <mainClass>com.stackoverflow.test</mainClass> 
        </manifest> 

        <manifestEntries> 
         <Class-Path>${project.build.outputDirectory}/unpacked/logback.xml</Class-Path> 
        </manifestEntries> 
       </archive> 
      </configuration> 
     </plugin>