use of org.apache.tools.ant.types.Path in project gcontracts by andresteingress.
the class ContractGroovyDoc method execute.
public void execute() throws BuildException {
List<String> packagesToDoc = new ArrayList<String>();
Path sourceDirs = new Path(getProject());
Properties properties = new Properties();
properties.setProperty("windowTitle", windowTitle);
properties.setProperty("docTitle", docTitle);
properties.setProperty("footer", footer);
properties.setProperty("header", header);
checkScopeProperties(properties);
properties.setProperty("publicScope", publicScope.toString());
properties.setProperty("protectedScope", protectedScope.toString());
properties.setProperty("packageScope", packageScope.toString());
properties.setProperty("privateScope", privateScope.toString());
properties.setProperty("author", author.toString());
properties.setProperty("processScripts", processScripts.toString());
properties.setProperty("includeMainForScripts", includeMainForScripts.toString());
properties.setProperty("overviewFile", overviewFile != null ? overviewFile.getAbsolutePath() : "");
if (sourcePath != null) {
sourceDirs.addExisting(sourcePath);
}
parsePackages(packagesToDoc, sourceDirs);
if (classTemplates.size() == 0)
throw new BuildException("Method getClassTemplates() needs to return at least a single classTemplate String!");
GroovyDocTool htmlTool = new GroovyDocTool(createResourceManager(), sourcePath.list(), getDocTemplates(), getPackageTemplates(), getClassTemplates(), links, properties);
try {
htmlTool.add(sourceFilesToDoc);
FileOutputTool output = new FileOutputTool();
// TODO push destDir through APIs?
htmlTool.renderToOutput(output, destDir.getCanonicalPath());
} catch (Exception e) {
e.printStackTrace();
}
// try to override the default stylesheet with custom specified one if needed
if (styleSheetFile != null) {
try {
String css = DefaultGroovyMethods.getText(styleSheetFile);
File outfile = new File(destDir, "stylesheet.css");
DefaultGroovyMethods.setText(outfile, css);
} catch (IOException e) {
System.out.println("Warning: Unable to copy specified stylesheet '" + styleSheetFile.getAbsolutePath() + "'. Using default stylesheet instead. Due to: " + e.getMessage());
}
}
}
use of org.apache.tools.ant.types.Path in project groovy by apache.
the class Groovydoc method execute.
public void execute() throws BuildException {
List<String> packagesToDoc = new ArrayList<String>();
Path sourceDirs = new Path(getProject());
Properties properties = new Properties();
properties.setProperty("windowTitle", windowTitle);
properties.setProperty("docTitle", docTitle);
properties.setProperty("footer", footer);
properties.setProperty("header", header);
checkScopeProperties(properties);
properties.setProperty("publicScope", publicScope.toString());
properties.setProperty("protectedScope", protectedScope.toString());
properties.setProperty("packageScope", packageScope.toString());
properties.setProperty("privateScope", privateScope.toString());
properties.setProperty("author", author.toString());
properties.setProperty("processScripts", processScripts.toString());
properties.setProperty("includeMainForScripts", includeMainForScripts.toString());
properties.setProperty("overviewFile", overviewFile != null ? overviewFile.getAbsolutePath() : "");
properties.setProperty("charset", charset != null ? charset : "");
properties.setProperty("fileEncoding", fileEncoding != null ? fileEncoding : "");
properties.setProperty("timestamp", Boolean.valueOf(!noTimestamp).toString());
properties.setProperty("versionStamp", Boolean.valueOf(!noVersionStamp).toString());
if (sourcePath != null) {
sourceDirs.addExisting(sourcePath);
}
parsePackages(packagesToDoc, sourceDirs);
GroovyDocTool htmlTool = new GroovyDocTool(// we're gonna get the default templates out of the dist jar file
new ClasspathResourceManager(), sourcePath.list(), getDocTemplates(), getPackageTemplates(), getClassTemplates(), links, properties);
try {
htmlTool.add(sourceFilesToDoc);
FileOutputTool output = new FileOutputTool();
// TODO push destDir through APIs?
htmlTool.renderToOutput(output, destDir.getCanonicalPath());
} catch (Exception e) {
e.printStackTrace();
}
// try to override the default stylesheet with custom specified one if needed
if (styleSheetFile != null) {
try {
String css = ResourceGroovyMethods.getText(styleSheetFile);
File outfile = new File(destDir, "stylesheet.css");
ResourceGroovyMethods.setText(outfile, css);
} catch (IOException e) {
System.out.println("Warning: Unable to copy specified stylesheet '" + styleSheetFile.getAbsolutePath() + "'. Using default stylesheet instead. Due to: " + e.getMessage());
}
}
}
use of org.apache.tools.ant.types.Path in project groovy by apache.
the class Groovy method createClasspathParts.
private void createClasspathParts() {
Path path;
if (classpath != null) {
path = super.createClasspath();
path.setPath(classpath.toString());
}
if (includeAntRuntime) {
path = super.createClasspath();
path.setPath(System.getProperty("java.class.path"));
}
String groovyHome = null;
final String[] strings = getSysProperties().getVariables();
if (strings != null) {
for (String prop : strings) {
if (prop.startsWith("-Dgroovy.home=")) {
groovyHome = prop.substring("-Dgroovy.home=".length());
}
}
}
if (groovyHome == null) {
groovyHome = System.getProperty("groovy.home");
}
if (groovyHome == null) {
groovyHome = System.getenv("GROOVY_HOME");
}
if (groovyHome == null) {
throw new IllegalStateException("Neither ${groovy.home} nor GROOVY_HOME defined.");
}
File jarDir = new File(groovyHome, "embeddable");
if (!jarDir.exists()) {
throw new IllegalStateException("GROOVY_HOME incorrectly defined. No embeddable directory found in: " + groovyHome);
}
final File[] files = jarDir.listFiles();
for (File file : files) {
try {
log.debug("Adding jar to classpath: " + file.getCanonicalPath());
} catch (IOException e) {
// ignore
}
path = super.createClasspath();
path.setLocation(file);
}
}
use of org.apache.tools.ant.types.Path in project groovy by apache.
the class Groovyc method compile.
protected void compile() {
if (compileList.length == 0)
return;
try {
log.info("Compiling " + compileList.length + " source file" + (compileList.length == 1 ? "" : "s") + (destDir != null ? " to " + destDir : ""));
listFiles();
Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject());
List<String> jointOptions = extractJointOptions(classpath);
String separator = System.getProperty("file.separator");
List<String> commandLineList = new ArrayList<String>();
doForkCommandLineList(commandLineList, classpath, separator);
doNormalCommandLineList(commandLineList, jointOptions, classpath);
addSourceFiles(commandLineList);
String[] commandLine = makeCommandLine(commandLineList);
if (fork) {
runForked(commandLine);
} else {
runCompiler(commandLine);
}
} finally {
for (File temporaryFile : temporaryFiles) {
try {
FileSystemCompiler.deleteRecursive(temporaryFile);
} catch (Throwable t) {
System.err.println("error: could not delete temp files - " + temporaryFile.getPath());
}
}
}
}
use of org.apache.tools.ant.types.Path in project groovy by apache.
the class CompileTaskSupport method createClassLoader.
protected GroovyClassLoader createClassLoader() {
ClassLoader parent = ClassLoader.getSystemClassLoader();
GroovyClassLoader gcl = new GroovyClassLoader(parent, config);
Path path = getClasspath();
if (path != null) {
final String[] filePaths = path.list();
for (int i = 0; i < filePaths.length; i++) {
String filePath = filePaths[i];
gcl.addClasspath(filePath);
}
}
return gcl;
}
Aggregations