本文整理汇总了Java中spoon.support.compiler.FileSystemFolder类的典型用法代码示例。如果您正苦于以下问题:Java FileSystemFolder类的具体用法?Java FileSystemFolder怎么用?Java FileSystemFolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemFolder类属于spoon.support.compiler包,在下文中一共展示了FileSystemFolder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compile
import spoon.support.compiler.FileSystemFolder; //导入依赖的package包/类
public boolean compile(String pathToAdditionalDependencies) {
if (this.factory == null) {
this.factory = this.launcher.getFactory();
}
javaCompliance = factory.getEnvironment().getComplianceLevel();
DSpotJDTBatchCompiler compiler = new DSpotJDTBatchCompiler(this, null);//environment);
final SourceOptions sourcesOptions = new SourceOptions();
sourcesOptions.sources((new FileSystemFolder(this.sourceOutputDirectory).getAllJavaFiles()));
this.reportProblems(this.factory.getEnvironment());
String[] sourcesArray = this.sourceOutputDirectory.getAbsolutePath().split(PATH_SEPARATOR);
String[] classpath = (this.dependencies + PATH_SEPARATOR + pathToAdditionalDependencies).split(PATH_SEPARATOR);
String[] finalClasspath = new String[sourcesArray.length + classpath.length];
System.arraycopy(sourcesArray, 0, finalClasspath, 0, sourcesArray.length);
System.arraycopy(classpath, 0, finalClasspath, sourcesArray.length, classpath.length);
final ClasspathOptions classpathOptions = new ClasspathOptions()
.encoding(getEnvironment().getEncoding().displayName())
.classpath(finalClasspath)
.binaries(getBinaryOutputDirectory());
final String[] args = new JDTBuilderImpl() //
.classpathOptions(classpathOptions) //
.complianceOptions(new ComplianceOptions().compliance(javaCompliance)) //
.advancedOptions(new AdvancedOptions().preserveUnusedVars().continueExecution().enableJavadoc()) //
.annotationProcessingOptions(new AnnotationProcessingOptions().compileProcessors()) //
.sources(sourcesOptions) //
.build();
final String[] finalArgs = new String[args.length + 1];
finalArgs[0] = "-proceedOnError";
System.arraycopy(args, 0, finalArgs, 1, args.length);
compiler.compile(finalArgs);
environment = compiler.getEnvironment();
return compiler.globalErrorsCount == 0;
}
示例2: compileFileIn
import spoon.support.compiler.FileSystemFolder; //导入依赖的package包/类
public boolean compileFileIn(File directory, boolean withLog) {
// initInputClassLoader();
javaCompliance = factory.getEnvironment().getComplianceLevel();
MainCompiler compiler = new MainCompiler(this, environment);
final SourceOptions sourcesOptions = new SourceOptions();
sourcesOptions.sources((new FileSystemFolder(directory).getAllJavaFiles()));
URL[] urls;
if(customClassLoader != null) {
urls = customClassLoader.getURLs();
} else {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
urls = ((URLClassLoader) classLoader).getURLs();
}
String[] finalClassPath = new String[urls.length];
for(int i = 0; i < urls.length; i++) {
finalClassPath[i] = urls[i].getFile();
}
final ClasspathOptions classpathOptions = new ClasspathOptions()
.encoding(this.encoding)
.classpath(finalClassPath)
.binaries(getBinaryOutputDirectory());
final String[] args = new JDTBuilderImpl() //
.classpathOptions(classpathOptions) //
.complianceOptions(new ComplianceOptions().compliance(javaCompliance)) //
.advancedOptions(new AdvancedOptions().preserveUnusedVars().continueExecution().enableJavadoc()) //
.annotationProcessingOptions(new AnnotationProcessingOptions().compileProcessors()) //
.sources(sourcesOptions) //
.build();
final String[] finalArgs = new String[args.length + 1];
finalArgs[0] = "-proceedOnError";
for(int i = 0; i < args.length; i++) {
finalArgs[i + 1] = args[i];
}
if(!withLog) {
compiler.logger = new Main.Logger(compiler, new PrintWriter(new NullWriter()), new PrintWriter(new NullWriter()));
}
compiler.compile(finalArgs);
environment = compiler.getEnvironment();
return compiler.globalErrorsCount == 0;
}