當前位置: 首頁>>代碼示例>>Java>>正文


Java CompilerResult類代碼示例

本文整理匯總了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 );
    }
}
 
開發者ID:rkunze,項目名稱:maven-checkerframework-javac,代碼行數:28,代碼來源:JavacJSR308Compiler.java

示例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;
}
 
開發者ID:rkunze,項目名稱:maven-checkerframework-javac,代碼行數:38,代碼來源:JavacJSR308Compiler.java

示例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;
}
 
開發者ID:CloudSlang,項目名稱:cloud-slang,代碼行數:30,代碼來源:CloudSlangMavenCompiler.java

示例4: compileInProcessWithProperClassloader

import org.codehaus.plexus.compiler.CompilerResult; //導入依賴的package包/類
protected CompilerResult compileInProcessWithProperClassloader( Class<?> javacClass, String[] args )
    throws CompilerException {
  return compileInProcess0(javacClass, args);
}
 
開發者ID:rkunze,項目名稱:maven-checkerframework-javac,代碼行數:5,代碼來源:JavacJSR308Compiler.java


注:本文中的org.codehaus.plexus.compiler.CompilerResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。