You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by xa...@apache.org on 2008/07/25 18:10:05 UTC

svn commit: r679847 - /ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileUpdater.java

Author: xavier
Date: Fri Jul 25 09:10:05 2008
New Revision: 679847

URL: http://svn.apache.org/viewvc?rev=679847&view=rev
Log:
small clean + API improvement

Modified:
    ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileUpdater.java

Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileUpdater.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileUpdater.java?rev=679847&r1=679846&r2=679847&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileUpdater.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileUpdater.java Fri Jul 25 09:10:05 2008
@@ -24,6 +24,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.id.ModuleRevisionId;
 import org.apache.ivy.util.FileUtil;
 
@@ -37,6 +38,11 @@
         String suffix = "";
     }
     
+    public void addDependency(File ivyFile, String org, String name, String revision, String confMapping) throws IOException {
+        ModuleRevisionId depId = new ModuleRevisionId(new ModuleId(org,name), revision);
+        addDependency(ivyFile, depId, confMapping);
+    }
+        
     public void addDependency(File ivyFile, ModuleRevisionId depId, String confMapping) throws IOException {
         String content = FileUtil.readEntirely(ivyFile);
         
@@ -76,15 +82,13 @@
     private UpdateInfo findUpdateInfoToAddDependency(String content) {
         UpdateInfo info = new UpdateInfo();
         
-        String reversed = new StringBuffer(content).reverse().toString();
-        int length = content.length();
-        
         Pattern dependenciesClose = Pattern.compile("<\\s*/dependencies");
         Matcher depsCloseMatcher = dependenciesClose.matcher(content);
         if (depsCloseMatcher.find()) {
             info.insertFromIndex = findLastDependencyEnd(content, depsCloseMatcher.start());
             if (info.insertFromIndex == -1) {
-                info.insertFromIndex = getLastEndIndex(Pattern.compile("<\\s*dependencies.*?>"), content, depsCloseMatcher.start());
+                info.insertFromIndex = getLastEndIndex(Pattern.compile("<\\s*dependencies.*?>"), 
+                                                        content, depsCloseMatcher.start());
                 if (info.insertFromIndex == -1) {
                     info.insertFromIndex = depsCloseMatcher.start();
                 } else {
@@ -136,8 +140,4 @@
         return index;
     }
 
-    private int reverse(int index, int length) {
-        return length - index;
-    }
-
 }