views:

86

answers:

0

I'm building an executable jar for a maven java project I have. It works great but I have a problem in that I want my config directory to live outside the jar so that I can change things easily if needed.

I've got to the point where I have the jar being built without the config include and the the config directory is placed in the same dir as the jar. So all looks good.

When I run the jar though it cannot find the config directory. My maven assembly plugin looks like this. You can see I'm adding . .. ./config and ../config to the classpath in an attempt to get it to work.

<plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2-beta-5</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.unicredit.limits.cache.Start</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>./config/ .. . ../config/</Class-Path>
                    </manifestEntries>
                </archive>
                <descriptors>
                    <descriptor>src/main/assembly/buildCombinedJarWithoutConfig.xml</descriptor>
                    <descriptor>src/main/assembly/buildZipWithCombinedJarAndExternalConfig.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

This results in my manifest.mf looking like

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: tmpcap1
Build-Jdk: 1.6.0_21
Main-Class: com.unicredit.limits.cache.Start
Class-Path: ./config/ .. . ../config/

It still doesn't find the dir though.

Reading java.class.path at startup always shows.

ClassPath : LimitsCache-1.0-SNAPSHOT-jar-with-dependencies.jar

Is it possible to get the config dir on the classpath?