2013-10-17 62 views
1

我正在使用來自mojo的appassembler。我需要做的是我必須添加項目的特定路徑(如%BASEDIR%\resources)到類路徑,目前它只將%REPO%添加到類路徑。我應該在我的pom.xml中做些什麼改變。我已經提供了下面的代碼。使用appassembler-maven-plugin添加classpath用於生成批處理文件

<configurationDirectory>/some/path</configurationDirectory> 
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath> 

和輸出批處理文件包含

set CLASSPATH=%BASEDIR%\\..\SOME\PATH;%REPO%\abc.jar 

我我最後的結果應該是什麼?

set CLASSPATH=%BASEDIR%\\..\SOME\PATH;%REPO%\abc.jar;%BASEDIR%\resources 

應該在我的pom.xml合併爲達到上述結果有何變化?

+0

重複http://stackoverflow.com/questions/19443377/how-can-i-add-classpath-location-by-using-mojo-appassembler-plugin-while-creatin – khmarbaise

+0

的酵母是重複但沒有人迴應如此創建一個新的線程。對不起。 –

回答

0

這個問題在許多情況下非常有用,例如允許不同的jdbc驅動程序或用戶插件。在我的情況下,我想要一個jrebel構建,因此我必須更改類路徑並通過構建目錄切換jar。但我認爲修改腳本以適應您的需求並不是很困難。請注意,您需要maven> = 3.0.3,因爲從maven 3.0.3開始,所有插件的執行順序與您在pom.xml中的順序完全相同。因此,在您的appassembler插件調用後立即插入此插件。

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-enforcer-plugin</artifactId> 
    <version>1.3.1</version> 
    <executions> 
     <execution> 
     <id>enforce-beanshell</id> 
     <phase>package</phase> 
     <goals> 
      <goal>enforce</goal> 
     </goals> 
     <configuration> 
      <rules> 
      <evaluateBeanshell> 
       <condition> 
        import java.io.File; 
        import java.nio.file.*; 
        import java.nio.charset.Charset; 
        import java.nio.charset.StandardCharsets; 

        print("replace jrebel classpath in ${basedir}/dist/bin/rebelServer"); 
        Path path = Paths.get("${basedir}/dist/bin/rebelServer", new String[]{}); 
        Charset charset = StandardCharsets.UTF_8; 

        String content = new String(Files.readAllBytes(path), charset); 
        content = content.replaceAll(
        "\"\\$REPO\"/kic/engine/CoreEngine/[^/]+/CoreEngine\\-[^;:/]+\\.jar", 
        "${basedir}/build/classes"); 

        Files.write(
        path, 
        content.getBytes(charset), 
        new OpenOption[]{StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING,StandardOpenOption.WRITE} 
       ); 

        true; 
       </condition> 
      </evaluateBeanshell> 
      </rules> 
      <fail>false</fail> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 
相關問題