use of org.codehaus.groovy.tools.javac.JavaStubCompilationUnit in project groovy by apache.
the class GenerateStubsTask method compile.
@Override
protected void compile() {
GroovyClassLoader gcl = createClassLoader();
JavaStubCompilationUnit cu = new JavaStubCompilationUnit(config, gcl, destdir);
int count = 0;
String[] list = src.list();
for (int i = 0; i < list.length; i++) {
File basedir = getProject().resolveFile(list[i]);
if (!basedir.exists()) {
throw new BuildException("Source directory does not exist: " + basedir, getLocation());
}
DirectoryScanner scanner = getDirectoryScanner(basedir);
String[] includes = scanner.getIncludedFiles();
log.debug("Including files from: " + basedir);
for (int j = 0; j < includes.length; j++) {
log.debug(" " + includes[j]);
File file = new File(basedir, includes[j]);
cu.addSource(file);
// Increment the count for each non/java src we found
if (!includes[j].endsWith(".java")) {
count++;
}
}
}
if (count > 0) {
log.info("Generating " + count + " Java stub" + (count > 1 ? "s" : "") + " to " + destdir);
cu.compile();
log.info("Generated " + cu.getStubCount() + " Java stub(s)");
} else {
log.info("No sources found for stub generation");
}
}
use of org.codehaus.groovy.tools.javac.JavaStubCompilationUnit in project groovy-core by groovy.
the class GenerateStubsTask method compile.
@Override
protected void compile() {
GroovyClassLoader gcl = createClassLoader();
JavaStubCompilationUnit cu = new JavaStubCompilationUnit(config, gcl, destdir);
int count = 0;
String[] list = src.list();
for (int i = 0; i < list.length; i++) {
File basedir = getProject().resolveFile(list[i]);
if (!basedir.exists()) {
throw new BuildException("Source directory does not exist: " + basedir, getLocation());
}
DirectoryScanner scanner = getDirectoryScanner(basedir);
String[] includes = scanner.getIncludedFiles();
log.debug("Including files from: " + basedir);
for (int j = 0; j < includes.length; j++) {
log.debug(" " + includes[j]);
File file = new File(basedir, includes[j]);
cu.addSource(file);
// Increment the count for each non/java src we found
if (!includes[j].endsWith(".java")) {
count++;
}
}
}
if (count > 0) {
log.info("Generating " + count + " Java stub" + (count > 1 ? "s" : "") + " to " + destdir);
cu.compile();
log.info("Generated " + cu.getStubCount() + " Java stub(s)");
} else {
log.info("No sources found for stub generation");
}
}
Aggregations