org.apache.tools.ant.Project.resolveFile()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(114)

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

Project.resolveFile介绍

[英]Return the canonical form of a filename.

If the specified file name is relative it is resolved with respect to the project's base directory.
[中]返回文件名的标准格式。
如果指定的文件名是相对的,则将根据项目的基本目录解析该文件名。

代码示例

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

/**
 * Constructor for Ant attribute introspection.
 * @param p the Project against which to resolve <code>s</code>.
 * @param s the absolute or Project-relative filename as a String.
 * @see org.apache.tools.ant.IntrospectionHelper
 */
public FileResource(Project p, String s) {
  this(p, p.resolveFile(s));
}

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

@Override
  public void set(final Project p, final Object parent, final String value)
      throws InvocationTargetException, IllegalAccessException {
    m.invoke(parent, p.resolveFile(value));
  }
};

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

@Override
  public void set(final Project p, final Object parent, final String value)
      throws InvocationTargetException, IllegalAccessException {
    m.invoke(parent, p.resolveFile(value).toPath());
  }
};

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

/**
 * Returns the resolved file
 * @param extension the extension
 * @param project the project
 * @return the file resolved
 * @throws BuildException if no location is set
 */
@Override
public File resolve(final Extension extension,
          final Project project) throws BuildException {
  if (null == location) {
    throw new BuildException("No location specified for resolver");
  }
  return project.resolveFile(location);
}
/**

代码示例来源:origin: jenkinsci/jenkins

/**
 * Adds an element to the classpath to be searched.
 *
 * @param pathElement The path element to add. Must not be
 *                    <code>null</code>.
 *
 * @exception BuildException if the given path element cannot be resolved
 *                           against the project.
 */
public void addPathElement(String pathElement) throws BuildException {
  File pathComponent = project != null ? project.resolveFile(pathElement) : new File(
      pathElement);
  try {
    addPathFile(pathComponent);
  } catch (IOException e) {
    throw new BuildException(e);
  }
}

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

/**
 * Set the directory.
 * @param d a <code>String</code> value
 */
public void setDir(String d) {
  this.dir = getProject().resolveFile(d);
}

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

@Override
  void set(final Project p, final Object parent, final String value)
      throws InvocationTargetException, IllegalAccessException, BuildException {
    m.invoke(parent, new FileResource(p, p.resolveFile(value)));
  }
};

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

/**
 * Adds an element to the classpath to be searched.
 *
 * @param pathElement The path element to add. Must not be
 *                    <code>null</code>.
 *
 * @exception BuildException if the given path element cannot be resolved
 *                           against the project.
 */
public void addPathElement(final String pathElement) throws BuildException {
  final File pathComponent = project != null ? project.resolveFile(pathElement) : new File(
      pathElement);
  try {
    addPathFile(pathComponent);
  } catch (final IOException e) {
    throw new BuildException(e);
  }
}

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

/**
 * Return a <code>File[]</code> from the specified set of filenames.
 * @param name   <code>String[]</code>
 * @return <code>File[]</code>.
 */
protected File[] toFileArray(String[] name) {
  if (name == null) {
    return null;
  }
  //remove any null elements
  ArrayList<File> list = new ArrayList<>(name.length);
  for (String n : name) {
    if (n != null) {
      list.add(getProject().resolveFile(n));
    }
  }
  return list.toArray(new File[list.size()]);
}

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

/**
 * Adds basedirs as a comma separated list.
 * @param dirs directories as CSV
 */
public void setBaseDirs(final String dirs) {
  if (isReference()) {
    throw tooManyAttributes();
  }
  if (dirs != null && !dirs.isEmpty()) {
    for (final String d : dirs.split(",")) {
      baseDirs.add(getProject().resolveFile(d));
    }
  }
}

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

/**
 * Set the list of files to be attached.
 *
 * @param filenames Comma-separated list of files.
 */
public void setFiles(String filenames) {
  StringTokenizer t = new StringTokenizer(filenames, ", ");
  while (t.hasMoreTokens()) {
    createAttachments()
      .add(new FileResource(getProject().resolveFile(t.nextToken())));
  }
}

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

/**
 * Set the list of source files to process.
 *
 * @param src a comma separated list of source files.
 */
public void setSourcefiles(final String src) {
  final StringTokenizer tok = new StringTokenizer(src, ",");
  while (tok.hasMoreTokens()) {
    final String f = tok.nextToken();
    final SourceFile sf = new SourceFile();
    sf.setFile(getProject().resolveFile(f.trim()));
    addSource(sf);
  }
}

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

