felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsav...@apache.org
Subject svn commit: r988131 - in /felix/trunk/sigil: bldcommon/ common/core/src/org/apache/felix/sigil/common/config/ ivy/resolver/src/org/apache/felix/sigil/ivy/
Date Mon, 23 Aug 2010 14:25:36 GMT
Author: dsavage
Date: Mon Aug 23 14:25:35 2010
New Revision: 988131

URL: http://svn.apache.org/viewvc?rev=988131&view=rev
Log:
repository config is now managed via a repository path approach (part of work for FELIX-1355)


Modified:
    felix/trunk/sigil/bldcommon/sigil-repos.properties
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConfig.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
    felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
    felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
    felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java
    felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java

Modified: felix/trunk/sigil/bldcommon/sigil-repos.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bldcommon/sigil-repos.properties?rev=988131&r1=988130&r2=988131&view=diff
==============================================================================
--- felix/trunk/sigil/bldcommon/sigil-repos.properties (original)
+++ felix/trunk/sigil/bldcommon/sigil-repos.properties Mon Aug 23 14:25:35 2010
@@ -2,35 +2,29 @@
 
 # repository config
 
--repositories:  system, project, bld-ant, bld-common, felix, spring
+-repositories:  system, project, bld-common, felix, spring, bld-ant
 
 system;provider:        system
-system;level:           -1
 
 project;provider:       project
-project;level:  	0
 project;pattern:        \
 	${..}/common/**/[sigilproject] \
 	${..}/eclipse/**/[sigilproject] \
 
 bld-ant;provider:	filesystem
-bld-ant;level:	5
 bld-ant;recurse:	true
 bld-ant;dir:		${cache.dir:-${..}/cache}/ant/lib
 
 bld-common;provider:	filesystem
-bld-common;level:	2
 bld-common;recurse:	true
 bld-common;dir:		${cache.dir:-${..}/cache}/all
 
 felix;provider:	obr
-felix;level:		4
 felix;url:              http://felix.apache.org/obr/releases.xml 
 felix;index:            ${..}/build/felix.obr
 felix;cache:		${..}/build/obr-cache
 
 spring;provider:	obr
