From b8fa877cdff25daee3832eed3ec641199b1f436a Mon Sep 17 00:00:00 2001 From: Petr Beran Date: Wed, 15 Nov 2023 15:13:20 +0100 Subject: [PATCH 1/2] [SHRINKRES-322] Setting variables as final --- .../archive/importer/MavenImporterImpl.java | 2 +- .../archive/plugins/ConfigurationUtils.java | 4 +- .../archive/util/JarGeneratorTestCase.java | 4 +- .../archive/util/WarGeneratorTestCase.java | 6 +-- .../impl/maven/embedded/BuildTrigger.java | 2 +- .../impl/maven/embedded/BuiltProjectImpl.java | 10 ++--- .../maven/embedded/DistributionStageImpl.java | 2 +- .../embedded/daemon/DaemonBuildImpl.java | 6 +-- .../daemon/DaemonBuildTriggerImpl.java | 4 +- ...MavenInvokerEquippedEmbeddedMavenImpl.java | 4 +- .../PomEquippedEmbeddedMavenImpl.java | 4 +- .../embedded/ConfigurationStageTestCase.java | 40 +++++++++---------- .../maven/embedded/FileExtractorTestCase.java | 2 +- .../embedded/MavenDownloadsTestCase.java | 2 +- .../resolver/impl/maven/embedded/Utils.java | 18 ++++----- .../ConfigurableMavenWorkingSessionImpl.java | 2 +- .../maven/bootstrap/MavenSettingsBuilder.java | 2 +- .../decrypt/MavenSecurityDispatcher.java | 4 +- .../decrypt/MavenSettingsDecrypter.java | 2 +- .../MavenSettingsDecryptionResult.java | 6 +-- .../impl/maven/PackageDirHelperTestCase.java | 2 +- .../impl/maven/RepositoryAuthEnvTestCase.java | 2 +- .../integration/DependencyDepthTestCase.java | 2 +- .../MavenPlexusCipherTestCase.java | 4 +- .../resolver/spi/loader/ServiceRegistry.java | 4 +- 25 files changed, 70 insertions(+), 70 deletions(-) diff --git a/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/MavenImporterImpl.java b/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/MavenImporterImpl.java index ca0b15461..dcd09f417 100644 --- a/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/MavenImporterImpl.java +++ b/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/MavenImporterImpl.java @@ -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 diff --git a/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/ConfigurationUtils.java b/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/ConfigurationUtils.java index 08d87a581..d2156382c 100644 --- a/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/ConfigurationUtils.java +++ b/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/plugins/ConfigurationUtils.java @@ -197,9 +197,9 @@ private static List 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}. diff --git a/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/util/JarGeneratorTestCase.java b/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/util/JarGeneratorTestCase.java index 5e8130c26..49fcfe20f 100644 --- a/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/util/JarGeneratorTestCase.java +++ b/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/util/JarGeneratorTestCase.java @@ -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 jars() { diff --git a/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/util/WarGeneratorTestCase.java b/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/util/WarGeneratorTestCase.java index ae6a503ee..0d88ca4aa 100644 --- a/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/util/WarGeneratorTestCase.java +++ b/maven/impl-maven-archive/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/util/WarGeneratorTestCase.java @@ -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 jars() { diff --git a/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/BuildTrigger.java b/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/BuildTrigger.java index 99f01ef4c..5c98b5894 100644 --- a/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/BuildTrigger.java +++ b/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/BuildTrigger.java @@ -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) { diff --git a/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/BuiltProjectImpl.java b/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/BuiltProjectImpl.java index 4d288d7b0..c99aa63bd 100644 --- a/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/BuiltProjectImpl.java +++ b/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/BuiltProjectImpl.java @@ -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); diff --git a/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/DistributionStageImpl.java b/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/DistributionStageImpl.java index 3fd71bb4e..ffa6e61dd 100644 --- a/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/DistributionStageImpl.java +++ b/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/DistributionStageImpl.java @@ -29,7 +29,7 @@ public abstract class DistributionStageImpl, 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; diff --git a/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/pom/equipped/PomEquippedEmbeddedMavenImpl.java b/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/pom/equipped/PomEquippedEmbeddedMavenImpl.java index 11e885574..b6ea86467 100644 --- a/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/pom/equipped/PomEquippedEmbeddedMavenImpl.java +++ b/maven/impl-maven-embedded/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/pom/equipped/PomEquippedEmbeddedMavenImpl.java @@ -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) { diff --git a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/ConfigurationStageTestCase.java b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/ConfigurationStageTestCase.java index f3ba4d804..c855c1ba5 100644 --- a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/ConfigurationStageTestCase.java +++ b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/ConfigurationStageTestCase.java @@ -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 shellEnvironments = new HashMap() {{ + final Map 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(); diff --git a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/FileExtractorTestCase.java b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/FileExtractorTestCase.java index 0a109d439..41bc423ab 100644 --- a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/FileExtractorTestCase.java +++ b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/FileExtractorTestCase.java @@ -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 { diff --git a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/MavenDownloadsTestCase.java b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/MavenDownloadsTestCase.java index e9bc59c23..b6cf7e723 100644 --- a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/MavenDownloadsTestCase.java +++ b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/MavenDownloadsTestCase.java @@ -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(); diff --git a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/Utils.java b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/Utils.java index 593890296..330141285 100644 --- a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/Utils.java +++ b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/Utils.java @@ -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)); diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/ConfigurableMavenWorkingSessionImpl.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/ConfigurableMavenWorkingSessionImpl.java index 9b1d6cba1..3a0e22ae8 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/ConfigurableMavenWorkingSessionImpl.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/ConfigurableMavenWorkingSessionImpl.java @@ -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; diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java index 0daf6a539..27207db85 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/bootstrap/MavenSettingsBuilder.java @@ -48,7 +48,7 @@ * @author Karel Piwko */ 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 diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSecurityDispatcher.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSecurityDispatcher.java index 9a326621e..d40c7934a 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSecurityDispatcher.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSecurityDispatcher.java @@ -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(); diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSettingsDecrypter.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSettingsDecrypter.java index ea9d06d79..061efd16f 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSettingsDecrypter.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSettingsDecrypter.java @@ -41,7 +41,7 @@ */ public class MavenSettingsDecrypter implements SettingsDecrypter { - private SecDispatcher securityDispatcher; + private final SecDispatcher securityDispatcher; public MavenSettingsDecrypter(File securitySettings) { this.securityDispatcher = new MavenSecurityDispatcher(securitySettings); diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSettingsDecryptionResult.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSettingsDecryptionResult.java index 76bfbbcaf..32efa7e4c 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSettingsDecryptionResult.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenSettingsDecryptionResult.java @@ -32,11 +32,11 @@ */ class MavenSettingsDecryptionResult implements SettingsDecryptionResult { - private List servers; + private final List servers; - private List proxies; + private final List proxies; - private List problems; + private final List problems; MavenSettingsDecryptionResult(List servers, List proxies, List problems) { this.servers = servers == null ? Collections. emptyList() : servers; diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/PackageDirHelperTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/PackageDirHelperTestCase.java index b5495e93b..40cf5e7eb 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/PackageDirHelperTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/PackageDirHelperTestCase.java @@ -21,7 +21,7 @@ public class PackageDirHelperTestCase { @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); + public final TemporaryFolder tempFolder = new TemporaryFolder(); @Test public void packageDirectories_empty_canUnzip() throws Exception { diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/RepositoryAuthEnvTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/RepositoryAuthEnvTestCase.java index 84cc4f18e..e64505f60 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/RepositoryAuthEnvTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/RepositoryAuthEnvTestCase.java @@ -37,7 +37,7 @@ */ public class RepositoryAuthEnvTestCase { - private static String ENV_PROPERTY = "${env.PATH}"; + private static final String ENV_PROPERTY = "${env.PATH}"; /** * There should be replaced the {@code ${env.PATH}} variable into the username and password elements diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/DependencyDepthTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/DependencyDepthTestCase.java index c536264e3..4577f03f4 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/DependencyDepthTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/DependencyDepthTestCase.java @@ -98,7 +98,7 @@ public void resolutionDepth2Pom() { private static class DepthStrategy implements MavenResolutionStrategy { - private int depth; + private final int depth; DepthStrategy(int depth) { this.depth = depth; diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/MavenPlexusCipherTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/MavenPlexusCipherTestCase.java index b71f8fb56..9f5a90ef5 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/MavenPlexusCipherTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/MavenPlexusCipherTestCase.java @@ -99,8 +99,8 @@ private static void addCombinations(String decorator1, String decorator2, String parameters.add(new Object[] { decorator2 + cipherString + decorator1, new Boolean(isPresent) }); } - private String str; - private boolean isStringEcrypted; + private final String str; + private final boolean isStringEcrypted; public MavenPlexusCipherTestCase(String str, Boolean isCypherPresent) { this.str = str; diff --git a/spi/src/main/java/org/jboss/shrinkwrap/resolver/spi/loader/ServiceRegistry.java b/spi/src/main/java/org/jboss/shrinkwrap/resolver/spi/loader/ServiceRegistry.java index 7c31bbe18..0b34f7784 100644 --- a/spi/src/main/java/org/jboss/shrinkwrap/resolver/spi/loader/ServiceRegistry.java +++ b/spi/src/main/java/org/jboss/shrinkwrap/resolver/spi/loader/ServiceRegistry.java @@ -30,9 +30,9 @@ */ public class ServiceRegistry implements ServiceLoader { - private ServiceLoader serviceLoader; + private final ServiceLoader serviceLoader; - private Map, Collection> cachedServiceInstances; + private final Map, Collection> cachedServiceInstances; private static ServiceRegistry instance; From c8c8221660adc327a93c617a8de4ea9e506c7f64 Mon Sep 17 00:00:00 2001 From: Petr Beran Date: Wed, 15 Nov 2023 15:19:21 +0100 Subject: [PATCH 2/2] [SHRINKRES-322] Removing redundant throws --- .../archive/importer/SecurityActions.java | 2 +- ...dEmbeddedMavenRunningAsDaemonTestCase.java | 6 +++--- ...dEmbeddedMavenRunningAsDaemonTestCase.java | 10 ++++----- .../maven/internal/MavenModelResolver.java | 5 ++--- .../internal/decrypt/MavenPlexusCipher.java | 2 +- .../impl/maven/task/SecurityActions.java | 2 +- .../aether/ClassPathScanningTestCase.java | 2 +- .../AdditionalRemoteRepositoryTestCase.java | 21 +++++++++---------- .../integration/ClassifiersTestCase.java | 2 +- .../ClasspathWorkspaceReaderTestCase.java | 2 +- .../integration/DependencyScopesTestCase.java | 2 +- .../integration/LocalRepositoryTestCase.java | 9 ++++---- .../MavenPlexusCipherTestCase.java | 3 +-- .../OfflineRepositoryTestCase.java | 3 +-- .../integration/RepositoryAuthTestCase.java | 11 +++++----- .../VersionResolvingUnitTestCase.java | 18 ++++++++-------- .../resolver/plugin/DependencyTreeMojo.java | 3 +-- .../plugin/PropagateExecutionContextMojo.java | 3 +-- 18 files changed, 49 insertions(+), 57 deletions(-) diff --git a/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/SecurityActions.java b/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/SecurityActions.java index ac04e057f..3ffac3442 100644 --- a/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/SecurityActions.java +++ b/maven/impl-maven-archive/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/archive/importer/SecurityActions.java @@ -130,7 +130,7 @@ static URL getResource(final String resource) { try { URL value = AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override - public URL run() throws Exception { + public URL run() { return getThreadContextClassLoader().getResource(resource); } diff --git a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/invoker/equipped/InvokerEquippedEmbeddedMavenRunningAsDaemonTestCase.java b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/invoker/equipped/InvokerEquippedEmbeddedMavenRunningAsDaemonTestCase.java index 5ee26738d..2ee7c3940 100644 --- a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/invoker/equipped/InvokerEquippedEmbeddedMavenRunningAsDaemonTestCase.java +++ b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/invoker/equipped/InvokerEquippedEmbeddedMavenRunningAsDaemonTestCase.java @@ -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(); @@ -53,7 +53,7 @@ public void testWhenDaemonIsUsedEndOfTheBuildIsNotReached() throws InterruptedEx Awaitility.await("Wait till maven build is started").atMost(5, TimeUnit.SECONDS).until(new Callable() { @Override - public Boolean call() throws Exception { + public Boolean call() { return outContent.toString().contains("Embedded Maven build started"); } }); @@ -61,7 +61,7 @@ public Boolean call() throws Exception { Awaitility.await("Wait till project is not be null").atMost(20, TimeUnit.SECONDS).until(new Callable() { @Override - public Boolean call() throws Exception { + public Boolean call() { return daemonBuild.getBuiltProject() != null; } }); diff --git a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/pom/equipped/PomEquippedEmbeddedMavenRunningAsDaemonTestCase.java b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/pom/equipped/PomEquippedEmbeddedMavenRunningAsDaemonTestCase.java index 32206e40e..45627f902 100644 --- a/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/pom/equipped/PomEquippedEmbeddedMavenRunningAsDaemonTestCase.java +++ b/maven/impl-maven-embedded/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/embedded/pom/equipped/PomEquippedEmbeddedMavenRunningAsDaemonTestCase.java @@ -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") @@ -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() { @Override - public Boolean call() throws Exception { + public Boolean call() { return !daemonBuild.isAlive(); } }); @@ -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)) @@ -57,7 +57,7 @@ public void testDaemonWithoutWaitShouldNotReachTheEndOfTheBuild() throws Interru Awaitility.await("Wait till maven build is started").atMost(5, TimeUnit.SECONDS).until(new Callable() { @Override - public Boolean call() throws Exception { + public Boolean call() { return systemOutRule.getLog().contains("Embedded Maven build started"); } }); @@ -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() { @Override - public Boolean call() throws Exception { + public Boolean call() { return !daemonBuild.isAlive(); } }); diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/MavenModelResolver.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/MavenModelResolver.java index 5c8d3a130..edd192d4c 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/MavenModelResolver.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/MavenModelResolver.java @@ -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; @@ -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); } @@ -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; diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenPlexusCipher.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenPlexusCipher.java index 69401c42d..ef4cf007c 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenPlexusCipher.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/internal/decrypt/MavenPlexusCipher.java @@ -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()) { diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/task/SecurityActions.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/task/SecurityActions.java index a32917b72..16acd2953 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/task/SecurityActions.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/task/SecurityActions.java @@ -130,7 +130,7 @@ static URL getResource(final String resource) { try { URL value = AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override - public URL run() throws Exception { + public URL run() { return getThreadContextClassLoader().getResource(resource); } diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/aether/ClassPathScanningTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/aether/ClassPathScanningTestCase.java index 6b0f47062..3056b5296 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/aether/ClassPathScanningTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/aether/ClassPathScanningTestCase.java @@ -43,7 +43,7 @@ public class ClassPathScanningTestCase { public final RestoreSystemProperties restoreSystemPropertiesRule = new RestoreSystemProperties(); @Test - public void classpathWithDanglingDirs() throws Exception { + public void classpathWithDanglingDirs() { System.setProperty(SUREFIRE_CLASS_PATH_KEY, createFakeClassPathWithDanglingDirs()); diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/AdditionalRemoteRepositoryTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/AdditionalRemoteRepositoryTestCase.java index 620854813..1ab816dba 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/AdditionalRemoteRepositoryTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/AdditionalRemoteRepositoryTestCase.java @@ -102,7 +102,7 @@ public void control4() { * Tests the addition of a remote repository */ @Test - public void shouldFindArtifactWithExplicitRemoteRepository() throws Exception { + public void shouldFindArtifactWithExplicitRemoteRepository() { final File file = Maven.configureResolver() .withClassPathResolution(false).withMavenCentralRepo(false) .withRemoteRepo("jboss", "https://repository.jboss.org/nexus/content/repositories/releases/", "default") @@ -118,7 +118,7 @@ public void shouldFindArtifactWithExplicitRemoteRepository() throws Exception { * Tests the addition of a remote repository through the builder API */ @Test - public void shouldFindArtifactWithExplicitRemoteRepositoryBuilder() throws Exception { + public void shouldFindArtifactWithExplicitRemoteRepositoryBuilder() { final File file = Maven .configureResolver() .withClassPathResolution(false) @@ -140,7 +140,7 @@ public void shouldFindArtifactWithExplicitRemoteRepositoryBuilder() throws Excep * Test behaviour with an invalid URL */ @Test(expected = IllegalArgumentException.class) - public void shouldThrowIllegalArgumentException4() throws Exception { + public void shouldThrowIllegalArgumentException4() { Maven.configureResolver() .withClassPathResolution(false).withMavenCentralRepo(false) .withRemoteRepo("jboss", "wrong://repository.jboss.org/nexus/content/repositories/releases/", "default") @@ -152,7 +152,7 @@ public void shouldThrowIllegalArgumentException4() throws Exception { * Test behaviour with a wrong URL */ @Test(expected = NoResolvedResultException.class) - public void shouldThrowNoResolvedResultException() throws Exception { + public void shouldThrowNoResolvedResultException() { Maven.configureResolver() .withClassPathResolution(false).withMavenCentralRepo(false) .withRemoteRepo("jboss", "https://repository123.jboss.org/nexus/content/repositories/releases/", "default") @@ -164,7 +164,7 @@ public void shouldThrowNoResolvedResultException() throws Exception { * Test behaviour with a null repository ID */ @Test(expected = IllegalArgumentException.class) - public void shouldThrowIllegalArgumentException1() throws Exception { + public void shouldThrowIllegalArgumentException1() { Maven.configureResolver() .withClassPathResolution(false).withMavenCentralRepo(false) .withRemoteRepo(null, "https://repository.jboss.org/nexus/content/repositories/releases/", "default") @@ -176,7 +176,7 @@ public void shouldThrowIllegalArgumentException1() throws Exception { * Test behaviour with a null URL */ @Test(expected = IllegalArgumentException.class) - public void shouldThrowIllegalArgumentException5() throws Exception { + public void shouldThrowIllegalArgumentException5() { Maven.configureResolver() .withClassPathResolution(false).withMavenCentralRepo(false) .withRemoteRepo("jboss", (String) null, "default").loadPomFromFile("pom.xml") @@ -188,7 +188,7 @@ public void shouldThrowIllegalArgumentException5() throws Exception { * Test behaviour with a non default layout (which is impossible in Maven 3) */ @Test(expected = IllegalArgumentException.class) - public void shouldThrowIllegalArgumentException2() throws Exception { + public void shouldThrowIllegalArgumentException2() { Maven.configureResolver() .withClassPathResolution(false).withMavenCentralRepo(false) .withRemoteRepo("jboss", "https://repository.jboss.org/nexus/content/repositories/releases/", "legacy") @@ -200,7 +200,7 @@ public void shouldThrowIllegalArgumentException2() throws Exception { * Test behaviour with a null layout */ @Test(expected = IllegalArgumentException.class) - public void shouldThrowIllegalArgumentException3() throws Exception { + public void shouldThrowIllegalArgumentException3() { Maven.configureResolver() .withClassPathResolution(false).withMavenCentralRepo(false) .withRemoteRepo("jboss", "https://repository.jboss.org/nexus/content/repositories/releases/", null) @@ -213,7 +213,7 @@ public void shouldThrowIllegalArgumentException3() throws Exception { * therefore not resolve. */ @Test(expected = NoResolvedResultException.class) - public void shouldOverloadRepository() throws Exception { + public void shouldOverloadRepository() { Resolvers.use(ConfigurableMavenResolverSystem.class) .withMavenCentralRepo(false) .withRemoteRepo("test-repository", "http://127.0.0.1", "default") @@ -226,10 +226,9 @@ public void shouldOverloadRepository() throws Exception { /** * This test overloads Maven Central repository * - * @throws Exception */ @Test(expected = NoResolvedResultException.class) - public void shouldOverloadCentral() throws Exception { + public void shouldOverloadCentral() { Maven.configureResolver() .withRemoteRepo("central", "http://127.0.0.1", "default") .withClassPathResolution(false).resolve("junit:junit:4.11") diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/ClassifiersTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/ClassifiersTestCase.java index cf80bbefd..aa49a5311 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/ClassifiersTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/ClassifiersTestCase.java @@ -103,7 +103,7 @@ public void testClassifierAndTestJarType() throws Exception { // SHRINKRES-162 @Test - public void testClassifierAndTestJarTypeMetadat() throws Exception { + public void testClassifierAndTestJarTypeMetadat() { MavenResolvedArtifact artifact = Maven.configureResolver().fromFile("target/settings/profiles/settings.xml") .loadPomFromFile("target/poms/test-tests-classifier.xml") diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/ClasspathWorkspaceReaderTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/ClasspathWorkspaceReaderTestCase.java index 0edff17d3..02d338517 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/ClasspathWorkspaceReaderTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/ClasspathWorkspaceReaderTestCase.java @@ -196,7 +196,7 @@ public void resolvesRightArtifactIdFromClasspath() throws Exception { } @Test - public void resolvesCorrectVersion() throws Exception { + public void resolvesCorrectVersion() { final String expectedVersion = "2.0.0-alpha-5"; diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/DependencyScopesTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/DependencyScopesTestCase.java index 874d4f480..1799da823 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/DependencyScopesTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/DependencyScopesTestCase.java @@ -58,7 +58,7 @@ public void wrongScopeRetrieved() { } @Test - public void resolveProvidedDependency() throws Exception { + public void resolveProvidedDependency() { final String coordinates = "org.jboss.xnio:xnio-api:jar:3.1.0.Beta7"; final MavenStrategyStage mss = Maven.configureResolver().fromFile(SETTINGS_XML).resolve(coordinates); diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/LocalRepositoryTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/LocalRepositoryTestCase.java index b64b96c27..00cbdc701 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/LocalRepositoryTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/LocalRepositoryTestCase.java @@ -17,7 +17,6 @@ package org.jboss.shrinkwrap.resolver.impl.maven.integration; import java.io.File; -import java.io.IOException; import org.jboss.shrinkwrap.resolver.api.NoResolvedResultException; import org.jboss.shrinkwrap.resolver.api.maven.Maven; @@ -88,7 +87,7 @@ public void resolveFromLocalRepository() throws Exception { * Sets legacy local repository */ @Test - public void legacyLocalRepository() throws IOException { + public void legacyLocalRepository() { // fixture prepareLocalRepository(); @@ -106,7 +105,7 @@ public void legacyLocalRepository() throws IOException { * Sets legacy local repository via property */ @Test - public void legacyLocalRepositoryViaProperty() throws IOException { + public void legacyLocalRepositoryViaProperty() { // fixture prepareLocalRepository(); @@ -129,7 +128,7 @@ public void legacyLocalRepositoryViaProperty() throws IOException { * Ensures that we can contact Maven Central (as a control test) */ @Test - public void resolveFromLocalRepositoryOffline() throws Exception { + public void resolveFromLocalRepositoryOffline() { // fixture prepareLocalRepository(); @@ -148,7 +147,7 @@ public void resolveFromLocalRepositoryOffline() throws Exception { * Ensures that we can contact Maven Central (as a control test) */ @Test(expected = NoResolvedResultException.class) - public void resolveFromLocalRepositoryTrackingRemotes() throws Exception { + public void resolveFromLocalRepositoryTrackingRemotes() { // fixture prepareLocalRepository(); diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/MavenPlexusCipherTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/MavenPlexusCipherTestCase.java index 9f5a90ef5..700dc9d46 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/MavenPlexusCipherTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/MavenPlexusCipherTestCase.java @@ -26,7 +26,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.sonatype.plexus.components.cipher.PlexusCipherException; /** * Tests the {@link MavenPlexusCipher} whether it correctly evaluates and undecorates the right strings containing a cipher. @@ -124,7 +123,7 @@ public void testIsEncryptedString() { * and returns the right cipher. */ @Test - public void testUnDecorate() throws PlexusCipherException { + public void testUnDecorate() { MavenPlexusCipher mavenPlexusCipher = new MavenPlexusCipher(); try { String undecorated = mavenPlexusCipher.unDecorate(str); diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/OfflineRepositoryTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/OfflineRepositoryTestCase.java index 3f30a347c..a75a0a562 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/OfflineRepositoryTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/OfflineRepositoryTestCase.java @@ -27,7 +27,6 @@ import java.net.URL; import java.util.logging.Logger; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -218,7 +217,7 @@ private static class StaticFileHandler extends AbstractHandler implements Handle @Override public void handle(final String target, Request request, final HttpServletRequest httpServletRequest, - final HttpServletResponse response) throws IOException, ServletException { + final HttpServletResponse response) throws IOException { // Set content type and status before we write anything to the stream response.setContentType("text/xml"); response.setStatus(HttpServletResponse.SC_OK); diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/RepositoryAuthTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/RepositoryAuthTestCase.java index fe9ab29e3..2107588a0 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/RepositoryAuthTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/RepositoryAuthTestCase.java @@ -27,7 +27,6 @@ import java.net.URL; import java.nio.charset.Charset; import java.util.logging.Logger; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.codehaus.plexus.util.Base64; @@ -72,20 +71,20 @@ public void init() throws Exception { } @After - public void after() throws Exception { + public void after() { shutdownHttpServer(server); System.clearProperty(MavenSettingsBuilder.ALT_SECURITY_SETTINGS_XML_LOCATION); } @Test(expected = NoResolvedResultException.class) - public void searchRemoteWithWrongPassword() throws Exception { + public void searchRemoteWithWrongPassword() { // Configure with wrong password and expect to fail Maven.configureResolver().fromFile("target/settings/profiles/settings-wrongauth.xml") .resolve("org.jboss.shrinkwrap.test:test-deps-i:1.0.0").withoutTransitivity().asSingle(File.class); } @Test - public void searchRemoteWithCorrectPassword() throws Exception { + public void searchRemoteWithCorrectPassword() { // Configure with correct password and expect to pass final File resolved = Maven.configureResolver().fromFile("target/settings/profiles/settings-auth.xml") .resolve("org.jboss.shrinkwrap.test:test-deps-i:1.0.0").withoutTransitivity().asSingle(File.class); @@ -99,7 +98,7 @@ public void searchRemoteWithCorrectPassword() throws Exception { // mvn --encrypt-password shrinkwrap // {70+YZM/w7f8HQrEZUGZABCHAW62qMo+Y8okw7xzLwOM=} @Test - public void searchRemoteWithEncryptedPassword() throws Exception { + public void searchRemoteWithEncryptedPassword() { // set settings-security.xml with master password location System.setProperty(MavenSettingsBuilder.ALT_SECURITY_SETTINGS_XML_LOCATION, @@ -155,7 +154,7 @@ private static class AuthStaticFileHandler extends AbstractHandler implements Ha @Override public void handle(final String target, Request request, final HttpServletRequest httpServletRequest, - final HttpServletResponse response) throws IOException, ServletException { + final HttpServletResponse response) throws IOException { log.fine("Authorizing request for artifact"); final String authHeader = httpServletRequest.getHeader(AUTH_HEADER); diff --git a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/VersionResolvingUnitTestCase.java b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/VersionResolvingUnitTestCase.java index 2adf0dcf6..4521ce41a 100644 --- a/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/VersionResolvingUnitTestCase.java +++ b/maven/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/integration/VersionResolvingUnitTestCase.java @@ -101,7 +101,7 @@ public void shouldResolveGreaterOrEqualWithoutLocalMetadata() throws Exception { } @Test - public void shouldResolveLowerOrEqual() throws Exception { + public void shouldResolveLowerOrEqual() { // given final String lowestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:1.0.0"; final String highestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:2.0.0"; @@ -122,7 +122,7 @@ public void shouldResolveLowerOrEqual() throws Exception { } @Test - public void shouldResolveLowerThan() throws Exception { + public void shouldResolveLowerThan() { // given final String lowestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:1.0.0"; final String highestCoordinate = lowestCoordinate; @@ -142,7 +142,7 @@ public void shouldResolveLowerThan() throws Exception { } @Test - public void shouldResolveEqual() throws Exception { + public void shouldResolveEqual() { // given final String lowestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:1.0.0"; final String highestCoordinate = lowestCoordinate; @@ -162,7 +162,7 @@ public void shouldResolveEqual() throws Exception { } @Test - public void shouldResolveGreaterOrEqual() throws Exception { + public void shouldResolveGreaterOrEqual() { // given final String lowestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:1.0.0"; final String highestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:2.0.0"; @@ -183,7 +183,7 @@ public void shouldResolveGreaterOrEqual() throws Exception { } @Test - public void shouldResolveGreater() throws Exception { + public void shouldResolveGreater() { // given final String lowestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:2.0.0"; final String highestCoordinate = lowestCoordinate; @@ -221,7 +221,7 @@ public void shouldNotResolveAnyVersion() { } @Test - public void shouldResolveRange() throws Exception { + public void shouldResolveRange() { // given // when @@ -236,7 +236,7 @@ public void shouldResolveRange() throws Exception { } @Test - public void shouldResolveIncludingRange() throws Exception { + public void shouldResolveIncludingRange() { // given final String lowestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:1.0.0"; final String highestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:2.0.0"; @@ -257,7 +257,7 @@ public void shouldResolveIncludingRange() throws Exception { } @Test - public void shouldResolveMultipleSets() throws Exception { + public void shouldResolveMultipleSets() { // given final String lowestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:1.0.0"; final String highestCoordinate = lowestCoordinate; @@ -277,7 +277,7 @@ public void shouldResolveMultipleSets() throws Exception { } @Test - public void shouldResolveDifferentThan() throws Exception { + public void shouldResolveDifferentThan() { // given final String lowestCoordinate = "org.jboss.shrinkwrap.test:test-deps-b:jar:2.0.0"; final String highestCoordinate = lowestCoordinate; diff --git a/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/DependencyTreeMojo.java b/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/DependencyTreeMojo.java index 060ca6957..506ec3bc7 100644 --- a/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/DependencyTreeMojo.java +++ b/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/DependencyTreeMojo.java @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.List; import org.apache.maven.classrealm.ClassRealmManager; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -71,7 +70,7 @@ public class DependencyTreeMojo extends AbstractResolverMojo { private ClassRealmManager classRealmManager; @Override - public void execute() throws MojoExecutionException { + public void execute() { // first, we need to propagate environment settings PropagateExecutionContextMojo mojo = new PropagateExecutionContextMojo(); diff --git a/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/PropagateExecutionContextMojo.java b/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/PropagateExecutionContextMojo.java index e29cf9208..dd4ca5988 100644 --- a/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/PropagateExecutionContextMojo.java +++ b/maven/maven-plugin/src/main/java/org/jboss/shrinkwrap/resolver/plugin/PropagateExecutionContextMojo.java @@ -23,7 +23,6 @@ import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Profile; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -49,7 +48,7 @@ public class PropagateExecutionContextMojo extends AbstractResolverMojo { private String namespace; @Override - public void execute() throws MojoExecutionException { + public void execute() { MavenExecutionRequest request = session.getRequest();