com.sourceclear.plugins.HeadlessLifecycle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of srcclr-maven-plugin Show documentation
Show all versions of srcclr-maven-plugin Show documentation
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.
/*
* © 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 -----------------------------
}