1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.javaconv.ant;
34
import com.sun.grid.cull.AbstractCullConverter;
36
import java.io.IOException;
37
import java.util.ArrayList;
38
import java.util.List;
39
import java.util.logging.Handler;
40
import java.util.logging.Level;
41
import java.util.logging.Logger;
42
import com.sun.grid.cull.ant.*;
43
import com.sun.grid.javaconv.JavaToJavaConverter;
44
import org.apache.tools.ant.BuildException;
45
import org.apache.tools.ant.Task;
46
import org.apache.tools.ant.types.Path;
51
public class JavaConvAntTask extends Task {
53
private File buildDir;
55
private List<AbstractConverterDefinition> converterList = new ArrayList<AbstractConverterDefinition>();
57
private Path classpath;
59
private String classname;
61
private ClassFilter classdef;
63
private String source = " converters and ";
64
private String target = " classes";
66
public ClassFilter createClassDef() {
67
if (classdef == null) {
68
classdef = new ClassFilter(this);
73
String getClassPathAsString() {
74
return classdef.getClassPathAsString();
77
public JavaTemplateConverterDefintion createTemplateconv() {
78
JavaTemplateConverterDefintion conv = new JavaTemplateConverterDefintion(this);
79
converterList.add(conv);
83
public TemplateConverterDefinition createSimpleTemplateConv() {
84
TemplateConverterDefinition conv = new TemplateConverterDefinition(this);
85
converterList.add(conv);
90
public void execute() throws org.apache.tools.ant.BuildException {
92
Logger logger = AbstractCullConverter.logger;
94
Handler[] handler = logger.getHandlers();
95
for (int i = 0; i < handler.length; i++) {
96
logger.removeHandler(handler[i]);
99
logger.setUseParentHandlers(false);
100
AntLoggingHandler myHandler = new AntLoggingHandler(getProject());
101
logger.addHandler(myHandler);
102
logger.setLevel(Level.ALL);
103
myHandler.setLevel(Level.ALL);
107
Class[] classes = classdef.getClasses();
108
JavaToJavaConverter[] conv = new JavaToJavaConverter[converterList.size()];
110
for (AbstractConverterDefinition convDef : converterList) {
111
conv[i++] = convDef.createConverter();
114
logger.fine("has " + conv.length + " converters and " + classes.length + " classes");
115
for (int convIndex = 0; convIndex < conv.length; convIndex++) {
116
for (int classIndex = 0; classIndex < classes.length; classIndex++) {
117
conv[convIndex].convert(classes[classIndex]);
119
conv[convIndex].finish();
121
} catch (ClassNotFoundException cnfe) {
122
throw new BuildException("a class was not found: " + cnfe.getMessage(), cnfe);
123
} catch (IOException ioe) {
124
throw new BuildException("IO/Error: " + ioe.getMessage(), ioe);
129
public File getBuildDir() {
133
public void setBuildDir(File buildDir) {
134
this.buildDir = buildDir;
137
public String getClassname() {
141
public String getSource() {
145
public void setSource(String source) {
146
this.source = source;
149
public String getTarget() {
153
public void setTarget(String target) {
154
this.target = target;