You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Schuett Thomas EXT <Th...@mchh.siemens.de> on 2004/10/27 13:42:00 UTC

copy, filterchain, replace, replacetoken -- too complicate

Hello,

I had the simple task of creating a MANIFEST file for a jar archive.
I Started with the echo task, but the result looked ugly in the ant script.
(Because a starting empty line as well as leading blanks had to be avoided.)

Then I had the idea to create a properties file and transform it into a manifest file.
Then all the problems started (and btw: Why didn't sun let the manifest file be a 
properties file? But o.k., this is offtopic here.)

Problem 1:
The propertyfile task always writes a starting comment. Why can't this be switched off?
The manifest file doesnt accept a starting comment line (nor an starting empty line).

Problem 2:
The replace task can't skip a line, only transform it. (O.k., this is the nature
of the replace. I rate it clean.)

Problem 3:
The filterchain can NOT have a nested replace. Why not? This is, what I rate really
unclean.

Problem 4:
The filterchain can have a nested replaceTokens, but this one can not simulate
a replace task, BECAUSE the begintoken and endtoken parameter may not be empty.
Why not? I can't see a good reason.

After all I ended with this ant script snipplet below, what looks far too complicate 
to me. 

	      <propertyfile file="${projX_projects}/META-INF/MANIFEST.MF_">
	         <entry key="Manifest-Version" value="1.0" />
	         <entry key="Core-Date" type="date" value="now" pattern="dd.MM.yyyy HH:mm" />
	         <entry key="Main-Class" value="projX/ProjXMain" />
            </propertyfile>
            
            <copy   file="${projX_projects}/META-INF/MANIFEST.MF_"
                  tofile="${projX_projects}/META-INF/MANIFEST.MF"
                  overwrite="true">
               <filterchain>
                  <striplinecomments><comment value="#"/></striplinecomments> 
               </filterchain>
            </copy>      
                  
	      <replace file="${projX_projects}/META-INF/MANIFEST.MF"
	         token="="
	         value=": "
	      />
	      <replace file="${projX_projects}/META-INF/MANIFEST.MF"
	         token="\:"
	         value=":"
	      />
	      
Is there an easier, better looking way to do this? 

Thomas

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


RE: copy, filterchain, replace, replacetoken -- too complicate

Posted by Charles Daniels <cj...@yahoo.com>.
Use the Ant manifest task. 

> -----Original Message-----
> From: Schuett Thomas EXT 
> [mailto:Thomas.Schuett.extern@mchh.siemens.de] 
> Sent: Wednesday, October 27, 2004 4:42 AM
> To: 'Ant Users List'
> Subject: copy, filterchain, replace, replacetoken -- too complicate
> 
> Hello,
> 
> I had the simple task of creating a MANIFEST file for a jar archive.
> I Started with the echo task, but the result looked ugly in 
> the ant script.
> (Because a starting empty line as well as leading blanks had 
> to be avoided.)
> 
> Then I had the idea to create a properties file and transform 
> it into a manifest file.
> Then all the problems started (and btw: Why didn't sun let 
> the manifest file be a 
> properties file? But o.k., this is offtopic here.)
> 
> Problem 1:
> The propertyfile task always writes a starting comment. Why 
> can't this be switched off?
> The manifest file doesnt accept a starting comment line (nor 
> an starting empty line).
> 
> Problem 2:
> The replace task can't skip a line, only transform it. (O.k., 
> this is the nature
> of the replace. I rate it clean.)
> 
> Problem 3:
> The filterchain can NOT have a nested replace. Why not? This 
> is, what I rate really
> unclean.
> 
> Problem 4:
> The filterchain can have a nested replaceTokens, but this one 
> can not simulate
> a replace task, BECAUSE the begintoken and endtoken parameter 
> may not be empty.
> Why not? I can't see a good reason.
> 
> After all I ended with this ant script snipplet below, what 
> looks far too complicate 
> to me. 
> 
> 	      <propertyfile 
> file="${projX_projects}/META-INF/MANIFEST.MF_">
> 	         <entry key="Manifest-Version" value="1.0" />
> 	         <entry key="Core-Date" type="date" value="now" 
> pattern="dd.MM.yyyy HH:mm" />
> 	         <entry key="Main-Class" value="projX/ProjXMain" />
>             </propertyfile>
>             
>             <copy   file="${projX_projects}/META-INF/MANIFEST.MF_"
>                   tofile="${projX_projects}/META-INF/MANIFEST.MF"
>                   overwrite="true">
>                <filterchain>
>                   <striplinecomments><comment 
> value="#"/></striplinecomments> 
>                </filterchain>
>             </copy>      
>                   
> 	      <replace file="${projX_projects}/META-INF/MANIFEST.MF"
> 	         token="="
> 	         value=": "
> 	      />
> 	      <replace file="${projX_projects}/META-INF/MANIFEST.MF"
> 	         token="\:"
> 	         value=":"
> 	      />
> 	      
> Is there an easier, better looking way to do this? 
> 
> Thomas
> 
> ---------------------------------------------------------------------
> 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