本文整理汇总了Java中org.codehaus.plexus.compiler.CompilerResult类的典型用法代码示例。如果您正苦于以下问题:Java CompilerResult类的具体用法?Java CompilerResult怎么用?Java CompilerResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompilerResult类属于org.codehaus.plexus.compiler包,在下文中一共展示了CompilerResult类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compileInProcess
import org.codehaus.plexus.compiler.CompilerResult; //导入依赖的package包/类
/**
* Compile the java sources in the current JVM, without calling an external executable,
* using <code>com.sun.tools.javac.Main</code> class
*
* @param args arguments for the compiler as they would be used in the command line javac
* @param config compiler configuration
* @return a CompilerResult object encapsulating the result of the compilation and any compiler messages
* @throws CompilerException
*/
CompilerResult compileInProcess( String[] args, CompilerConfiguration config )
throws CompilerException
{
final Class<?> javacClass = getJavacClass( config );
final Thread thread = Thread.currentThread();
final ClassLoader contextClassLoader = thread.getContextClassLoader();
thread.setContextClassLoader( javacClass.getClassLoader() );
getLogger().debug( "ttcl changed run compileInProcessWithProperClassloader" );
try
{
return compileInProcessWithProperClassloader(javacClass, args);
}
finally
{
releaseJavaccClass( javacClass, config );
thread.setContextClassLoader( contextClassLoader );
}
}
示例2: performCompile
import org.codehaus.plexus.compiler.CompilerResult; //导入依赖的package包/类
public CompilerResult performCompile( CompilerConfiguration config )
throws CompilerException
{
if ( config.isFork() )
{
throw new CompilerException("'fork' not supported.");
}
File destinationDir = new File( config.getOutputLocation() );
if ( !destinationDir.exists() )
{
destinationDir.mkdirs();
}
String[] sourceFiles = getSourceFiles( config );
if ( ( sourceFiles == null ) || ( sourceFiles.length == 0 ) )
{
return new CompilerResult();
}
if ( ( getLogger() != null ) && getLogger().isInfoEnabled() )
{
getLogger().info( "Compiling " + sourceFiles.length + " " +
"source file" + ( sourceFiles.length == 1 ? "" : "s" ) +
" to " + destinationDir.getAbsolutePath() );
}
String[] args = buildCompilerArguments( config, sourceFiles );
CompilerResult result;
result = compileInProcess( args, config );
return result;
}
示例3: performCompile
import org.codehaus.plexus.compiler.CompilerResult; //导入依赖的package包/类
@Override
public CompilerResult performCompile(CompilerConfiguration config) throws CompilerException {
init(config);
CompilerResult compilerResult = new CompilerResult();
List<CompilerMessage> compilerMessage = new ArrayList<>();
//we do not want the source files that were calculated because we have multiple suffix
//and the framework support only one via the inputFileEnding
config.setSourceFiles(null);
String[] sourceFiles = getSourceFiles(config);
Map<String, byte[]> dependenciesSourceFiles = getDependenciesSourceFiles(config);
if (sourceFiles.length > 0) {
System.out.println("Compiling " + sourceFiles.length + " " +
"source file" + (sourceFiles.length == 1 ? "" : "s"));
for (String sourceFile : sourceFiles) {
compilerMessage.addAll(compileFile(sourceFile, sourceFiles, dependenciesSourceFiles));
}
if (compilerMessage.size() > 0) {
compilerResult.setCompilerMessages(compilerMessage);
//we want to set it to false only in case we want to fail the build
if (errorLevel.equals(CompilerMessage.Kind.ERROR)) {
compilerResult.setSuccess(false);
}
}
}
return compilerResult;
}
示例4: compileInProcessWithProperClassloader
import org.codehaus.plexus.compiler.CompilerResult; //导入依赖的package包/类
protected CompilerResult compileInProcessWithProperClassloader( Class<?> javacClass, String[] args )
throws CompilerException {
return compileInProcess0(javacClass, args);
}