KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ecm > taskdefs > OpenORBIDLtoJavaTask


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@objectweb.org
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Lesser General Public
9
// License as published by the Free Software Foundation; either
10
// version 2.1 of the License, or any later version.
11
//
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
// Lesser General Public License for more details.
16
//
17
// You should have received a copy of the GNU Lesser General Public
18
// License along with this library; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
// USA
21
//
22
// Initial developer(s): Mathieu Vadet.
23
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.ecm.taskdefs;
31
32 /**
33  ** <p>Concrete implementation of the <tt>IDLtoJavaTask</tt> for OpenORB.</p>
34  **/

35 public class OpenORBIDLtoJavaTask
36 extends IDLtoJavaTask
37 {
38     //
39

40     // default constructor
41
public
42     OpenORBIDLtoJavaTask()
43     {
44         //
45
}
46
47     //
48
// abstract operations implementation
49
//
50

51     final protected void
52     compileIDL(java.io.File JavaDoc idlfile, java.io.File JavaDoc compileto,
53                java.io.File JavaDoc[] includedirs, String JavaDoc prefix)
54     {
55         // use java task
56
org.apache.tools.ant.Task task = getProject().createTask("java");
57         org.apache.tools.ant.taskdefs.Java java = (org.apache.tools.ant.taskdefs.Java)task;
58         java.setClassname("org.openorb.compiler.IdlCompiler");
59         java.setFork(true);
60         java.setFailonerror(true);
61
62         // create classpath
63
org.apache.tools.ant.types.Path cp = java.createClasspath();
64         // put path to OpenORB jar in cp
65
// NOTE: use version independent path of OpenORB for that
66
cp.setRefid(new org.apache.tools.ant.types.Reference("OpenORB.class.path"));
67         org.apache.tools.ant.types.Commandline.Argument args = java.createArg();
68
69         // build arg line
70
String JavaDoc argline = "-D__OPENORB__";
71         // add included directories
72
for (int i=0;i<includedirs.length;i++) {
73             argline = argline+" -I "+includedirs[i].getPath();
74         }
75
76         // add "idlfile -d compileto"
77
argline = argline+" "+idlfile.getPath()+" -d "+compileto.getPath();
78         //log("[compileIDL] argline: "+argline);
79
args.setLine(argline);
80
81         // execute
82
java.execute();
83     }
84 }
85
Popular Tags