Skip to content

Commit

Permalink
Convert to Guice
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Nov 21, 2024
1 parent 5307e98 commit 250e0fb
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.apache.maven.plugins.checkstyle.exec;

import javax.inject.Inject;
import javax.inject.Named;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -49,8 +52,6 @@
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.resource.ResourceManager;
import org.codehaus.plexus.resource.loader.FileResourceCreationException;
Expand All @@ -63,14 +64,20 @@
* @since 2.5
*
*/
@Component(role = CheckstyleExecutor.class, hint = "default", instantiationStrategy = "per-lookup")
@Named
public class DefaultCheckstyleExecutor extends AbstractLogEnabled implements CheckstyleExecutor {
@Requirement(hint = "default")
private ResourceManager locator;

@Requirement(hint = "license")
private ResourceManager licenseLocator;

@Inject
public DefaultCheckstyleExecutor(
@Named("default") ResourceManager locator, @Named("license") ResourceManager licenseLocator) {
this.locator = locator;
this.licenseLocator = licenseLocator;
}

@Override
public CheckstyleResults executeCheckstyle(CheckstyleExecutorRequest request)
throws CheckstyleExecutorException, CheckstyleException {
if (getLogger().isDebugEnabled()) {
Expand Down Expand Up @@ -255,6 +262,7 @@ protected void addSourceDirectory(
}
}

@Override
public Configuration getConfiguration(CheckstyleExecutorRequest request) throws CheckstyleExecutorException {
try {
// Checkstyle will always use the context classloader in order
Expand Down

0 comments on commit 250e0fb

Please sign in to comment.