You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by carlos f <ca...@yahoo.com> on 2008/10/23 22:34:47 UTC

assembly - grabbing runtime classpath for bat script

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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: assembly - grabbing runtime classpath for bat script

Posted by carlos f <ca...@yahoo.com>.
i discovered the app assembler
(http://mojo.codehaus.org/appassembler/index.html) 5 minutes after i posted. 
I am just working out how to pass in some jvm args at runtime.

Thanks!

Carlos

Stephen Connolly-2 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 <ca...@yahoo.com>
> 
>>
>> 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: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/assembly---grabbing-runtime-classpath-for-bat-script-tp20138852p20149998.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: My Maven central repositori

Posted by Wendy Smoak <ws...@gmail.com>.
On Sun, Oct 26, 2008 at 6:06 AM, Koxkorrita <ko...@laudio.info> wrote:
> for the project developers i want to generate one central repositori (in my
> office) where are all the libraries.
> for this pourpose i want to download the maven central all libraries or
> almost al libraries that uses my project.

Take a look at the various repository managers (Archiva, Nexus, etc.,)
which can host your internal repositories and optionally act as a
proxy for the central repository.

http://maven.apache.org/repository-management.html

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


My Maven central repositori

Posted by Koxkorrita <ko...@laudio.info>.
Hello.

i must to begin one java project using maven.
for the project developers i want to generate one central repositori (in my 
office) where are all the libraries.
for this pourpose i want to download the maven central all libraries or 
almost al libraries that uses my project.

how can i made this?
i want to put this libraries into one of my servers. for this pourpose i 
have installed the maven into one of them. how can i setup this maven 
instalation for downloading i need libraries and i'll use this server as my 
central repositori?

can you help me please?

thanks 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: assembly - grabbing runtime classpath for bat script

Posted by Rusty Wright <ru...@gmail.com>.
In my setup the jars are all listed in the manifest but they don't have any directory prepended.  The jar with main is in the same directory as the jars listed in its manifest.  The script that runs it cds to that directory.  It doesn't set classpath since the current directory is normally in it.

If I understand your description, with your setup the jars in the manifest would each need to have the lib directory prepended to them (classpathPrefix).  The advantage of my method (probably minor) is that I can move the work and lib directories (since they are the same directory) and it still works.  The disadvantage is that each app has its own copy of the jar files, but that could be an advantage since I don't have to worry about version issues with shared jars.


Kalle Korhonen wrote:
> 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 <ru...@gmail.com>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 <ca...@yahoo.com>
>>>
>>>  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: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: assembly - grabbing runtime classpath for bat script

Posted by Kalle Korhonen <ka...@gmail.com>.
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 <ru...@gmail.com>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 <ca...@yahoo.com>
>>
>>  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: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: assembly - grabbing runtime classpath for bat script

Posted by Rusty Wright <ru...@gmail.com>.
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 <ca...@yahoo.com>
> 
>> 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: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: assembly - grabbing runtime classpath for bat script

Posted by Stephen Connolly <st...@gmail.com>.
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 <ca...@yahoo.com>

>
> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>