如何在创建批处理文件时使用mojo appassembler插件添加类路径位置

时间:2013-10-18 06:52:54

标签: maven batch-file pom.xml appassembler

我正在使用mojo的appassembler插件为我的应用程序创建一个可运行的批处理/ shell脚本。我必须在我的类路径中添加一个特定的目录,所以我应该在我的pom.xml配置中为mojo的插件做些什么更改。

目前,我的批处理文件中生成了包含所有必需库路径的类路径,如下所示

set CLASSPATH=%BASEDIR%\abc.jar;%REPO%\*.properties

我需要做的就是添加一个单独的变量,如MY_PATH,并将其添加到类路径中,如下所示

set MY_PATH=%BASEDIR%\resources
set CLASSPATH=%BASEDIR%\abc.jar;%REPO%\*.properties;%MY_PATH% 

要进一步添加标签<configurationDirectory>,但我已经提供了另一个目录,现在如果我必须添加更多目录,那么什么是解决方案?

我怎样才能实现它?下面是pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <artifactId>jgcode-framework-parent</artifactId>
    <groupId>com.jaggs</groupId>
    <version>1.0.2</version>
</parent>
<groupId>com.jaggs.server</groupId>
<artifactId>jaggs-code-server</artifactId>
<version>1.0.1-SNAPSHOT</version>


<dependencies>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.4</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.jaggs.password</groupId>
        <artifactId>mypassword</artifactId>
        <version>1.0</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.3</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <configuration>
                <repositoryLayout>flat</repositoryLayout>
                <installArtifacts>false</installArtifacts>
                <assembleDirectory>${project.build.directory}/appassembler</assembleDirectory>
                <includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
                <platforms>
                    <platform>windows</platform>
                    <platform>unix</platform>
                </platforms>
                <defaultJvmSettings>
                    <initialMemorySize>256M</initialMemorySize>
                    <maxMemorySize>256M</maxMemorySize>
                </defaultJvmSettings>
                <programs>
                    <program>
                        <name>ManualDataEntry</name>
                        <mainClass>com.jaggs.bean.ManualDataEntry</mainClass>
                    </program>
                </programs>
                <configurationDirectory>\..\..\jaggs\sec\configuration\</configurationDirectory>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>assemble</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptors>
                    <descriptor>src/main/assembly/assemble.xml</descriptor>
                </descriptors>
                <archive>
                    <manifest>
                        <mainClass>com.jaggs.bean.ManualDataEntry</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>/jaggs/sec/configuration/</Class-Path>
                    </manifestEntries>
                </archive>
                <delimiters>
                    <delimiter>${*}</delimiter>
                </delimiters>
            </configuration>
            <executions>
                <execution>
                    <id>my-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>assembly</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <escapeString>\</escapeString>
            </configuration>
        </plugin>
    </plugins>
</build>

0 个答案:

没有答案