You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Hendrik Maryns <qw...@sneakemail.com> on 2008/10/22 11:31:37 UTC

Can I rename a file when jarring it?

Hi,

I create a jar with some of my own files and another jar as zipfileset.
 I’d like one of the files of the other jar (which I do not produce) to
be renamed on the fly.  Is this possible?

What I have:

<target name="jar" depends="build" description="Make a jar file">
  <jar destfile="${releasedir}/${name}.jar" manifestencoding="UTF-8">
  	<manifest>
    <attribute name="Main-Class"
           value="de.uni_tuebingen.sfb.lichtenstein.main.MonaSearch" />
    <attribute name="Class-Path" value="." />
    <attribute name="Implementation-Title" value="${name}" />
    <attribute name="Implementation-Version" value="${version}" />
  	</manifest>
 	<metainf dir="${releasedir}" includes="COPYING,AUTHORS,THANKS" />
  	<zipfileset dir="${bindir}" excludes="**/tests/*,Mona/*" />
<!-- note “dir”-->
  	<zipfileset src="commons-cli-2.0-SNAPSHOT.jar"
               excludes="META-INF/*.SF,META-INF/LICENSE.txt" />
<!-- note “src”, see
http://ant.apache.org/manual/CoreTypes/zipfileset.html-->
  </jar>
  <signjar jar="${releasedir}/${name}.jar"
           alias="MonaSearch"
           storepass="monasearch"
           keystore="keystore"
           keypass="monasearch" />
</target>

Regarding the two comments: the error messages emitted by Ant are not
really helpful, it took me quite some googling around before I noticed
that I had a ‘src’ in the first case, the error message ‘the archive
can't be a directory’ is, like, not helpful at all.

Another very unhelpful error message was ‘only single argument resource
collections are supported as archives’ which was caused because I had a
<fileset> inside of <meta-inf>.  Here the documentation could be made
better: it just says ‘The nested metainf element specifies a FileSet.’
I interpreted that as that is should contain a FileSet.

Is a developer reading this, or should I create bugs all around?

H.
-- 
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


Re: Can I rename a file when jarring it?

Posted by supareno <re...@free.fr>.
Hendrik Maryns a écrit :
> supareno schreef:
>   
>> Hendrik ,
>>
>> check out this:
>> http://ant.apache.org/manual/CoreTypes/mapper.html#identity-mapper
>> and this:
>> http://ant.apache.org/manual/CoreTasks/copy.html
>> "[...]
>>
>> *Copy a set of files to a directory, appending |.bak| to the file name
>> on the fly*
>>
>>  <copy todir="../backup/dir">
>>    <fileset dir="src_dir"/>
>>    <globmapper from="*" to="*.bak"/>
>>  </copy>
>>     
>
> Thanks, indeed this was what I was thinking of, but unfortunately <jar>
> does not allow a nested <mapper> element.
>   
so, you could create a build directory where you can copy all the files 
needed for the jar (class files, properties files, ...)
and, after, you can do this:

<jar destfile="${dist}/lib/app.jar">
    <fileset dir="${build}/classes" excludes="**/Test.class"/>
    <!-- adding to the jar the folder where the files are renamed -->
    <fileset dir="${build}/resources"/>
</jar>

i will do it like that!
Do someone else have an alternative?

supareno

> Should I put in an rfe for this?
>
> H.
>   


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


Re: Can I rename a file when jarring it?

Posted by Hendrik Maryns <qw...@sneakemail.com>.
supareno schreef:
> Hendrik ,
> 
> check out this:
> http://ant.apache.org/manual/CoreTypes/mapper.html#identity-mapper
> and this:
> http://ant.apache.org/manual/CoreTasks/copy.html
> "[...]
> 
> *Copy a set of files to a directory, appending |.bak| to the file name
> on the fly*
> 
>  <copy todir="../backup/dir">
>    <fileset dir="src_dir"/>
>    <globmapper from="*" to="*.bak"/>
>  </copy>

Thanks, indeed this was what I was thinking of, but unfortunately <jar>
does not allow a nested <mapper> element.

Should I put in an rfe for this?

H.
-- 
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


Re: Can I rename a file when jarring it?

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

check out this:
http://ant.apache.org/manual/CoreTypes/mapper.html#identity-mapper
and this:
http://ant.apache.org/manual/CoreTasks/copy.html
"[...]

*Copy a set of files to a directory, appending |.bak| to the file name 
on the fly*

  <copy todir="../backup/dir">
    <fileset dir="src_dir"/>
    <globmapper from="*" to="*.bak"/>
  </copy>

[...]"
> Hi,
>
> I create a jar with some of my own files and another jar as zipfileset.
>  I’d like one of the files of the other jar (which I do not produce) to
> be renamed on the fly.  Is this possible?
>
> What I have:
>
> <target name="jar" depends="build" description="Make a jar file">
>   <jar destfile="${releasedir}/${name}.jar" manifestencoding="UTF-8">
>   	<manifest>
>     <attribute name="Main-Class"
>            value="de.uni_tuebingen.sfb.lichtenstein.main.MonaSearch" />
>     <attribute name="Class-Path" value="." />
>     <attribute name="Implementation-Title" value="${name}" />
>     <attribute name="Implementation-Version" value="${version}" />
>   	</manifest>
>  	<metainf dir="${releasedir}" includes="COPYING,AUTHORS,THANKS" />
>   	<zipfileset dir="${bindir}" excludes="**/tests/*,Mona/*" />
> <!-- note “dir”-->
>   	<zipfileset src="commons-cli-2.0-SNAPSHOT.jar"
>                excludes="META-INF/*.SF,META-INF/LICENSE.txt" />
> <!-- note “src”, see
> http://ant.apache.org/manual/CoreTypes/zipfileset.html-->
>   </jar>
>   <signjar jar="${releasedir}/${name}.jar"
>            alias="MonaSearch"
>            storepass="monasearch"
>            keystore="keystore"
>            keypass="monasearch" />
> </target>
>
> Regarding the two comments: the error messages emitted by Ant are not
> really helpful, it took me quite some googling around before I noticed
> that I had a ‘src’ in the first case, the error message ‘the archive
> can't be a directory’ is, like, not helpful at all.
>
> Another very unhelpful error message was ‘only single argument resource
> collections are supported as archives’ which was caused because I had a
> <fileset> inside of <meta-inf>.  Here the documentation could be made
> better: it just says ‘The nested metainf element specifies a FileSet.’
> I interpreted that as that is should contain a FileSet.
>
> Is a developer reading this, or should I create bugs all around?
>
> H.
>   


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