Author: dan.j.allen
Date: 2010-08-27 17:40:16 -0400 (Fri, 27 Aug 2010)
New Revision: 13656
Modified:
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/support/MavenArtifactResolver.java
Log:
add support for custom local repo configuration
add comments
Modified:
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/support/MavenArtifactResolver.java
===================================================================
---
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/support/MavenArtifactResolver.java 2010-08-27
21:39:42 UTC (rev 13655)
+++
examples/trunk/javaee-booking/src/test/java/org/jboss/seam/examples/booking/support/MavenArtifactResolver.java 2010-08-27
21:40:16 UTC (rev 13656)
@@ -2,11 +2,48 @@
import java.io.File;
+/**
+ * A temporary resolver that converts a Maven artifact reference
+ * into a {@link java.io.File} object.
+ *
+ * <p>This approach is an interim solution for Maven projects
+ * until the open feature request to add formally add artifacts
+ * to a test (<a
href="https://jira.jboss.org/browse/ARQ-66">ARQ-66</a>) is
implementated.</p>
+ *
+ * <p>The testCompile goal will resolve any test dependencies and
+ * put them in your local Maven repository. By the time the test
+ * executes, you can be sure that the JAR files you need will be
+ * in your local repository.</p>
+ *
+ * <p>Example usage:</p>
+ *
+ * <pre>
+ * WebArchive war = ShrinkWrap.create("test.war", WebArchive.class)
+ *
.addLibrary(MavenArtifactResolver.resolve("commons-lang:commons-lang:2.5"));
+ * </pre>
+
+ * <p>If you are using an alternate local Maven repository, you need to pass it
+ * to the Maven surefire plugin using the following stanza in the plugin
+ * configuration element:</p>
+ *
+ * <pre>
+ * <systemProperties>
+ * <property>
+ * <name>maven.repo.local</name>
+ * <value>${maven.repo.local}</value>
+ * </property>
+ * </systemProperties>
+ * </pre>
+ *
+ * <p>Another approach to pull in a library is to add packages recursively from
the
+ * root library package.</p>
+ */
public class MavenArtifactResolver
{
private static final String LOCAL_MAVEN_REPO =
- System.getProperty("user.home") + File.separatorChar +
- ".m2" + File.separatorChar + "repository";
+ System.getProperty("maven.repo.local") != null ?
System.getProperty("maven.repo.local") :
+ (System.getProperty("user.home") + File.separatorChar +
+ ".m2" + File.separatorChar + "repository");
public static File resolve(String groupId, String artifactId, String version)
{