<commit_before>package org.jvnet.hudson.maven.plugins.hpi;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.kohsuke.jnt.FileStatus;
import org.kohsuke.jnt.JNFileFolder;
import org.kohsuke.jnt.JNProject;
import org.kohsuke.jnt.ProcessingException;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Set;

/**
 * Posts the hpi file to java.net.
 *
 * @goal upload
 * @execute phase=package
 * @requiresDependencyResolution compile
 * @author <NAME>
 */
public class UploadMojo extends AbstractJavaNetMojo {
    public void execute() throws MojoExecutionException, MojoFailureException {
        if(!project.getPackaging().equals("hpi")) {
            getLog().warn("Skipping hpi:upload because this is not an hpi project");
            return;
        }

        Artifact artifact = project.getArtifact();
        if(artifact==null)
            throw new MojoExecutionException("Project has no artifact, whereas an .hpi artifact was expected");
        File archive = artifact.getFile();
        if(archive==null || !archive.exists())
            throw new MojoExecutionException("Project has no artifact, whereas an .hpi artifact was expected");

        try {
            JNProject p = connect().getProject("hudson");
            JNFileFolder f = p.getFolder("/plugins/" + project.getArtifactId());
            if(f==null) {
                getLog().info("Creating folder");
                f = p.getFolder("/plugins");
                f = f.createFolder(project.getArtifactId(),project.getDescription());
            }

            String date = new SimpleDateFormat("yyyy/MM/dd", Locale.ENGLISH).format(new Date());
            f.uploadFile(project.getVersion(),date+" release. Built with Hudson "+getHudsonVersion(),
                project.getVersion().endsWith("SNAPSHOT") ? FileStatus.DRAFT : FileStatus.STABLE,
                archive);
        } catch (ProcessingException e) {
            throw new MojoExecutionException("Failed to upload the artifact",e);
        }
    }

    private String getHudsonVersion() {
        for(Artifact a : (Set<Artifact>)project.getArtifacts()) {
            if(a.getArtifactId().equals("hudson-core"))
                return a.getVersion();
        }
        return "UNKNOWN";
    }
}
<commit_msg>to assist the trouble-shooting, report the root cause. See http://n4.nabble.com/Can-t-release-the-findbugs-plugin-tp1745343p1745343.html<commit_after>package org.jvnet.hudson.maven.plugins.hpi;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.kohsuke.jnt.FileStatus;
import org.kohsuke.jnt.JNFileFolder;
import org.kohsuke.jnt.JNProject;
import org.kohsuke.jnt.ProcessingException;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Set;

/**
 * Posts the hpi file to java.net.
 *
 * @goal upload
 * @execute phase=package
 * @requiresDependencyResolution compile
 * @author <NAME>
 */
public class UploadMojo extends AbstractJavaNetMojo {
    public void execute() throws MojoExecutionException, MojoFailureException {
        if(!project.getPackaging().equals("hpi")) {
            getLog().warn("Skipping hpi:upload because this is not an hpi project");
            return;
        }

        Artifact artifact = project.getArtifact();
        if(artifact==null)
            throw new MojoExecutionException("Project has no artifact, whereas an .hpi artifact was expected");
        File archive = artifact.getFile();
        if(archive==null || !archive.exists())
            throw new MojoExecutionException("Project has no artifact, whereas an .hpi artifact was expected");

        try {
            JNProject p = connect().getProject("hudson");
            JNFileFolder f = p.getFolder("/plugins/" + project.getArtifactId());
            if(f==null) {
                getLog().info("Creating folder");
                f = p.getFolder("/plugins");
                f = f.createFolder(project.getArtifactId(),project.getDescription());
            }

            String date = new SimpleDateFormat("yyyy/MM/dd", Locale.ENGLISH).format(new Date());
            f.uploadFile(project.getVersion(),date+" release. Built with Hudson "+getHudsonVersion(),
                project.getVersion().endsWith("SNAPSHOT") ? FileStatus.DRAFT : FileStatus.STABLE,
                archive);
        } catch (ProcessingException e) {
            // because Maven fail to properly report a chained exception,
            // I'm reporting the stack trace here to assist trouble-shooting.
            e.printStackTrace();
            throw new MojoExecutionException("Failed to upload the artifact",e);
        }
    }

    private String getHudsonVersion() {
        for(Artifact a : (Set<Artifact>)project.getArtifacts()) {
            if(a.getArtifactId().equals("hudson-core"))
                return a.getVersion();
        }
        return "UNKNOWN";
    }
}

{'fraction_non_alphanumeric': 0.11744186046511627, 'fraction_numerical': 0.0029069767441860465, 'mean_word_length': 2.84575260804769, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4229800', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1437, 'n_words': 322}