You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by lobesquare <lo...@googlemail.com> on 2009/08/14 20:48:03 UTC

Copy arbitrary files into jar (generation)

Hello,

i am quite new to ant and would like to modify a generated ant file from
eclipse in that way that certain files are copied into the created jar. Here
is what I tried

<target name="create_run_jar">
        <jar destfile="/dv/ws/my.jar" filesetmanifest="mergewithoutmain">
            <manifest>
                <attribute name="Main-Class" value="ec.main"/>
                <attribute name="Class-Path" value="."/>
            </manifest>
            <fileset dir="/dv/ws/bin"/>

The previous part is generated ... now I try to copy a source folder into
the jar ...

            <fileset dir="/dv/ws/javasources"> 
        	<include name="**/*.java"/>
             </fileset>

Unfortunately this fails (no folder "javasources" is created in the
resulting jar).

Any hints would be great! :)

Greetings,

   lobequadrat
-- 
View this message in context: http://www.nabble.com/Copy-arbitrary-files-into-jar-%28generation%29-tp24976733p24976733.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Copy arbitrary files into jar (generation)

Posted by lobesquare <lo...@googlemail.com>.
Supareno,


supareno wrote:
> 
> lobesquare,
> 
> why the sources files in the jar
> why don't you try to do a zip ou tar.gz file with the sources files and 
> the jar ?
> it could be easier...
> 
> 

Hm, I'd like to have a single file (to distribute). Is this not directly
possible?

Greetings,

   lobesquare
-- 
View this message in context: http://www.nabble.com/Copy-arbitrary-files-into-jar-%28generation%29-tp24976733p24978058.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Copy arbitrary files into jar (generation)

Posted by supareno <re...@free.fr>.
lobesquare,

why the sources files in the jar
why don't you try to do a zip ou tar.gz file with the sources files and 
the jar ?
it could be easier...

> Hello,
>
> i am quite new to ant and would like to modify a generated ant file from
> eclipse in that way that certain files are copied into the created jar. Here
> is what I tried
>
> <target name="create_run_jar">
>         <jar destfile="/dv/ws/my.jar" filesetmanifest="mergewithoutmain">
>             <manifest>
>                 <attribute name="Main-Class" value="ec.main"/>
>                 <attribute name="Class-Path" value="."/>
>             </manifest>
>             <fileset dir="/dv/ws/bin"/>
>
> The previous part is generated ... now I try to copy a source folder into
> the jar ...
>
>             <fileset dir="/dv/ws/javasources"> 
>         	<include name="**/*.java"/>
>              </fileset>
>
> Unfortunately this fails (no folder "javasources" is created in the
> resulting jar).
>
> Any hints would be great! :)
>
> Greetings,
>
>    lobequadrat
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Copy arbitrary files into jar (generation)

Posted by Andy Stevens <in...@googlemail.com>.
2009/8/14 Mike Baranczak <mb...@gmail.com>:
>2009/8/14 supareno <re...@free.fr>:
>>           <fileset dir="/dv/ws/javasources">
>>        <include name="**/*.java"/>
>>            </fileset>
>
> 2. What this fileset specifies is "all Java files in directory
> /dv/ws/javasources/". It doesn't say anything about creating a "javasources"
> directory in the jar.
>
> You probably want something like this:
>
> <fileset dir="${basedir}/dv/ws">
>   <include name="javasources"/>
> </fileset>

Or, given that http://ant.apache.org/manual/CoreTasks/jar.html states
"The extended fileset and groupfileset child elements from the zip
task are also available in the jar task",

<zipfileset dir="${basedir}/dv/ws/javasources" includes="**/*.java"
prefix="srcfiles"/>

could work too, and allows for using a different directory name for
those files in the zip.


Andy
-- 
http://pseudoq.sourceforge.net/  Open source java sudoku creator

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Copy arbitrary files into jar (generation)

Posted by lobesquare <lo...@googlemail.com>.
Hi Mike,


Mike Baranczak-3 wrote:
> 
> 
>>            <fileset dir="/dv/ws/javasources">
>>        	<include name="**/*.java"/>
>>             </fileset>
> 
> I see two problems here.
> 
> 1. A path that begins with a "/" is an absolute path. I can't tell if  
> this is what you want, but I suspect you actually want a path relative  
> to the project directory.
> 
> 2. What this fileset specifies is "all Java files in directory /dv/ws/ 
> javasources/". It doesn't say anything about creating a "javasources"  
> directory in the jar.
> 
> You probably want something like this:
> 
> <fileset dir="${basedir}/dv/ws">
>     <include name="javasources"/>
> </fileset>
> 
> -MB
> 
> 

1. was/is correct but 2. did the trick ... thanks! :)

Greetings,
   
   lobesquare
-- 
View this message in context: http://www.nabble.com/Copy-arbitrary-files-into-jar-%28generation%29-tp24976733p24982398.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Copy arbitrary files into jar (generation)

Posted by Mike Baranczak <mb...@gmail.com>.
>            <fileset dir="/dv/ws/javasources">
>        	<include name="**/*.java"/>
>             </fileset>

I see two problems here.

1. A path that begins with a "/" is an absolute path. I can't tell if  
this is what you want, but I suspect you actually want a path relative  
to the project directory.

2. What this fileset specifies is "all Java files in directory /dv/ws/ 
javasources/". It doesn't say anything about creating a "javasources"  
directory in the jar.

You probably want something like this:

<fileset dir="${basedir}/dv/ws">
    <include name="javasources"/>
</fileset>

-MB



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org