public void execute()

in src/main/java/org/apache/maven/ant/tasks/AttachArtifactTask.java [52:82]


    public void execute() {
        File file = configuration.getFile();
        if (file == null) {
            throw new BuildException("File is a required parameter.");
        }

        if (!file.exists()) {
            throw new BuildException("File does not exist: " + file);
        }

        if (this.getProject().getReference(mavenProjectRefId) == null) {
            throw new BuildException("Maven project reference not found: " + mavenProjectRefId);
        }

        String type = configuration.getType();
        if (type == null) {
            type = FileUtils.getExtension(file.getName());
        }

        MavenProject mavenProject =
                ((MavenAntRunProject) this.getProject().getReference(mavenProjectRefId)).getMavenProject();

        if (this.getProject().getReference(mavenProjectHelperRefId) == null) {
            throw new BuildException("Maven project helper reference not found: " + mavenProjectHelperRefId);
        }

        String classifier = configuration.getClassifier();
        log("Attaching " + file + " as an attached artifact", Project.MSG_VERBOSE);
        MavenProjectHelper projectHelper = getProject().getReference(mavenProjectHelperRefId);
        projectHelper.attachArtifact(mavenProject, type, classifier, file);
    }