felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From db...@apache.org
Subject svn commit: r816296 [2/2] - in /felix/trunk/sigil: common/core/src/org/apache/felix/sigil/config/ common/obr/src/org/apache/felix/sigil/obr/ common/obr/src/org/apache/felix/sigil/obr/impl/ ivy/resolver/src/org/apache/felix/sigil/ivy/
Date Thu, 17 Sep 2009 17:30:21 GMT
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=816296&r1=816295&r2=816296&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
Thu Sep 17 17:30:21 2009
@@ -73,15 +73,23 @@
                 // cache is directory where synchronized bundles are stored;
                 // not needed in ivy.
                 repo.setProperty("cache", "/no-cache");
+                String index = repo.getProperty("index");
 
-                if (!repo.containsKey("index"))
+                if (index == null)
                 {
-                    // index is created as copy of url
+                    // 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());
                 }
+                else
+                {
+                    if (!new File(index).getParentFile().mkdirs())
+                    {
+                        // ignore - but keeps findbugs happy
+                    }
+                }
             }
 
             int level = Integer.parseInt(repo.getProperty(
@@ -97,10 +105,10 @@
             }
             catch (Exception e)
             {
-                String msg = "failed to create repository: " + repo + " : " + e;
+                String msg = "failed to create repository: ";
                 if (!optional)
-                    throw new Error(msg, e);
-                System.err.println("WARNING: " + msg);
+                    throw new Error(msg + repo + " " + e, e);
+                System.err.println("WARNING: " + msg + e);
             }
         }
     }

Modified: felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java?rev=816296&r1=816295&r2=816296&view=diff
==============================================================================
--- felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java (original)
+++ felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java Thu Sep 17
17:30:21 2009
@@ -19,60 +19,57 @@
 
 package org.apache.felix.sigil.ivy;
 
-
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 
-
 public class FindUtil
 {
     static final String WILD_ANY = "[^.].*";
     static final String WILD_ONE = "[^.][^;]*"; // WILD_ONE.endsWith(WILD_ANY) == false
 
-
     // example pattern: ${repository}/projects/abc*/*/project.sigil
-    public static Collection<File> findFiles( String pattern ) throws IOException
+    public static Collection<File> findFiles(String pattern) throws IOException
     {
-        int star = pattern.indexOf( "*" );
-        if ( star == -1 )
+        int star = pattern.indexOf("*");
+        if (star == -1)
         {
-            throw new IOException( "pattern doesn't contain '*': " + pattern );
+            throw new IOException("pattern doesn't contain '*': " + pattern);
         }
-        int slash = pattern.lastIndexOf( '/', star );
+        int slash = pattern.lastIndexOf('/', star);
 
-        String regex = pattern.substring( slash + 1 );
-        regex = regex.replaceAll( "\\*\\*", "-wildany-" );
-        regex = regex.replaceAll( "\\*", "-wildone-" );
-        regex = regex.replaceAll( "-wildany-", WILD_ANY );
-        regex = regex.replaceAll( "-wildone-", WILD_ONE );
+        String regex = pattern.substring((slash == -1) ? 0 : slash + 1);
+        regex = regex.replaceAll("\\*\\*", "-wildany-");
+        regex = regex.replaceAll("\\*", "-wildone-");
+        regex = regex.replaceAll("-wildany-", WILD_ANY);
+        regex = regex.replaceAll("-wildone-", WILD_ONE);
 
-        String[] patterns = regex.split( "/" );
+        String[] patterns = regex.split("/");
 
         ArrayList<File> list = new ArrayList<File>();
-        File root = new File( pattern.substring( 0, slash ) );
+        File root = new File(slash == -1 ? "." : pattern.substring(0, slash));
 
-        if ( root.isDirectory() )
+        if (root.isDirectory())
         {
-            findFiles( root, 0, patterns, list );
+            findFiles(root, 0, patterns, list);
         }
         else
         {
-            throw new IOException( "pattern root directory does not exist: " + root );
+            throw new IOException("pattern root directory does not exist: " + root);
         }
 
         return list;
     }
 
-
-    private static void findFiles( File dir, int level, String[] patterns, Collection<File>
list )
+    private static void findFiles(File dir, int level, String[] patterns,
+        Collection<File> list)
     {
         final String filePattern = patterns[patterns.length - 1];
         final String dirPattern;
 
-        if ( level < patterns.length - 1 )
+        if (level < patterns.length - 1)
         {
             dirPattern = patterns[level];
         }
@@ -82,7 +79,8 @@
         }
 
         final boolean stillWild;
-        if ( ( level > 0 ) && ( level < patterns.length ) && patterns[level
- 1].endsWith( WILD_ANY ) )
+        if ((level > 0) && (level < patterns.length)
+            && patterns[level - 1].endsWith(WILD_ANY))
         {
             stillWild = true;
         }
@@ -91,34 +89,35 @@
             stillWild = false;
         }
 
