Author: dan.j.allen
Date: 2010-11-24 14:17:03 -0500 (Wed, 24 Nov 2010)
New Revision: 7095
Modified:
archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/test/MavenArtifactResolver.java
Log:
add simplified methods
Modified:
archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/test/MavenArtifactResolver.java
===================================================================
---
archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/test/MavenArtifactResolver.java 2010-11-24
19:16:41 UTC (rev 7094)
+++
archetypes/javaee6-webapp/trunk/src/test/java/com/mycompany/test/MavenArtifactResolver.java 2010-11-24
19:17:03 UTC (rev 7095)
@@ -47,18 +47,45 @@
(System.getProperty("user.home") + File.separatorChar +
".m2" + File.separatorChar + "repository");
- public static File resolve(String groupId, String artifactId, String version)
+ public static File resolve(final String groupId, final String artifactId, final String
version)
{
+ return resolve(groupId, artifactId, version, null);
+ }
+
+ public static File resolve(final String groupId, final String artifactId,
+ final String version, final String classifier)
+ {
return new File(LOCAL_MAVEN_REPO + File.separatorChar +
groupId.replace(".", File.separator) + File.separatorChar +
artifactId + File.separatorChar +
version + File.separatorChar +
- artifactId + "-" + version + ".jar");
+ artifactId + "-" + version +
+ (classifier != null ? ("-" + classifier) : "") +
".jar");
}
- public static File resolve(String qualifiedArtifactId)
+ public static File resolve(final String qualifiedArtifactId)
{
String[] segments = qualifiedArtifactId.split(":");
- return resolve(segments[0], segments[1], segments[2]);
+ if (segments.length == 3)
+ {
+ return resolve(segments[0], segments[1], segments[2]);
+ }
+ else if (segments.length == 4)
+ {
+ return resolve(segments[0], segments[1], segments[2], segments[3]);
+ }
+ throw new IllegalArgumentException("Invalid format for qualified artifactId:
" + qualifiedArtifactId);
}
+
+ public static File[] resolve(final String... qualifiedArtifactIds)
+ {
+ int n = qualifiedArtifactIds.length;
+ File[] artifacts = new File[n];
+ for (int i = 0; i < n; i++)
+ {
+ artifacts[i] = resolve(qualifiedArtifactIds[i]);
+ }
+
+ return artifacts;
+ }
}