Java Code Examples for org.apache.tools.ant.types.Path#setPath()

The following examples show how to use org.apache.tools.ant.types.Path#setPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AntTaskUtils.java    From was-maven-plugin with Apache License 2.0 6 votes vote down vote up
private static Path getPathFromArtifacts(Collection<Artifact> artifacts, Project antProject)
    throws DependencyResolutionRequiredException {
  if (artifacts == null) {
    return new Path(antProject);
  }

  List<String> list = new ArrayList<String>(artifacts.size());
  for (Artifact a : artifacts) {
    File file = a.getFile();
    if (file == null) {
      throw new DependencyResolutionRequiredException(a);
    }
    list.add(file.getPath());
  }

  Path p = new Path(antProject);
  p.setPath(StringUtils.join(list.iterator(), File.pathSeparator));

  return p;
}
 
Example 2
Source File: SortSuiteModulesTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Path createPath(String[] paths) {
    Path path = new Path(project);
    StringBuffer sb = new StringBuffer();
    for (int it = 0; it < paths.length; it++) {
        if (sb.length() > 0) {
            sb.append(":");
        }
        sb.append(paths[it]);
    }
    path.setPath(sb.toString());
    return path;
}
 
Example 3
Source File: SortSuiteModulesTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String[] getSorted(String property) {
    Path path = new Path(project);
    path.setPath(property);
    String paths[] = path.list();

    String rets [] = new String[paths.length];
    for (int i = 0; i < paths.length; i++) {
        rets[i] = new File(paths[i]).getName();

    }
    return rets;
}
 
Example 4
Source File: BundleLocator.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void transformPath()
{
  final Path newPath = new Path(getProject());
  log("Updating bundle paths in class path reference '"
      +classPathRef.getRefId() +"'.", Project.MSG_DEBUG);

  String[] pathElements = null;
  try {
    final Path path = (Path) classPathRef.getReferencedObject();
    pathElements = path.list();
  } catch (final BuildException e) {
    // Unsatisfied ref in the given path; can not expand.
    // Make the new path a reference to the old one.
    log("Unresolvable reference in '" +classPathRef.getRefId()
        +"' can not expand bundle names in it.", Project.MSG_WARN);
    newPath.setRefid(classPathRef);
  }

  if (null!=pathElements) {
    for (final String pathElement2 : pathElements) {
      final File pathElement = new File(pathElement2);
      boolean added = false;
      log("path element: "+pathElement, Project.MSG_DEBUG);
      if (!pathElement.exists()) {
        log("Found non existing path element: " +pathElement,
            Project.MSG_DEBUG);
        final String fileName = pathElement.getName();
        final BundleArchives.BundleArchive ba = getBundleArchive(fileName);
        if (ba!=null) {
          final String filePath = ba.file.getAbsolutePath();
          newPath.setPath(filePath);
          added = true;
          log(fileName +" => " +filePath, Project.MSG_VERBOSE);
        } else if (isBundleNameWithWildcardVersion(fileName)) {
          final int logLevel = failOnMissingBundles
            ? Project.MSG_ERR : Project.MSG_INFO;
          log("No match for '" +fileName +"' when expanding the path named '"
              +classPathRef.getRefId() +"'.", logLevel);
          log("Known bundles names: " +bas.getKnownNames(), logLevel);
          if (failOnMissingBundles) {
            throw new BuildException
              ("No bundle with name like '" +fileName+"' found.");
          }
        } else {
          log("No match for '" +fileName +"' when expanding the path named '"
              +classPathRef.getRefId() +"'.", Project.MSG_VERBOSE);
        }
      }
      if (!added) {
        newPath.setPath(pathElement.getAbsolutePath());
      }
    }
    log(newClassPathId +" = " +newPath, Project.MSG_VERBOSE);
  }
  getProject().addReference(newClassPathId, newPath);
}
 
Example 5
Source File: Groovy.java    From groovy with Apache License 2.0 4 votes vote down vote up
private void createClasspathParts() {
    Path path;
    if (classpath != null) {
        path = super.createClasspath();
        path.setPath(classpath.toString());
    }

    if (includeAntRuntime) {
        path = super.createClasspath();
        path.setPath(System.getProperty("java.class.path"));
    }
    String groovyHome = null;
    final String[] strings = getSysProperties().getVariables();
    if (strings != null) {
        for (String prop : strings) {
            if (prop.startsWith("-Dgroovy.home=")) {
                groovyHome = prop.substring("-Dgroovy.home=".length());
            }
        }
    }
    if (groovyHome == null) {
        groovyHome = System.getProperty("groovy.home");
    }
    if (groovyHome == null) {
        groovyHome = System.getenv("GROOVY_HOME");
    }
    if (groovyHome == null) {
        throw new IllegalStateException("Neither ${groovy.home} nor GROOVY_HOME defined.");
    }
    File jarDir = new File(groovyHome, "lib");
    if (!jarDir.exists()) {
        throw new IllegalStateException("GROOVY_HOME incorrectly defined. No lib directory found in: " + groovyHome);
    }
    final File[] files = jarDir.listFiles();
    if (files != null) {
        for (File file : files) {
            try {
                log.debug("Adding jar to classpath: " + file.getCanonicalPath());
            } catch (IOException e) {
                // ignore
            }
            path = super.createClasspath();
            path.setLocation(file);
        }
    }
}