ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject script task using java
Date Tue, 07 Dec 2004 11:46:43 GMT

Hi, i want to use an existing regex class into my build script.

This is my first try using script/java with ant, so please don't laugh ;-)

See my questions marked with ***

Tried like that =

<project name="MyProject" basedir="." default="main">
   <target name="main2">
     <script language="javascript"> <![CDATA[

       
	*** i also tried without .* in packagedeclaration without success	
	
	 importPackage(java.lang);
       importPackage(java.util.regex.*);
       importPackage(java.io.*);
       
       		BufferedReader f;
		String line;
		StringBuffer content = new StringBuffer();
		String lineSep = System.getProperty("line.separator");

		//		pattern  projectname
		String pattern = "^testproject";
		Pattern p = Pattern.compile(pattern);

		//		pattern deploytarget
		String patternt1 = "^test";
		String patternt2 = "^test1";
		Pattern p1 = Pattern.compile(patternt1);
		Pattern p2 = Pattern.compile(patternt2);
		

		try
		{
			f =
				new BufferedReader(
					new FileReader("logfile.txt"));
			while ((line = f.readLine()) != null)
			{
				content.append(line).append(lineSep);
			}
			f.close();

		*** -> how to 'cast' to a build exception ? ***

		} catch (IOException e)
		{
			System.out.println("Oops ..." + e);
		}

		Matcher m = p.matcher(content);
		Matcher m1 = p1.matcher(content);
		Matcher m2 = p2.matcher(content);
		
		if (m.find())
		project.setNewProperty("projectname", "testproject");
				
		if (m1.find()& m2.find())
		
		*** -> OK to use coma separated values for one property ? ***

		project.setNewProperty("email", "list1,list2");
		
		if (m1.find() & (!m2.find()))
		
		project.setNewProperty("email", "list1");
		
		if (m2.find() & (!m1.find()))
		
		project.setNewProperty("email", "list2");
						
     ]]></script>
   </target>
   
   <target name="main" depends="main2>
   		<echo message="${projectname}"></echo>
   		<echo message="${email}"></echo>
   </target>
</project>

But it gave me an error right at the beginning =

[script] BUILD FAILED: C:\Programme\IBM\WebSphere Studio\Application Developer\WSADworkspace\Ant_Test\regexp.xml:3
: SyntaxError: missing name after . operator (ANT; line 3)

line 3 =  <script language="javascript"> <![CDATA[

I believe there are much more errors ?!

Thanks for any advice!!

Regards, Gilbert


 

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


Mime
View raw message