Or, do it the Java way: add the libs to the manifest of your executable jar
(http://maven.apache.org/guides/mini/guide-manifest.html, the libs can stay
in your lib dir) and just have the start-up script set the work dir or cd to
the home directory of the app.
Kalle
On Thu, Oct 23, 2008 at 6:36 PM, Rusty Wright <[EMAIL PROTECTED]>wrote:
> What about simply adding the jars to the classpath without any path, then
> when you run the jar have your script cd into the directory where the jars
> are? The jar with main will be in the same directory as its dependencies.
>
> For example, my pom has
>
> <!-- don't add classpath prefix; that way the jar can run -->
> <!-- from any directory as long as the executing script -->
> <!-- cds into the directory it's in. -->
> <!-- <classpathPrefix> -->
> <!-- ${classpathPrefix}/cars_download -->
> <!-- </classpathPrefix> -->
> <plugin>
> <artifactId>maven-jar-plugin</artifactId>
> <configuration>
> <archive>
> <manifest>
> <addClasspath>true</addClasspath>
>
> <mainClass>
> edu.berkeley.ist.cars.download.main.CarsDownloadMain
> </mainClass>
> </manifest>
> </archive>
> </configuration>
> </plugin>
>
> Then my shell script (unix) looks like
>
> JAVACMD=/usr/jdk/latest/bin/java
>
> FLAVOR=download
>
> RUNDIR=/users/facility/cars_runner/${FLAVOR}
>
> JARFILE=cars_${FLAVOR}.jar
>
> JARPATH=${RUNDIR}/${JARFILE}
>
> # first cd to the directory where everything is.
> # the classpath in the jar file doesn't specify the
> # full path so we need to be in with the jars.
>
> cd ${RUNDIR}
>
> 2>&1 ( ${JAVACMD} -jar ${JARPATH} ) >> ${RUNDIR}/logs/${FLAVOR}.log
>
> Here's my assembly xml file that generates the zip file where all the jars
> and shell script go in; this gets extracted on the server where the jar
> runs.
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <assembly>
> <id>download</id>
>
> <formats>
> <format>zip</format>
> </formats>
>
> <includeBaseDirectory>false</includeBaseDirectory>
>
> <baseDirectory>/</baseDirectory>
>
> <moduleSets>
> <moduleSet>
> <includes>
> <include>edu.berkeley.ist:cars_download</include>
> </includes>
>
> <binaries>
> <unpack>false</unpack>
> <useStrictFiltering>true</useStrictFiltering>
> <includeDependencies>true</includeDependencies>
> <outputDirectory>download</outputDirectory>
> </binaries>
> </moduleSet>
> </moduleSets>
>
> <files>
> <file>
> <source>src/stuff/scripts/cars_download.sh</source>
> <lineEnding>unix</lineEnding>
> <filtered>true</filtered>
> <outputDirectory>download</outputDirectory>
> </file>
>
> <file>
> <source>src/stuff/notes/crontab.txt</source>
> <lineEnding>unix</lineEnding>
> <filtered>true</filtered>
> <outputDirectory>download</outputDirectory>
> </file>
> </files>
> </assembly>
>
>
>
> Stephen Connolly wrote:
>
>> have you had a look at the appassembler-mavn-plugin on mojo?
>>
>> I use it and antrun and buildhelper to create a zip with batch files and
>> bash scripts and all the dependencies for projects
>>
>> -Stephen
>>
>> 2008/10/23 carlos f <[EMAIL PROTECTED]>
>>
>> jar-with-dependencies is not a practical option for our project so we
>>> have
>>> come up with a custom assembly that generates a zip/tar of:
>>> - our projects jar
>>> - a lib dir with all of our projects dependencies
>>> - bat scripts to execute the jar
>>>
>>> However I still need to add all of the jars in the lib to the classpath
>>> when
>>> invoking java in the bat scripts.
>>>
>>> Is there any way to have maven add the appropriate dependencies entries
>>> for
>>> the bat script based on the current runtime classpath?
>>>
>>> Carlos
>>> --
>>> View this message in context:
>>>
>>> http://www.nabble.com/assembly---grabbing-runtime-classpath-for-bat-script-tp20138852p20138852.html
>>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>