tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meer...@apache.org
Subject svn commit: r449388 - in /incubator/tuscany/java/sca/services/maven/src: main/java/org/apache/tuscany/services/maven/ test/java/org/apache/tuscany/services/maven/
Date Sun, 24 Sep 2006 10:28:14 GMT
Author: meerajk
Date: Sun Sep 24 03:28:14 2006
New Revision: 449388

URL: http://svn.apache.org/viewvc?view=rev&rev=449388
Log:
More tests.

Modified:
    incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java
    incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyMavenException.java
    incubator/tuscany/java/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTest.java

Modified: incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java?view=diff&rev=449388&r1=449387&r2=449388
==============================================================================
--- incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java
(original)
+++ incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/MavenHelper.java
Sun Sep 24 03:28:14 2006
@@ -151,26 +151,34 @@
 
         org.apache.maven.artifact.Artifact mavenRootArtifact = artifactFactory.createArtifact(rootArtifact.getGroup(),
rootArtifact.getName(),
                 rootArtifact.getVersion(), org.apache.maven.artifact.Artifact.SCOPE_RUNTIME,
rootArtifact.getType());
-        try {
 
-            boolean resolvedFromDeployment = true;
-            artifactResolver.resolve(mavenRootArtifact, Collections.EMPTY_LIST, deployedRepository);
-            if (mavenRootArtifact.getFile() == null) {
-                artifactResolver.resolve(mavenRootArtifact, remoteRepositories, localRepository);
-                resolvedFromDeployment = false;
+        try {
+            if (resolve(mavenRootArtifact, Collections.EMPTY_LIST, deployedRepository)) {
+                rootArtifact.setUrl(mavenRootArtifact.getFile().toURL());
+                resolveDependencies(rootArtifact, mavenRootArtifact, true);
+            } else if (resolve(mavenRootArtifact, remoteRepositories, localRepository)) {
+                resolveDependencies(rootArtifact, mavenRootArtifact, false);
+            } else {
+                throw new TuscanyMavenException("Unable to resolve artifact " + mavenRootArtifact.toString());
             }
-            rootArtifact.setUrl(mavenRootArtifact.getFile().toURL());
+        } catch (MalformedURLException ex) {
+            throw new TuscanyMavenException(ex);
+        }
 
-            resolveDependencies(rootArtifact, mavenRootArtifact, resolvedFromDeployment);
+    }
 
+    /*
+     * Resolves the artifact.
+     */
+    private boolean resolve(org.apache.maven.artifact.Artifact mavenRootArtifact, List remoteRepositories,
ArtifactRepository localRepository) {
+        try {
+            artifactResolver.resolve(mavenRootArtifact, remoteRepositories, localRepository);
+            return true;
         } catch (ArtifactResolutionException ex) {
-            throw new TuscanyMavenException(ex);
+            return false;
         } catch (ArtifactNotFoundException ex) {
-            throw new TuscanyMavenException(ex);
-        } catch (MalformedURLException ex) {
-            throw new TuscanyMavenException(ex);
+            return false;
         }
-
     }
 
     /*

Modified: incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyMavenException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyMavenException.java?view=diff&rev=449388&r1=449387&r2=449388
==============================================================================
--- incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyMavenException.java
(original)
+++ incubator/tuscany/java/sca/services/maven/src/main/java/org/apache/tuscany/services/maven/TuscanyMavenException.java
Sun Sep 24 03:28:14 2006
@@ -35,4 +35,12 @@
         super(cause);
     }
 
+    /**
+     * Initializes the message.
+     * @param message Message of the exception.
+     */
+    public TuscanyMavenException(String message) {
+        super(message);
+    }
+
 }

Modified: incubator/tuscany/java/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTest.java?view=diff&rev=449388&r1=449387&r2=449388
==============================================================================
--- incubator/tuscany/java/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTest.java
(original)
+++ incubator/tuscany/java/sca/services/maven/src/test/java/org/apache/tuscany/services/maven/MavenArtifactRepositoryTest.java
Sun Sep 24 03:28:14 2006
@@ -48,9 +48,9 @@
     /*
      * Test method for 'org.apache.tuscany.services.maven.MavenArtifactRepository.resolve(Artifact)'
      */
-    public void testResolveArtifact() throws Exception {
+    public void testResolveArtifactFromLocalRepository() throws Exception {
 
-        final URL BASE_URL = new File(System.getProperty("user.home") + File.separator +
"m2").toURL();
+        final URL BASE_URL = new File(System.getProperty("user.home") + File.separator +
"m3").toURL();
         String[] remoteRepoUrls = { "http://repo1.maven.org/maven2/" };
         MavenArtifactRepository repository = new MavenArtifactRepository(remoteRepoUrls,
new RuntimeInfo() {
             public File getApplicationRootDirectory() { return null; }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message