You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Robert Pepersack <RP...@mdinsurance.state.md.us> on 2006/09/13 18:56:55 UTC

Need Help With Task

Hi all,

I'm a to Ant.  I have some Java classes in a single directory tree that
has two child directories (i.e. mia/gui and mia/middleware).  I need to
create two .jar files, one that contains the classes in the mia.gui
package and the other that contains the classes in mia.middleware.  When
I use the <jar> task to archive mia/gui, the directories in the .jar
file start with mia's children, not mia.  I need the root directory in
the .jar file to be mia.

I've tried this a number of ways in my build file with different
elements and attributes.  Here's the simplest:

    <target name="archive" depends="compile" description="Create the
Java archive files">
        <jar destfile="${classes.dir}/mia_gui.jar"
             index="true">
            <fileset dir="${classes.dir}/mia/gui" />
        </jar>
    </target>

Here are the equivalent commands from the batch file (which I don't
want to use any more) that archives my classes:

"%JAVA_HOME%\bin\jar" cf mia_gui.jar mia\gui

"%JAVA_HOME%\bin\jar" cf mia_middleware.jar mia\middleware

Thanks,

Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054

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


Re: Need Help With Task

Posted by Peter Reilly <pe...@gmail.com>.
<jar destfile="${classes.dir}/mia_gui.jar">
    <fileset dir="${classes.dir}" includes="mia/gui/**/>
 </jar>
<jar destfile="${classes.dir}/mia_middleware.jar">
    <fileset dir="${classes.dir}" includes="mia/middleware/**/>
 </jar>

Should do the trick.

Peter

On 9/13/06, Robert Pepersack <RP...@mdinsurance.state.md.us> wrote:
>
> Hi all,
>
> I'm a to Ant.  I have some Java classes in a single directory tree that
> has two child directories (i.e. mia/gui and mia/middleware).  I need to
> create two .jar files, one that contains the classes in the mia.gui
> package and the other that contains the classes in mia.middleware.  When
> I use the <jar> task to archive mia/gui, the directories in the .jar
> file start with mia's children, not mia.  I need the root directory in
> the .jar file to be mia.
>
> I've tried this a number of ways in my build file with different
> elements and attributes.  Here's the simplest:
>
>     <target name="archive" depends="compile" description="Create the
> Java archive files">
>         <jar destfile="${classes.dir}/mia_gui.jar"
>              index="true">
>             <fileset dir="${classes.dir}/mia/gui" />
>         </jar>
>     </target>
>
> Here are the equivalent commands from the batch file (which I don't
> want to use any more) that archives my classes:
>
> "%JAVA_HOME%\bin\jar" cf mia_gui.jar mia\gui
>
> "%JAVA_HOME%\bin\jar" cf mia_middleware.jar mia\middleware
>
> Thanks,
>
> Robert Pepersack
> Senior Lead Developer
> Maryland Insurance Administration
> 410-468-2054
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

RE: Need Help With Task

Posted by Stephen McConnell <mc...@dpml.net>.
 

> -----Original Message-----
> From: Robert Pepersack [mailto:RPepersack@mdinsurance.state.md.us] 
> Sent: Thursday, 14 September 2006 2:27 AM
> To: user@ant.apache.org
> Subject: Need Help With <jar> Task
> 
> Hi all,
> 
> I'm a to Ant.  I have some Java classes in a single directory 
> tree that has two child directories (i.e. mia/gui and 
> mia/middleware).  I need to create two .jar files, one that 
> contains the classes in the mia.gui package and the other 
> that contains the classes in mia.middleware.  When I use the 
> <jar> task to archive mia/gui, the directories in the .jar 
> file start with mia's children, not mia.  I need the root 
> directory in the .jar file to be mia.
> 
> I've tried this a number of ways in my build file with 
> different elements and attributes.  Here's the simplest:
> 
>     <target name="archive" depends="compile" 
> description="Create the Java archive files">
>         <jar destfile="${classes.dir}/mia_gui.jar"
>              index="true">
>             <fileset dir="${classes.dir}/mia/gui" />
>         </jar>
>     </target>

Robert:

How about the following? 

     <target name="archive" depends="compile" 
           description="Create the Java archive files">
         <jar destfile="${classes.dir}/mia_gui.jar" index="true">
             <fileset dir="${classes.dir}">
               <include name="mia/gui/**.*"/>
             </fileset>
         </jar>
     </target>

I've changed the fileset directory to be the directory containing the root
of the classes directory tree and explicity selected classes in the mia.gui
group.

/Steve.


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


Re: Need Help With Task

Posted by Matt Benson <gu...@yahoo.com>.
--- Robert Pepersack
<RP...@mdinsurance.state.md.us> wrote:

> Hi all,
> 
> I'm a to Ant.  I have some Java classes in a single
> directory tree that
> has two child directories (i.e. mia/gui and
> mia/middleware).  I need to
> create two .jar files, one that contains the classes
> in the mia.gui
> package and the other that contains the classes in
> mia.middleware.  When
> I use the <jar> task to archive mia/gui, the
> directories in the .jar
> file start with mia's children, not mia.  I need the
> root directory in
> the .jar file to be mia.
> 
> I've tried this a number of ways in my build file
> with different
> elements and attributes.  Here's the simplest:
> 
>     <target name="archive" depends="compile"
> description="Create the
> Java archive files">
>         <jar destfile="${classes.dir}/mia_gui.jar"
>              index="true">
>             <fileset dir="${classes.dir}/mia/gui" />
>         </jar>
>     </target>

Define your filesets like this:

<fileset dir="${classes.dir}" includes="mia/gui/**" />

HTH,
Matt

> 
> Here are the equivalent commands from the batch file
> (which I don't
> want to use any more) that archives my classes:
> 
> "%JAVA_HOME%\bin\jar" cf mia_gui.jar mia\gui
> 
> "%JAVA_HOME%\bin\jar" cf mia_middleware.jar
> mia\middleware
> 
> Thanks,
> 
> Robert Pepersack
> Senior Lead Developer
> Maryland Insurance Administration
> 410-468-2054
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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