All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.pmckeown.dependencytrack.project.DeleteProjectMojo Maven / Gradle / Ivy

Go to download

Maven plugin to integrate with a Dependency Track server to submit dependency manifests and gather project metrics.

There is a newer version: 1.7.0
Show newest version
package io.github.pmckeown.dependencytrack.project;

import io.github.pmckeown.dependencytrack.AbstractDependencyTrackMojo;
import io.github.pmckeown.dependencytrack.CommonConfig;
import io.github.pmckeown.dependencytrack.DependencyTrackException;
import io.github.pmckeown.util.Logger;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;

import javax.inject.Inject;

import static java.lang.String.format;

/**
 * Provides the capability to delete a project on the remote Dependency Track Server.
 *
 * @author Paul McKeown
 */
@Mojo(name = "delete-project")
public class DeleteProjectMojo extends AbstractDependencyTrackMojo {

    private ProjectAction projectAction;

    @Inject
    public DeleteProjectMojo(ProjectAction projectAction, CommonConfig commonConfig, Logger logger) {
        super(commonConfig, logger);
        this.projectAction = projectAction;
    }

    @Override
    protected void performAction() throws MojoExecutionException, MojoFailureException {
        try {
            Project project = projectAction.getProject(projectName, projectVersion);

            boolean success = projectAction.deleteProject(project);

            if (!success) {
                handleFailure(format("Failed to delete project: %s-%s", commonConfig.getProjectName(),
                        commonConfig.getProjectVersion()));
            }
        } catch (DependencyTrackException ex) {
            handleFailure(format("Exception occurred while trying to delete project: %s-%s",
                    commonConfig.getProjectName(), commonConfig.getProjectVersion()), ex);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy