private ArtifactDeployerRequest createDeployerRequest()

in src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java [261:306]


    private ArtifactDeployerRequest createDeployerRequest() {
        ProjectManager projectManager = getProjectManager();
        Collection<ProducedArtifact> deployables = projectManager.getAllArtifacts(project);
        Collection<ProducedArtifact> attachedArtifacts = projectManager.getAttachedArtifacts(project);

        ArtifactManager artifactManager = getArtifactManager();
        if (artifactManager.getPath(project.getPomArtifact()).isEmpty()) {
            artifactManager.setPath(project.getPomArtifact(), project.getPomPath());
        }

        for (Artifact deployable : deployables) {
            if (!isValidPath(deployable)) {
                if (deployable == project.getMainArtifact().orElse(null)) {
                    if (attachedArtifacts.isEmpty()) {
                        throw new MojoException(
                                "The packaging for this project did not assign a file to the build artifact");
                    } else {
                        if (allowIncompleteProjects) {
                            getLog().warn("");
                            getLog().warn("The packaging plugin for this project did not assign");
                            getLog().warn(
                                            "a main file to the project but it has attachments. Change packaging to 'pom'.");
                            getLog().warn("");
                            getLog().warn("Incomplete projects like this will fail in future Maven versions!");
                            getLog().warn("");
                        } else {
                            throw new MojoException("The packaging plugin for this project did not assign "
                                    + "a main file to the project but it has attachments. Change packaging to 'pom'.");
                        }
                    }
                } else {
                    throw new MojoException("The packaging for this project did not assign "
                            + "a file to the attached artifact: " + deployable);
                }
            }
        }

        ArtifactDeployerRequest request = ArtifactDeployerRequest.builder()
                .session(session)
                .repository(getDeploymentRepository(session.isVersionSnapshot(project.getVersion())))
                .artifacts(deployables)
                .retryFailedDeploymentCount(Math.max(1, Math.min(10, getRetryFailedDeploymentCount())))
                .build();

        return request;
    }