On second thought, it may not be difficult if you use some of the
ant-contrib targets like <for>, <var file="" name=""/> and
<propertyregex.../> I think you can do it all in straight XML markup.
Let me know if you need an example...
Scot P. Floess wrote:
You might check out the ant-contrib project's propertyregex for
regular expressions (I don't think this will be the best route - will
take somre work)...
Or...I had a similar need where I wanted to replace the contents of -a
file- (meaning only one file) where it had the text "http://some-url"
/ "ftp://some-other-url" and convert it to a real <a
href="http://some-url> / <a href="ftp://some-other-url"> - in this
case I used a <scripdef language="beanshell"> to look modify the
file... The beanshell script looks an awful lot like plain old
Java... With that said, you have access to -real- java
packages/classes like java.io.File :)
So, you could do something with that...
Below is the later solution...
<scriptdef
name = "replace-url"
language = "beanshell"
description = "Converts static text URL to an HTML a-href."
uri = "http://jplate.sourceforge.net/documentation" >
<classpath>
<path refid = "jplate.LIB_PATH_REF"/>
</classpath>
<attribute name = "file"/>
<![CDATA[
java.io.File file = new java.io.File (
attributes.get ( "file" ) );
java.io.RandomAccessFile raf = null;
try
{
raf = new java.io.RandomAccessFile ( file, "rw" );
byte[] rawData = new byte [ ( int ) file.length () ];
raf.read ( rawData );
java.lang.String data = new java.lang.String ( rawData );
java.lang.String toWrite =
data.replaceAll ( "&", "&" ).replaceAll (
"(http|ftp)://([\\w\\.?=&])*(([/\\w\\.?=&])*(/)?)?", "<a href =
\"$0\">$0</a>" );
raf.seek ( 0 );
raf.write ( toWrite.getBytes () );
}
finally
{
if ( raf != null )
{
try
{
raf.close ();
}
catch ( java.io.IOException closeException )
{
closeException.printStackTrace ();
}
}
}
]]>
</scriptdef>
</project>
Vladimir Kravchenko wrote:
Hi,
I have a lot of small css files and one index file which imports all
other
using the following format:
@import url("default.css");
@import url("default_behaviour.css");
@import url("default_form.css");
...
I would like to go through this file and replace lines @import
url("*.css");
with actual content of css file the line imports.
So that at the end I have all css included in one file.
How could I accomplish my task using Ant?
Is there are any task I can use for this case, or do I have to write
a new
one?
Thank you in advance!
/Vlad
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-392-6730 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]