001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.xslt.project.anttasks;
020:
021: import java.io.File;
022: import java.util.ArrayList;
023: import java.util.List;
024:
025: import org.apache.tools.ant.BuildException;
026: import org.apache.tools.ant.Task;
027: import org.apache.tools.ant.AntClassLoader;
028: import org.apache.tools.ant.types.Path;
029: import org.apache.tools.ant.types.Reference;
030:
031: import java.util.StringTokenizer;
032:
033: import java.util.logging.Logger;
034:
035: import org.netbeans.modules.xslt.project.XsltproConstants;
036:
037: import org.netbeans.modules.xslt.project.CommandlineXsltProjectXmlCatalogProvider;
038:
039: /**
040: * Ant task wrapper which invokes the JBI Generation task
041: * @author Vitaly Bychkov
042: * @author Sreenivasan Genipudi
043: */
044: public class IDEGenerateJBIDescriptor extends org.apache.tools.ant.Task {
045: /**
046: * Source directory
047: */
048: private String mSourceDirectory = null;
049: /**
050: * Build directory
051: */
052: private String mBuildDirectory = null;
053: /**
054: * Project classpath
055: */
056: private String mProjectClassPath = null;
057: /**
058: * Custom classloader used to invoke the JBI Generation task
059: */
060: private AntClassLoader m_myClassLoader = null;
061: /**
062: * Classpath Reference
063: */
064: private Reference m_ref = null;
065:
066: /**
067: * Logger instance
068: */
069: private Logger logger = Logger
070: .getLogger(GenerateJBIDescriptor.class.getName());
071:
072: public IDEGenerateJBIDescriptor() {
073: }
074:
075: /**
076: * Set the classpath reference
077: * @param ref Classpath Reference
078: */
079: public void setClasspathRef(Reference ref) {
080: this .m_ref = ref;
081: }
082:
083: /**
084: * Set the build directory
085: * @param buildDir build directory
086: */
087: public void setBuildDirectory(String buildDir) {
088: mBuildDirectory = buildDir;
089: }
090:
091: /**
092: * Get the build directory
093: * @return String value of the build directory
094: */
095: public String getBuildDirectory() {
096: return mBuildDirectory;
097: }
098:
099: /**
100: * Set the source directory
101: * @param srcDir source directory
102: */
103: public void setSourceDirectory(String srcDir) {
104: this .mSourceDirectory = srcDir;
105: }
106:
107: /**
108: * Get the source directory
109: * @return String value of the source directory
110: */
111: public String getSourceDirectory() {
112: return this .mSourceDirectory;
113: }
114:
115: /**
116: * Set the project classpath
117: * @param projectClassPath Project classpath
118: */
119: public void setProjectClassPath(String projectClassPath) {
120: this .mProjectClassPath = projectClassPath;
121: }
122:
123: /**
124: * Invoke the task that generates the JBI.xml
125: */
126: public void execute() throws BuildException {
127: if (this .mSourceDirectory == null) {
128: throw new BuildException(
129: "No directory is set for source files.");
130: }
131:
132: CommandlineXsltProjectXmlCatalogProvider.getInstance()
133: .setSourceDirectory(this .mSourceDirectory);
134: AbstractJBIGenerator generator = new IDEJBIGenerator(
135: mSourceDirectory, mBuildDirectory);
136: generator.generate();
137:
138: }
139:
140: public static void main(String[] args) {
141: GenerateJBIDescriptor dd = new GenerateJBIDescriptor();
142:
143: }
144: }
|