当前位置: 首页>>代码示例>>Java>>正文


Java Javac.setIncludejavaruntime方法代码示例

本文整理汇总了Java中org.apache.tools.ant.taskdefs.Javac.setIncludejavaruntime方法的典型用法代码示例。如果您正苦于以下问题:Java Javac.setIncludejavaruntime方法的具体用法?Java Javac.setIncludejavaruntime怎么用?Java Javac.setIncludejavaruntime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tools.ant.taskdefs.Javac的用法示例。


在下文中一共展示了Javac.setIncludejavaruntime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compile

import org.apache.tools.ant.taskdefs.Javac; //导入方法依赖的package包/类
/**
     * Compile generated code.
     *
     * @param outdir
     */
    private void compile(String outdir) throws Exception {
        String cp = null;
        try {
            BufferedReader br = new BufferedReader(
                    new FileReader(System.getProperty("basedir", ".") + "/target/cp.txt"));
            cp = br.readLine();
        } catch (Exception e) {
            // Don't care
        }
        if (cp == null) {
            cp = "";
        }

        //using the ant javac task for compilation
        Javac javaCompiler = new Javac();
        Project codeGenProject = new Project();
        Target compileTarget = new Target();

        compileTarget.setName(COMPILE_TARGET_NAME);
        compileTarget.addTask(javaCompiler);
        codeGenProject.addTarget(compileTarget);
        codeGenProject.setSystemProperties();
        javaCompiler.setProject(codeGenProject);
        javaCompiler.setIncludejavaruntime(true);
        javaCompiler.setIncludeantruntime(true);

        /*
          This harmless looking setFork is actually very important. unless the compiler is
          forked it wont work!
        */
        javaCompiler.setFork(true);

        //Create classpath - The generated output directories also become part of the classpath
        //reason for this is that some codegenerators(XMLBeans) produce compiled classes as part of
        //generated artifacts
        String classdir = outdir + "/classes";
        File outputLocationFile = new File(classdir);
        outputLocationFile.mkdir();
        Path classPath = new Path(codeGenProject, classdir);
        classPath.add(new Path(codeGenProject, TEST_CLASSES_DIR));
        classPath.addExisting(classPath.concatSystemClasspath(), false);
        for (int i = 0; i < moduleNames.length; i++) {
            classPath.add(new Path(codeGenProject,
                                   MODULE_PATH_PREFIX + moduleNames[i] + CLASSES_DIR));
        }
        classPath.add(new Path(codeGenProject, cp));

        javaCompiler.setClasspath(classPath);

        //set sourcePath - The generated output directories also become part of the sourcepath
        Path sourcePath = new Path(codeGenProject, outdir);
        sourcePath.setLocation(outputLocationFile);
        javaCompiler.setSrcdir(sourcePath);

        //output the classes into the output dir as well
        javaCompiler.setDestdir(outputLocationFile);
        javaCompiler.setDebug(true);
        javaCompiler.setVerbose(true);
        javaCompiler.execute();
//        codeGenProject.executeTarget(COMPILE_TARGET_NAME);
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:67,代码来源:Test.java

示例2: compile

import org.apache.tools.ant.taskdefs.Javac; //导入方法依赖的package包/类
/** @param outputLocation  */
private void compile(String outputLocation) {
    String cp = null;
    try {
        BufferedReader br = new BufferedReader(
                new FileReader(System.getProperty("basedir", ".") + "/target/cp.txt"));
        cp = br.readLine();
    } catch (Exception e) {
        // Don't care
    }
    if (cp == null) {
        cp = "";
    }

    //using the ant javac task for compilation
    Javac javaCompiler = new Javac();
    Project codeGenProject = new Project();
    Target compileTarget = new Target();

    compileTarget.setName(COMPILE_TARGET_NAME);
    compileTarget.addTask(javaCompiler);
    codeGenProject.addTarget(compileTarget);
    codeGenProject.setSystemProperties();
    javaCompiler.setProject(codeGenProject);
    javaCompiler.setIncludejavaruntime(true);
    javaCompiler.setIncludeantruntime(true);

    /*
      This harmless looking setFork is actually very important. unless the compiler is
      forked it wont work!
    */
    javaCompiler.setFork(true);

    //Create classpath - The generated output directories also become part of the classpath
    //reason for this is that some codegenerators(XMLBeans) produce compiled classes as part of
    //generated artifacts
    File outputLocationFile = new File(outputLocation);
    Path classPath = new Path(codeGenProject, outputLocation);
    classPath.addExisting(classPath.concatSystemClasspath(), false);
    for (int i = 0; i < moduleNames.length; i++) {
        classPath.add(new Path(codeGenProject,
                               MODULE_PATH_PREFIX + moduleNames[i] + CLASSES_DIR));
    }

    classPath.add(new Path(codeGenProject, cp));

    javaCompiler.setClasspath(classPath);

    //set sourcePath - The generated output directories also become part of the sourcepath
    Path sourcePath = new Path(codeGenProject, outputLocation);
    sourcePath.setLocation(outputLocationFile);
    javaCompiler.setSrcdir(sourcePath);

    //output the classes into the output dir as well
    javaCompiler.setDestdir(outputLocationFile);
    javaCompiler.setVerbose(true);
    javaCompiler.execute();

}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:60,代码来源:WSDL2JavaSuccessTestBase.java


注:本文中的org.apache.tools.ant.taskdefs.Javac.setIncludejavaruntime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。