KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > DavaBuildFile


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2006 Nomair A. Naeem
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot.dava;
21
22 import java.io.*;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Iterator JavaDoc;
25
26
27
28 /*
29  * TODO: Jalopy would be awesome here!!
30  */

31 public class DavaBuildFile {
32     public static void generate(PrintWriter out, ArrayList JavaDoc decompiledClasses){
33         out.print("<project default=\"compile\" name=\"Build file for decompiled code\">\n");
34         out.print(" <description>\n");
35         out.print(" This is the build file produced by Dava for the decompiled code.\n");
36         out.print(" New features like (formatting using jalopy etc) will be added to this build file\n");
37         out.print("</description>\n");
38         out.print("<!-- properties for project directories -->\n");
39         out.print("<property name=\"srcDir\" location=\"src\"/>\n");
40         out.print("<property name=\"classesDir\" location=\"classes\"/>\n");
41         out.print("");
42         out.print("");
43         out.print("");
44         out.print("");
45         out.print("");
46         out.print("");
47         out.print("");
48 /* out.print("<target name=\"init\" description=\"Create necessary directories\">\n");
49         out.print("<tstamp/>\n");
50         out.print(" <!-- set the timestamps -->\n");
51         out.print(" <mkdir dir=\"${classesDir}\"/>\n");
52         out.print(" <mkdir dir=\"${docDir}\"/>\n");
53 // out.print(" <mkdir dir=\"${libDir}\"/>\n");
54         out.print("</target>\n");
55         */

56         out.print(" <!-- ========== Compile Target ================= -->\n");
57         out.print(" <target name=\"compile\" description=\"Compile .java files\">\n");
58         out.print(" <javac srcdir=\"${srcDir}\" destdir=\"${classesDir}\">\n");
59         out.print(" <classpath>\n");
60         out.print(" <pathelement location=\"${junitJar}\"/>\n");
61         out.print(" </classpath>\n");
62         out.print(" </javac>\n");
63         out.print(" </target>\n");
64
65         
66         
67         
68         out.print(" <!-- ==========AST METRICS FOR DECOMPILED CODE================= -->\n");
69         out.print("<target name=\"ast-metrics\" description=\"Compute the ast metrics\">\n");
70         /*
71          * NEED TO MAKE SURE SRC-PREC IS SET so that java to jimple gets evaluate
72          * The command is going to be java soot.Main -ast-metrics followed by
73          * all the classes on which we had originally done the decompile
74          * Need a specialized task
75          */

76         
77         out.print(" <exec executable=\"java\" dir=\"src\">\n");
78         out.print(" <arg value=\"-Xmx400m\" />\n");
79         out.print(" <arg value=\"soot.Main\" />\n");
80         out.print(" <arg value=\"-ast-metrics\" />\n");
81         out.print(" <arg value=\"--src-prec\" />\n");
82         out.print(" <arg value=\"java\" />\n");
83
84         
85         Iterator JavaDoc it = decompiledClasses.iterator();
86         while(it.hasNext()){
87             String JavaDoc temp = (String JavaDoc)it.next();
88             if(temp.endsWith(".java")){
89                 temp = temp.substring(0,temp.length()-5);
90             }
91             //System.out.println(temp);
92
out.print(" <arg value=\"" + temp + "\" />\n");
93             
94         }
95
96         out.print("");
97         out.print(" </exec>\n");
98         out.print(" </target>\n");
99         out.print("");
100         out.print("");
101         out.print("");
102         out.print("");
103         out.print("");
104         out.print("");
105         out.print("");
106         out.print("</project>");
107
108
109     }
110 }
111
Popular Tags