You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Erskine, Chris" <ch...@eds.com> on 2004/11/23 00:09:52 UTC

Fileset within a jar file

Working with Ant 1.6.2 on a Linux machine, I am trying to create a jar file.
As part of my jar file, I want to exclude my test classes.  I am using the
following:

    <jar destfile="${build.dir}/hatsIO.jar" basedir="${classes.dir}">
      <fileset dir="${classes.dir}">
        <include name="**/*.class" />
        <exclude name="**/*Test*" />
      </fileset>
      <manifest>
        <attribute name="Built-By" value="${user.name}"/>
      <section name="IntegrationObject">
	  <attribute name="Implementation-Version" value="${label}"/>
	</section>
      </manifest>
    </jar>

The problem that I am having is that it is adding my file, StubTest.class to
the jar.  Is there something that I am doing wrong on this?  I have also
tried **/*Test.class but I get the same problem.

Thanks,

Chris Erskine
 
EDS Consulting Services
F5-EDS-001
2424 Garden of the Gods Rd
Colorado Springs, CO  80919
 
Phone: 719-535-6064


> -----Original Message-----
> From: Eric Lubin [mailto:elubin@yahoo.com]
> Sent: Monday, November 22, 2004 11:50 AM
> To: Ant Users List
> Subject: RE: newbie <delete> not removing my empty directory?
> 
> Is there a way to specify a delete command that might run after this one,
> that might hit NO files,
> but that could remove my empty directories?  ie, a delete that ONLY
> deletes empty subdirs?
> 
> Eric
> 
> 
> --- Vadim Kazakov <Va...@quadrus.com> wrote:
> 
> > Exactly, since the directory doesn't match the filter, it won't get
> > deleted.
> >
> > -----Original Message-----
> > From: Eric Lubin [mailto:elubin@yahoo.com]
> > Sent: November 22, 2004 11:24 AM
> > To: Ant Users List
> > Subject: RE: newbie <delete> not removing my empty directory?
> >
> > well, I would have to specify which directories are going to be EMPTY
> > when I'm done with the
> > delete?  How would I know that?
> >
> > No, there are no class files left in the directory when the operation is
> > done.  The directory is
> > empty, but doesn't get removed.
> >
> > Thanks, Eric
> >
> >
> >
> > --- Vadim Kazakov <Va...@quadrus.com> wrote:
> >
> > > Because you're not specifying the directory in the include tags so it
> > > only deletes .java and .class files unless the .class files are in a
> > > subdirectory xyz/test1.
> > >
> > > -----Original Message-----
> > > From: Eric Lubin [mailto:elubin@yahoo.com]
> > > Sent: November 19, 2004 2:07 PM
> > > To: user@ant.apache.org
> > > Subject: newbie <delete> not removing my empty directory?
> > >
> > > Based on the directory structure and files listed at the bottom, why
> > > doesn't the last delete
> > > remove the test2_sub1 directory?
> > >
> > > Thanks, Eric
> > >
> > > <project name="Test" default="doIt" basedir=".">
> > >  <description>simple example build file</description>
> > >  <target name="doIt">
> > >   <tstamp/>
> > >   <mkdir dir="TempCom" />
> > >   <delete includeEmptyDirs="true"><fileset dir="TempCom" /></delete>
> > >   <mkdir dir="TempCom" />
> > >   <copy todir="TempCom"><fileset dir="com" /></copy>
> > >   <delete includeEmptyDirs="true">
> > >    <fileset dir="TempCom">
> > >     <include name="**/*.java" />
> > >     <include name="**/*.class" />
> > >     <exclude name="xyz/test1/**/*.class" />
> > >    </fileset>
> > >   </delete>
> > >  </target>
> > > </project>
> > >
> > >
> > -----------------------------------------------------------------------
> > >
> > > root
> > > |-com
> > >   |-xyz
> > >     |-test1 (with file a.java and a.class)
> > >       |-test1_sub1 (with file b.java and b.class)
> > >     |-test2 (with file c.java and c.class)
> > >       |-test2_sub1 (with file d.java and d.class)
> > >       |-test2_sub2 (with file e.txt and f.txt)
> > >
> > >
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > The all-new My Yahoo! - Get yours free!
> > > http://my.yahoo.com
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> > >
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Meet the all-new My Yahoo! - Try it today!
> > http://my.yahoo.com
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Meet the all-new My Yahoo! - Try it today!
> http://my.yahoo.com
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org

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


Re: Fileset within a jar file

Posted by Peter Reilly <pe...@apache.org>.
You are actually using *two* filesets, the implicit
fileset associated with the jar task (triggered by the "basedir" attribute),
and the explicit one associated with the <fileset> nested element.
Use:

  <jar destfile="${build.dir}/hatsIO.jar" basedir="${classes.dir}">
      <include name="**/*.class" />
      <exclude name="**/*Test*" />
      <manifest>
        <attribute name="Built-By" value="${user.name}"/>
      <section name="IntegrationObject">
	  <attribute name="Implementation-Version" value="${label}"/>
	</section>
      </manifest>
    </jar>

or
    <jar destfile="${build.dir}/hatsIO.jar">
      <fileset dir="${classes.dir}">
        <include name="**/*.class" />
        <exclude name="**/*Test*" />
      </fileset>
      <manifest>
        <attribute name="Built-By" value="${user.name}"/>
      <section name="IntegrationObject">
	  <attribute name="Implementation-Version" value="${label}"/>
	</section>
      </manifest>
    </jar>

