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


Java Javac类代码示例

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


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

示例1: compileJavaVersionChecker

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
private void compileJavaVersionChecker() {
    PhetBuildUtils.antEcho( antTaskRunner, "Compiling java version checker for " + project.getName() + ".", getClass() );

    Javac javac = new Javac();
    javac.setIncludeantruntime( false );//see #2431, should not include full classpath if running from IDE
    javac.setSource( BuildToolsConstants.BOOTSTRAP_JAVA_VERSION );//Java version checker must be compiled in lowest language version
    javac.setTarget( BuildToolsConstants.BOOTSTRAP_JAVA_VERSION );//so it can run in lowest language version jvms
    javac.setClasspath( new Path( antTaskRunner.getProject(), new File( project.getTrunk(), BuildToolsPaths.JNLP_JAR ).getAbsolutePath() ) );
    javac.setSrcdir( new Path( antTaskRunner.getProject(), new File( project.getTrunk(), BuildToolsPaths.JAVA_COMMON + "/java-version-checker/src" ).getAbsolutePath() ) );
    javac.setDestdir( project.getClassesDirectory() );
    javac.setDebugLevel( "lines,source" );
    javac.setDebug( true );

    //if this fails, you may need to add Oracles's tools.jar to your working copy (ignored from svn for legal reasons)
    //see trunk/build-tools/contrib/sun-tools/readme.txt
    antTaskRunner.runTask( javac );

    PhetBuildUtils.antEcho( antTaskRunner, "Finished compiling java version checker for " + project.getName() + ".", getClass() );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:JavaBuildCommand.java

示例2: setJavac

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
@Override
public void setJavac(Javac attributes) {
        if (attributes.getTarget() == null) {
                attributes.setTarget("1.5");
        }
        if (attributes.getSource() == null) {
                attributes.setSource("1.5");
        }
        super.setJavac(attributes);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:11,代码来源:JDTCompiler15.java

示例3: setJavac

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
/**
 * Set the Javac instance which contains the configured compilation
 * attributes.
 *
 * @param attributes a configured Javac task.
 */
@Override
public void setJavac(final Javac attributes) {
    this.attributes = attributes;
    src = attributes.getSrcdir();
    destDir = attributes.getDestdir();
    encoding = attributes.getEncoding();
    debug = attributes.getDebug();
    optimize = attributes.getOptimize();
    deprecation = attributes.getDeprecation();
    depend = attributes.getDepend();
    verbose = attributes.getVerbose();
    target = attributes.getTarget();
    release = attributes.getRelease();
    bootclasspath = attributes.getBootclasspath();
    extdirs = attributes.getExtdirs();
    compileList = attributes.getFileList();
    compileClasspath = attributes.getClasspath();
    modulepath = attributes.getModulepath();
    upgrademodulepath = attributes.getUpgrademodulepath();
    compileSourcepath = attributes.getSourcepath();
    moduleSourcepath = attributes.getModulesourcepath();
    project = attributes.getProject();
    location = attributes.getLocation();
    includeAntRuntime = attributes.getIncludeantruntime();
    includeJavaRuntime = attributes.getIncludejavaruntime();
    memoryInitialSize = attributes.getMemoryInitialSize();
    memoryMaximumSize = attributes.getMemoryMaximumSize();
    if (moduleSourcepath != null && src == null && compileSourcepath == null) {
        //Compatibility to prevent NPE from Jikes, Jvc, Kjc
        compileSourcepath = new Path(getProject());
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:39,代码来源:DefaultCompilerAdapter.java

示例4: setClassPath

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
/**
 * 设置需要的classpath.
 */
public static void setClassPath(Project p, Javac javac, ClassGenerator cg)
{
	Set paths = new HashSet();
	parseClassPath(cg.getClassLoader(), paths);
	Class[] arr = cg.getClassPaths();
	for (int i = 0; i < arr.length; i++)
	{
		parseClassPath(arr[i].getClassLoader(), paths);
	}
	ClassPathFilter filter = (ClassPathFilter) cg.getExtParam(ANT_CLASSPATH_FILTER);
	Iterator itr = paths.iterator();
	Path path = null;
	while (itr.hasNext())
	{
		String tmp = (String) itr.next();
		if (filter != null && !filter.isValid(tmp))
		{
			continue;
		}
		if (path == null)
		{
			path = new Path(p, tmp);
		}
		else
		{
			path.add(new Path(p, tmp));
		}
	}
	if (path != null)
	{
		javac.setClasspath(path);
		if (ClassGenerator.COMPILE_LOG_TYPE > COMPILE_LOG_TYPE_DEBUG)
		{
			log.info("Added classpath:" + path);
		}
	}
}
 
开发者ID:micromagic,项目名称:eterna,代码行数:41,代码来源:AntCG.java

示例5: compileJava

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
private void compileJava() {
    if ( useJavaVersionChecker ) {
        compileJavaVersionChecker();
    }

    File[] src = project.getAllJavaSourceRoots();
    File[] classpath = project.getAllJarFiles();

    // trace out all of the dependency information, since this can be very helpful in debugging the build process
    for ( PhetProject dependency : project.getAllDependencies() ) {
        System.out.println( "dependency: " + dependency.getName() );
        for ( File sourceRoot : dependency.getSourceRoots() ) {
            System.out.println( "\tsource path: " + sourceRoot.getAbsolutePath() );
        }
        for ( File jarFile : dependency.getJarFiles() ) {
            System.out.println( "\tclass path: " + jarFile.getAbsolutePath() );
        }
    }

    PhetBuildUtils.antEcho( antTaskRunner, "Compiling " + project.getName() + ".", getClass() );

    Javac javac = new Javac();
    javac.setIncludeantruntime( false );//see #2431, should not include full classpath if running from IDE
    javac.setSource( project.getJavaSourceVersion() );
    javac.setTarget( project.getJavaTargetVersion() );
    javac.setSrcdir( new Path( antTaskRunner.getProject(), toClasspathString( src ) ) );
    javac.setDestdir( project.getClassesDirectory() );

    //This block enables compilation of mixed java-scala sources by pointing the java compiler at the compiled scala source
    // see http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources
    if ( project.containsScalaSource() ) {
        ArrayList<File> all = new ArrayList<File>( Arrays.asList( classpath ) );
        all.add( project.getClassesDirectory() );
        classpath = all.toArray( new File[all.size()] );
    }

    javac.setClasspath( new Path( antTaskRunner.getProject(), project.getClasspath() ) );

    //"lines,source" appears to be necessary to get line number debug info
    javac.setDebugLevel( "lines,source" );
    javac.setDebug( true );

    antTaskRunner.runTask( javac );

    PhetBuildUtils.antEcho( antTaskRunner, "Finished compiling " + project.getName() + ".", getClass() );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:47,代码来源:JavaBuildCommand.java

示例6: compile

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
private void compile() {
    Javac j = new Javac();
    j.setProject(getProject());
    j.setTaskName("compile");

    j.setSrcdir(new Path(getProject(), sources_path));

    File tmp;
    if (classes_path != null) {
        tmp = getProject().resolveFile(classes_path);
        if (!tmp.exists()) {
            if (!tmp.mkdir())
                throw new BuildException("Could not create temporary folder " + tmp.getAbsolutePath());
        }
    } else {
        // Generate temporary folder
        java.nio.file.Path p = mktemp();
        temporary.add(p);
        tmp = p.toFile();
        classes_path = tmp.getAbsolutePath();
    }

    j.setDestdir(tmp);
    // See "Setting Java Compiler Options" in User Guide
    j.setDebug(true);
    if (jckit.version == JC.V212) {
        j.setTarget("1.1");
        j.setSource("1.1");
        // Always set debug to disable "contains local variables,
        // but not local variable table." messages
        j.setDebug(true);
    } else if (jckit.version == JC.V221) {
        j.setTarget("1.2");
        j.setSource("1.2");
    } else {
        j.setTarget("1.5");
        j.setSource("1.5");
    }
    j.setIncludeantruntime(false);
    j.createCompilerArg().setValue("-Xlint");
    j.createCompilerArg().setValue("-Xlint:-options");
    j.createCompilerArg().setValue("-Xlint:-serial");

    j.setFailonerror(true);
    j.setFork(true);

    // set classpath
    Path cp = j.createClasspath();
    String api = null;
    if (jckit.version == JC.V3) {
        api = Paths.get(jckit.path, "lib", "api_classic.jar").toAbsolutePath().toString();
    } else if (jckit.version == JC.V212) { // V2.1.X
        api = Paths.get(jckit.path, "lib", "api21.jar").toAbsolutePath().toString();
    } else { // V2.2.X
        api = Paths.get(jckit.path, "lib", "api.jar").toAbsolutePath().toString();
    }
    cp.append(new Path(getProject(), api));
    for (JCImport i : raw_imports) {
        // Support import clauses with only jar or exp values
        if (i.jar != null) {
            cp.append(new Path(getProject(), i.jar));
        }
    }
    j.execute();
}
 
开发者ID:martinpaljak,项目名称:ant-javacard,代码行数:66,代码来源:JavaCard.java

示例7: addConfiguredJavac

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
/**
 * Add the configured nested javac task if present to initiate joint compilation.
 */
public void addConfiguredJavac(final Javac javac) {
    this.javac = javac;
    jointCompilation = true;
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:Groovyc.java

示例8: 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

示例9: 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

示例10: setJavac

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
/**
 * Sets the compiler attributes, which are stored in the Javac task.
 * @param attributes the compiler attributes
 */
void setJavac(Javac attributes);
 
开发者ID:apache,项目名称:ant,代码行数:6,代码来源:CompilerAdapter.java

示例11: getJavac

import org.apache.tools.ant.taskdefs.Javac; //导入依赖的package包/类
/**
 * Get the Javac task instance associated with this compiler adapter
 *
 * @return the configured Javac task instance used by this adapter.
 */
public Javac getJavac() {
    return attributes;
}
 
开发者ID:apache,项目名称:ant,代码行数:9,代码来源:DefaultCompilerAdapter.java


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