2016-02-18 106 views
0

我正在编写一个Java应用程序,它使用来自我的服务器上运行的其他第三方应用程序的一些库。目前,我正在用appassembler-maven-plugin构建我的应用程序。这个插件将我的jar(app和依赖项)复制到lib文件夹中,并在bin目录中生成一个shellscript。appassembler-maven-plugin将自定义条目添加到类路径

在此shellscirpt中生成类路径。此解决方案的工作原理,但我dublicate依赖性罐(按时间在我的应用程序和第三方 - 应用程序编写应用程序)。我的第三方应用程序的类路径设置为像$ THIRDPARTYAPP_CLASSPATH这样的系统变量。

我想在我的pom.xml中设置依赖项以便提供,以便appassembler不会将它们添加到lib和classpath,并且希望在我的shell脚本中添加systemvar $ THIRDPARTYAPP_CLASSPATH,以便我的应用程序使用jar从已安装的第三方应用程序。

此刻我正在手动执行此操作(在编译后编辑shellscript)并且它工作正常。在appassembler-maven-plugin中是否有任何方法将systemvar自动添加到类路径中?

我在文档中找不到任何东西,其他有关类似问题的问题都没有很好的回答。

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>appassembler-maven-plugin</artifactId> 
    <version>1.8.1</version> 
    <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
       <goal>assemble</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <assembleDirectory>${project.build.directory}/appassembler</assembleDirectory> 
     <extraJvmArguments>-Xms512m -Xmx1024m</extraJvmArguments> 
     <generateRepository>true</generateRepository> 
     <repositoryName>lib</repositoryName> 
     <repositoryLayout>flat</repositoryLayout> 
     <includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath> 
     <platforms> 
      <platform>unix</platform> 
     </platforms> 
     <programs> 
      <program> 
       <mainClass>${mainClass}</mainClass> 
       <id>app</id> 
      </program> 
     </programs> 
    </configuration> 
</plugin> 
+0

首先,为什么要配置默认'assembleDirectory'?你可以配置创建一个' setup-env'',它可以通过'CLASSPATH_PREFIX'定义一个新的classpath部分,它可以解决你的问题。 (顺便说一句:为什么不使用最新版的appassembler?)... – khmarbaise

+0

谢谢!那正是我所期待的。并感谢有关版本和目录的提示。 – Daniel

回答

0

您可以配置创建一个<environmentSetupFileName>setup-env</environmentSetupFileName>可以定义通过CLASSPATH_PREFIX新的类路径一部分应该解决您的问题。

相关问题