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

com.sourceclear.plugins.HeadlessLifecycle Maven / Gradle / Ivy

Go to download

The SRC:CLR Maven Plugin analyzes the dependencies of your project, both immediate and transitive, to see if you are including any known security vulnerabilities through third-party packages in your project.

There is a newer version: 3.1.25
Show newest version
/*
 * © Copyright -  SourceClear Inc
 */

package com.sourceclear.plugins;

import com.sourceclear.util.config.EnvironmentProvider;
import com.srcclr.sdk.LibraryGraphContainer;
import com.srcclr.sdk.LibraryGraphSerializer;
import org.apache.maven.plugin.MojoExecutionException;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * The plugin uses the headless lifecycle when it is called by the agent. This
 * happens when a headless output file is supplied.
 */
public class HeadlessLifecycle implements Lifecycle {

  ///////////////////////////// Class Attributes \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  ////////////////////////////// Class Methods \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  //////////////////////////////// Attributes \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  private final File headlessOutputFile;

  /////////////////////////////// Constructors \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  public HeadlessLifecycle(File headlessOutputFile) {
    this.headlessOutputFile = headlessOutputFile;
  }

  ////////////////////////////////// Methods \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

  //------------------------ Implements:

  //------------------------ Overrides:

  @Override
  public void configure(EnvironmentProvider environmentProvider) {
    /* Empty for now */
  }

  @Override
  public void execute(LibraryGraphContainer dependencyTree) throws MojoExecutionException {
    try (FileOutputStream fileOut = new FileOutputStream(headlessOutputFile)) {
      LibraryGraphSerializer.write(dependencyTree, fileOut);
    } catch (IOException e) {
      throw new MojoExecutionException("Problem writing to headless output file " + headlessOutputFile.toString(), e);
    }
  }

  //---------------------------- Abstract Methods -----------------------------

  //---------------------------- Utility Methods ------------------------------

  //---------------------------- Property Methods -----------------------------
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy