org.apache.tools.ant.taskdefs.Javac类的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(456)

本文整理了Java中org.apache.tools.ant.taskdefs.Javac类的一些代码示例,展示了Javac类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Javac类的具体详情如下:
包路径:org.apache.tools.ant.taskdefs.Javac
类名称:Javac

Javac介绍

[英]Compiles Java source files. This task can take the following arguments:

  • sourcedir
  • destdir
  • deprecation
  • classpath
  • bootclasspath
  • extdirs
  • optimize
  • debug
  • encoding
  • target
  • depend
  • verbose
  • failonerror
  • includeantruntime
  • includejavaruntime
  • source
  • compiler
  • release
    Of these arguments, the sourcedir and destdir are required.

When this task executes, it will recursively scan the sourcedir and destdir looking for Java source files to compile. This task makes its compile decision based on timestamp.
[中]编译Java源文件。此任务可以采用以下参数:
*sourcedir
*德斯特迪尔
*贬低
*类路径
*引导类路径
*extdirs
*优化
*调试
*编码
*目标
*依靠
*冗长的
*失败者
*包含时间
*includejavaruntime
*来源
*编译程序
*释放
在这些参数中,sourcedir和destdir是必需的。
执行此任务时,它将递归扫描sourcedir和destdir,以查找要编译的Java源文件。此任务根据时间戳做出编译决策。

代码示例

代码示例来源:origin: org.apache.xmlbeans/xmlbeans

Javac javac = new Javac();
javac.setProject(project);
javac.setTaskName(getTaskName());
javac.setClasspath(classpath);
if (compiler != null) javac.setCompiler(compiler);
javac.setDebug(debug);
if (debugLevel != null) javac.setDebugLevel(debugLevel);
javac.setDestdir(classgendir);
javac.setExecutable(forkedExecutable);
javac.setFailonerror(failonerror);
javac.setFork(fork);
if (javasource != null)
  javac.setSource(javasource);
  javac.setTarget(javasource);
  javac.setSource("1.4");
  javac.setTarget("1.4");
javac.setIncludeantruntime(includeAntRuntime);
javac.setIncludejavaruntime(includeJavaRuntime);
javac.setSrcdir(new Path(project, srcgendir.getAbsolutePath()));
if (memoryInitialSize != null) javac.setMemoryInitialSize(memoryInitialSize);
if (memoryMaximumSize != null) javac.setMemoryMaximumSize(memoryMaximumSize);
javac.setOptimize(optimize);
javac.setVerbose(verbose);
javac.execute();

代码示例来源:origin: com.sun.xml.ws/jaxws-tools

/**
   * Performs a compile using the Javac externally.
   *
   * @throws BuildException if there is a problem.
   */
  public void execute() throws BuildException {
    ImplementationSpecificArgument argument = super.createCompilerArg();
    argument.setLine("-processor " + WebServiceAp.class.getName());
    argument = super.createCompilerArg();
    argument.setLine("-s " + sourceDestDir);
    if (procOnly) {
      argument = super.createCompilerArg();
      argument.setLine("-proc:only");
    }
    super.execute();
  }
}

代码示例来源:origin: org.bluestemsoftware.open.maven.tparty/jsp-2.1

public void setDebug(boolean debug) {
  javac.setDebug(debug);
  javac.setOptimize(!debug);
}

代码示例来源:origin: stackoverflow.com

Javac javaCompile = (Javac) webServiceProject.createTask("javac");
javaCompile.createCompilerArg().setValue("-Xstdout");
String filePath = basePath + "resources" + File.separator
    + "errorlog.log";
javaCompile.createCompilerArg().setFile(new File(filePath));
javaCompile.setNowarn(true);

代码示例来源:origin: org.apache.geronimo.ext.tomcat/jasper

javac.setExtdirs(extdirs);
  info.append("    extension dir=" + exts + "\n");
  if(endorsed != null) {
    Javac.ImplementationSpecificArgument endorsedArg = 
      javac.createCompilerArg();
    endorsedArg.setLine("-J-Djava.endorsed.dirs=" +
        quotePathList(endorsed));
javac.setEncoding(javaEncoding);
javac.setClasspath(path);
javac.setDebug(ctxt.getOptions().getClassDebugInfo());
javac.setSrcdir(srcPath);
javac.setTempdir(options.getScratchDir());
javac.setOptimize(! ctxt.getOptions().getClassDebugInfo() );
javac.setFork(ctxt.getOptions().getFork());
info.append("    srcDir=" + srcPath + "\n" );
  javac.setCompiler(options.getCompiler());
  info.append("    compiler=" + options.getCompiler() + "\n");
  javac.setTarget(options.getCompilerTargetVM());
  info.append("   compilerTargetVM=" + options.getCompilerTargetVM() + "\n");
  javac.setSource(options.getCompilerSourceVM());
  info.append("   compilerSourceVM=" + options.getCompilerSourceVM() + "\n");
PatternSet.NameEntry includes = javac.createInclude();

代码示例来源:origin: martinpaljak/ant-javacard

Javac j = new Javac();
j.setProject(project);
j.setTaskName("compile");
j.setSrcdir(sources);
j.setDestdir(tmp);
j.setDebug(true);
String javaVersion = jckit.getJavaVersion();
if (java_version != null) {
j.setTarget(javaVersion);
j.setSource(javaVersion);
if (jckit.isVersion(JavaCardSDK.Version.V21)) {
  j.setDebug(true);
j.setIncludeantruntime(false);
j.createCompilerArg().setValue("-Xlint");
j.createCompilerArg().setValue("-Xlint:-options");
j.createCompilerArg().setValue("-Xlint:-serial");
if (jckit.getVersion() == JavaCardSDK.Version.V304) {
  j.createCompilerArg().setLine("-processor com.oracle.javacard.stringproc.StringConstantsProcessor");
  Path pcp = new Javac().createClasspath();
  j.createCompilerArg().setLine("-processorpath \"" + pcp.toString() + "\"");
  j.createCompilerArg().setValue("-Xlint:all,-processing");

代码示例来源:origin: org.codehaus.castor/castor-testsuite-xml-framework

project.setBasedir(srcDir.getAbsolutePath());
Javac compiler = new Javac();
compiler.setProject(project);
compiler.setDestdir(destDir.getAbsoluteFile());
compiler.setOptimize(false);
compiler.setDebug(true);
compiler.setDebugLevel("lines,vars,source");
compiler.setIncludejavaruntime(true);
if (XMLTestCase._verbose) {
 compiler.setListfiles(true);
 compiler.setVerbose(true);
} else {
 compiler.setNowarn(true);
 compiler.setSource(_javaVersion);
Path classpath = compiler.createClasspath();
classpath.setPath(System.getProperty("java.class.path"));
classpath.add(new Path(project, destDir.getAbsolutePath()));
compiler.setClasspath(classpath);
return compiler;

代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal

public void compile(List files, CompilationUnit cu) {
    // forward options
    if (javac.getClasspath()==null) {
      javac.setClasspath(compileClasspath);
    }
    if (javac.getSourcepath()==null && compileSourcepath!=null) {
      javac.createSourcepath().add(compileSourcepath);
    }
    if (javac.getEncoding()==null) {
      javac.setEncoding(encoding);
    }
    javac.setDestdir(destDir);
    
    Path p = javac.createSrc();
    p.add(src);
    
    Path tmpDir = new Path(getProject());
    File dir = (File) cu.getConfiguration().getJointCompilationOptions().get("stubDir");
    tmpDir.setLocation(dir);
    p.add(tmpDir);
    javac.execute();
  }
};

代码示例来源:origin: org.tinygroup/org.tinygroup.jspengine

javac.setEncoding(javaEncoding);
Path srcPath = new Path(project);
srcPath.setLocation(options.getScratchDir());
javac.setSrcdir(srcPath);
info.append("    srcDir=" + srcPath + "\n");
info.append("    work dir=" + options.getScratchDir() + "\n");
PatternSet.NameEntry includes = javac.createInclude();
includes.setName(ctxt.getJavaPath());
info.append("    include=" + ctxt.getJavaPath() + "\n");
if (ctxt.getOptions().getFork()) {
  try {
    javac.execute();
  } catch (BuildException e) {
    be = e;

代码示例来源:origin: org.bluestemsoftware.open.maven.tparty/jsp-2.1

public void setClassPath(List<File> cpath) {
  Path path = new Path(project);
  for (File file: cpath) {
    path.setLocation(file);
    info.append("    cp=" + file + "\n");
  }
  javac.setClasspath(path);
}

代码示例来源:origin: net.sf.antenna/antenna

String bcp = utility.getMidpApi();
if (getClasspath() == null) {
  setClasspath(new Path(getProject(), bcp));
  getClasspath().add(new Path(getProject(), bcp));
super.execute();

代码示例来源:origin: org.codehaus.castor/castor-testsuite-xml-framework

/**
 * Compiles a directory tree. Throws a <code>CompilationException</code> if build fails.
 *
 * @param srcDir Source directory holding the files to be compiled.
 * @param destDir Destination directory to put the compiled classes in.
 */
private void compileDirectory(final File srcDir, final File destDir) {
 File[] entries = srcDir.listFiles();
 for (int i = 0; i < entries.length; i++) {
  File entry = entries[i];
  if (entry.isDirectory() && !IGNORE_DIRS.contains(entry.getName())) {
   compileDirectory(entry, destDir);
  }
 }
 entries = null;
 try {
  Path srcPath = _compiler.createSrc();
  srcPath.setLocation(destDir);
  _compiler.setSrcdir(srcPath);
  _compiler.execute();
 } catch (BuildException ex) {
  throw new CompilationException("Problem compiling directory " + srcDir, ex);
 }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.jspengine

public void init(JspCompilationContext ctxt,
         ErrorDispatcher errDispatcher,
         boolean suppressLogging) {
  this.ctxt = ctxt;
  this.errDispatcher = errDispatcher;
  options = ctxt.getOptions();
  log = suppressLogging ?
      new org.tinygroup.jspengine.org.apache.commons.logging.impl.NoOpLog() :
      org.tinygroup.jspengine.org.apache.commons.logging.LogFactory.getLog(
          AntJavaCompiler.class);
  getProject();
  javac = (Javac) project.createTask("javac");
  javac.setFork(options.getFork());
  // Set the Java compiler to use
  if (options.getCompiler() != null) {
    javac.setCompiler(options.getCompiler());
  }
  startThreadPool();
}

代码示例来源:origin: org.bluestemsoftware.open.maven.tparty/jsp-2.1

public void run() {
  SystemLogHandler.setThread();
  try {
    _javac.execute();
  } catch  (BuildException e) {
    _be = e;
  } finally {
    _errorCapture = SystemLogHandler.unsetThread();
    synchronized(this) {
      this.notify();
    }
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.jspengine

public void setSourceVM(String sourceVM) {
  javac.setSource(sourceVM);
  info.append("   compilerSourceVM=" + sourceVM + "\n");
}

代码示例来源:origin: org.bluestemsoftware.open.maven.tparty/jsp-2.1

public void setTargetVM(String targetVM) {
  javac.setTarget(targetVM);
  info.append("   compilerTargetVM=" + targetVM + "\n");
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

javac.setExtdirs(extdirs);
  info.append("    extension dir=" + exts + "\n");
  if(endorsed != null) {
    Javac.ImplementationSpecificArgument endorsedArg = 
      javac.createCompilerArg();
    endorsedArg.setLine("-J-Djava.endorsed.dirs=" +
        quotePathList(endorsed));
javac.setEncoding(javaEncoding);
javac.setClasspath(path);
javac.setDebug(ctxt.getOptions().getClassDebugInfo());
javac.setSrcdir(srcPath);
javac.setTempdir(options.getScratchDir());
javac.setOptimize(! ctxt.getOptions().getClassDebugInfo() );
javac.setFork(ctxt.getOptions().getFork());
info.append("    srcDir=" + srcPath + "\n" );
  javac.setCompiler(options.getCompiler());
  info.append("    compiler=" + options.getCompiler() + "\n");
  javac.setTarget(options.getCompilerTargetVM());
  info.append("   compilerTargetVM=" + options.getCompilerTargetVM() + "\n");
  javac.setSource(options.getCompilerSourceVM());
  info.append("   compilerSourceVM=" + options.getCompilerSourceVM() + "\n");
PatternSet.NameEntry includes = javac.createInclude();

代码示例来源:origin: org.bluestemsoftware.open.maven.tparty/jsp-2.1

javac.setEncoding(javaEncoding);
Path srcPath = new Path(project);
srcPath.setLocation(options.getScratchDir());
javac.setSrcdir(srcPath);
info.append("    srcDir=" + srcPath + "\n" );
info.append("    work dir=" + options.getScratchDir() + "\n");
PatternSet.NameEntry includes = javac.createInclude();
includes.setName(ctxt.getJavaPath());
info.append("    include="+ ctxt.getJavaPath() + "\n" );
if (ctxt.getOptions().getFork()) {
  try {
    javac.execute();
  } catch (BuildException e) {
    be = e;

代码示例来源:origin: org.tinygroup/org.tinygroup.jspengine

public void setClassPath(List<File> cpath) {
  Path path = new Path(project);
  for (File file : cpath) {
    path.setLocation(file);
    info.append("    cp=" + file + "\n");
  }
  javac.setClasspath(path);
}

代码示例来源:origin: org.bluestemsoftware.open.maven.tparty/jsp-2.1

public void init(JspCompilationContext ctxt,
         ErrorDispatcher errDispatcher,
         boolean suppressLogging) {
  this.ctxt = ctxt;
  this.errDispatcher = errDispatcher;
  options = ctxt.getOptions();
  log = suppressLogging?
    new com.sun.org.apache.commons.logging.impl.NoOpLog():
    com.sun.org.apache.commons.logging.LogFactory.getLog(
      AntJavaCompiler.class);
  getProject();
  javac = (Javac) project.createTask("javac");
  javac.setFork(options.getFork());
  // Set the Java compiler to use
  if (options.getCompiler() != null) {
    javac.setCompiler(options.getCompiler());
  }
  startThreadPool();
}

相关文章

微信公众号

最新文章

更多