-spring;level:		4
 spring;url:             http://sigil.codecauldron.org/spring-external.obr
 spring;index:           ${..}/build/spring-external.obr
 spring;cache:		${..}/build/obr-cache

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConfig.java?rev=988131&r1=988130&r2=988131&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConfig.java
(original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConfig.java
Mon Aug 23 14:25:35 2010
@@ -36,6 +36,7 @@ public class BldConfig
     // control properties
     public static final String C_BUNDLES = "-bundles";
     public static final String C_REPOSITORIES = "-repositories";
+    public static final String C_REPOSITORY_PATH = "-repositorypath";
 
     // string properties
     public static final String S_ACTIVATOR = "-activator";
@@ -75,7 +76,7 @@ public class BldConfig
     private static final String MAPATTR_REGEX = ";\\s*";
     private static final String MAPATTR_SEP = ";";
     private static final String SUBKEY_SEP = ";";
-
+    
     // configuration is stored in typed maps
     private Map<String, String> string = new TreeMap<String, String>();
     private Map<String, List<String>> list = new TreeMap<String, List<String>>();

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java?rev=988131&r1=988130&r2=988131&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
(original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
Mon Aug 23 14:25:35 2010
@@ -36,6 +36,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -648,11 +649,19 @@ public class BldProject implements IBldP
         return list;
     }
 
-    // Implement IBldConfig: getRepositoryConfig
-
+    public List<String> getRepositoryPath() 
+    {
+        List<String> ids = config.getList(null, BldConfig.C_REPOSITORY_PATH);
+        
+        if (ids.isEmpty())
+            return Collections.singletonList(IRepositoryConfig.WILD_CARD);
+        
+        return ids;
+    }
+    
     public Map<String, Properties> getRepositoryConfig()
     {
-        HashMap<String, Properties> map = new HashMap<String, Properties>();
+        LinkedHashMap<String, Properties> map = new LinkedHashMap<String, Properties>();
         BldProperties bp = new BldProperties(baseDir, bldOverrides);
 
         for (String name : config.getList(null, BldConfig.C_REPOSITORIES))

Modified: felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java?rev=988131&r1=988130&r2=988131&view=diff
==============================================================================
--- felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
(original)
+++ felix/trunk/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
Mon Aug 23 14:25:35 2010
@@ -19,18 +19,26 @@
 
 package org.apache.felix.sigil.common.config;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
 public interface IRepositoryConfig
 {
     static final String REPOSITORY_PROVIDER = "provider";
-    static final String REPOSITORY_LEVEL = "level";
+    static final String WILD_CARD = "*";
+    
+    /**
+     * Return the ordered list of repositories to search
+     * for dependencies.
+     * 
+     * @return
+     */
+    List<String> getRepositoryPath();
 
     /**
      * get properties with which to instantiate repositories.
      * The key REPOSITORY_PROVIDER will be set to the fully qualified class name of the IRepositoryProvider.
-     * The key REPOSITORY_LEVEL indicates repository search order.
      * @return
      */
     Map<String, Properties> getRepositoryConfig();

Modified: felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java?rev=988131&r1=988130&r2=988131&view=diff
==============================================================================
--- felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
(original)
+++ felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
Mon Aug 23 14:25:35 2010
@@ -21,6 +21,9 @@ package org.apache.felix.sigil.ivy;
 
 import java.io.File;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -43,78 +46,123 @@ public class BldRepositoryManager extend
             "org.apache.felix.sigil.common.core.repository.SystemRepositoryProvider");
     };
 
-    private Map<String, Properties> repos;
+    private final Map<String, Properties> repos;
+    private final List<String> repositoryPath;
 
-    public BldRepositoryManager(Map<String, Properties> repos)
+    public BldRepositoryManager(List<String> repositoryPath, Map<String, Properties>
repos)
     {
+        System.out.println("RepositoryPath=" + repositoryPath);
+        System.out.println("Repos=" + repos);
+        this.repositoryPath = repositoryPath;
         this.repos = repos;
     }
 
     @Override
     protected void loadRepositories()
     {
-        for (String name : repos.keySet())
-        {
-            Properties repo = repos.get(name);
-            if (Boolean.parseBoolean(repo.getProperty("disabled", "false")))
-            {
-                continue;
-            }
-
-            String optStr = repo.getProperty("optional", "false");
-            boolean optional = Boolean.parseBoolean(optStr.trim());
-
-            String alias = repo.getProperty(IRepositoryConfig.REPOSITORY_PROVIDER);
-            if (alias == null)
-            {
-                Log.error("provider not specified for repository: " + name);
-                continue;
-            }
-
-            String provider = (aliases.containsKey(alias) ? aliases.get(alias) : alias);
-
-            if (alias.equals("obr"))
-            {
-                // cache is directory where synchronized bundles are stored;
-                // not needed in ivy.
-                repo.setProperty("cache", "/no-cache");
-                String index = repo.getProperty("index");
+        scanRepositories(repositoryPath, repos, 0);
+    }
 
-                if (index == null)
-                {
-                    // index is created to cache OBR url
-                    File indexFile = new File(System.getProperty("java.io.tmpdir"),
-                        "obr-index-" + name);
-                    indexFile.deleteOnExit();
-                    repo.setProperty("index", indexFile.getAbsolutePath());
+    /**
+     * @param repos2 
+     * @param repositoryPath2
+     */
+    private int scanRepositories(List<String> repositoryPath, Map<String, Properties>
repos, int start)
+    {
+        int count = start;
+        for (String name : repositoryPath)
+        {
+            System.out.println("Building repository for " + name);
+            if ( IRepositoryConfig.WILD_CARD.equals(name) ) {
+                HashSet<String> defined = new HashSet<String>();
+                for (String n : repositoryPath) {
+                    if (!IRepositoryConfig.WILD_CARD.equals(n)) {
+                        defined.add(n);
+                    }
                 }
-                else
-                {
-                    if (!new File(index).getParentFile().mkdirs())
+                List<String> path = new LinkedList<String>();
+                for (String key : repos.keySet()) {
+                    if (!defined.contains(key))
                     {
-                        // ignore - but keeps findbugs happy
+                        path.add(key);
                     }
                 }
+                count = scanRepositories(path, repos, start + 1);
+            }
+            else {
+                Properties props = repos.get(name);
+                IBundleRepository repo = buildRepository(name, props);
+                System.out.println("Built repository " + repo + " for " + name + " at " +
count);
+                
+                if ( repo != null ) {
+                    addRepository(repo, count++);
+                }                
             }
+        }
+        
+        return count;
+    }
+
+    /**
+     * @param repo
+     * @return 
+     */
+    private static IBundleRepository buildRepository(String name, Properties repo)
+    {
+        String optStr = repo.getProperty("optional", "false");
+        boolean optional = Boolean.parseBoolean(optStr.trim());
+
+        String alias = repo.getProperty(IRepositoryConfig.REPOSITORY_PROVIDER);
+        if (alias == null)
+        {
+            String msg = "provider not specified for repository: " + name;
+            
+            if (!optional)
+                throw new IllegalStateException(msg);
+            
+            Log.warn(msg);
+        }
+
+        String provider = (aliases.containsKey(alias) ? aliases.get(alias) : alias);
 
-            int level = Integer.parseInt(repo.getProperty(
-                IRepositoryConfig.REPOSITORY_LEVEL,
-                Integer.toString(IBundleRepository.NORMAL_PRIORITY)));
+        if (alias.equals("obr"))
+        {
+            // cache is directory where synchronized bundles are stored;
+            // not needed in ivy.
+            repo.setProperty("cache", "/no-cache");
+            String index = repo.getProperty("index");
 
-            try
+            if (index == null)
             {
-                IRepositoryProvider instance = (IRepositoryProvider) (Class.forName(provider).newInstance());
-                IBundleRepository repository = instance.createRepository(name, repo);
-                addRepository(repository, level);
-                Log.verbose("added repository: " + repository + " : " + level);
+                // index is created to cache OBR url
+                File indexFile = new File(System.getProperty("java.io.tmpdir"),
+                    "obr-index-" + name);
+                indexFile.deleteOnExit();
+                repo.setProperty("index", indexFile.getAbsolutePath());
             }
-            catch (Exception e)
+            else
             {
-                String msg = "failed to create repository: ";
-                if (!optional)
-                    throw new Error(msg + repo + " " + e, e);
-                System.err.println("WARNING: " + msg + e);
+                if (!new File(index).getParentFile().mkdirs())
+                {
+                    // ignore - but keeps findbugs happy
+                }
             }
         }
+
+        try
+        {
+            IRepositoryProvider instance = (IRepositoryProvider) (Class.forName(provider).newInstance());
+            IBundleRepository repository = instance.createRepository(name, repo);
+            return repository;
+        }
+        catch (Exception e)
+        {
+            String msg = "failed to create repository: ";
+            if (!optional)
+                throw new IllegalStateException(msg + repo + " " + e, e);
+            Log.warn(msg + e);
+        }
+        
+        return null;
     }
 }
\ No newline at end of file

Modified: felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java?rev=988131&r1=988130&r2=988131&view=diff
==============================================================================
--- felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java (original)
+++ felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java Mon Aug
23 14:25:35 2010
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ivy;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -32,9 +33,11 @@ import org.apache.felix.sigil.common.rep
 
 public class BldResolver implements IBldResolver
 {
-    private Map<String, Properties> repos;
-    private BldRepositoryManager manager;
+    private final Map<String, Properties> repos;
+    private final List<String> repositoryPath;
 
+    private BldRepositoryManager manager;
+    
     static
     {
         try
@@ -48,8 +51,9 @@ public class BldResolver implements IBld
         }
     };
 
-    public BldResolver(Map<String, Properties> repos)
+    public BldResolver(List<String> repositoryPath, Map<String, Properties> repos)
     {
+        this.repositoryPath = repositoryPath;
         this.repos = repos;
     }
 
@@ -86,7 +90,7 @@ public class BldResolver implements IBld
     {
         if (manager == null)
         {
-            manager = new BldRepositoryManager(repos);
+            manager = new BldRepositoryManager(repositoryPath, repos);
         }
 
         IResolutionMonitor ivyMonitor = new IResolutionMonitor()

Modified: felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java?rev=988131&r1=988130&r2=988131&view=diff
==============================================================================
--- felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java (original)
+++ felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java Mon Aug
23 14:25:35 2010
@@ -30,6 +30,7 @@ import java.net.URL;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.jar.JarEntry;
@@ -37,6 +38,7 @@ import java.util.jar.JarInputStream;
 import java.util.jar.Manifest;
 
 import org.apache.felix.sigil.common.config.BldFactory;
+import org.apache.felix.sigil.common.config.IRepositoryConfig;
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.model.ModelElementFactory;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
@@ -120,8 +122,10 @@ public class SigilResolver extends Basic
                     uri = cwd.resolve(config);
                 }
 
-                Map<String, Properties> repositories = BldFactory.getConfig(uri).getRepositoryConfig();
-                resolver = new BldResolver(repositories);
+                IRepositoryConfig project = BldFactory.getConfig(uri);
+                List<String> repositoryPath = project.getRepositoryPath(); 
+                Map<String, Properties> repositories = project.getRepositoryConfig();
+                resolver = new BldResolver(repositoryPath, repositories);
             }
             catch (IOException e)
             {



Mime
View raw message