public void execute()

in src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java [257:315]


    public void execute() throws MojoExecutionException, MojoFailureException {
        checkDeprecatedParameterUsage(tasks, "tasks", "target");
        checkDeprecatedParameterUsage(sourceRoot, "sourceRoot", "the build-helper-maven-plugin");
        checkDeprecatedParameterUsage(testSourceRoot, "testSourceRoot", "the build-helper-maven-plugin");
        if (skip) {
            getLog().info("Skipping Antrun execution");
            return;
        }

        if (target == null) {
            getLog().info("No Ant target defined - SKIPPED");
            return;
        }

        if (propertyPrefix == null) {
            propertyPrefix = "";
        }

        String antTargetName = target.getAttribute("name", DEFAULT_ANT_TARGET_NAME);
        target.setAttribute("name", antTargetName);

        Project antProject = new Project();
        antProject.addBuildListener(getConfiguredBuildLogger());
        try {
            File antBuildFile = writeTargetToProjectFile(antTargetName);
            ProjectHelper.configureProject(antProject, antBuildFile);
            antProject.init();

            antProject.setBaseDir(mavenProject.getBasedir());

            addAntProjectReferences(mavenProject, antProject);
            initMavenTasks(antProject);

            // The Ant project needs actual properties vs. using expression evaluator when calling an external build
            // file.
            copyProperties(mavenProject, antProject);

            getLog().info("Executing tasks");
            antProject.executeTarget(antTargetName);
            getLog().info("Executed tasks");

            copyProperties(antProject, mavenProject);
        } catch (BuildException e) {
            StringBuilder sb = new StringBuilder();
            sb.append("An Ant BuildException has occurred: ").append(e.getMessage());
            String fragment = findFragment(e);
            if (fragment != null) {
                sb.append("\n").append(fragment);
            }
            if (!failOnError) {
                getLog().info(sb.toString(), e);
                return; // do not register roots.
            } else {
                throw new MojoExecutionException(sb.toString(), e);
            }
        } catch (Throwable e) {
            throw new MojoExecutionException("Error executing Ant tasks: " + e.getMessage(), e);
        }
    }