You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/07/13 15:26:06 UTC

svn commit: r793581 [3/23] - in /felix/trunk/sigil: ./ bld-ivy/ bld-ivy/example/ bld-ivy/example/dependence/ bld-ivy/example/dependence/dependee/ bld-ivy/example/dependence/dependee/src/ bld-ivy/example/dependence/dependee/src/standalone/ bld-ivy/examp...

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/list/src/list/ListFile.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/list/src/list/ListFile.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/list/src/list/ListFile.java (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/list/src/list/ListFile.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package list;
+
+import version.Version;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.io.File;
+
+public class ListFile {
+  static {
+    Version.register("list");
+  }
+  
+  public static Collection list(File dir) {
+    Collection files = new ArrayList();
+    
+    return list(dir, files);
+  }
+  
+  private static Collection list(File file, Collection files) {
+    if (file.isDirectory()) {
+      File[] f = file.listFiles();
+      for (int i=0; i<f.length; i++) {
+        list(f[i], files);
+      }
+    } else {
+      files.add(file);
+    }
+    return files;
+  }
+}

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/list/src/list/Main.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/list/src/list/Main.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/list/src/list/Main.java (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/list/src/list/Main.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package list;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+public class Main {
+    private static Options getOptions() {
+        Option dir = OptionBuilder.withArgName( "dir" )
+            .hasArg()
+            .withDescription(  "list files in given dir" )
+            .create( "dir" );
+        Options options = new Options();
+
+        options.addOption(dir);
+        
+        return options;
+    }
+    
+    public static void main(String[] args) throws Exception {
+      Options options = getOptions();
+      try {
+        
+        CommandLineParser parser = new GnuParser();
+
+        CommandLine line = parser.parse( options, args );
+        File dir = new File(line.getOptionValue("dir", "."));
+        Collection files = ListFile.list(dir);
+        System.out.println("listing files in "+dir);
+        for (Iterator it = files.iterator(); it.hasNext(); ) {
+          System.out.println("\t"+it.next()+"\n");
+        }
+      } catch( ParseException exp ) {
+          // oops, something went wrong
+          System.err.println( "Parsing failed.  Reason: " + exp.getMessage() );
+          
+        HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp( "list", options );
+      }        
+    }
+            
+}

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/sigil-defaults.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/sigil-defaults.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/sigil-defaults.properties (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/sigil-defaults.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,4 @@
+# sigil-defaults.properties
+
+package;org.apache.commons.cli: [1.1,1.2)
+package;org.apache.commons.collections: [3.0,4.0)

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/build.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/build.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/build.properties (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/build.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,21 @@
+#	 ***************************************************************
+#	 * Licensed to the Apache Software Foundation (ASF) under one
+#	 * or more contributor license agreements.  See the NOTICE file
+#	 * distributed with this work for additional information
+#	 * regarding copyright ownership.  The ASF licenses this file
+#	 * to you under the Apache License, Version 2.0 (the
+#	 * "License"); you may not use this file except in compliance
+#	 * with the License.  You may obtain a copy of the License at
+#	 * 
+#	 *   http://www.apache.org/licenses/LICENSE-2.0
+#	 * 
+#	 * Unless required by applicable law or agreed to in writing,
+#	 * software distributed under the License is distributed on an
+#	 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#	 * KIND, either express or implied.  See the License for the
+#	 * specific language governing permissions and limitations
+#	 * under the License.
+#	 ***************************************************************
+projects.dir = ${basedir}/..
+wkspace.dir = ${projects.dir}/..
+common.dir = ${wkspace.dir}/common

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/build.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/build.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/build.xml (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/build.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0">
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+    http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project name="size" default="compile">
+	<property file="build.properties"/>
+	
+	<import file="${common.dir}/common.xml"/>
+</project>

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/ivy.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/ivy.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/ivy.xml (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/ivy.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+    http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<ivy-module version="1.0">
+    <info 
+        organisation="org.apache.ivy.example"
+        module="size"
+        status="integration"/>
+    <dependencies>
+      <dependency name="version" rev="latest.integration" conf="default" />
+      <dependency name="list" rev="latest.integration" conf="default->core" />
+    </dependencies>
+</ivy-module>

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/sigil.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/sigil.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/sigil.properties (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/sigil.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,8 @@
+
+-bundles: size
+
+-exports: size
+
+-imports:\
+  list, \
+  version

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/src/size/FileSize.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/src/size/FileSize.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/src/size/FileSize.java (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/size/src/size/FileSize.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package size;
+
+import version.Version;
+import java.util.Collection;
+import java.util.Iterator;
+import java.io.File;
+
+public class FileSize {
+  static {
+    Version.register("size");
+  }
+
+  public static long totalSize(File dir) {
+    return totalSize(list.ListFile.list(dir));
+  }
+  
+  public static long totalSize(Collection files) {
+    long total = 0;
+    for (Iterator it = files.iterator(); it.hasNext(); ) {
+      File f = (File)it.next();
+      total += f.length();
+    }
+    return total;
+  }  
+}

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.properties (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,21 @@
+#	 ***************************************************************
+#	 * Licensed to the Apache Software Foundation (ASF) under one
+#	 * or more contributor license agreements.  See the NOTICE file
+#	 * distributed with this work for additional information
+#	 * regarding copyright ownership.  The ASF licenses this file
+#	 * to you under the Apache License, Version 2.0 (the
+#	 * "License"); you may not use this file except in compliance
+#	 * with the License.  You may obtain a copy of the License at
+#	 * 
+#	 *   http://www.apache.org/licenses/LICENSE-2.0
+#	 * 
+#	 * Unless required by applicable law or agreed to in writing,
+#	 * software distributed under the License is distributed on an
+#	 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#	 * KIND, either express or implied.  See the License for the
+#	 * specific language governing permissions and limitations
+#	 * under the License.
+#	 ***************************************************************
+projects.dir = ${basedir}/..
+wkspace.dir = ${projects.dir}/..
+common.dir = ${wkspace.dir}/common

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.xml (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0">
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+    http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project name="sizewhere" default="compile">
+	<property file="build.properties"/>
+	
+	<import file="${common.dir}/common.xml"/>
+</project>

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/ivy.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/ivy.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/ivy.xml (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/ivy.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+    http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<ivy-module version="1.0">
+    <info 
+        organisation="org.apache.ivy.example"
+        module="sizewhere"
+        status="integration"/>
+    <configurations>
+      <conf name="core"/>
+      <conf name="standalone" extends="core"/>
+    </configurations>
+    <publications>
+      <artifact name="sizewhere" type="jar" conf="core" />
+    </publications>
+    <dependencies>
+      <dependency name="version" rev="latest.integration" conf="core->default" />
+      <dependency name="size" rev="latest.integration" conf="core->default" />
+      <dependency name="find" rev="latest.integration" conf="core" />
+      <dependency org="commons-cli" name="commons-cli" rev="1.0" conf="standalone->default" />
+    </dependencies>
+</ivy-module>

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/sigil.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/sigil.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/sigil.properties (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/sigil.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,10 @@
+
+-bundles: sizewhere
+
+-exports: sizewhere
+
+-imports:\
+  find, \
+  size, \
+  version, \
+  org.apache.commons.cli

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/Main.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/Main.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/Main.java (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/Main.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sizewhere;
+
+import java.io.File;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+public class Main {
+    private static Options getOptions() {
+        Option dir = OptionBuilder.withArgName( "dir" )
+            .hasArg()
+            .withDescription(  "give total size of files in given dir" )
+            .create( "dir" );
+        Option name = OptionBuilder.withArgName( "name" )
+            .hasArg()
+            .withDescription(  "give total size of files with given name" )
+            .create( "name" );
+        Options options = new Options();
+
+        options.addOption(dir);
+        options.addOption(name);
+        
+        return options;
+    }
+    
+    public static void main(String[] args) throws Exception {
+      Options options = getOptions();
+      try {
+        
+        CommandLineParser parser = new GnuParser();
+
+        CommandLine line = parser.parse( options, args );
+        File dir = new File(line.getOptionValue("dir", "."));
+        String name = line.getOptionValue("name", "jar");
+        System.out.println("total size of files in "+dir+" containing "+name+": "+SizeWhere.totalSize(dir, name));
+      } catch( ParseException exp ) {
+          // oops, something went wrong
+          System.err.println( "Parsing failed.  Reason: " + exp.getMessage() );
+          
+        HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp( "sizewhere", options );
+      }        
+    }
+            
+}

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sizewhere;
+
+import version.Version;
+import size.FileSize;
+import find.FindFile;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.io.File;
+
+public class SizeWhere {
+  static {
+    Version.register("sizewhere");
+  }
+  
+  public static long totalSize(File dir, String name) {
+    return FileSize.totalSize(FindFile.find(dir, name));
+  }
+}

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/build.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/build.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/build.properties (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/build.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,21 @@
+#	 ***************************************************************
+#	 * Licensed to the Apache Software Foundation (ASF) under one
+#	 * or more contributor license agreements.  See the NOTICE file
+#	 * distributed with this work for additional information
+#	 * regarding copyright ownership.  The ASF licenses this file
+#	 * to you under the Apache License, Version 2.0 (the
+#	 * "License"); you may not use this file except in compliance
+#	 * with the License.  You may obtain a copy of the License at
+#	 * 
+#	 *   http://www.apache.org/licenses/LICENSE-2.0
+#	 * 
+#	 * Unless required by applicable law or agreed to in writing,
+#	 * software distributed under the License is distributed on an
+#	 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#	 * KIND, either express or implied.  See the License for the
+#	 * specific language governing permissions and limitations
+#	 * under the License.
+#	 ***************************************************************
+projects.dir = ${basedir}/..
+wkspace.dir = ${projects.dir}/..
+common.dir = ${wkspace.dir}/common

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/build.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/build.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/build.xml (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/build.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0">
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+    http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project name="version" default="compile">
+	<property file="build.properties"/>
+	
+	<import file="${common.dir}/common.xml"/>
+</project>

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/ivy.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/ivy.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/ivy.xml (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/ivy.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+    http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<ivy-module version="1.0">
+    <info 
+        organisation="org.apache.ivy.example"
+        module="version"
+        status="integration"/>
+</ivy-module>

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/sigil.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/sigil.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/sigil.properties (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/sigil.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,4 @@
+
+-bundles: version
+
+-exports: version

Added: felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/src/version/Version.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/src/version/Version.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/src/version/Version.java (added)
+++ felix/trunk/sigil/bld-ivy/example/multi-project/projects/version/src/version/Version.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package version;
+
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+
+public class Version {
+    static {
+        versions = new HashMap();
+        register("version");
+    }
+  
+    private static Map versions;
+  
+    public static void register(String module) {
+        try {
+            InputStream moduleVersion = Version.class.getResourceAsStream("/"+module+".properties");
+            Properties props = new Properties();
+            props.load(moduleVersion);
+            String version = (String)props.get("version");
+            versions.put(module, version);
+            System.out.println("--- using "+module+" v"+version);
+        } catch (Exception ex) {
+            System.err.println("an error occured while registering "+module+": "+ex.getMessage());
+            ex.printStackTrace();
+        }
+    }
+}

Added: felix/trunk/sigil/bld-ivy/sigil-ivy-plugin.bnd
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/sigil-ivy-plugin.bnd?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/sigil-ivy-plugin.bnd (added)
+++ felix/trunk/sigil/bld-ivy/sigil-ivy-plugin.bnd Mon Jul 13 13:25:46 2009
@@ -0,0 +1,23 @@
+# sigil-ivy-plugin.jar
+
+Bundle-DocURL: http://sigil.codecauldron.org
+Bundle-Vendor: Paremus Limited
+Bundle-Version: ${version}
+
+# we depend on bndlib, but don't want to embed it,
+# in case other tasks want a different version.
+# So just add Class-Path to the manifest, so we load bndlib.jar
+# if it's in the same directory as the sigil-ivy-plugin.
+Class-Path: bndlib.jar
+
+# embed other dependencies directly in the plugin
+Private-Package: \
+  org.cauldron.*, \
+  profiles.*, \
+  org.eclipse.core.runtime, \
+  org.osgi.framework
+
+-removeheaders: TODAY, DSTAMP, TSTAMP
+-pedantic: true
+
+# end

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleInfoTask.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleInfoTask.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleInfoTask.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleInfoTask.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ant;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class BundleInfoTask extends Task {
+	private File bundle;
+	private String header;
+	private String property;
+	private String defaultValue;
+	
+	@Override
+	public void execute() throws BuildException {
+		if (bundle == null)
+			throw new BuildException("missing attribute: bundle");
+		if (header == null)
+			throw new BuildException("missing attribute: header");
+		
+		try {
+			JarFile jar = new JarFile(bundle);
+			Manifest mf = jar.getManifest();
+			String value = mf.getMainAttributes().getValue(header);
+			if ( property == null ) {
+				log(header + "=" + value);
+			}
+			else {
+			    if ("Bundle-SymbolicName".equals(header) && value != null) {
+			        // remove singleton flag
+			        int semi = value.indexOf(';');
+			        if (semi > 0)
+			            value = value.substring(0, semi);
+			    }
+				if ( value == null ) {
+					value = defaultValue;
+				}
+				if ( value != null ) {
+					getProject().setNewProperty(property, value);
+				}
+			}
+		} catch (IOException e) {
+			throw new BuildException( "Failed to access bundle", e);
+		}
+	}
+	
+	public void setBundle(String bundle) {
+		this.bundle = new File( bundle );
+	}
+	
+	public void setHeader(String header) {
+		this.header = header;
+	}
+	
+	public void setProperty(String property) {
+		this.property = property;
+	}
+	
+	public void setDefaultValue(String defaultValue) {
+		this.defaultValue = defaultValue;
+	}
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleTask.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleTask.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleTask.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleTask.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ant;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
+import org.cauldron.bld.bnd.BundleBuilder;
+import org.cauldron.bld.config.BldFactory;
+import org.cauldron.bld.config.IBldProject;
+import org.cauldron.bld.config.IBldProject.IBldBundle;
+
+public class BundleTask extends Task {
+	private File[] classpath;
+	private String destPattern;
+	private boolean force;
+	private String property;
+	private String sigilFile;
+
+	@Override
+	public void execute() throws BuildException {
+		if (classpath == null)
+			throw new BuildException("missing: attribute: classpathref");
+		if (destPattern == null)
+			throw new BuildException("missing attribute: destpattern");
+		
+		IBldProject project;
+
+		try {
+			project = BldFactory.getProject(getSigilFileURI());
+
+		} catch (IOException e) {
+			throw new BuildException("failed to get project file: " + e);
+		}
+		
+		Properties env = new Properties();
+		@SuppressWarnings("unchecked") Hashtable<String, String> properties = getProject().getProperties();
+		for (String key : properties.keySet()) {
+			if (key.matches("^[a-z].*")) {    // avoid props starting with Uppercase - bnd adds them to manifest
+				env.setProperty(key, properties.get(key));
+			}
+		}
+		
+		BundleBuilder bb = new BundleBuilder(project, classpath, destPattern, env);
+		boolean anyModified = false;
+
+		for (IBldBundle bundle : project.getBundles()) {
+			String id = bundle.getId();
+			log("creating bundle: " + id);
+			int nWarn = 0;
+			int nErr = 0;
+			String msg = "";
+			
+			try {
+				boolean modified = (bb.createBundle(bundle, force, new BundleBuilder.Log() {
+					public void warn(String msg) {
+						log(msg, Project.MSG_WARN);
+					}
+					public void verbose(String msg) {
+						log(msg, Project.MSG_VERBOSE);
+					}
+				}));
+				nWarn = bb.warnings().size();
+				if (modified) {
+					anyModified = true;
+				} else {
+					msg = " (not modified)";
+				}
+			} catch (Exception e) {
+				List<String> errors = bb.errors();
+				if (errors != null) {
+    				nErr = errors.size();
+    				for (String err : errors) {
+    					log(err, Project.MSG_ERR);
+    				}
+				}
+				throw new BuildException("failed to create: " + id + ": " + e, e);
+			} finally {
+				log(id + ": " + count(nErr, "error") + ", " + count(nWarn, "warning") + msg);
+			}
+		}
+		
+		if (anyModified && property != null) {
+			getProject().setProperty(property, "true");
+		}
+	}
+	
+	private URI getSigilFileURI() {
+		File file = sigilFile == null ? new File(getProject().getBaseDir(), IBldProject.PROJECT_FILE) : new File(sigilFile);
+		if ( !file.isFile() ) {
+			throw new BuildException( "File not found " + file.getAbsolutePath() );
+		}
+		return file.toURI();
+	}
+
+	private String count(int count, String msg) {
+		return count + " " + msg + (count == 1 ? "" : "s");
+	}
+
+	public void setDestpattern(String pattern) {
+		this.destPattern = pattern;
+	}
+	
+	public void setForce(String force) {
+		this.force = Boolean.parseBoolean(force);
+	}
+	
+	public void setProperty(String property) {
+		this.property = property;
+	}
+
+	public void setClasspathref(String value) {
+		Path p = (Path) getProject().getReference(value);
+		if (p == null) {
+			throw new BuildException(value + "is not a path reference.");
+		}
+
+		String[] paths = p.list();
+		classpath = new File[paths.length];
+		for (int i = 0; i < paths.length; ++i) {
+			classpath[i] = new File(paths[i]);
+		}
+	}
+
+	public void setSigilFile(String sigilFile) {
+		this.sigilFile = sigilFile;
+	}
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldRepositoryManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldRepositoryManager.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldRepositoryManager.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldRepositoryManager.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ivy;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.cauldron.bld.config.IRepositoryConfig;
+import org.cauldron.sigil.repository.AbstractRepositoryManager;
+import org.cauldron.sigil.repository.IBundleRepository;
+import org.cauldron.sigil.repository.IRepositoryProvider;
+
+public class BldRepositoryManager extends AbstractRepositoryManager {
+	private static Map<String, String> aliases = new HashMap<String, String>();
+
+	static {
+		aliases.put("filesystem", "org.cauldron.bld.core.repository.FileSystemRepositoryProvider");
+		aliases.put("obr", "org.cauldron.bld.obr.OBRRepositoryProvider");
+		aliases.put("project", "org.cauldron.bld.ivy.ProjectRepositoryProvider");
+		aliases.put("system", "org.cauldron.bld.core.repository.SystemRepositoryProvider");
+	};
+
+	private Map<String, Properties> repos;
+
+	public BldRepositoryManager(Map<String, Properties> repos) {
+		this.repos = repos;
+	}
+
+	@Override
+	protected void loadRepositories() {
+		for (String name : repos.keySet()) {
+			Properties repo = repos.get(name);
+
+			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");
+				
+				if (!repo.containsKey("index")) {
+    				// index is created as copy of url
+    				File indexFile = new File(System.getProperty("java.io.tmpdir"), "obr-index-" + name);
+    				indexFile.deleteOnExit();
+    				repo.setProperty("index", indexFile.getAbsolutePath());
+				}
+			}
+
+			int level = Integer.parseInt(repo.getProperty(IRepositoryConfig.REPOSITORY_LEVEL,
+					IBundleRepository.NORMAL_PRIORITY + ""));
+
+			try {
+				IRepositoryProvider instance = (IRepositoryProvider) (Class.forName(provider).newInstance());
+				IBundleRepository repository = instance.createRepository(name, repo);
+				addRepository(repository, level);
+				Log.verbose("added repository: " + repository);
+			} catch (Exception e) {
+				throw new Error("createRepository() failed: " + repo + " : " + e, e);
+			}
+		}
+	}
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldResolver.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldResolver.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldResolver.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ivy;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.cauldron.bld.core.BldCore;
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.repository.IResolution;
+import org.cauldron.sigil.repository.IResolutionMonitor;
+import org.cauldron.sigil.repository.ResolutionConfig;
+import org.cauldron.sigil.repository.ResolutionException;
+
+public class BldResolver implements IBldResolver {
+	private Map<String, Properties> repos;
+	private BldRepositoryManager manager;
+	
+	static {
+		try {
+			BldCore.init();
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	};
+	
+	public BldResolver(Map<String,Properties> repos) {
+		this.repos = repos;
+	}
+
+	public IResolution resolve(IModelElement element, boolean transitive) {
+		int options = ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INCLUDE_OPTIONAL;
+		if (transitive) options |= ResolutionConfig.INCLUDE_DEPENDENTS;
+		
+		ResolutionConfig config = new ResolutionConfig(options);
+		try {
+			return resolve(element, config);
+		} catch (ResolutionException e) {
+			throw new IllegalStateException("eek! this shouldn't happen when ignoreErrors=true", e);
+		}
+	}
+		
+	public IResolution resolveOrFail(IModelElement element, boolean transitive) throws ResolutionException {
+		int options = 0;
+		if ( transitive ) options |= ResolutionConfig.INCLUDE_DEPENDENTS;
+		ResolutionConfig config = new ResolutionConfig(options);
+		return resolve(element, config);
+	}
+	
+	private IResolution resolve(IModelElement element, ResolutionConfig config) throws ResolutionException {
+		if (manager == null) {
+			manager = new BldRepositoryManager(repos);
+		}
+
+		IResolutionMonitor nullMonitor = new IResolutionMonitor() {
+			public void endResolution(IModelElement requirement, ISigilBundle sigilBundle) {
+			}
+
+			public boolean isCanceled() {
+				return false;
+			}
+
+			public void startResolution(IModelElement requirement) {
+			}
+		};
+
+		return manager.getBundleResolver().resolve(element, config, nullMonitor);
+	}
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/FindUtil.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/FindUtil.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/FindUtil.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/FindUtil.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.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 {
+		int star = pattern.indexOf("*");
+		if (star == -1) {
+			throw new IOException("pattern doesn't contain '*': " + pattern);
+		}
+		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[] patterns = regex.split("/");
+		
+		ArrayList<File> list = new ArrayList<File>();
+		File root = new File(pattern.substring(0, slash));
+		
+		if (root.isDirectory()) {
+    		findFiles(root, 0, patterns, list);
+		} else {
+			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) {
+		final String filePattern = patterns[patterns.length-1];
+		final String dirPattern;
+		
+		if (level < patterns.length-1) {
+			dirPattern = patterns[level];
+		} else {
+			dirPattern = "/";    // impossible to match marker
+		}
+		
+		final boolean stillWild;
+		if ((level > 0) && (level < patterns.length) && patterns[level-1].endsWith(WILD_ANY)) {
+			stillWild = true;
+		} else {
+			stillWild = false;
+		}
+		
+		for (File path : dir.listFiles(new FileFilter() {
+			public boolean accept(File pathname) {
+				String name = pathname.getName();
+				if (pathname.isDirectory()) {
+					return name.matches(dirPattern) || (stillWild && name.matches(WILD_ANY));
+				} else if (dirPattern.equals("/") || dirPattern.equals(WILD_ANY)) {
+					return name.matches(filePattern);
+				} else {
+					return false;
+				}
+			}
+		})) {
+			if (path.isDirectory()) {
+				int inc = path.getName().matches(dirPattern) ? 1 : 0;
+				findFiles(path, level + inc, patterns, list);
+			} else {
+				list.add(path);
+			}
+		}
+	}
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/IBldResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/IBldResolver.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/IBldResolver.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/IBldResolver.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ivy;
+
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.repository.IResolution;
+import org.cauldron.sigil.repository.ResolutionException;
+
+public interface IBldResolver {
+	IResolution resolveOrFail(IModelElement element, boolean transitive) throws ResolutionException;
+	IResolution resolve(IModelElement element, boolean transitive);
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/Log.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/Log.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/Log.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/Log.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ivy;
+
+import org.apache.ivy.util.Message;
+
+// ensure common prefix to all sigil messages
+public class Log {
+	public static final String PREFIX = "Sigil: ";
+	
+	private static final boolean highlight = false;
+	
+	public static void error(String msg) {
+		if (highlight)
+    		Message.deprecated(PREFIX + "[error] " + msg);
+		Message.error(PREFIX + msg);
+	}
+
+	public static void warn(String msg) {
+		if (highlight)
+    		Message.deprecated(PREFIX + "[warn] " + msg);
+		else
+    		Message.warn(PREFIX + msg);
+	}
+	
+	public static void info(String msg) {
+		if (highlight)
+    		Message.deprecated(PREFIX + "[info] " + msg);
+		else
+    		Message.info(PREFIX + msg);
+	}
+
+	public static void verbose(String msg) {
+		Message.verbose(PREFIX + "[verbose] " + msg);
+	}
+	
+	public static void debug(String msg) {
+		if (highlight)
+    		Message.deprecated(PREFIX + "[debug] " + msg);
+		else
+    		Message.debug(PREFIX + msg);
+	}
+
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepository.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepository.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepository.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,292 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ivy;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.cauldron.bld.config.BldFactory;
+import org.cauldron.bld.config.IBldProject;
+import org.cauldron.bld.config.IBldProject.IBldBundle;
+import org.cauldron.bld.core.internal.model.eclipse.SigilBundle;
+import org.cauldron.bld.core.internal.model.osgi.BundleModelElement;
+import org.cauldron.bld.core.licence.ILicensePolicy;
+import org.cauldron.sigil.model.common.VersionRange;
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.model.osgi.IBundleModelElement;
+import org.cauldron.sigil.model.osgi.IPackageExport;
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.osgi.IRequiredBundle;
+import org.cauldron.sigil.repository.AbstractBundleRepository;
+import org.cauldron.sigil.repository.IRepositoryVisitor;
+
+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) {
+        super(id);
+        this.projectFilePattern = projectFilePattern.replaceAll("\\[sigilproject\\]",
+                IBldProject.PROJECT_FILE);
+    }
+
+    @Override
+    public void accept(IRepositoryVisitor visitor, int options) {
+        for (ISigilBundle b : getBundles()) {
+            if (!visitor.visit(b)) {
+                break;
+            }
+        }
+    }
+
+    // override to provide fuzzy matching for wild-card exports.
+    @Override
+    public Collection<ISigilBundle> findAllProviders(final IPackageImport pi, int options) {
+        return findProviders(pi, options, false);
+    }
+
+    @Override
+    public ISigilBundle findProvider(IPackageImport pi, int options) {
+        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) {
+        ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
+        ILicensePolicy policy = findPolicy(pi);
+        String name = pi.getPackageName();
+        VersionRange versions = pi.getVersions();
+
+        // find exact match(es)
+        for (ISigilBundle bundle : getBundles()) {
+            if (policy.accept(bundle)) {
+                for (IPackageExport exp : bundle.getBundleInfo().getExports()) {
+                    if (name.equals(exp.getPackageName())
+                            && versions.contains(exp.getVersion())) {
+                        found.add(bundle);
+                        if (findFirst)
+                            return found;
+                    }
+                }
+            }
+        }
+
+        if (!found.isEmpty())
+            return found;
+
+        // find best fuzzy match
+        ISigilBundle fuzzyMatch = null;
+        int fuzzyLen = 0;
+
+        for (ISigilBundle bundle : getWildBundles()) {
+            if (policy.accept(bundle)) {
+                for (IPackageExport exp : bundle.getBundleInfo().getExports()) {
+                    String export = exp.getPackageName();
+                    if (export.endsWith("*")) {
+                        String export1 = export.substring(0, export.length() - 1);
+                        if ((name.startsWith(export1) || export1.equals(name + "."))
+                                && versions.contains(exp.getVersion())) {
+                            if (export1.length() > fuzzyLen) {
+                                fuzzyLen = export1.length();
+                                fuzzyMatch = bundle;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (fuzzyMatch != null)
+            found.add(fuzzyMatch);
+
+        return found;
+    }
+
+    private synchronized void init() {
+        System.out.println("Sigil: loading Project Repository: " + projectFilePattern);
+
+        ArrayList<File> projects = new ArrayList<File>();
+
+        for (String pattern : projectFilePattern.split("\\s+")) {
+            try {
+                Collection<File> files = FindUtil.findFiles(pattern);
+                if (files.isEmpty()) {
+                    Log.warn("ProjectRepository: no projects match: " + pattern);
+                } else {
+                    projects.addAll(files);
+                }
+            } catch (IOException e) {
+                // pattern root dir does not exist
+                Log.error("ProjectRepository: " + pattern + ": " + e.getMessage());
+            }
+        }
+
+        if (projects.isEmpty()) {
+            throw new IllegalArgumentException(
+                    "ProjectRepository: no projects found using pattern: "
+                            + projectFilePattern);
+        }
+
+        bundles = new ArrayList<ISigilBundle>();
+
+        for (File proj : projects) {
+            try {
+                addBundles(proj, bundles);
+            } catch (IOException e) {
+                Log.warn("Skipping project: " + proj + ": " + e.getMessage());
+            } catch (ParseException e) {
+                Log.warn("Skipping project: " + proj + ": " + e.getMessage());
+            }
+        }
+    }
+
+    private List<ISigilBundle> getBundles() {
+        if (bundles == null) {
+            init();
+        }
+        return bundles;
+    }
+
+    private List<ISigilBundle> getWildBundles() {
+        if (wildBundles == null) {
+            wildBundles = new ArrayList<ISigilBundle>();
+            for (ISigilBundle bundle : getBundles()) {
+                for (IPackageExport exp : bundle.getBundleInfo().getExports()) {
+                    String export = exp.getPackageName();
+                    if (export.endsWith("*")) {
+                        wildBundles.add(bundle);
+                        break;
+                    }
+                }
+            }
+        }
+        return wildBundles;
+    }
+
+    public void refresh() {
+        bundles = null;
+        wildBundles = null;
+        notifyChange();
+    }
+
+    private void addBundles(File file, List<ISigilBundle> list) throws IOException,
+            ParseException {
+        URI uri = file.getCanonicalFile().toURI();
+        IBldProject project = BldFactory.getProject(uri);
+
+        for (IBldBundle bb : project.getBundles()) {
+            IBundleModelElement info = new BundleModelElement();
+
+            for (IPackageExport pexport : bb.getExports()) {
+                info.addExport(pexport);
+            }
+
+            for (IPackageImport import1 : bb.getImports()) {
+                IPackageImport clone = (IPackageImport) import1.clone();
+                clone.setParent(null);
+                info.addImport(clone);
+            }
+
+            for (IRequiredBundle require : bb.getRequires()) {
+                IRequiredBundle clone = (IRequiredBundle) require.clone();
+                clone.setParent(null);
+                info.addRequiredBundle(clone);
+            }
+
+            info.setSymbolicName(bb.getSymbolicName());
+
+            Version version = new Version(bb.getVersion());
+            info.setVersion(version);
+
+            ProjectBundle pb = new ProjectBundle();
+            pb.setBundleInfo(info);
+            pb.setId(bb.getId());
+
+            ModuleDescriptor md = SigilParser.instance().parseDescriptor(uri.toURL());
+
+            ModuleRevisionId mrid = md.getModuleRevisionId();
+            pb.setModule(mrid.getName());
+            pb.setOrg(mrid.getOrganisation());
+            // XXX: should revision be configurable?
+            pb.setRevision("latest." + md.getStatus());
+
+            list.add(pb);
+            Log.debug("ProjectRepository: added " + pb);
+            Log.debug("ProjectRepository: exports " + bb.getExports());
+        }
+    }
+
+    public static class ProjectBundle extends SigilBundle {
+        private String id;
+        private String module;
+        private String org;
+        private String revision;
+
+        @Override
+        public String toString() {
+            return "ProjectBundle[" + org + "@" + module + (id == null ? "" : "$" + id)
+                    + "#" + revision + "]";
+        }
+
+        public String getModule() {
+            return module;
+        }
+
+        public void setModule(String module) {
+            this.module = module;
+        }
+
+        public String getId() {
+            return id;
+        }
+
+        public void setId(String id) {
+            this.id = id;
+        }
+
+        public String getRevision() {
+            return revision;
+        }
+
+        public void setRevision(String rev) {
+            this.revision = rev;
+        }
+
+        public String getOrg() {
+            return org;
+        }
+
+        public void setOrg(String org) {
+            this.org = org;
+        }
+    }
+
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepositoryProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepositoryProvider.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepositoryProvider.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepositoryProvider.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ivy;
+
+import java.util.HashMap;
+import java.util.Properties;
+
+import org.cauldron.sigil.repository.IBundleRepository;
+import org.cauldron.sigil.repository.IRepositoryProvider;
+import org.cauldron.sigil.repository.RepositoryException;
+
+public class ProjectRepositoryProvider implements IRepositoryProvider{
+	private static HashMap<String, ProjectRepository> cache = new HashMap<String, ProjectRepository>();
+	
+	public IBundleRepository createRepository(String id, Properties properties) throws RepositoryException {
+		ProjectRepository repository = cache.get(id);
+		
+		if (repository == null) {
+    		String pattern = properties.getProperty("pattern");
+    		if (pattern == null) {
+    		    throw new RepositoryException("property 'pattern' not specified.");
+    		}
+            repository = new ProjectRepository(id, pattern);
+            cache.put(id, repository);
+		}
+		
+        return repository;
+    }
+}

Added: felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilParser.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilParser.java (added)
+++ felix/trunk/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilParser.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,587 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.bld.ivy;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import org.apache.ivy.Ivy;
+import org.apache.ivy.core.IvyContext;
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
+import org.apache.ivy.plugins.parser.ParserSettings;
+import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
+import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorWriter;
+import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.repository.file.FileResource;
+import org.apache.ivy.plugins.repository.url.URLResource;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.cauldron.bld.config.BldFactory;
+import org.cauldron.bld.config.IBldProject;
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.model.common.VersionRange;
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.model.osgi.IBundleModelElement;
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.osgi.IRequiredBundle;
+import org.cauldron.sigil.repository.IResolution;
+
+public class SigilParser implements ModuleDescriptorParser {
+
+	private static DelegateParser instance;
+
+	// used by ProjectRepository
+    static DelegateParser instance() {
+		if (instance == null)
+			throw new IllegalStateException("SigilParser is not instantiated.");
+		return instance;
+	}
+
+	public SigilParser() {
+		if (instance == null) {
+			instance = new DelegateParser();
+		}
+	}
+	
+	/**
+	 * In IvyDE, IvyContext is not available, so we can't find the SigilResolver.
+	 * This allows us to construct one.
+	 * @deprecated temporary to support IvyDE
+	 */
+	public void setConfig(String config) {
+		instance.config = config;
+	}
+
+	/**
+	 * sets delegate parser.
+	 * If not set, we delegate to the default Ivy parser.
+	 * @param type name returned by desired parser's getType() method.
+	 */
+	public void setDelegateType(String type) {
+		for (ModuleDescriptorParser parser : ModuleDescriptorParserRegistry.getInstance().getParsers()) {
+			if (parser.getType().equals(type)) {
+				instance.delegate = parser;
+				break;
+			}
+		}
+
+		if (instance.delegate == null) {
+			throw new IllegalArgumentException("Can't find parser delegateType=" + type);
+		}
+	}
+
+	/**
+	 * sets default file name the delegate parser accepts.
+	 * If not set, defaults to "ivy.xml".
+	 * @param name
+	 */
+	public void setDelegateFile(String name) {
+		instance.ivyFile = name;
+	}
+
+	/**
+	 * sets the dependencies to keep from the delegate parser.
+	 * If not set, all existing dependencies are dropped.
+	 * @param regex pattern matching dependency names to keep.
+	 */
+	public void setKeepDependencies(String regex) {
+		instance.keepDependencyPattern = Pattern.compile(regex);
+	}
+	
+	/**
+	 * reduce level of info logging.
+	 * @param quiet
+	 */
+	public void setQuiet(String quiet) {
+		instance.quiet = Boolean.parseBoolean(quiet);
+	}
+
+	/**
+	 * sets the SigilResolver we use.
+	 * If not set, we use the first SigilResolver we find.
+	 * @param name
+	 */
+	public void setResolver(String name) {
+		instance.resolverName = name;
+	}
+
+	/**
+	 * adds override element: <override name="X" pattern="Y" replace="Z"/>. Overrides
+	 * Ivy variables using a pattern substitution on the resource directory path.
+	 * 
+	 * @deprecated
+	 * This is only needed when a delegate parser expects Ant variables to be set
+	 * during the ivy:buildlist task (or the ProjectRepository initialisation),
+	 * which they are not. The delegate parser should really be fixed, as otherwise
+	 * the ivy:buildlist task won't work without this workaround.
+	 */
+	// e.g. <override name="ant.project.name" pattern=".*/([^/]+)/([^/]+)$" replace="$1-$2"/>
+	public void addConfiguredOverride(Map<String, String> var) {
+		final String name = var.get("name");
+		final String regex = var.get("pattern");
+		final String replace = var.get("replace");
+
+		if (name == null || regex == null || replace == null)
+			throw new IllegalArgumentException("override must contain name, pattern and replace attributes.");
+
+		instance.varRegex.put(name, Pattern.compile(regex));
+		instance.varReplace.put(name, replace);
+	}
+
+	// implement ModuleDescriptorParser interface by delegation to singleton instance.
+
+	public boolean accept(Resource res) {
+		return instance.accept(res);
+	}
+
+	public Artifact getMetadataArtifact(ModuleRevisionId mrid, Resource res) {
+		return instance.getMetadataArtifact(mrid, res);
+	}
+
+	public String getType() {
+		return instance.getType();
+	}
+
+	public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL, boolean validate)
+			throws ParseException, IOException {
+		return instance.parseDescriptor(settings, xmlURL, validate);
+	}
+
+	public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL, Resource res, boolean validate)
+			throws ParseException, IOException {
+		return instance.parseDescriptor(settings, xmlURL, res, validate);
+	}
+
+	public void toIvyFile(InputStream source, Resource res, File destFile, ModuleDescriptor md) throws ParseException,
+			IOException {
+		instance.toIvyFile(source, res, destFile, md);
+	}
+
+	/**
+	 * delegating parser.
+	 * (optionally) removes original dependencies and augments with sigil-determined dependencies.
+	 */
+	static class DelegateParser extends XmlModuleDescriptorParser {
+
+		private static final String SIGIL_BUILDLIST = IBldProject.PROJECT_FILE;
+		private static final String KEEP_ALL = ".*";
+		
+		private IBldResolver resolver;
+		private ParserSettings defaultSettings;
+		private Map<String, DefaultModuleDescriptor> rawCache = new HashMap<String, DefaultModuleDescriptor>();
+		private Map<String, DefaultModuleDescriptor> augmentedCache = new HashMap<String, DefaultModuleDescriptor>();
+
+		private HashMap<String, String> varReplace = new HashMap<String, String>();
+		private HashMap<String, Pattern> varRegex = new HashMap<String, Pattern>();
+
+		private ModuleDescriptorParser delegate;
+		private String ivyFile = "ivy.xml";
+		private String resolverName;
+		private Pattern keepDependencyPattern;
+    	private boolean quiet;
+    	private String config;
+
+		@Override
+		public boolean accept(Resource res) {
+			boolean accept = (res instanceof SigilResolver.SigilIvy)
+					|| res.getName().endsWith("/" + SIGIL_BUILDLIST)
+					|| ((instance.getSigilURI(res) != null) &&
+						((instance.delegate != null ? instance.delegate.accept(res) : false) || super.accept(res)));
+			if (accept)
+    			Log.verbose("accepted: " + res);
+			return accept;
+		}
+
+		@Override
+		public void toIvyFile(InputStream source, Resource res, File destFile, ModuleDescriptor md)
+				throws ParseException, IOException {
+			Log.verbose("writing resource: " + res + " toIvyFile: " + destFile);
+			// source allows us to keep layout and comments,
+			// but this doesn't work if source is not ivy.xml.
+			// So just write file directly from descriptor.
+			try {
+				XmlModuleDescriptorWriter.write(md, destFile);
+			} finally {
+				if (source != null)
+					source.close();
+			}
+		}
+		
+		@Override
+		public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL, boolean validate)
+				throws ParseException, IOException {
+			return parseDescriptor(settings, xmlURL, new URLResource(xmlURL), validate);
+		}
+
+		@Override
+		public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL, Resource res, boolean validate)
+				throws ParseException, IOException {
+			String cacheKey = xmlURL.toString() + settings.hashCode();
+			DefaultModuleDescriptor dmd = augmentedCache.get(cacheKey);
+
+			if (dmd == null) {
+				dmd = rawCache.get(cacheKey);
+				if (dmd == null) {
+					dmd = delegateParse(settings, xmlURL, res, validate);
+    			}
+
+				if (!quiet)
+    				Log.info("augmenting module=" + dmd.getModuleRevisionId().getName() +
+						" ant.project.name=" + settings.substitute("${ant.project.name}"));
+				
+				addDependenciesToDescriptor(res, dmd);
+				augmentedCache.put(cacheKey, dmd);
+				
+				Log.verbose("augmented dependencies: " + Arrays.asList(dmd.getDependencies()));
+			}
+
+			return dmd;
+		}
+		
+		// used by ProjectRepository
+		ModuleDescriptor parseDescriptor(URL projectURL) throws ParseException, IOException {
+			if (defaultSettings == null) {
+				Ivy ivy = IvyContext.getContext().peekIvy();
+				if (ivy == null)
+					throw new IllegalStateException("can't get default settings - no ivy context.");
+				defaultSettings = ivy.getSettings();
+			}
+			
+			URL ivyURL = new URL(projectURL, ivyFile);
+			String cacheKey = ivyURL.toString() + defaultSettings.hashCode();
+			DefaultModuleDescriptor dmd = rawCache.get(cacheKey);
+			
+			if (dmd == null) {
+				URLResource res = new URLResource(ivyURL);
+				// Note: this doesn't contain the augmented dependencies, which is OK,
+				// since the ProjectRepository only needs the id and status.
+				dmd = delegateParse(defaultSettings, ivyURL, res, false);
+				rawCache.put(cacheKey, dmd);
+			}
+
+			return dmd;
+		}
+
+		private DefaultModuleDescriptor delegateParse(ParserSettings settings, URL xmlURL, Resource res,
+				boolean validate) throws ParseException, IOException {
+			String resName = res.getName();
+
+			if (resName.endsWith("/" + SIGIL_BUILDLIST)) {
+				String name = resName.substring(0, resName.length() - SIGIL_BUILDLIST.length());
+				res = res.clone(name + ivyFile);
+				xmlURL = new URL(xmlURL, ivyFile);
+			}
+
+			if (settings instanceof IvySettings) {
+				IvySettings ivySettings = (IvySettings) settings;
+				String dir = new File(res.getName()).getParent();
+
+				for (String name : varRegex.keySet()) {
+					Pattern regex = varRegex.get(name);
+					String replace = varReplace.get(name);
+
+					String value = regex.matcher(dir).replaceAll(replace);
+
+					Log.debug("overriding variable " + name + "=" + value);
+					ivySettings.setVariable(name, value);
+				}
+			}
+
+			ModuleDescriptor md = null;
+			if (delegate == null || !delegate.accept(res)) {
+				md = super.parseDescriptor(settings, xmlURL, res, validate);
+			} else {
+				md = delegate.parseDescriptor(settings, xmlURL, res, validate);
+			}
+
+			return mungeDescriptor(md, res);
+		}
+
+		/**
+		 * clones descriptor and removes dependencies, as descriptor MUST have
+		 * 'this' as the parser given to its constructor.
+		 * Only dependency names matched by keepDependencyPattern are kept,
+		 * as we're going to add our own dependencies later.
+		 */
+		private DefaultModuleDescriptor mungeDescriptor(ModuleDescriptor md, Resource res) {
+
+			if ((md instanceof DefaultModuleDescriptor) &&
+					(md.getParser() == this) &&
+					(KEEP_ALL.equals(keepDependencyPattern))) {
+				return (DefaultModuleDescriptor) md;
+			}
+				
+			DefaultModuleDescriptor dmd = new DefaultModuleDescriptor(this, res);
+
+			dmd.setModuleRevisionId(md.getModuleRevisionId());
+			dmd.setPublicationDate(md.getPublicationDate());
+
+			for (Configuration c : md.getConfigurations()) {
+				String conf = c.getName();
+
+				dmd.addConfiguration(c);
+
+				for (Artifact a : md.getArtifacts(conf)) {
+					dmd.addArtifact(conf, a);
+				}
+			}
+
+			if (keepDependencyPattern != null) {
+    			for (DependencyDescriptor dependency : md.getDependencies()) {
+    				String name = dependency.getDependencyId().getName();
+    				if (keepDependencyPattern.matcher(name).matches()) {
+    					dmd.addDependency(dependency);
+    				}
+    			}
+			}
+
+			return dmd;
+		}
+
+		/*
+		 * find URI to Sigil project file. This assumes that it is in the same
+		 * directory as the ivy file.
+		 */
+		private URI getSigilURI(Resource res) {
+			URI uri = null;
+
+			if (res instanceof URLResource) {
+				URL url = ((URLResource) res).getURL();
+				uri = URI.create(url.toString()).resolve(IBldProject.PROJECT_FILE);
+				try {
+					InputStream stream = uri.toURL().openStream(); // check file
+																	// exists
+					stream.close();
+				} catch (IOException e) {
+					uri = null;
+				}
+			} else if (res instanceof FileResource) {
+				uri = ((FileResource) res).getFile().toURI().resolve(IBldProject.PROJECT_FILE);
+				if (!(new File(uri).exists()))
+					uri = null;
+			}
+
+			return uri;
+		}
+
+		/*
+		 * add sigil dependencies to ModuleDescriptor.
+		 */
+		private void addDependenciesToDescriptor(Resource res, DefaultModuleDescriptor md) throws IOException {
+			// FIXME: transitive should be configurable
+			final boolean transitive = true; // ivy default is true
+			final boolean changing = false;
+			final boolean force = false;
+
+			URI uri = getSigilURI(res);
+			if (uri == null)
+				return;
+
+			IBldProject project;
+
+			project = BldFactory.getProject(uri);
+
+			IBundleModelElement requirements = project.getDependencies();
+			Log.verbose("requirements: " + Arrays.asList(requirements.children()));
+
+			// preserve version range for Require-Bundle
+			// XXX: synthesise bundle version range corresponding to package version ranges?
+			HashMap<String, VersionRange> versions = new HashMap<String, VersionRange>();
+			for (IModelElement child : requirements.children()) {
+				if (child instanceof IRequiredBundle) {
+					IRequiredBundle bundle = (IRequiredBundle) child;
+					versions.put(bundle.getSymbolicName(), bundle.getVersions());
+				}
+			}
+
+			IBldResolver resolver = findResolver();
+			if (resolver == null) {
+				// this can happen in IvyDE, but it retries and is OK next time.
+				Log.warn("failed to find resolver - IvyContext not yet available.");
+				return;
+			}
+			
+			IResolution resolution = resolver.resolve(requirements, false);
+			Log.verbose("resolution: " + resolution.getBundles());
+
+			ModuleRevisionId masterMrid = md.getModuleRevisionId();
+			DefaultDependencyDescriptor dd;
+			ModuleRevisionId mrid;
+
+			for (ISigilBundle bundle : resolution.getBundles()) {
+				IBundleModelElement info = bundle.getBundleInfo();
+				String name = info.getSymbolicName();
+
+				if (name == null) {
+					// e.g. SystemProvider with framework=null
+					continue;
+				}
+
+				if (bundle instanceof ProjectRepository.ProjectBundle) {
+					ProjectRepository.ProjectBundle pb = (ProjectRepository.ProjectBundle) bundle;
+					String org = pb.getOrg();
+					if (org == null)
+						org = masterMrid.getOrganisation();
+					String id = pb.getId();
+					String module = pb.getModule();
+					String rev = pb.getRevision();
+
+					mrid = ModuleRevisionId.newInstance(org, module, rev);
+					dd = new SigilDependencyDescriptor(md, mrid, force, changing, transitive);
+
+					if (!id.equals(module)) { // non-default artifact
+						dd.addDependencyArtifact(module,
+								new DefaultDependencyArtifactDescriptor(dd, id, "jar", "jar", null, null));
+					}
+				} else {
+					VersionRange version = versions.get(name);
+					String rev = version != null ? version.toString() : info.getVersion().toString();
+					mrid = ModuleRevisionId.newInstance(SigilResolver.ORG_SIGIL, name, rev);
+					dd = new SigilDependencyDescriptor(md, mrid, force, changing, transitive);
+				}
+
+				int nDeps = 0;
+				boolean foundDefault = false;
+
+				// TODO: make dependency configurations configurable SIGIL-176
+				for (String conf : md.getConfigurationsNames()) {
+					if (conf.equals("default")) {
+						foundDefault = true;
+					} else if (md.getArtifacts(conf).length == 0) {
+						dd.addDependencyConfiguration(conf, conf + "(default)");
+						nDeps++;
+					}
+				}
+
+				if (nDeps > 0) {
+					if (foundDefault)
+						dd.addDependencyConfiguration("default", "default");
+				} else {
+					dd.addDependencyConfiguration("*", "*");    // all configurations
+				}
+
+				md.addDependency(dd);
+			}
+
+			boolean resolved = true;
+			for (IModelElement child : requirements.children()) {
+				ISigilBundle provider = resolution.getProvider(child);
+				if (provider == null) {
+					resolved = false;
+					// this is parse phase, so only log verbose message.
+					// error is produced during resolution phase.
+					Log.verbose("WARN: can't resolve: " + child);
+
+					String name;
+					String version;
+					if (child instanceof IRequiredBundle) {
+						IRequiredBundle rb = (IRequiredBundle) child;
+						name = rb.getSymbolicName();
+						version = rb.getVersions().toString();
+					} else {
+						IPackageImport pi = (IPackageImport) child;
+						name = "import!" + pi.getPackageName();
+						version = pi.getVersions().toString();
+					}
+
+					mrid = ModuleRevisionId.newInstance("!" + SigilResolver.ORG_SIGIL, name, version);
+					dd = new SigilDependencyDescriptor(md, mrid, force, changing, transitive);
+					dd.addDependencyConfiguration("*", "*"); // all
+					// configurations
+					md.addDependency(dd);
+				}
+			}
+
+			if (!resolved) {
+				// Ivy does not show warnings or errors logged from parse phase, until after resolution.
+				// but <buildlist> ant task doesn't do resolution, so errors would be silently ignored.
+				// Hence, we must use Message.info to ensure this failure is seen.
+				if (!quiet)
+    				Log.info("WARN: resolution failed in: " + masterMrid.getName() + ". Use -v for details.");
+			}
+		}
+
+		/*
+		 * find named resolver, or first resolver that implements IBldResolver.
+		 */
+		private IBldResolver findResolver() {
+			if (resolver == null) {
+				Ivy ivy = IvyContext.getContext().peekIvy();
+				if (ivy != null) {
+    				if (resolverName != null) {
+    					DependencyResolver r = ivy.getSettings().getResolver(resolverName);
+    					if (r == null) {
+    						throw new Error("SigilParser: resolver \"" + resolverName + "\" not defined.");
+    					} else if (r instanceof IBldResolver) {
+    						resolver = (IBldResolver) r;
+    					} else {
+    						throw new Error("SigilParser: resolver \"" + resolverName + "\" is not a SigilResolver.");
+    					}
+    				} else {
+    					for (Object r : ivy.getSettings().getResolvers()) {
+    						if (r instanceof IBldResolver) {
+    							resolver = (IBldResolver) r;
+    							break;
+    						}
+    					}
+    				}
+    
+    				if (resolver == null) {
+    					throw new Error("SigilParser: can't find SigilResolver. Check ivysettings.xml.");
+    				}
+				} else if (config != null) {
+					Log.warn("creating duplicate resolver to support IvyDE.");
+					resolver = new SigilResolver();
+					((SigilResolver)resolver).setConfig(config);
+				}
+			}
+			return resolver;
+		}
+	}
+
+}
+
+/*
+ * this is only needed so that we can distinguish sigil-added dependencies from
+ * existing ones.
+ */
+class SigilDependencyDescriptor extends DefaultDependencyDescriptor {
+	public SigilDependencyDescriptor(DefaultModuleDescriptor md, ModuleRevisionId mrid, boolean force,
+			boolean changing, boolean transitive) {
+		super(md, mrid, force, changing, transitive);
+	}
+}