3

I would like to set up an External Tool in Eclipse that does some custom compilation of classes in the project by calling javac directly. For this, I need to pass javac the classpath parameter so it knows where to go looking for dependencies.

Is it possible, e.g. in the External Tools Configurations dialog, to tell Eclipse to pass a list of all referenced libraries and source directories to my external tool, preferrably in the semi-colon separated way that javac expects? There is a variable called project_classpath, but unfortunately it returns the output directory for the compiled classes generated by Eclipse, rather than the dependency directories.

I would think Eclipse should have this information readily available somewhere as it probably needs it for its own calls to javac.

Is there some other place where I can find this information? Unfortunately the .classpath file associated with the project contains all sorts of cryptic references to Eclipse-internally defined libraries rather than simple path names.

Markus A.
  • 12,349
  • 8
  • 52
  • 116
  • In a similar problem with ant i have checked the box "Run in the same JRE with the workspace" at the JRE tab of external tool dialog. Additional you can add libs and folders at the classpath tab (select User Entries). Wich tool you use - ant or other? – Huluvu424242 Jan 06 '13 at 01:37

1 Answers1

0

I use minimal appliction to print out classpath for jsp-compilation task. Adapt as needed

public class JspCompileArgs {
    static public void main(String [] args){
        StringBuilder sb=new StringBuilder();
        sb.append("-war.path \"${resource_loc}/src/main/webapp\"\n");
        sb.append("-keepgenerated true\n");
        sb.append("-compileToDir /tmp/jsp_compile\n");
        sb.append("-additional.classpath \"");
        ClassLoader cl = ClassLoader.getSystemClassLoader();
        URL[] urls = ((URLClassLoader)cl).getURLs();
        for(URL url: urls){
            sb.append(url.getFile());
            sb.append(";");
        }
        sb.append('"');
        System.out.println(sb);
    }
}
Simo Nikula
  • 51
  • 2
  • 3