KickJava   Java API By Example, From Geeks To Geeks.

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


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 ORBacus.</p>
34  **/

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

40     // default constructor
41
public
42     ORBacusIDLtoJavaTask()
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 the exec task
56
org.apache.tools.ant.taskdefs.ExecTask cmd = null;
57         cmd = (org.apache.tools.ant.taskdefs.ExecTask)getProject().createTask("exec");
58
59         // convert "ORBacus.bin.dir" to OS specific path
60
OSHelper.pathConvert(getProject(), "os.ORBacus.bin.dir", "ORBacus.bin.dir");
61
62         String JavaDoc cmdname = "jidl";
63         if (OSHelper.isUnix()) {
64             cmdname = getProject().getProperty("os.ORBacus.bin.dir")+"/jidl";
65         }
66         else if (OSHelper.isWindows()) {
67             cmdname = getProject().getProperty("os.ORBacus.bin.dir")+"\\jidl";
68         }
69
70         cmd.setExecutable(cmdname);
71
72         // add LD_LIBRARY_PATH to ${ORBacus.lib.dir}${PSEP}${LD_LIBRARY_PATH}
73
OSHelper.pathConvert(getProject(), "os.ORBacus.lib.dir", "ORBacus.lib.dir");
74         String JavaDoc slibpath = getProject().getProperty("os.ORBacus.lib.dir")+
75             java.io.File.pathSeparator+
76             OSHelper.envVar("LD_LIBRARY_PATH");
77
78         //log("[compileIDL] LD_LIBRARY_PATH="+slibpath);
79
org.apache.tools.ant.types.Environment.Variable libpath_env = new org.apache.tools.ant.types.Environment.Variable();
80         libpath_env.setKey("LD_LIBRARY_PATH");
81         org.apache.tools.ant.types.Path libpath = new org.apache.tools.ant.types.Path(getProject());
82         libpath.setPath(slibpath);
83         libpath_env.setPath(libpath);
84         cmd.addEnv(libpath_env);
85
86         // build arg line
87
// NOTE: include ORBacus IDL directory by default
88
OSHelper.pathConvert(getProject(), "os.ORBacus.idl.dir", "ORBacus.idl.dir");
89         String JavaDoc argline = "-D__ORBACUS__"+
90             " -I"+getProject().getProperty("os.ORBacus.idl.dir");
91         // add included directories
92
for (int i=0;i<includedirs.length;i++) {
93             argline = argline+" -I"+includedirs[i].getPath();
94         }
95
96         //
97
String JavaDoc ppline = " --prefix-package omg.org org.omg "+
98             " --prefix-package coach.org org.coach "+
99             " --prefix-package objectweb.org org.objectweb ";
100
101         // add "--auto-package --tie --output-dir compileto idlfile"
102
org.apache.tools.ant.types.Commandline.Argument arg = cmd.createArg();
103         argline = argline+ppline+" --tie --output-dir "+compileto.getPath()+" "+idlfile.getPath();
104         //log("[compileIDL] argline: "+argline);
105
arg.setLine(argline);
106
107         // launch
108
cmd.execute();
109     }
110 }
111
Popular Tags