Hello all,
I'm trying to read an ant script through java and find where all its .java files and libraries are located. I've gone through the Apache ant API but couldn't find an appropriate method. So far all I could come up was the below code, it gives the properties and all but the problem is if the .java classes are not in a src folder I won't be able to sort the results. I would appreciate any help. Thanx in advance.

public class PropertyReader {
    public static void main(String[] args) throws Exception {

        File buildFile = new File("build1.xml");
        final Project project = new Project();
        ProjectHelper.configureProject(project, buildFile);
        Hashtable<String, Integer> prop = project.getProperties();
        for (Entry<String, Integer> entry : prop.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            System.out.println(key+" --- "+value);



Since you are able to read your Ant build you are able to determinate absolute path of the file, that mean that you are able to get parent path. With this data and with info from build file you shouldn't have any problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.