Search in sources :

Example 1 with JavahAdapter

use of org.apache.tools.ant.taskdefs.optional.javah.JavahAdapter in project ant by apache.

the class Javah method execute.

/**
 * Execute the task
 *
 * @throws BuildException is there is a problem in the task execution.
 */
@Override
public void execute() throws BuildException {
    // first off, make sure that we've got a srcdir
    final Set<Settings> settings = EnumSet.noneOf(Settings.class);
    if (cls != null) {
        settings.add(Settings.cls);
    }
    if (!classes.isEmpty()) {
        settings.add(Settings.classes);
    }
    if (!files.isEmpty()) {
        settings.add(Settings.files);
    }
    if (settings.size() > 1) {
        throw new BuildException("Exactly one of " + Settings.values() + " attributes is required", getLocation());
    }
    if (destDir != null) {
        if (!destDir.isDirectory()) {
            throw new BuildException("destination directory \"" + destDir + "\" does not exist or is not a directory", getLocation());
        }
        if (outputFile != null) {
            throw new BuildException("destdir and outputFile are mutually " + "exclusive", getLocation());
        }
    }
    if (classpath == null) {
        classpath = new Path(getProject()).concatSystemClasspath("last");
    } else {
        classpath = classpath.concatSystemClasspath("ignore");
    }
    JavahAdapter ad = nestedAdapter != null ? nestedAdapter : JavahAdapterFactory.getAdapter(facade.getImplementation(), this, createImplementationClasspath());
    if (!ad.compile(this)) {
        throw new BuildException("compilation failed");
    }
}
Also used : Path(org.apache.tools.ant.types.Path) JavahAdapter(org.apache.tools.ant.taskdefs.optional.javah.JavahAdapter) BuildException(org.apache.tools.ant.BuildException)

Aggregations

BuildException (org.apache.tools.ant.BuildException)1 JavahAdapter (org.apache.tools.ant.taskdefs.optional.javah.JavahAdapter)1 Path (org.apache.tools.ant.types.Path)1