01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: /*
12: * Created on Aug 23, 2004
13: */
14:
15: /**
16: * This file was edited for Poleposition to make it compilable.
17: * June 20 2005
18: * see XXPP
19: */package com.versant.core.jdo.tools.ant;
20:
21: import java.util.*;
22:
23: // XXPP commented out
24: // import com.versant.core.vds.tools.jdo.SchemaTool;
25:
26: /**
27: * @author hzhao
28: */
29:
30: /**
31: * This ant task will create/evolve the VDS schema for a set of .jdo files and
32: * classes. The classes do not have to be enhanced. The schema will be created
33: * in VDS database specified in the project file. This class is a wrapper class
34: * of {@link com.versant.core.vds.tools.jdo.SchemaTool} which should be used
35: * outside of Ant by creating an instance and setting properties or by using
36: * the mainmethod and command line args. {@see com.versant.jdo.tools.SchemaTool}
37: * for options and arguments.
38: */
39: public class VdsSchemaTask extends JdoTaskBase {
40:
41: private ArrayList cmdArgs = new ArrayList();
42:
43: public void execute() {
44: cmdArgs.add("-cp");
45: cmdArgs.add(classpath.toString());
46: cmdArgs.add("-p");
47: cmdArgs.add(configFilename);
48:
49: String[] args = new String[cmdArgs.size()];
50: cmdArgs.toArray(args);
51:
52: try {
53:
54: // XXPP commented out
55: // SchemaTool.main(args);
56:
57: } catch (Exception exp) {
58: System.err.println(exp);
59: exp.printStackTrace();
60: }
61: }
62:
63: public void setOutputdir(String out) {
64: cmdArgs.add("-out");
65: cmdArgs.add(out);
66: }
67:
68: public void setDefine(String s) {
69: if (isTrue(s)) {
70: cmdArgs.add("-action");
71: cmdArgs.add("define");
72: }
73: }
74:
75: public void setCompare(String s) {
76: if (isTrue(s)) {
77: cmdArgs.add("-action");
78: cmdArgs.add("compare");
79: }
80: }
81:
82: public void setEvolve(String s) {
83: if (isTrue(s)) {
84: cmdArgs.add("-action");
85: cmdArgs.add("evolve");
86: }
87: }
88:
89: private static boolean isTrue(String s) {
90: return "*".equals(s) || "true".equals(s);
91: }
92: }
|