01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2008 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the
09: * Free Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15: * for more details.
16: *
17: * You should have received a copy of the GNU General Public License along with
18: * this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: *
21: *
22: * $Id$
23: */
24: package com.bostechcorp.cbesb.build.ant;
25:
26: import java.io.File;
27:
28: import org.apache.tools.ant.BuildException;
29: import org.apache.tools.ant.Task;
30:
31: import com.bostechcorp.cbesb.build.ant.util.EclipseProjectFile;
32:
33: public class IsPluginProjectTask extends Task {
34:
35: private String workspace;
36: private String projectName;
37: private String returnProperty;
38:
39: public void setProjectName(String projectName) {
40: this .projectName = projectName;
41: }
42:
43: public void setWorkspace(String workspace) {
44: this .workspace = workspace;
45: }
46:
47: public void setReturnProperty(String returnProperty) {
48: this .returnProperty = returnProperty;
49: }
50:
51: public void execute() throws BuildException {
52: if (workspace == null) {
53: throw new BuildException("Missing workspace attribute.");
54: }
55: if (projectName == null) {
56: throw new BuildException("Missing projectName attribute.");
57: }
58: if (returnProperty == null) {
59: throw new BuildException(
60: "Missing returnProperty attribute.");
61: }
62:
63: File workspaceFile = new File(workspace);
64: File projectFile = new File(workspaceFile, projectName
65: + File.separator + ".project");
66: if (!projectFile.exists()) {
67: throw new BuildException("Could not find project file: "
68: + projectFile.getAbsolutePath());
69: }
70:
71: EclipseProjectFile epf = new EclipseProjectFile();
72: try {
73: epf.load(projectFile);
74: } catch (Exception e) {
75: getProject().log(e.getLocalizedMessage());
76: throw new BuildException("Exception loading .project file:"
77: + projectFile.getAbsolutePath(), e);
78: }
79:
80: getProject().setProperty(returnProperty,
81: Boolean.toString(epf.isPluginProject()));
82:
83: }
84: }
|