-        for ( File path : dir.listFiles( new FileFilter()
+        for (File path : dir.listFiles(new FileFilter()
         {
-            public boolean accept( File pathname )
+            public boolean accept(File pathname)
             {
                 String name = pathname.getName();
-                if ( pathname.isDirectory() )
+                if (pathname.isDirectory())
                 {
-                    return name.matches( dirPattern ) || ( stillWild && name.matches(
WILD_ANY ) );
+                    return name.matches(dirPattern)
+                        || (stillWild && name.matches(WILD_ANY));
                 }
-                else if ( dirPattern.equals( "/" ) || dirPattern.equals( WILD_ANY ) )
+                else if (dirPattern.equals("/") || dirPattern.equals(WILD_ANY))
                 {
-                    return name.matches( filePattern );
+                    return name.matches(filePattern);
                 }
                 else
                 {
                     return false;
                 }
             }
-        } ) )
+        }))
         {
-            if ( path.isDirectory() )
+            if (path.isDirectory())
             {
-                int inc = path.getName().matches( dirPattern ) ? 1 : 0;
-                findFiles( path, level + inc, patterns, list );
+                int inc = path.getName().matches(dirPattern) ? 1 : 0;
+                findFiles(path, level + inc, patterns, list);
             }
             else
             {
-                list.add( path );
+                list.add(path);
             }
         }
     }

Modified: felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java?rev=816296&r1=816295&r2=816296&view=diff
==============================================================================
--- felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java (original)
+++ felix/trunk/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java Thu
Sep 17 17:30:21 2009
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.ivy;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
@@ -47,95 +46,92 @@
 
 import org.osgi.framework.Version;
 
