polishing

This commit is contained in:
Mark Fisher
2015-07-29 11:19:05 -04:00
parent 5a145eacfe
commit ab8ff0e4f3
3 changed files with 10 additions and 13 deletions

View File

@@ -86,25 +86,22 @@ public class AetherModuleResolver implements ModuleResolver {
* @param groupId the groupId * @param groupId the groupId
* @param artifactId the artifactId * @param artifactId the artifactId
* @param extension the file extension * @param extension the file extension
* @param classifer classifier can be null if none * @param classifier classifier can be null if none
* @param version the version * @param version the version
* @return a {@ link FileSystemResource} representing the resolved artifact in the local repository * @return a {@ link FileSystemResource} representing the resolved artifact in the local repository
* @throws a RuntimeException if the artifact does not exist or the resolution fails * @throws a RuntimeException if the artifact does not exist or the resolution fails
*/ */
@Override @Override
public Resource resolve(String groupId, String artifactId, String extension, String classifer, String version) { public Resource resolve(String groupId, String artifactId, String extension, String classifier, String version) {
Assert.hasText(groupId, "'groupId' cannot be blank."); Assert.hasText(groupId, "'groupId' cannot be blank.");
Assert.hasText(artifactId, "'artifactId' cannot be blank."); Assert.hasText(artifactId, "'artifactId' cannot be blank.");
Assert.hasText(extension, "'extension' cannot be blank."); Assert.hasText(extension, "'extension' cannot be blank.");
if (classifier == null) {
if (classifer == null) { classifier = "";
classifer = "";
} }
Assert.hasText(version, "'version' cannot be blank."); Assert.hasText(version, "'version' cannot be blank.");
Artifact artifact = new DefaultArtifact(groupId, artifactId, classifer, extension, version); Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version);
RepositorySystemSession session = newRepositorySystemSession(repositorySystem, RepositorySystemSession session = newRepositorySystemSession(repositorySystem,
localRepository.getAbsolutePath()); localRepository.getAbsolutePath());
ArtifactResult result; ArtifactResult result;

View File

@@ -31,10 +31,10 @@ public interface ModuleResolver {
* @param groupId the groupId * @param groupId the groupId
* @param artifactId the artifactId * @param artifactId the artifactId
* @param extension the file extension * @param extension the file extension
* @param classifer classifier * @param classifier classifier
* @param version the version * @param version the version
* @return the resource * @return the resource
*/ */
public Resource resolve(String groupId, String artifactId, String extension, String classifer, String version); public Resource resolve(String groupId, String artifactId, String extension, String classifier, String version);
} }

View File

@@ -51,7 +51,7 @@ public class AetherModuleResolverTests {
ClassPathResource cpr = new ClassPathResource("local-repo"); ClassPathResource cpr = new ClassPathResource("local-repo");
File localRepository = cpr.getFile(); File localRepository = cpr.getFile();
AetherModuleResolver defaultModuleResolver = new AetherModuleResolver(localRepository, null); AetherModuleResolver defaultModuleResolver = new AetherModuleResolver(localRepository, null);
Resource resource = defaultModuleResolver.resolve("foo.bar", "foo-bar", "jar","","1.0.0"); Resource resource = defaultModuleResolver.resolve("foo.bar", "foo-bar", "jar", "", "1.0.0");
assertTrue(resource.exists()); assertTrue(resource.exists());
assertEquals(resource.getFile().getName(), "foo-bar-1.0.0.jar"); assertEquals(resource.getFile().getName(), "foo-bar-1.0.0.jar");
} }
@@ -61,7 +61,7 @@ public class AetherModuleResolverTests {
ClassPathResource cpr = new ClassPathResource("local-repo"); ClassPathResource cpr = new ClassPathResource("local-repo");
File localRepository = cpr.getFile(); File localRepository = cpr.getFile();
AetherModuleResolver defaultModuleResolver = new AetherModuleResolver(localRepository, null); AetherModuleResolver defaultModuleResolver = new AetherModuleResolver(localRepository, null);
defaultModuleResolver.resolve("niente", "nada", "jar","", "zilch"); defaultModuleResolver.resolve("niente", "nada", "jar", "", "zilch");
} }
@Test @Test
@@ -92,7 +92,7 @@ public class AetherModuleResolverTests {
.withStatus(200) .withStatus(200)
.withBodyFile(stubFileName))); .withBodyFile(stubFileName)));
AetherModuleResolver defaultModuleResolver = new AetherModuleResolver(localRepository, remoteRepos); AetherModuleResolver defaultModuleResolver = new AetherModuleResolver(localRepository, remoteRepos);
Resource resource = defaultModuleResolver.resolve("org.bar", "foo","jar", "", "1.0.0"); Resource resource = defaultModuleResolver.resolve("org.bar", "foo", "jar", "", "1.0.0");
assertTrue(resource.exists()); assertTrue(resource.exists());
assertEquals(resource.getFile().getName(), "foo-1.0.0.jar"); assertEquals(resource.getFile().getName(), "foo-1.0.0.jar");
} }