private void collectFileListFromSourcePath() {
  for (String filename : src.list()) {
    final File srcDir = getProject().resolveFile(filename);
    if (!srcDir.exists()) {
      throw new BuildException("srcdir \""
                   + srcDir.getPath()
                   + "\" does not exist!", getLocation());
    }
    final DirectoryScanner ds = this.getDirectoryScanner(srcDir);
    scanDir(srcDir, destDir != null ? destDir : srcDir, ds.getIncludedFiles());
  }
}

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

/**
 * Link to docs at "url" using package list at "url2"
 * - separate the URLs by using a space character.
 *
 * @param src the offline link specification (url and package list)
 */
public void setLinkoffline(final String src) {
  final LinkArgument le = createLink();
  le.setOffline(true);
  final String linkOfflineError = "The linkoffline attribute must include"
    + " a URL and a package-list file location separated by a"
    + " space";
  if (src.trim().isEmpty()) {
    throw new BuildException(linkOfflineError);
  }
  final StringTokenizer tok = new StringTokenizer(src, " ", false);
  le.setHref(tok.nextToken());
  if (!tok.hasMoreTokens()) {
    throw new BuildException(linkOfflineError);
  }
  le.setPackagelistLoc(getProject().resolveFile(tok.nextToken()));
}

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

/**
 * @deprecated since 1.5.x.
 *             setSrc(String) is deprecated and is replaced with
 *             setSrc(File) to make Ant's Introspection
 *             mechanism do the work and also to encapsulate operations on
 *             the type in its own class.
 * @ant.attribute ignore="true"
 * @param src a <code>String</code> value
 */
@Deprecated
public void setSrc(String src) {
  log("DEPRECATED - The setSrc(String) method has been deprecated."
    + " Use setSrc(File) instead.");
  setSrc(getProject().resolveFile(src));
}

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

/**
 * @deprecated since 1.5.x.
 *             setDest(String) is deprecated and is replaced with
 *             setDest(File) to make Ant's Introspection
 *             mechanism do the work and also to encapsulate operations on
 *             the type in its own class.
 * @ant.attribute ignore="true"
 * @param dest a <code>String</code> value
 */
@Deprecated
public void setDest(String dest) {
  log("DEPRECATED - The setDest(String) method has been deprecated."
    + " Use setDest(File) instead.");
  setDest(getProject().resolveFile(dest));
}

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

/**
   * Creates the temporary file.
   *
   * @exception  BuildException  if something goes wrong with the build
   */
  @Override
  public void execute() throws BuildException {
    if (property == null || property.isEmpty()) {
      throw new BuildException("no property specified");
    }
    if (destDir == null) {
      destDir = getProject().resolveFile(".");
    }
    File tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir,
          deleteOnExit, createFile);
    getProject().setNewProperty(property, tfile.toString());
  }
}

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

/**
 * Called to validate that the tool parameters have been configured.
 * @throws BuildException if there is an error.
 */
@Override
public void validateConfigured() throws BuildException {
  super.validateConfigured();
  if (ejbdeploy) {
    String home = getTask().getProject().getProperty("websphere.home");
    if (home == null) {
      throw new BuildException(
        "The 'websphere.home' property must be set when 'ejbdeploy=true'");
    }
    websphereHome = getTask().getProject().resolveFile(home);
  }
}

代码示例来源:origin: apache/groovy

/**
 * Executes the task.
 *
 * @throws BuildException if an error occurs
 */
public void execute() throws BuildException {
  checkParameters();
  resetFileLists();
  loadRegisteredScriptExtensions();
  if (javac != null) jointCompilation = true;
  // scan source directories and dest directory to build up
  // compile lists
  String[] list = src.list();
  for (String filename : list) {
    File file = getProject().resolveFile(filename);
    if (!file.exists()) {
      throw new BuildException("srcdir \"" + file.getPath() + "\" does not exist!", getLocation());
    }
    DirectoryScanner ds = this.getDirectoryScanner(file);
    String[] files = ds.getIncludedFiles();
    scanDir(file, destDir != null ? destDir : file, files);
  }
  compile();
  if (updatedProperty != null
      && taskSuccess
      && compileList.length != 0) {
    getProject().setNewProperty(updatedProperty, "true");
  }
}

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

private void touch(Resource r, long defaultTimestamp) {
  if (fileNameMapper == null) {
    FileProvider fp = r.as(FileProvider.class);
    if (fp != null) {
      // use this to create file and deal with non-writable files
      touch(fp.getFile(), defaultTimestamp);
    } else {
      r.as(Touchable.class).touch(defaultTimestamp);
    }
  } else {
    String[] mapped = fileNameMapper.mapFileName(r.getName());
    if (mapped != null && mapped.length > 0) {
      long modTime = defaultTimestamp;
      if (millis < 0 && r.isExists()) {
        modTime = r.getLastModified();
      }
      for (String fileName : mapped) {
        touch(getProject().resolveFile(fileName), modTime);
      }
    }
  }
}

相关文章