2013-10-17 29 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> 
相关问题