
de.is24.maven.slf4j.AbstractSlf4jMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deadcode4j-maven-plugin Show documentation
Show all versions of deadcode4j-maven-plugin Show documentation
Finds unused classes of a project
package de.is24.maven.slf4j;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.slf4j.impl.StaticLoggerBinder;
/**
* A subclass of AbstractMojo
that makes sure the {@link MavenPluginLoggerFactory} is set up and torn down.
*
* @author Sebastian Kirsch
* @since 1.5
*/
public abstract class AbstractSlf4jMojo extends AbstractMojo {
@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
StaticLoggerBinder staticLoggerBinder = StaticLoggerBinder.getSingleton();
staticLoggerBinder.setLog(getLog());
try {
doExecute();
} finally {
staticLoggerBinder.revokeLog();
}
}
/**
* Subclasses need to implement this method instead of {@link org.apache.maven.plugin.Mojo#execute()}.
*
* @since 1.5
*/
protected abstract void doExecute() throws MojoExecutionException, MojoFailureException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy