0

I am using appassembler plugin from mojo for creating a runnable batch/shell script for my application. I have to add a particular directory to my classpath, so what changes should I do in my pom.xml configuration for mojo's plugin.

Currently classpath is generated with all required library path in my batch file as below

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

All I need to do is add a separate variable like MY_PATH and add it to the classpath as below

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

To add to further there is a tag <configurationDirectory> but that I have already provided for a different directory, now if I have to add further more directory then what would be solution?

How can i achieve it? Below is the 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>

Ducaz035
  • 3,054
  • 2
  • 25
  • 45
gahlot.jaggs
  • 1,083
  • 3
  • 11
  • 21
  • 1
    As you showed how to solve it, I can't see the problem? Or do you ask for something like `set "CLASSPATH=%CLASSPATH%;%MY_PATH%"` – jeb Oct 18 '13 at 06:56
  • This should be done using mojo plugin automatically by providing appropriate configuration in my pom.xml file. The one which I have written should be the final outcome of my batchfile after running `mvn package appassembler:assemble` – gahlot.jaggs Oct 18 '13 at 07:06
  • The classpath can contain a folder `etc` which is usally used for properties/configuration files via `includeConfigurationDirectoryInClasspath`. Apart from that it would be helpful to see your pom file. Furthermore you should bind the appassembler plugin to the package phase instead of calling the goal manually. – khmarbaise Oct 18 '13 at 07:32
  • @khmarbaise. added pom.xml as requested. I didnt understant by what u said "bind the appassembler plugin to the package phase instead of calling the goal manually" – gahlot.jaggs Oct 18 '13 at 08:02
  • I am trying indent my code but not doing well. – gahlot.jaggs Oct 18 '13 at 08:12
  • Which version of appassembler-maven-plugin do you use? – khmarbaise Oct 18 '13 at 08:27
  • @khmarbaise how can I be sure which version of plugin I am using ? basically I am getting warning while doing `mvn package...` as below `[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:appassembler-maven-plugin is missing. @ line 48, column 12` – gahlot.jaggs Oct 18 '13 at 08:55
  • Based on the warning you should add a line with the version `1.5` for the plugin. – khmarbaise Oct 18 '13 at 09:08
  • Added but no change in output batch file, yea warning gone – gahlot.jaggs Oct 18 '13 at 09:10

0 Answers0