instead.

Peter
Erskine, Chris wrote:

>Working with Ant 1.6.2 on a Linux machine, I am trying to create a jar file.
>As part of my jar file, I want to exclude my test classes.  I am using the
>following:
>
>    <jar destfile="${build.dir}/hatsIO.jar" basedir="${classes.dir}">
>      <fileset dir="${classes.dir}">
>        <include name="**/*.class" />
>        <exclude name="**/*Test*" />
>      </fileset>
>      <manifest>
>        <attribute name="Built-By" value="${user.name}"/>
>      <section name="IntegrationObject">
>	  <attribute name="Implementation-Version" value="${label}"/>
>	</section>
>      </manifest>
>    </jar>
>
>The problem that I am having is that it is adding my file, StubTest.class to
>the jar.  Is there something that I am doing wrong on this?  I have also
>tried **/*Test.class but I get the same problem.
>
>Thanks,
>
>Chris Erskine
> 
>EDS Consulting Services
>F5-EDS-001
>2424 Garden of the Gods Rd
>Colorado Springs, CO  80919
> 
>Phone: 719-535-6064
>
>
>  
>
>>-----Original Message-----
>>From: Eric Lubin [mailto:elubin@yahoo.com]
>>Sent: Monday, November 22, 2004 11:50 AM
>>To: Ant Users List
>>Subject: RE: newbie <delete> not removing my empty directory?
>>
>>Is there a way to specify a delete command that might run after this one,
>>that might hit NO files,
>>but that could remove my empty directories?  ie, a delete that ONLY
>>deletes empty subdirs?
>>
>>Eric
>>
>>
>>--- Vadim Kazakov <Va...@quadrus.com> wrote:
>>
>>    
>>
>>>Exactly, since the directory doesn't match the filter, it won't get
>>>deleted.
>>>
>>>-----Original Message-----
>>>From: Eric Lubin [mailto:elubin@yahoo.com]
>>>Sent: November 22, 2004 11:24 AM
>>>To: Ant Users List
>>>Subject: RE: newbie <delete> not removing my empty directory?
>>>
>>>well, I would have to specify which directories are going to be EMPTY
>>>when I'm done with the
>>>delete?  How would I know that?
>>>
>>>No, there are no class files left in the directory when the operation is
>>>done.  The directory is
>>>empty, but doesn't get removed.
>>>
>>>Thanks, Eric
>>>
>>>
>>>
>>>--- Vadim Kazakov <Va...@quadrus.com> wrote:
>>>
>>>      
>>>
>>>>Because you're not specifying the directory in the include tags so it
>>>>only deletes .java and .class files unless the .class files are in a
>>>>subdirectory xyz/test1.
>>>>
>>>>-----Original Message-----
>>>>From: Eric Lubin [mailto:elubin@yahoo.com]
>>>>Sent: November 19, 2004 2:07 PM
>>>>To: user@ant.apache.org
>>>>Subject: newbie <delete> not removing my empty directory?
>>>>
>>>>Based on the directory structure and files listed at the bottom, why
>>>>doesn't the last delete
>>>>remove the test2_sub1 directory?
>>>>
>>>>Thanks, Eric
>>>>
>>>><project name="Test" default="doIt" basedir=".">
>>>> <description>simple example build file</description>
>>>> <target name="doIt">
>>>>  <tstamp/>
>>>>  <mkdir dir="TempCom" />
>>>>  <delete includeEmptyDirs="true"><fileset dir="TempCom" /></delete>
>>>>  <mkdir dir="TempCom" />
>>>>  <copy todir="TempCom"><fileset dir="com" /></copy>
>>>>  <delete includeEmptyDirs="true">
>>>>   <fileset dir="TempCom">
>>>>    <include name="**/*.java" />
>>>>    <include name="**/*.class" />
>>>>    <exclude name="xyz/test1/**/*.class" />
>>>>   </fileset>
>>>>  </delete>
>>>> </target>
>>>></project>
>>>>
>>>>
>>>>        
>>>>
>>>-----------------------------------------------------------------------
>>>      
>>>
>>>>root
>>>>|-com
>>>>  |-xyz
>>>>    |-test1 (with file a.java and a.class)
>>>>      |-test1_sub1 (with file b.java and b.class)
>>>>    |-test2 (with file c.java and c.class)
>>>>      |-test2_sub1 (with file d.java and d.class)
>>>>      |-test2_sub2 (with file e.txt and f.txt)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>__________________________________
>>>>Do you Yahoo!?
>>>>The all-new My Yahoo! - Get yours free!
>>>>http://my.yahoo.com
>>>>
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>>For additional commands, e-mail: user-help@ant.apache.org
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>>For additional commands, e-mail: user-help@ant.apache.org
>>>>
>>>>
>>>>        
>>>>
>>>
>>>
>>>__________________________________
>>>Do you Yahoo!?
>>>Meet the all-new My Yahoo! - Try it today!
>>>http://my.yahoo.com
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>
>>>      
>>>
>>
>>
>>__________________________________
>>Do you Yahoo!?
>>Meet the all-new My Yahoo! - Try it today!
>>http://my.yahoo.com
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>For additional commands, e-mail: user-help@ant.apache.org
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>  
>


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