ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r540535 - in /ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian: ControlFile.java ControlFileTask.java
Date Tue, 22 May 2007 11:38:08 GMT
Author: kevj
Date: Tue May 22 04:38:07 2007
New Revision: 540535

URL: http://svn.apache.org/viewvc?view=rev&rev=540535
Log:
-fix dependency header, add support for provides & recommends

Modified:
    ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFile.java
    ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFileTask.java

Modified: ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFile.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFile.java?view=diff&rev=540535&r1=540534&r2=540535
==============================================================================
--- ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFile.java (original)
+++ ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFile.java Tue May
22 04:38:07 2007
@@ -42,11 +42,16 @@
     private static final String MAINTAINER_HEADER = "Maintainer: ";
     private static final String PROVIDES_HEADER = "Provides: ";
     private static final String DESCRIPTION_HEADER = "Description: ";
-    private static final String DEPENDENCIES_HEADER = "Dependencies: ";
-
+    private static final String DEPENDENCIES_HEADER = "Depends: ";
+    private static final String RECOMMENDS_HEADER = "Recommeds: ";
+    
 
     private Vector dependencies = new Vector();
+    
+    private Vector recommends = new Vector();
 
+    private Vector provides = new Vector();
+    
     private String debPackage;
 
     private String debVersion;
@@ -61,8 +66,6 @@
 
     private String debMaintainer;
 
-    private String debProvides;
-
     private Description description;
 
     /* default */
@@ -72,6 +75,14 @@
         dependencies.add(d);
     }
 
+    public void addRecommends(Recommends r) {
+        recommends.add(r);
+    }
+    
+    public void addProvides(Provides p) {
+        provides.add(p);
+    }
+    
     public String getDebPackage() {
         return debPackage;
     }
@@ -128,14 +139,6 @@
         this.debMaintainer = debMaintainer;
     }
 
-    public String getDebProvides() {
-        return debProvides;
-    }
-
-    public void setDebProvides(String debProvides) {
-        this.debProvides = debProvides;
-    }
-
     public void addDescription(Description d) {
         this.description = d;
     }
@@ -148,41 +151,39 @@
         writer.println(ARCHITECTURE_HEADER+debArchitecture);
         writer.println(ESSENTIAL_HEADER+debEssential);
         writer.println(MAINTAINER_HEADER+debMaintainer);
-        writer.println(PROVIDES_HEADER+debProvides);
-        if(dependencies.size() > 0) {
-            writer.print(DEPENDENCIES_HEADER);
-            for(Iterator i = dependencies.iterator();i.hasNext();) {
-                writer.print(((Dependency)i.next()).getName());
-                if(i.hasNext()) {
-                    writer.print(",");
-                } else {
-                    writer.print("\n");
-                }
-            }
-        }
+        writeVector(dependencies, DEPENDENCIES_HEADER, writer);
+        writeVector(recommends, RECOMMENDS_HEADER, writer);
+        writeVector(provides, PROVIDES_HEADER, writer);
+        
         if(null != description) {
             writer.println(DESCRIPTION_HEADER+description.getDesc());
         }
     }
 
-    public static class Dependency {
-        private String name;
-
-        public Dependency() {}
-
-        public String getName() {
-            return name;
-        }
-
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        public void addText(String text) {
-            this.name = text;
+    private void writeVector(Vector v, String header, PrintWriter w) 
+            throws IOException {
+        
+        if (v.size() > 0) {
+            for(Iterator i = v.iterator();i.hasNext();) {
+                w.print(header);
+                w.print(((DpkgLine)i.next()).getName());
+                w.print("\n");
+            }
         }
     }
+    
+    public static class Dependency extends DpkgLine {
+        public Dependency() {}
+    }
 
+    public static class Recommends extends DpkgLine {
+        public Recommends() {}
+    }
+    
+    public static class Provides extends DpkgLine {
+        public Provides() {}
+    }
+    
     public static class Description {
         private String desc;
 
@@ -198,6 +199,22 @@
 
         public void addText(String text) {
             this.desc = text;
+        }
+    }
+    
+    public abstract static class DpkgLine {
+        private String name;
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public void addText(String text) {
+            this.name = text;
         }
     }
 }

Modified: ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFileTask.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFileTask.java?view=diff&rev=540535&r1=540534&r2=540535
==============================================================================
--- ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFileTask.java (original)
+++ ant/sandbox/antlibs/debian/trunk/src/main/org/apache/ant/debian/ControlFileTask.java Tue
May 22 04:38:07 2007
@@ -108,8 +108,8 @@
         controlFile.setDebMaintainer(debMaintainer);
     }
 
-    public void setProvides(String debProvides) {
-        controlFile.setDebProvides(debProvides);
+    public void addProvides(ControlFile.Provides provides) {
+        controlFile.addProvides(provides);
     }
 
     public void addDescription(ControlFile.Description description) {
@@ -118,5 +118,9 @@
 
     public void addDependency(ControlFile.Dependency dependency) {
         controlFile.addDependency(dependency);
+    }
+    
+    public void addRecommends(ControlFile.Recommends recommends) {
+        controlFile.addRecommends(recommends);
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message