Skip to content

Commit

Permalink
Merge pull request #186 from petrberan/SHRINKRES-322
Browse files Browse the repository at this point in the history
[SHRINKRES-322] Resolve declaration redundancy
  • Loading branch information
petrberan authored Mar 4, 2024
2 parents 9b436f9 + c8c8221 commit 53e3aae
Show file tree
Hide file tree
Showing 42 changed files with 119 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class MavenImporterImpl implements MavenImporter, ConfiguredMavenImporter {

private MavenWorkingSession session;
private Archive<?> archive;
private final Archive<?> archive;

public MavenImporterImpl(Archive<?> archive) {
// this is needed to boostrap session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static URL getResource(final String resource) {
try {
URL value = AccessController.doPrivileged(new PrivilegedExceptionAction<URL>() {
@Override
public URL run() throws Exception {
public URL run() {
return getThreadContextClassLoader().getResource(resource);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ private static List<String> tokenize(Object object, String delimiter) {
*/
static final class Key {
static final String DEFAULT_DELIMITER = ",";
String key;
final String key;
String subKey;
String delimiter;
final String delimiter;

/**
* Constructs a simple key. It equals xpath {@code /key}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
*/
@RunWith(Parameterized.class)
public class JarGeneratorTestCase {
private String name;
private Class<?>[] content;
private final String name;
private final Class<?>[] content;

@Parameters
public static Collection<Object[]> jars() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
*/
@RunWith(Parameterized.class)
public class WarGeneratorTestCase {
private String name;
private Class<?>[] classes;
private String[] directories;
private final String name;
private final Class<?>[] classes;
private final String[] directories;

@Parameters
public static Collection<Object[]> jars() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class BuildTrigger {
private final InvocationRequest invocationRequest;
private final Invoker invoker;
private final StringBuffer logBuffer;
private boolean quiet;
private final boolean quiet;

public BuildTrigger(File mavenInstallation, InvocationRequest invocationRequest, Invoker invoker,
StringBuffer logBuffer, boolean quiet, boolean ignoreFailure) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
*/
public class BuiltProjectImpl implements BuiltProject {

private File pom;
private File globalSettingsXml;
private File userSettingsXml;
private String[] profiles;
private final File pom;
private final File globalSettingsXml;
private final File userSettingsXml;
private final String[] profiles;
private Model model;
private String mavenLog;
private int mavenBuildExitCode = 0;
private Properties properties;
private final Properties properties;

public BuiltProjectImpl(String pom, String... profiles) {
this(new File(pom), null, null, null, profiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class DistributionStageImpl<NEXT_STEP extends BuildStage<DAEMON_

private File setMavenInstallation = null;
private boolean useLocalInstallation = false;
private Logger log = Logger.getLogger(DistributionStage.class.getName());
private final Logger log = Logger.getLogger(DistributionStage.class.getName());

@Override
public NEXT_STEP useMaven3Version(String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class DaemonBuildImpl implements DaemonBuild {

private Thread daemonBuildThread;
private DaemonRunnable daemonRunnable;
private final DaemonRunnable daemonRunnable;

public DaemonBuildImpl(BuildTrigger buildTrigger){
daemonRunnable = new DaemonRunnable(buildTrigger, null);
Expand Down Expand Up @@ -48,8 +48,8 @@ DaemonBuild build() {
private class DaemonRunnable implements Runnable {

private CountDownLatch countDownLatch;
private String expectedRegex;
private BuildTrigger buildTrigger;
private final String expectedRegex;
private final BuildTrigger buildTrigger;
private BuiltProject builtProject;

DaemonRunnable(BuildTrigger buildTrigger, String expectedRegex){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class DaemonBuildTriggerImpl implements WithTimeoutDaemonBuilder, DaemonBuildTriggerWithoutTimeout,
WithoutTimeoutDaemonBuilder {

private BuildTrigger buildTrigger;
private final BuildTrigger buildTrigger;

public DaemonBuildTriggerImpl(BuildTrigger buildTrigger) {
this.buildTrigger = buildTrigger;
Expand All @@ -37,7 +37,7 @@ public DaemonBuildTriggerWithTimeout withWaitUntilOutputLineMathes(String expect

class DaemonBuildTriggerWithTimeoutImpl implements DaemonBuildTriggerWithTimeout {

private DaemonBuildImpl daemonBuild;
private final DaemonBuildImpl daemonBuild;
private long timeout = 2;
private TimeUnit timeoutUnit = TimeUnit.MINUTES;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class MavenInvokerEquippedEmbeddedMavenImpl
extends BuildStageImpl<BuildStage<WithoutTimeoutDaemonBuilder>, WithoutTimeoutDaemonBuilder>
implements MavenInvokerEquippedEmbeddedMaven {

private InvocationRequest request;
private Invoker invoker;
private final InvocationRequest request;
private final Invoker invoker;

public MavenInvokerEquippedEmbeddedMavenImpl(InvocationRequest request, Invoker invoker){
this.request = request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
public class PomEquippedEmbeddedMavenImpl extends ConfigurationStageImpl implements PomEquippedEmbeddedMaven {

protected final InvocationRequest request = new DefaultInvocationRequest();
protected Invoker invoker = new DefaultInvoker();
private StringBuffer logBuffer = new StringBuffer("");
protected final Invoker invoker = new DefaultInvoker();
private final StringBuffer logBuffer = new StringBuffer("");
private boolean quiet = false;

protected PomEquippedEmbeddedMavenImpl(File pomFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,34 @@
*/
public class ConfigurationStageTestCase {

String[] goals = new String[] { "clean", "test", "package", "install" };
final String[] goals = new String[] { "clean", "test", "package", "install" };
String[] includes = new String[] { "include1", "include2" };
String[] excludes = new String[] { "exclude1", "exclude2" };
Properties properties = new Properties() {{
final Properties properties = new Properties() {{
put("propertyKey1", "propertyValue1");
put("propertyKey2", "propertyValue2");
}};
Map<String, String> shellEnvironments = new HashMap() {{
final Map<String, String> shellEnvironments = new HashMap() {{
put("shellEnvName1", "shellEnvValue1");
put("shellEnvName2", "shellEnvValue2");
}};
InvocationRequest.ReactorFailureBehavior failureBehavior = InvocationRequest.ReactorFailureBehavior.FailNever;
InvocationRequest.CheckSumPolicy globalChecksumPolicy = InvocationRequest.CheckSumPolicy.Warn;
InputStream inputStream = new ByteArrayInputStream(new byte[] {});
File globalSettingFile = new File("globalSettingFile");
File javaHome = new File("javaHome");
File localRepositoryDirectory = new File("localRepositoryDirectory");
InvokerLogger invokerLogger = new DummyInvokerLogger();
String mavenOpts = "--maven --opts";
String[] profiles = new String[] { "profile1", "profile2" };
String[] projects = new String[] { "project1", "project2" };
String resumeFrom = "resumeFrom";
String threads = "8.0C";
String builderId = "builderId";
File toolChainsFile = new File("toolChainsFile");
File globalToolChainsFile = new File("globalToolChainsFile");
File userSettingFile = new File("userSettingFile");
File workingDirectory = new File("workingDirectory");
final InvocationRequest.ReactorFailureBehavior failureBehavior = InvocationRequest.ReactorFailureBehavior.FailNever;
final InvocationRequest.CheckSumPolicy globalChecksumPolicy = InvocationRequest.CheckSumPolicy.Warn;
final InputStream inputStream = new ByteArrayInputStream(new byte[] {});
final File globalSettingFile = new File("globalSettingFile");
final File javaHome = new File("javaHome");
final File localRepositoryDirectory = new File("localRepositoryDirectory");
final InvokerLogger invokerLogger = new DummyInvokerLogger();
final String mavenOpts = "--maven --opts";
final String[] profiles = new String[] { "profile1", "profile2" };
final String[] projects = new String[] { "project1", "project2" };
final String resumeFrom = "resumeFrom";
final String threads = "8.0C";
final String builderId = "builderId";
final File toolChainsFile = new File("toolChainsFile");
final File globalToolChainsFile = new File("globalToolChainsFile");
final File userSettingFile = new File("userSettingFile");
final File workingDirectory = new File("workingDirectory");

private final TestWorkDirRule workDirRule = new TestWorkDirRule();
private final JUnitSoftAssertions softly = new JUnitSoftAssertions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FileExtractorTestCase {

@Rule
public final SystemOutRule systemOutRule = new SystemOutRule().enableLog();
private File targetMavenDir = new File(MAVEN_TARGET_DIR);
private final File targetMavenDir = new File(MAVEN_TARGET_DIR);

@Before
public void cleanup() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class MavenDownloadsTestCase {

private File targetMavenDir = new File(DistributionStageImpl.MAVEN_TARGET_DIR);
private final File targetMavenDir = new File(DistributionStageImpl.MAVEN_TARGET_DIR);

private final SystemOutRule systemOutRule = new SystemOutRule().enableLog();
private final TestWorkDirRule workDirRule = new TestWorkDirRule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
public class Utils {

// Jar sample constants
public static String pathToJarSamplePom = "src/it/jar-sample/pom.xml";
public static String jarSampleArchiveBaseName =
public static final String pathToJarSamplePom = "src/it/jar-sample/pom.xml";
public static final String jarSampleArchiveBaseName =
"shrinkwrap-resolver-impl-maven-embedded-integration-tests-jar-3.0.0-SNAPSHOT";

// War sample constants
public static String pathToWarSamplePom = "src/it/war-sample/pom.xml";
public static final String pathToWarSamplePom = "src/it/war-sample/pom.xml";

// multi module sample constants
public static String pathToMultiModulePom = "src/it/multi-module-sample/pom.xml";
public static String baseArchiveNameModuleOne =
public static final String pathToMultiModulePom = "src/it/multi-module-sample/pom.xml";
public static final String baseArchiveNameModuleOne =
"shrinkwrap-resolver-impl-maven-embedded-integration-tests-module-one-3.0.0-SNAPSHOT";
public static String multiModuleactivateModulesParamKey = "activate-modules";
public static String multiModuleactivateModulesParamValue = "activated";
public static String archiveNameModuleTwoParamKey = "module.two.archive.name";
public static String archiveNameModuleTwoParamValue = "cool-ear-name";
public static final String multiModuleactivateModulesParamKey = "activate-modules";
public static final String multiModuleactivateModulesParamValue = "activated";
public static final String archiveNameModuleTwoParamKey = "module.two.archive.name";
public static final String archiveNameModuleTwoParamValue = "cool-ear-name";

public static void verifyThatArchiveContains(Archive archive, String path) {
assertTrue("The archive should contain " + path, archive.contains(path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void setUpStreams() {
}

@Test
public void testWhenDaemonIsUsedEndOfTheBuildIsNotReached() throws InterruptedException {
public void testWhenDaemonIsUsedEndOfTheBuildIsNotReached() {

final InvocationRequest request = new DefaultInvocationRequest();
Invoker invoker = new DefaultInvoker();
Expand All @@ -53,15 +53,15 @@ public void testWhenDaemonIsUsedEndOfTheBuildIsNotReached() throws InterruptedEx

Awaitility.await("Wait till maven build is started").atMost(5, TimeUnit.SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
public Boolean call() {
return outContent.toString().contains("Embedded Maven build started");
}
});
Assertions.assertThat(outContent.toString()).doesNotContain("Embedded Maven build stopped");

Awaitility.await("Wait till project is not be null").atMost(20, TimeUnit.SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
public Boolean call() {
return daemonBuild.getBuiltProject() != null;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class PomEquippedEmbeddedMavenRunningAsDaemonTestCase {
public final RuleChain ruleChain = RuleChain.outerRule(systemOutRule).around(workDirRule);

@Test
public void testDaemonShouldWaitForBuildSuccess() throws TimeoutException, InterruptedException {
public void testDaemonShouldWaitForBuildSuccess() throws TimeoutException {
final DaemonBuild daemonBuild = EmbeddedMaven
.forProject(workDirRule.prepareProject(pathToJarSamplePom))
.setGoals("package")
Expand All @@ -36,7 +36,7 @@ public void testDaemonShouldWaitForBuildSuccess() throws TimeoutException, Inter

Awaitility.await("Wait till thread is not be alive").atMost(20, TimeUnit.SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
public Boolean call() {
return !daemonBuild.isAlive();
}
});
Expand All @@ -47,7 +47,7 @@ public Boolean call() throws Exception {
}

@Test
public void testDaemonWithoutWaitShouldNotReachTheEndOfTheBuild() throws InterruptedException {
public void testDaemonWithoutWaitShouldNotReachTheEndOfTheBuild() {

final DaemonBuild daemonBuild = EmbeddedMaven
.forProject(workDirRule.prepareProject(pathToJarSamplePom))
Expand All @@ -57,7 +57,7 @@ public void testDaemonWithoutWaitShouldNotReachTheEndOfTheBuild() throws Interru

Awaitility.await("Wait till maven build is started").atMost(5, TimeUnit.SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
public Boolean call() {
return systemOutRule.getLog().contains("Embedded Maven build started");
}
});
Expand All @@ -68,7 +68,7 @@ public Boolean call() throws Exception {

Awaitility.await("Wait till thread is not be alive").atMost(20, TimeUnit.SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
public Boolean call() {
return !daemonBuild.isAlive();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class ConfigurableMavenWorkingSessionImpl implements MavenWorkin
private static final Logger log = Logger.getLogger(ConfigurableMavenWorkingSessionImpl.class.getName());

private DefaultRepositorySystemSession session;
private SettingsManager settingsManager;
private final SettingsManager settingsManager;
private boolean useLegacyLocalRepository = false;
private final MavenRepositorySystem system;
private boolean disableClassPathWorkspaceReader = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* @author <a href="mailto:kpiwko@redhat.com">Karel Piwko</a>
*/
public class MavenSettingsBuilder {
private static Logger log = Logger.getLogger(MavenSettingsBuilder.class.getName());
private static final Logger log = Logger.getLogger(MavenSettingsBuilder.class.getName());

/**
* Sets an alternate location to Maven user settings.xml configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.apache.maven.model.Repository;
import org.apache.maven.model.building.FileModelSource;
import org.apache.maven.model.building.ModelSource;
import org.apache.maven.model.resolution.InvalidRepositoryException;
import org.apache.maven.model.resolution.ModelResolver;
import org.apache.maven.model.resolution.UnresolvableModelException;
import org.eclipse.aether.RepositorySystem;
Expand Down Expand Up @@ -103,7 +102,7 @@ private MavenModelResolver(MavenModelResolver origin) {
* @see org.apache.maven.model.resolution.ModelResolver#addRepository(org.apache.maven.model.Repository)
*/
@Override
public void addRepository(Repository repository) throws InvalidRepositoryException {
public void addRepository(Repository repository) {
addRepository(repository, false);
}

Expand Down Expand Up @@ -218,7 +217,7 @@ public ModelSource resolveModel(Dependency dependency) throws UnresolvableModelE
}

@Override
public void addRepository(Repository repository, boolean replace) throws InvalidRepositoryException {
public void addRepository(Repository repository, boolean replace) {

if (session.isIgnoreArtifactDescriptorRepositories()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public boolean isEncryptedString(final String str) {
}

@Override
public String unDecorate(final String str) throws PlexusCipherException {
public String unDecorate(final String str) {

Matcher matcherWithoutPrecString = ENCRYPTED_PATTERN_WITHOUT_PRECEDING_STRING.matcher(str);
if (matcherWithoutPrecString.matches() || matcherWithoutPrecString.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ class MavenSecurityDispatcher implements SecDispatcher {

private static final char ATTR_STOP = ']';

private PlexusCipher cipher;
private final PlexusCipher cipher;

private SettingsSecurity securitySettings;

private File securitySettingsPath;
private final File securitySettingsPath;

MavenSecurityDispatcher(File securitySettings) throws InvalidConfigurationFileException {
this.cipher = new MavenPlexusCipher();
Expand Down
Loading

0 comments on commit 53e3aae

Please sign in to comment.