-
 public class ProjectRepository extends AbstractBundleRepository
 {
     private ArrayList<ISigilBundle> bundles;
     private ArrayList<ISigilBundle> wildBundles;
     private String projectFilePattern;
 
-
-    /* package */ProjectRepository( String id, String projectFilePattern )
+    /* package */ProjectRepository(String id, String projectFilePattern)
     {
-        super( id );
-        this.projectFilePattern = projectFilePattern.replaceAll( "\\[sigilproject\\]", IBldProject.PROJECT_FILE
);
+        super(id);
+        this.projectFilePattern = projectFilePattern.replaceAll("\\[sigilproject\\]",
+            IBldProject.PROJECT_FILE);
     }
 
-
     @Override
-    public void accept( IRepositoryVisitor visitor, int options )
+    public void accept(IRepositoryVisitor visitor, int options)
     {
-        for ( ISigilBundle b : getBundles() )
+        for (ISigilBundle b : getBundles())
         {
-            if ( !visitor.visit( b ) )
+            if (!visitor.visit(b))
             {
                 break;
             }
         }
     }
 
-
     // override to provide fuzzy matching for wild-card exports.
     @Override
-    public Collection<ISigilBundle> findAllProviders( final IPackageImport pi, int
options )
+    public Collection<ISigilBundle> findAllProviders(final IPackageImport pi, int options)
     {
-        return findProviders( pi, options, false );
+        return findProviders(pi, options, false);
     }
 
-
     @Override
-    public ISigilBundle findProvider( IPackageImport pi, int options )
+    public ISigilBundle findProvider(IPackageImport pi, int options)
     {
-        Collection<ISigilBundle> found = findProviders( pi, options, true );
+        Collection<ISigilBundle> found = findProviders(pi, options, true);
         return found.isEmpty() ? null : found.iterator().next();
     }
 
-
-    private Collection<ISigilBundle> findProviders( final IPackageImport pi, int options,
boolean findFirst )
+    private Collection<ISigilBundle> findProviders(final IPackageImport pi, int options,
+        boolean findFirst)
     {
         ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
-        ILicensePolicy policy = findPolicy( pi );
+        ILicensePolicy policy = findPolicy(pi);
         String name = pi.getPackageName();
         VersionRange versions = pi.getVersions();
 
         // find exact match(es)
-        for ( ISigilBundle bundle : getBundles() )
+        for (ISigilBundle bundle : getBundles())
         {
-            if ( policy.accept( bundle ) )
+            if (policy.accept(bundle))
             {
-                for ( IPackageExport exp : bundle.getBundleInfo().getExports() )
+                for (IPackageExport exp : bundle.getBundleInfo().getExports())
                 {
-                    if ( name.equals( exp.getPackageName() ) && versions.contains(
exp.getVersion() ) )
+                    if (name.equals(exp.getPackageName())
+                        && versions.contains(exp.getVersion()))
                     {
-                        found.add( bundle );
-                        if ( findFirst )
+                        found.add(bundle);
+                        if (findFirst)
                             return found;
                     }
                 }
             }
         }
 
-        if ( !found.isEmpty() )
+        if (!found.isEmpty())
             return found;
 
         // find best fuzzy match
         ISigilBundle fuzzyMatch = null;
         int fuzzyLen = 0;
 
-        for ( ISigilBundle bundle : getWildBundles() )
+        for (ISigilBundle bundle : getWildBundles())
         {
-            if ( policy.accept( bundle ) )
+            if (policy.accept(bundle))
             {
-                for ( IPackageExport exp : bundle.getBundleInfo().getExports() )
+                for (IPackageExport exp : bundle.getBundleInfo().getExports())
                 {
                     String export = exp.getPackageName();
-                    if ( export.endsWith( "*" ) )
+                    if (export.endsWith("*"))
                     {
-                        String export1 = export.substring( 0, export.length() - 1 );
-                        if ( ( name.startsWith( export1 ) || export1.equals( name + "." )
)
-                            && versions.contains( exp.getVersion() ) )
+                        String export1 = export.substring(0, export.length() - 1);
+                        if ((name.startsWith(export1) || export1.equals(name + "."))
+                            && versions.contains(exp.getVersion()))
                         {
-                            if ( export1.length() > fuzzyLen )
+                            if (export1.length() > fuzzyLen)
                             {
                                 fuzzyLen = export1.length();
                                 fuzzyMatch = bundle;
@@ -146,89 +142,87 @@
             }
         }
 
-        if ( fuzzyMatch != null )
-            found.add( fuzzyMatch );
+        if (fuzzyMatch != null)
+            found.add(fuzzyMatch);
 
         return found;
     }
 
-
     private synchronized void init()
     {
-        System.out.println( "Sigil: loading Project Repository: " + projectFilePattern );
+        System.out.println("Sigil: loading Project Repository: " + projectFilePattern);
 
         ArrayList<File> projects = new ArrayList<File>();
 
-        for ( String pattern : projectFilePattern.split( "\\s+" ) )
+        for (String pattern : projectFilePattern.split("\\s+"))
         {
             try
             {
-                Collection<File> files = FindUtil.findFiles( pattern );
-                if ( files.isEmpty() )
+                Collection<File> files = FindUtil.findFiles(pattern);
+                if (files.isEmpty())
                 {
-                    Log.warn( "ProjectRepository: no projects match: " + pattern );
+                    Log.warn("ProjectRepository: no projects match: " + pattern);
                 }
                 else
                 {
-                    projects.addAll( files );
+                    projects.addAll(files);
                 }
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
                 // pattern root dir does not exist
-                Log.error( "ProjectRepository: " + pattern + ": " + e.getMessage() );
+                Log.error("ProjectRepository: " + pattern + ": " + e.getMessage());
             }
         }
 
-        if ( projects.isEmpty() )
+        if (projects.isEmpty())
         {
-            throw new IllegalArgumentException( "ProjectRepository: no projects found using
pattern: "
-                + projectFilePattern );
+            throw new IllegalArgumentException(
+                "ProjectRepository: no projects found using pattern: "
+                    + projectFilePattern + " pwd=" + new File("").getAbsolutePath());
         }
 
         bundles = new ArrayList<ISigilBundle>();
 
-        for ( File proj : projects )
+        for (File proj : projects)
         {
             try
             {
-                addBundles( proj, bundles );
+                addBundles(proj, bundles);
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                Log.warn( "Skipping project: " + proj + ": " + e.getMessage() );
+                Log.warn("Skipping project: " + proj + ": " + e.getMessage());
             }
-            catch ( ParseException e )
+            catch (ParseException e)
             {
-                Log.warn( "Skipping project: " + proj + ": " + e.getMessage() );
+                Log.warn("Skipping project: " + proj + ": " + e.getMessage());
             }
         }
     }
 
-
     private List<ISigilBundle> getBundles()
     {
-        if ( bundles == null )
+        if (bundles == null)
         {
             init();
         }
         return bundles;
     }
 
-
     private List<ISigilBundle> getWildBundles()
     {
-        if ( wildBundles == null )
+        if (wildBundles == null)
         {
             wildBundles = new ArrayList<ISigilBundle>();
-            for ( ISigilBundle bundle : getBundles() )
+            for (ISigilBundle bundle : getBundles())
             {
-                for ( IPackageExport exp : bundle.getBundleInfo().getExports() )
+                for (IPackageExport exp : bundle.getBundleInfo().getExports())
                 {
                     String export = exp.getPackageName();
-                    if ( export.endsWith( "*" ) )
+                    if (export.endsWith("*"))
                     {
-                        wildBundles.add( bundle );
+                        wildBundles.add(bundle);
                         break;
                     }
                 }
@@ -237,7 +231,6 @@
         return wildBundles;
     }
 
-
     public void refresh()
     {
         bundles = null;
@@ -245,55 +238,55 @@
         notifyChange();
     }
 
-
-    private void addBundles( File file, List<ISigilBundle> list ) throws IOException,
ParseException
+    private void addBundles(File file, List<ISigilBundle> list) throws IOException,
+        ParseException
     {
         URI uri = file.getCanonicalFile().toURI();
-        IBldProject project = BldFactory.getProject( uri );
+        IBldProject project = BldFactory.getProject(uri);
 
-        for ( IBldBundle bb : project.getBundles() )
+        for (IBldBundle bb : project.getBundles())
         {
             IBundleModelElement info = new BundleModelElement();
 
-            for ( IPackageExport pexport : bb.getExports() )
+            for (IPackageExport pexport : bb.getExports())
             {
-                info.addExport( pexport );
+                info.addExport(pexport);
             }
 
-            for ( IPackageImport import1 : bb.getImports() )
+            for (IPackageImport import1 : bb.getImports())
             {
-                IPackageImport clone = ( IPackageImport ) import1.clone();
-                clone.setParent( null );
-                info.addImport( clone );
+                IPackageImport clone = (IPackageImport) import1.clone();
+                clone.setParent(null);
+                info.addImport(clone);
             }
 
-            for ( IRequiredBundle require : bb.getRequires() )
+            for (IRequiredBundle require : bb.getRequires())
             {
-                IRequiredBundle clone = ( IRequiredBundle ) require.clone();
-                clone.setParent( null );
-                info.addRequiredBundle( clone );
+                IRequiredBundle clone = (IRequiredBundle) require.clone();
+                clone.setParent(null);
+                info.addRequiredBundle(clone);
             }
 
-            info.setSymbolicName( bb.getSymbolicName() );
+            info.setSymbolicName(bb.getSymbolicName());
 
-            Version version = new Version( bb.getVersion() );
-            info.setVersion( version );
+            Version version = new Version(bb.getVersion());
+            info.setVersion(version);
 
             ProjectBundle pb = new ProjectBundle();
-            pb.setBundleInfo( info );
-            pb.setId( bb.getId() );
+            pb.setBundleInfo(info);
+            pb.setId(bb.getId());
 
-            ModuleDescriptor md = SigilParser.instance().parseDescriptor( uri.toURL() );
+            ModuleDescriptor md = SigilParser.instance().parseDescriptor(uri.toURL());
 
             ModuleRevisionId mrid = md.getModuleRevisionId();
-            pb.setModule( mrid.getName() );
-            pb.setOrg( mrid.getOrganisation() );
+            pb.setModule(mrid.getName());
+            pb.setOrg(mrid.getOrganisation());
             // XXX: should revision be configurable?
-            pb.setRevision( "latest." + md.getStatus() );
+            pb.setRevision("latest." + md.getStatus());
 
-            list.add( pb );
-            Log.debug( "ProjectRepository: added " + pb );
-            Log.debug( "ProjectRepository: exports " + bb.getExports() );
+            list.add(pb);
+            Log.debug("ProjectRepository: added " + pb);
+            Log.debug("ProjectRepository: exports " + bb.getExports());
         }
     }
 
@@ -304,57 +297,49 @@
         private String org;
         private String revision;
 
-
         @Override
         public String toString()
         {
-            return "ProjectBundle[" + org + "@" + module + ( id == null ? "" : "$" + id )
+ "#" + revision + "]";
+            return "ProjectBundle[" + org + "@" + module + (id == null ? "" : "$" + id)
+                + "#" + revision + "]";
         }
 
-
         public String getModule()
         {
             return module;
         }
 
-
-        public void setModule( String module )
+        public void setModule(String module)
         {
             this.module = module;
         }
 
-
         public String getId()
         {
             return id;
         }
 
-
-        public void setId( String id )
+        public void setId(String id)
         {
             this.id = id;
         }
 
-
         public String getRevision()
         {
             return revision;
         }
 
-
-        public void setRevision( String rev )
+        public void setRevision(String rev)
         {
             this.revision = rev;
         }
 
-
         public String getOrg()
         {
             return org;
         }
 
-
-        public void setOrg( String org )
+        public void setOrg(String org)
         {
             this.org = org;
         }



Mime
View raw message