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

The following examples show how to use org.apache.tools.ant.types.Path#setLocation() . 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: PathBuilder.java    From development with Apache License 2.0 5 votes vote down vote up
private void addClasses(Path path, IEclipseProject project) {
    File javasrc = new File(project.getLocation(), "javasrc");
    if (javasrc.exists()) {
        // Add class files only if this project has Java sources
        File projectWorkDir = new File(workdir, project.getName());
        path.setLocation(new File(projectWorkDir, "classes"));
    }
}
 
Example 2
Source File: PathBuilder.java    From development with Apache License 2.0 5 votes vote down vote up
private void addLibrary(Path path, File library) {
    if (!library.exists()) {
        throw new BuildException("Class path entry does not exist: "
                + library);
    }
    path.setLocation(library);
}
 
Example 3
Source File: TaskModelTest.java    From testability-explorer with Apache License 2.0 5 votes vote down vote up
public void testGetClassPath() throws Exception {
  Project proj = new Project();
  Path p = new Path(proj);

  proj.setBasedir(".");
  p.setLocation(new File("src-test/com/google/ant"));

  model.addClasspath(p);
  Matcher matcher = Pattern.compile("src-test.com.google.ant").matcher(model.getClassPath());
  assertTrue(matcher.find());
}
 
Example 4
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);
        }
    }
}