Initial commit of Sigil contribution. (FELIX-1142)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@793581 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/bld-ivy/.classpath b/sigil/bld-ivy/.classpath
new file mode 100644
index 0000000..f03d6f0
--- /dev/null
+++ b/sigil/bld-ivy/.classpath
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.cauldron.bld.core"/>
+ <classpathentry kind="lib" path="lib/runtime/equinox.common.jar"/>
+ <classpathentry kind="lib" path="lib/runtime/osgi.core.jar"/>
+ <classpathentry kind="lib" path="lib/compile/ant.jar"/>
+ <classpathentry kind="lib" path="lib/compile/ivy-2.0.0-rc1.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/sigil/bld-ivy/.project b/sigil/bld-ivy/.project
new file mode 100644
index 0000000..4ccb600
--- /dev/null
+++ b/sigil/bld-ivy/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bld-ivy</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/sigil/bld-ivy/build.xml b/sigil/bld-ivy/build.xml
new file mode 100644
index 0000000..b9f9dbf
--- /dev/null
+++ b/sigil/bld-ivy/build.xml
@@ -0,0 +1,118 @@
+<?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 xmlns:ivy="antlib:org.apache.ivy.ant" name="bld-ivy" default="jar">
+
+ <!-- buildVersion is overridden by Hudson -->
+ <property name="buildVersion" value="0.8.0-dev" />
+ <property name="version" value="${buildVersion}" />
+
+ <property name="name" value="sigil-ivy-plugin" />
+ <property name="name.jar" value="${name}.jar" />
+ <property name="name-version.jar" value="${name}-${version}.jar" />
+
+ <property name="lib.dir" value="${basedir}/lib" />
+ <property name="target.dir" value="${basedir}/target" />
+ <property name="classes.dir" value="${basedir}/target/classes" />
+
+ <property name="java-src.dir" value="${basedir}/src" />
+
+ <property name="sigil-plugins.dir" location="../sigil-builder/target/tmp/eclipse/plugins" />
+ <property name="bnd-plugins.dir" location="../org.cauldron.bld.core/lib" />
+
+ <target name="init" depends="find-plugins">
+
+ <path id="run.classpath">
+ <pathelement location="${classes.dir}" />
+ <pathelement location="${bld-core.jar}" />
+ <pathelement location="${bld-obr.jar}" />
+ <pathelement location="${equinox-common.jar}" />
+ <pathelement location="${osgi-core.jar}" />
+ </path>
+
+ <path id="compile.classpath">
+ <path refid="run.classpath"/>
+ <fileset dir="${lib.dir}/compile">
+ <include name="*.jar" />
+ </fileset>
+ </path>
+
+ </target>
+
+ <target name="mkdirs">
+ <mkdir dir="${target.dir}" />
+ <mkdir dir="${classes.dir}" />
+ </target>
+
+ <target name="find-plugins" depends="mkdirs">
+ <property name="osgi-core.jar" value="${lib.dir}/runtime/osgi.core.jar"/>
+ <property name="equinox-common.jar" value="${lib.dir}/runtime/equinox.common.jar"/>
+
+ <fileset id="bld-core" dir="${sigil-plugins.dir}"
+ includes="org.cauldron.bld.core_*.jar" />
+ <property name="bld-core" refid="bld-core"/>
+ <property name="bld-core.jar" location="${sigil-plugins.dir}/${bld-core}"/>
+
+ <fileset id="bld-obr" dir="${sigil-plugins.dir}"
+ includes="org.cauldron.bld.obr*.jar" />
+ <property name="bld-obr" refid="bld-obr"/>
+ <property name="bld-obr.jar" location="${sigil-plugins.dir}/${bld-obr}"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="${target.dir}" />
+ </target>
+
+ <target name="compile" depends="init">
+ <javac debug="true" debuglevel="source,lines,vars" source="1.5" target="1.5" fork="true" destdir="${classes.dir}" srcdir="${java-src.dir}">
+ <classpath refid="compile.classpath" />
+ </javac>
+ </target>
+
+ <target name="dist" depends="jar">
+ <zip destfile="${target.dir}/sigil-${version}.zip">
+ <zipfileset dir="example" prefix="sigil-${version}/example"
+ excludes="**/build/**, **/lib/**, **/ivy-cache/**, **/repository/**"/>
+ <zipfileset dir="target" prefix="sigil-${version}/lib"
+ includes="${name.jar}, bndlib.jar"/>
+ </zip>
+
+ <copy file="${target.dir}/${name.jar}" tofile="${target.dir}/${name-version.jar}"/>
+ </target>
+
+ <target name="jar" depends="compile, taskdefs">
+ <bnd
+ classpath="${toString:run.classpath}"
+ files="sigil-ivy-plugin.bnd"
+ output="${target.dir}/${name.jar}"
+ eclipse="false"
+ failok="false"
+ exceptions="true" />
+
+ <copy todir="${target.dir}">
+ <fileset dir="${bnd-plugins.dir}" includes="bndlib.jar"/>
+ </copy>
+ </target>
+
+ <target name="taskdefs">
+ <taskdef resource="aQute/bnd/ant/taskdef.properties"
+ classpath="${lib.dir}/ant/bnd-0.0.312.jar"/>
+ </target>
+
+</project>
diff --git a/sigil/bld-ivy/example/dependence/README b/sigil/bld-ivy/example/dependence/README
new file mode 100644
index 0000000..09ecfa8
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/README
@@ -0,0 +1,19 @@
+# http://sigil.codecauldron.org
+
+This example is based on the Ivy Tutorial project dependencies example:
+http://ant.apache.org/ivy/history/latest-milestone/tutorial/dependence.html
+
+Dependencies are resolved using an OBR index for the Spring repository,
+hosted at sigil.codecauldron.org.
+
+1. set ivy.jar location in settings/build.properties
+
+2. build dependee
+$ cd dependee
+$ ant jar
+$ ant publish
+
+3. build depender
+$ cd ../depender
+$ ant
+
diff --git a/sigil/bld-ivy/example/dependence/build.xml b/sigil/bld-ivy/example/dependence/build.xml
new file mode 100644
index 0000000..ccc460d
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/build.xml
@@ -0,0 +1,46 @@
+<?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 default="clean">
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" description="--> clean directories">
+ <delete includeemptydirs="true">
+ <fileset dir="settings">
+ <exclude name="ivysettings.*" />
+ <exclude name="sigil-repos.properties" />
+ </fileset>
+ </delete>
+ <ant dir="dependee" antfile="build.xml" target="clean" inheritall="false" inheritrefs="false" />
+ <ant dir="depender" antfile="build.xml" target="clean" inheritall="false" inheritrefs="false" />
+ </target>
+
+ <!-- =================================
+ target: all
+ ================================= -->
+ <target name="all" depends="clean" description="--> make the whole example of dependency">
+ <ant dir="dependee" antfile="build.xml" target="publish" inheritall="false" inheritrefs="false" />
+ <ant dir="depender" antfile="build.xml" inheritall="false" inheritrefs="false" />
+ <ant dir="dependee" antfile="build.xml" target="publish" inheritall="false" inheritrefs="false" />
+ <ant dir="depender" antfile="build.xml" inheritall="false" inheritrefs="false" />
+ </target>
+
+</project>
diff --git a/sigil/bld-ivy/example/dependence/dependee/build.xml b/sigil/bld-ivy/example/dependence/dependee/build.xml
new file mode 100644
index 0000000..4eab164
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/dependee/build.xml
@@ -0,0 +1,130 @@
+<?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="dependee" default="run" xmlns:ivy="antlib:org.apache.ivy.ant">
+ <!-- some variables used -->
+ <property name="lib.dir" value="${basedir}/lib" />
+ <property name="build.dir" value="${basedir}/build" />
+ <property name="classes.dir" value="${build.dir}/classes" />
+ <property name="src.dir" value="${basedir}/src" />
+
+ <!-- ivy properties used -->
+ <property name="ivy.settings.dir" value="../settings" />
+ <property file="${ivy.settings.dir}/ivysettings.properties" />
+
+ <!-- paths used for compilation and run -->
+ <path id="lib.path.id">
+ <fileset dir="${lib.dir}" />
+ </path>
+ <path id="run.path.id">
+ <path refid="lib.path.id" />
+ <path location="${classes.dir}" />
+ </path>
+
+ <!-- =================================
+ target: init
+ ================================= -->
+ <target name="init">
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant"
+ classpath="${ivy.jar}"/>
+
+ <ivy:settings file="${ivy.settings.dir}/ivysettings.xml" />
+
+ <taskdef name="sigil.bundle"
+ classname="org.cauldron.bld.ant.BundleTask"
+ classpath="${sigil-ivy-plugin.jar}"/>
+ </target>
+
+ <!-- =================================
+ target: resolve
+ ================================= -->
+ <target name="resolve" depends="init"
+ description="--> resolve and retrieve dependencies with ivy">
+ <ivy:retrieve />
+ </target>
+
+ <!-- =================================
+ target: report
+ ================================= -->
+ <target name="report" depends="resolve" description="--> generates a report of dependencies">
+ <ivy:report todir="${build.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: compile
+ ================================= -->
+ <target name="compile" depends="resolve" description="--> description">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" />
+ </target>
+
+ <!-- =================================
+ target: run
+ ================================= -->
+ <target name="run" depends="compile" description="--> compile and run the project">
+ <java classpathref="run.path.id" classname="standalone.Main"/>
+ </target>
+
+ <!-- =================================
+ target: jar
+ ================================= -->
+ <target name="jar" depends="compile" description="--> make a jar file for this project">
+ <propertyfile file="${classes.dir}/version.properties">
+ <entry key="version" type="int" operation="+" default="0" />
+ </propertyfile>
+ <property file="${classes.dir}/version.properties" />
+ <!--
+ <jar destfile="${build.dir}/${ant.project.name}.jar">
+ <fileset dir="${classes.dir}" />
+ </jar>
+ -->
+ <sigil.bundle destpattern="${build.dir}/[id].[ext]"
+ classpathref="run.path.id" />
+ </target>
+
+ <!-- =================================
+ target: publish
+ ================================= -->
+ <target name="publish" depends="jar" description="--> publish this project in the ivy repository">
+ <property name="revision" value="${version}"/>
+ <delete file="${build.dir}/ivy.xml"/>
+ <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
+ resolver="projects"
+ pubrevision="${revision}"
+ status="release"
+ />
+ <echo message="project ${ant.project.name} released with version ${revision}" />
+ </target>
+
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" description="--> clean the project">
+ <delete includeemptydirs="true">
+ <fileset dir="${basedir}">
+ <exclude name="src/**" />
+ <exclude name="build.xml" />
+ <exclude name="ivy.xml" />
+ <exclude name="sigil.properties" />
+ </fileset>
+ </delete>
+ </target>
+</project>
diff --git a/sigil/bld-ivy/example/dependence/dependee/ivy.xml b/sigil/bld-ivy/example/dependence/dependee/ivy.xml
new file mode 100644
index 0000000..631338a
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/dependee/ivy.xml
@@ -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" module="dependee"/>
+ <dependencies>
+ <dependency org="commons-lang" name="commons-lang" rev="2.0"/>
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/example/dependence/dependee/sigil.properties b/sigil/bld-ivy/example/dependence/dependee/sigil.properties
new file mode 100644
index 0000000..619a841
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/dependee/sigil.properties
@@ -0,0 +1,24 @@
+# dependee sigil.properties
+
+version: 1.0.0
+
+-bundles: dependee
+
+-exports: standalone
+
+-imports: \
+ org.apache.commons.lang;version="[2.0.0,2.4.0)", \
+
+# add these to -imports to test the resolution process
+# javax.servlet;version="(2.4,3.0]", \
+# org.apache.log4j;version="[1.2.14,1.3)", \
+# org.apache.commons.logging, \
+
+# this is a require-bundle dependency
+#-requires: \
+# com.springsource.org.apache.commons.lang;version="[2.0.0,2.4.0)", \
+
+-resources: \
+ version.properties
+
+# end
diff --git a/sigil/bld-ivy/example/dependence/dependee/src/standalone/Main.java b/sigil/bld-ivy/example/dependence/dependee/src/standalone/Main.java
new file mode 100644
index 0000000..1b7398c
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/dependee/src/standalone/Main.java
@@ -0,0 +1,66 @@
+/*
+ * 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 standalone;
+
+import java.util.Properties;
+
+import org.apache.commons.lang.WordUtils;
+
+/**
+ * TODO write javadoc
+ */
+public final class Main {
+ /**
+ * Returns the version of the project
+ * @return a string representation of the version, null if the version could not be retreived
+ */
+ public static String getVersion() {
+ Properties p = new Properties();
+ try {
+ p.load(Main.class.getResourceAsStream("/version.properties"));
+ String version = p.getProperty("version");
+ if (version != null) {
+ return String.valueOf(Integer.parseInt(version));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Return the same string with all words capitalized.
+ * @param str the string conatining the words to capitalize
+ * @return null if the string was null, the string with all words capitalized otherwise
+ */
+ public static String capitalizeWords(String str) {
+ System.out.println(" [" + Main.class.getName() + "] capitalizing string \""
+ + str + "\" using " + WordUtils.class.getName());
+ return WordUtils.capitalizeFully(str);
+ }
+ public static void main(String[] args) {
+ String message = "sentence to capitalize";
+ System.out.println("standard message : " + message);
+ System.out.println("capitalized message : " + capitalizeWords(message));
+ }
+
+ private Main() {
+ }
+}
diff --git a/sigil/bld-ivy/example/dependence/depender/build.xml b/sigil/bld-ivy/example/dependence/depender/build.xml
new file mode 100644
index 0000000..f2f9190
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/depender/build.xml
@@ -0,0 +1,110 @@
+<?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="depender" default="run" xmlns:ivy="antlib:org.apache.ivy.ant">
+ <!-- some variables used -->
+ <property name="lib.dir" value="${basedir}/lib" />
+ <property name="build.dir" value="${basedir}/build" />
+ <property name="classes.dir" value="${build.dir}/classes" />
+ <property name="src.dir" value="${basedir}/src" />
+
+ <!-- ivy properties used -->
+ <property name="ivy.settings.dir" value="../settings" />
+ <property file="${ivy.settings.dir}/ivysettings.properties" />
+
+ <!-- paths used for compilation and run -->
+ <path id="lib.path.id">
+ <fileset dir="${lib.dir}" />
+ </path>
+ <path id="run.path.id">
+ <path refid="lib.path.id" />
+ <path location="${classes.dir}" />
+ </path>
+
+ <!-- =================================
+ target: init
+ ================================= -->
+ <target name="init">
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant"
+ classpath="${ivy.jar}"/>
+
+ <ivy:settings file="${ivy.settings.dir}/ivysettings.xml" />
+
+ <taskdef name="sigil.bundle"
+ classname="org.cauldron.bld.ant.BundleTask"
+ classpath="${sigil-ivy-plugin.jar}"/>
+ </target>
+
+
+ <!-- =================================
+ target: resolve
+ ================================= -->
+ <target name="resolve" depends="init"
+ description="--> resolve and retrieve dependencies with ivy">
+ <ivy:retrieve />
+ </target>
+
+ <!-- =================================
+ target: report
+ ================================= -->
+ <target name="report" depends="resolve" description="--> generates a report of dependencies">
+ <ivy:report todir="${build.dir}" dot="true"/>
+ </target>
+
+ <!-- =================================
+ target: gen-graph
+ ================================= -->
+ <target name="gen-graph" depends="report" description="--> generates a graph of dependencies (requires dot in your path - see http://www.graphviz.org/)">
+ <property name="dot.file" value="${build.dir}/apache-depending-default.dot" />
+ <property name="ivygraph.output.file" value="${build.dir}/graph.png" />
+ <exec executable="dot">
+ <arg line="-T png -o ${ivygraph.output.file} ${dot.file}" />
+ </exec>
+ </target>
+
+ <!-- =================================
+ target: compile
+ ================================= -->
+ <target name="compile" depends="resolve" description="--> description">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" />
+ </target>
+
+ <!-- =================================
+ target: run
+ ================================= -->
+ <target name="run" depends="clean, compile" description="--> compile and run the project">
+ <java classpathref="run.path.id" classname="depending.Main"/>
+ </target>
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" description="--> clean the project">
+ <delete includeemptydirs="true">
+ <fileset dir="${basedir}">
+ <exclude name="src/**" />
+ <exclude name="build.xml" />
+ <exclude name="ivy.xml" />
+ <exclude name="sigil.properties" />
+ </fileset>
+ </delete>
+ </target>
+</project>
diff --git a/sigil/bld-ivy/example/dependence/depender/ivy.xml b/sigil/bld-ivy/example/dependence/depender/ivy.xml
new file mode 100644
index 0000000..d8031f3
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/depender/ivy.xml
@@ -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" module="depender"/>
+ <dependencies>
+ <dependency name="dependee" rev="latest.integration" />
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/example/dependence/depender/sigil.properties b/sigil/bld-ivy/example/dependence/depender/sigil.properties
new file mode 100644
index 0000000..e76ec83
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/depender/sigil.properties
@@ -0,0 +1,7 @@
+# depender sigil.properties
+
+-bundles: depender
+
+-imports: standalone
+
+# end
diff --git a/sigil/bld-ivy/example/dependence/depender/src/depending/Main.java b/sigil/bld-ivy/example/dependence/depender/src/depending/Main.java
new file mode 100644
index 0000000..59b0399
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/depender/src/depending/Main.java
@@ -0,0 +1,42 @@
+/*
+ * 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 depending;
+
+/**
+ * TODO write javadoc
+ */
+public final class Main {
+ public static void main(String[] args) {
+ String standaloneVersion = standalone.Main.getVersion();
+ if (standaloneVersion != null) {
+ System.out.println("you are using version " + standaloneVersion
+ + " of class " + standalone.Main.class.getName());
+ } else {
+ System.err.println("failed to get version of " + standalone.Main.class.getName());
+ }
+ String message = "i am " + Main.class.getName()
+ + " and " + standalone.Main.class.getName() + " will do the job for me";
+ System.out.println("standard message : " + message);
+ System.out.println("capitalized message : " + standalone.Main.capitalizeWords(message));
+ }
+
+ private Main() {
+ }
+}
diff --git a/sigil/bld-ivy/example/dependence/settings/ivysettings.properties b/sigil/bld-ivy/example/dependence/settings/ivysettings.properties
new file mode 100644
index 0000000..737733c
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/settings/ivysettings.properties
@@ -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.
+# ***************************************************************
+repository.dir=${ivy.settings.dir}/repository
+sigil-ivy-plugin.jar=${ivy.settings.dir}/../../../lib/sigil-ivy-plugin.jar
+ivy.jar=/opt/apache-ivy-2.0.0-rc2/ivy-2.0.0-rc2.jar
diff --git a/sigil/bld-ivy/example/dependence/settings/ivysettings.xml b/sigil/bld-ivy/example/dependence/settings/ivysettings.xml
new file mode 100644
index 0000000..5dd4e63
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/settings/ivysettings.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+<ivysettings>
+ <properties file="${ivy.settings.dir}/ivysettings.properties"/>
+ <settings defaultResolver="projects"/>
+ <caches defaultCacheDir="${ivy.settings.dir}/ivy-cache" />
+
+ <classpath file="${sigil-ivy-plugin.jar}" />
+ <typedef name="sigil-parser" classname="org.cauldron.bld.ivy.SigilParser" />
+ <typedef name="sigil-resolver" classname="org.cauldron.bld.ivy.SigilResolver" />
+
+ <parsers>
+ <sigil-parser/>
+ </parsers>
+
+ <resolvers>
+ <sigil-resolver name="sigil" config="${ivy.settings.dir}/sigil-repos.properties" />
+ <filesystem name="projects">
+ <artifact pattern="${repository.dir}/[artifact]-[revision].[ext]" />
+ <ivy pattern="${repository.dir}/[module]-[revision].xml" />
+ </filesystem>
+ <!--
+ <ibiblio name="libraries" m2compatible="true" usepoms="false" />
+ -->
+ </resolvers>
+ <modules>
+ <module organisation="sigil" name="*" resolver="sigil"/>
+ </modules>
+</ivysettings>
diff --git a/sigil/bld-ivy/example/dependence/settings/sigil-repos.properties b/sigil/bld-ivy/example/dependence/settings/sigil-repos.properties
new file mode 100644
index 0000000..85150e2
--- /dev/null
+++ b/sigil/bld-ivy/example/dependence/settings/sigil-repos.properties
@@ -0,0 +1,17 @@
+# repository config
+
+-repositories: system, project, spring
+
+system;provider: system
+system;level: -1
+
+project;provider: project
+project;level: 0
+project;pattern: ../*/[sigilproject]
+
+spring;provider: obr
+spring;level: 2
+spring;url: http://sigil.codecauldron.org/spring-external.obr
+spring;index: ../settings/spring-external.obr
+
+# end
diff --git a/sigil/bld-ivy/example/felix-log/README b/sigil/bld-ivy/example/felix-log/README
new file mode 100644
index 0000000..df71d9b
--- /dev/null
+++ b/sigil/bld-ivy/example/felix-log/README
@@ -0,0 +1,22 @@
+# http://sigil.codecauldron.org
+
+This example shows how to build the felix log service, using Ant/Ivy,
+instead of Maven.
+
+sigil.properties has been constructed to produce an identical bundle to the
+one produced by Maven.
+
+The Felix dependencies are obtained from an OBR index of
+http://repo1.maven.org/maven2/org/apache/felix, Maven repos can't be searched
+directly for package import dependencies.
+
+1. checkout felix log code
+ $ cd felix-log
+ $ svn co http://svn.apache.org/repos/asf/felix/trunk/log
+
+2. set ivy.jar location in common/build.properties
+
+3. build
+ $ cd log
+ $ ant
+
diff --git a/sigil/bld-ivy/example/felix-log/bldcommon/build.properties b/sigil/bld-ivy/example/felix-log/bldcommon/build.properties
new file mode 100644
index 0000000..ff1bcc1
--- /dev/null
+++ b/sigil/bld-ivy/example/felix-log/bldcommon/build.properties
@@ -0,0 +1,26 @@
+# common properties
+
+# CHANGE ivy.jar TO REFLECT YOUR INSTALLATION
+ivy.jar = /opt/apache-ivy-2.0.0-rc2/ivy-2.0.0-rc2.jar
+
+sigil-ivy-plugin.jar = ${common.dir}/../../../lib/sigil-ivy-plugin.jar
+
+build.dir = ${basedir}/build
+classes.dir = ${build.dir}/classes
+deps.dir = ${build.dir}/deps
+resource.dir = ${basedir}/xml
+src.dir = ${basedir}/src
+
+dest.dir = ${build.dir}
+dest.lib.dir = ${dest.dir}/lib
+dest.etc.dir = ${dest.dir}/etc
+
+ivy.file = ${basedir}/ivy.xml
+module.version.target = 1.0
+
+cache.dir = ${common.dir}/ivy-cache
+repository.dir = ${common.dir}/repository
+
+example.version = 1.0.0
+bundle.version = ${example.version}
+
diff --git a/sigil/bld-ivy/example/felix-log/bldcommon/common.xml b/sigil/bld-ivy/example/felix-log/bldcommon/common.xml
new file mode 100644
index 0000000..8431484
--- /dev/null
+++ b/sigil/bld-ivy/example/felix-log/bldcommon/common.xml
@@ -0,0 +1,230 @@
+<?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="common"
+ xmlns:ivy="antlib:org.apache.ivy.ant">
+
+ <dirname property="common.dir" file="${ant.file.common}"/>
+ <property file="${common.dir}/build.properties"/>
+
+ <path id="lib.path.id">
+ <fileset dir="${deps.dir}" />
+ </path>
+
+ <path id="sigil.path.id">
+ <path refid="lib.path.id" />
+ <path location="${classes.dir}" />
+ </path>
+
+ <!-- setup ivy default configuration with some custom info -->
+ <property name="ivy.local.default.root" value="${repository.dir}/local"/>
+ <property name="ivy.shared.default.root" value="${repository.dir}/shared"/>
+
+ <!-- =================================
+ target: load-ivy
+ ================================= -->
+ <target name="load-ivy" depends="ivy-taskdefs">
+ <ivy:settings file="${common.dir}/ivysettings.xml" />
+ </target>
+
+ <!-- =================================
+ target: ivy-taskdefs
+ ================================= -->
+ <target name="ivy-taskdefs" unless="ivy.loaded">
+ <property name="ivy.loaded" value="true"/>
+ <echo message="Loading Ivy ... common.dir=${common.dir}"/>
+
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant"
+ classpath="${ivy.jar}"/>
+
+ <taskdef name="sigil.bundle"
+ classname="org.cauldron.bld.ant.BundleTask"
+ classpath="${sigil-ivy-plugin.jar}"/>
+ </target>
+
+
+
+ <!-- =================================
+ target: build (default target)
+ ================================= -->
+ <target name="build" depends="ident, jar, resources" />
+
+ <target name="ident">
+ <echo message="${ant.project.name}"/>
+ </target>
+
+ <!-- =================================
+ target: resolve
+ ================================= -->
+ <target name="resolve" depends="load-ivy, clean-deps"
+ description="--> resolve and retrieve dependencies with ivy">
+ <mkdir dir="${deps.dir}"/>
+ <ivy:resolve file="${ivy.file}"/>
+ <ivy:retrieve pattern="${deps.dir}/[artifact].[ext]" />
+ </target>
+
+ <!-- =================================
+ target: install
+ ================================= -->
+ <target name="install" depends="install-version, build"
+ description="--> publish this project in the local repository">
+ <ivy:publish artifactspattern="${dest.lib.dir}/[artifact].[ext]"
+ resolver="local"
+ pubrevision="${version}"
+ pubdate="${now}"
+ forcedeliver="true"
+ status="integration"/>
+ <echo message="project ${ant.project.name} published locally with version ${version}" />
+ </target>
+
+ <target name="install-version">
+ <tstamp>
+ <format property="now" pattern="yyyyMMddHHmmss"/>
+ </tstamp>
+ <property name="version"
+ value="${module.version.target}-local-${now}"/>
+ </target>
+
+ <!-- =================================
+ target: report
+ ================================= -->
+ <target name="report" depends="resolve"
+ description="--> generates a report of dependencies">
+ <ivy:report todir="${build.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: compile
+ ================================= -->
+ <target name="compile" depends="resolve"
+ description="--> compile the project">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}"
+ destdir="${classes.dir}"
+ classpathref="lib.path.id"
+ target="1.5"
+ debug="true" />
+ </target>
+
+ <!-- =================================
+ target: jar
+ ================================= -->
+ <target name="jar" depends="compile"
+ description="--> make a jar file for this project">
+ <mkdir dir="${dest.lib.dir}"/>
+ <sigil.bundle destpattern="${dest.lib.dir}/[id].[ext]"
+ classpathref="sigil.path.id"/>
+ </target>
+
+ <!-- =================================
+ target: resources
+ ================================= -->
+ <available file="${resource.dir}" type="dir"
+ property="resource.dir.present"/>
+
+ <target name="resources" if="resource.dir.present"
+ description="--> filter xml resources replacing ${VERSION} etc.">
+ <mkdir dir="${dest.etc.dir}"/>
+ <copy todir="${dest.etc.dir}">
+ <fileset dir="${resource.dir}">
+ <include name="*.composite"/>
+ <include name="*.system"/>
+ </fileset>
+ <filterset begintoken="$${" endtoken="}">
+ <filter token="VERSION" value="${bundle.version}"/>
+ <filter token="BLITZ_VERSION" value="${blitz.version}"/>
+ <filter token="JINI_VERSION" value="${jini.version}"/>
+ </filterset>
+ </copy>
+ </target>
+
+ <!-- =================================
+ target: clean-local
+ ================================= -->
+ <target name="clean-local"
+ description="--> cleans the local repository for the current module">
+ <delete dir="${ivy.local.default.root}/${ant.project.name}"/>
+ </target>
+
+ <!-- =================================
+ target: clean-deps
+ ================================= -->
+ <target name="clean-deps"
+ description="--> clean the project libraries directory (dependencies)">
+ <delete includeemptydirs="true" dir="${deps.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: clean-build
+ ================================= -->
+ <target name="clean-build"
+ description="--> clean the project built files">
+ <delete includeemptydirs="true" dir="${build.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" depends="clean-build, clean-deps"
+ description="--> clean the project" />
+
+
+ <!-- =================================
+ target: buildlist
+ ================================= -->
+ <fileset id="projects" dir="${basedir}" includes="**/build.xml"/>
+
+ <target name="buildlist" depends="load-ivy">
+ <ivy:buildlist reference="ordered-list"
+ onMissingDescriptor="skip">
+ <fileset refid="projects"/>
+ </ivy:buildlist>
+ </target>
+
+ <!-- =================================
+ target: install-list
+ ================================= -->
+ <target name="install-list" depends="buildlist"
+ description="--> compile, jar and install all projects in the right order">
+ <subant target="install" buildpathref="ordered-list">
+ <propertyset>
+ <propertyref name="ivy.loaded" />
+ </propertyset>
+ </subant>
+ </target>
+
+ <!-- =================================
+ target: clean-list
+ ================================= -->
+ <target name="clean-list" depends="clean, buildlist"
+ description="--> clean all projects">
+ <subant target="clean" buildpathref="ordered-list" />
+ </target>
+
+ <!-- =================================
+ target: clean-all
+ ================================= -->
+ <target name="clean-all" depends="clean-list"
+ description="--> delete repository, ivy cache, and all projects">
+ <delete dir="${repository.dir}"/>
+ <ivy:cleancache />
+ </target>
+
+</project>
diff --git a/sigil/bld-ivy/example/felix-log/bldcommon/ivysettings.xml b/sigil/bld-ivy/example/felix-log/bldcommon/ivysettings.xml
new file mode 100644
index 0000000..dd336c7
--- /dev/null
+++ b/sigil/bld-ivy/example/felix-log/bldcommon/ivysettings.xml
@@ -0,0 +1,54 @@
+<?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.
+-->
+<ivysettings>
+ <properties file="${ivy.settings.dir}/build.properties"/>
+ <caches defaultCacheDir="${cache.dir}" />
+
+ <settings defaultResolver="local" circularDependencyStrategy="error" />
+
+ <classpath file="${sigil-ivy-plugin.jar}" />
+ <typedef name="sigil-parser" classname="org.cauldron.bld.ivy.SigilParser" />
+ <typedef name="sigil" classname="org.cauldron.bld.ivy.SigilResolver" />
+
+ <parsers>
+ <sigil-parser config="${ivy.settings.dir}/sigil-repos.properties"
+ quiet="true"/>
+ </parsers>
+
+ <resolvers>
+ <sigil name="sigil"
+ config="${ivy.settings.dir}/sigil-repos.properties"
+ extractBCP="true"/>
+
+ <filesystem name="local">
+ <ivy pattern="${repository.dir}/local/[module]-[revision].xml" />
+ <artifact pattern="${repository.dir}/local/[artifact]-[revision].[ext]" />
+ </filesystem>
+
+ <filesystem name="shared">
+ <ivy pattern="${repository.dir}/shared/[module]-[revision].xml" />
+ <artifact pattern="${repository.dir}/shared/[module]/[artifact]-[revision].[ext]" />
+ </filesystem>
+ </resolvers>
+
+ <modules>
+ <module organisation="sigil" resolver="sigil"/>
+ </modules>
+</ivysettings>
diff --git a/sigil/bld-ivy/example/felix-log/bldcommon/sigil-repos.properties b/sigil/bld-ivy/example/felix-log/bldcommon/sigil-repos.properties
new file mode 100644
index 0000000..fbc95c6
--- /dev/null
+++ b/sigil/bld-ivy/example/felix-log/bldcommon/sigil-repos.properties
@@ -0,0 +1,17 @@
+# sigil repository config
+
+-repositories: system, project, felix
+
+system;provider: system
+system;level: -1
+
+project;provider: project
+project;level: 0
+project;pattern: ../*/[sigilproject]
+
+felix;provider: obr
+felix;level: 1
+felix;url: http://sigil.codecauldron.org/maven-felix.obr
+felix;index: ../bldcommon/maven-felix.obr
+
+# end
diff --git a/sigil/bld-ivy/example/felix-log/log/build.xml b/sigil/bld-ivy/example/felix-log/log/build.xml
new file mode 100644
index 0000000..c7c19f6
--- /dev/null
+++ b/sigil/bld-ivy/example/felix-log/log/build.xml
@@ -0,0 +1,22 @@
+<?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="felix-log" default="build">
+ <import file="../bldcommon/common.xml"/>
+</project>
diff --git a/sigil/bld-ivy/example/felix-log/log/ivy.xml b/sigil/bld-ivy/example/felix-log/log/ivy.xml
new file mode 100644
index 0000000..6e0b4db
--- /dev/null
+++ b/sigil/bld-ivy/example/felix-log/log/ivy.xml
@@ -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.felix"
+ module="felix-log"
+ status="integration"/>
+</ivy-module>
diff --git a/sigil/bld-ivy/example/felix-log/log/sigil.properties b/sigil/bld-ivy/example/felix-log/log/sigil.properties
new file mode 100644
index 0000000..3443218
--- /dev/null
+++ b/sigil/bld-ivy/example/felix-log/log/sigil.properties
@@ -0,0 +1,38 @@
+# sigil project file, saved by plugin.
+
+-activator: ${Bundle-SymbolicName}.impl.Activator
+
+name: org.apache.felix.log
+
+version: 0.9.0.SNAPSHOT
+
+-bundles: \
+ felix-log, \
+
+-contents: \
+ ${Bundle-SymbolicName}.impl, \
+ org.osgi.service.log, \
+
+-resources: \
+ =src/main/resources, \
+
+-sourcedirs: \
+ src/main/java, \
+
+-exports: \
+ org.osgi.service.log, \
+
+-imports: \
+ org.osgi.framework;version=1.4, \
+ org.osgi.service.log;version=1.3, \
+
+header;Bundle-Vendor: The Apache Software Foundation
+
+header;Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+
+header;Export-Service: org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService
+
+header;Bundle-Name: Apache Felix Log Service
+
+header;Bundle-DocURL: http://www.apache.org/
+
diff --git a/sigil/bld-ivy/example/multi-project/README b/sigil/bld-ivy/example/multi-project/README
new file mode 100644
index 0000000..ed39dc3
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/README
@@ -0,0 +1,19 @@
+# http://sigil.codecauldron.org
+
+This example is based on the Ivy Tutorial multi-project example:
+http://ant.apache.org/ivy/history/latest-milestone/tutorial/multiproject.html
+
+Dependencies are resolved using an OBR index for the Spring repository,
+hosted at sigil.codecauldron.org.
+
+projects/sigil-defaults.properties specifies default package version ranges,
+which are inherited by the -imports in sigil.properties.
+
+1. set ivy.jar location in common/build.properties
+
+2. test build order (determined automatically from the dependencies)
+$ ant order
+
+3. build
+$ ant publish
+
diff --git a/sigil/bld-ivy/example/multi-project/build.xml b/sigil/bld-ivy/example/multi-project/build.xml
new file mode 100644
index 0000000..a04ef74
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/build.xml
@@ -0,0 +1,60 @@
+<?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="all" default="publish" xmlns:ivy="antlib:org.apache.ivy.ant">
+ <property name="common.dir" value="${basedir}/common" />
+ <import file="${common.dir}/common.xml"/>
+
+ <fileset id="projects" dir="projects" includes="**/build.xml"/>
+
+ <path id="unordered-list">
+ <fileset refid="projects"/>
+ </path>
+
+ <target name="buildlist" depends="load-ivy">
+ <ivy:buildlist reference="ordered-list">
+ <fileset refid="projects"/>
+ </ivy:buildlist>
+ </target>
+
+ <target name="publish" depends="buildlist"
+ description="compile, jar and publish all projects in the right order">
+ <subant target="publish" buildpathref="ordered-list">
+ <propertyset>
+ <propertyref name="ivy.loaded" />
+ </propertyset>
+ </subant>
+ </target>
+
+ <target name="clean" description="clean all projects">
+ <subant target="clean" buildpathref="unordered-list" />
+ </target>
+
+ <target name="fullclean" depends="clean, load-ivy"
+ description="clean tutorial: delete repository, ivy cache, and all projects">
+ <delete dir="repository"/>
+ <ivy:cleancache />
+ </target>
+
+ <target name="order" depends="buildlist"
+ description="test buildlist order">
+ <subant target="hello" buildpathref="ordered-list" />
+ </target>
+
+</project>
diff --git a/sigil/bld-ivy/example/multi-project/common/build.properties b/sigil/bld-ivy/example/multi-project/common/build.properties
new file mode 100644
index 0000000..79298b4
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/common/build.properties
@@ -0,0 +1,36 @@
+# ***************************************************************
+# * 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.
+# ***************************************************************
+
+# CHANGE ivy.jar TO REFLECT YOUR INSTALLATION
+ivy.jar = /opt/apache-ivy-2.0.0-rc2/ivy-2.0.0-rc2.jar
+
+sigil-ivy-plugin.jar = ${common.dir}/../../../lib/sigil-ivy-plugin.jar
+
+lib.dir = ${basedir}/lib
+build.dir = ${basedir}/build
+classes.dir = ${build.dir}/classes
+src.dir = ${basedir}/src
+repository.dir=${common.dir}/../repository
+
+ivy.file = ${basedir}/ivy.xml
+
+jar.file = ${build.dir}/${ant.project.name}.jar
+main.class.name = ${ant.project.name}.Main
+
+module.version.target = 1.0
diff --git a/sigil/bld-ivy/example/multi-project/common/common.xml b/sigil/bld-ivy/example/multi-project/common/common.xml
new file mode 100644
index 0000000..f464e32
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/common/common.xml
@@ -0,0 +1,218 @@
+<?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="common"
+ xmlns:ivy="antlib:org.apache.ivy.ant">
+ <!-- a sample common ant build file, used for ivy multi-project tutorial
+ feel free to copy and adapt it to your own needs
+ Note that the only targets specific to ivy are:
+ load-ivy
+ resolve
+ report
+ ivy-new-version
+ publish
+ publish-local
+
+ All other targets are usual ant based targets, which could have been written
+ in a build not depending at all on ivy:
+ resolve constructs a lib directory based upon ivy dependencies, and then the lib dir
+ is used as in any classical ant build
+ -->
+
+ <property file="${common.dir}/build.properties"/>
+
+ <!-- =================================
+ target: load-ivy
+ this target is not necessary if you put ivy.jar in your ant lib directory
+ if you already have ivy 2.0 in your ant lib, you can simply remove this
+ target
+ ================================= -->
+
+ <target name="load-ivy" depends="ivy-taskdefs">
+ <ivy:settings file="${common.dir}/ivysettings.xml" />
+ </target>
+
+ <target name="ivy-taskdefs" unless="ivy.loaded">
+ <property name="ivy.loaded" value="true"/>
+ <echo message="Loading Ivy ..."/>
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant"
+ classpath="${ivy.jar}"/>
+
+ <taskdef name="sigil.bundle"
+ classname="org.cauldron.bld.ant.BundleTask"
+ classpath="${sigil-ivy-plugin.jar}"/>
+ </target>
+
+ <path id="lib.path.id">
+ <fileset dir="${lib.dir}" />
+ </path>
+
+ <path id="run.path.id">
+ <path refid="lib.path.id" />
+ <path location="${classes.dir}" />
+ </path>
+
+
+ <!-- setup ivy default configuration with some custom info -->
+ <property name="ivy.local.default.root" value="${repository.dir}/local"/>
+ <property name="ivy.shared.default.root" value="${repository.dir}/shared"/>
+
+ <!-- here is how we would have configured ivy if we had our own ivysettings file
+ <ivy:settings file="${common.dir}/ivysettings.xml" />
+ -->
+
+ <!-- =================================
+ target: hello
+ ================================= -->
+ <target name="hello" description="--> identify project (useful to test buildlist)">
+ <echo message="${ant.project.name}"/>
+ </target>
+
+ <!-- =================================
+ target: resolve
+ ================================= -->
+ <target name="resolve" depends="clean-lib, load-ivy" description="--> resolve and retrieve dependencies with ivy">
+ <mkdir dir="${lib.dir}"/> <!-- not usually necessary, ivy creates the directory IF there are dependencies -->
+
+ <!-- the call to resolve is not mandatory, retrieve makes an implicit call if we don't -->
+ <ivy:resolve file="${ivy.file}"/>
+ <ivy:retrieve pattern="${lib.dir}/[artifact].[ext]" />
+ </target>
+
+ <!-- =================================
+ target: report
+ ================================= -->
+ <target name="report" depends="resolve" description="--> generates a report of dependencies">
+ <ivy:report todir="${build.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: compile
+ ================================= -->
+ <target name="compile" depends="resolve" description="--> compile the project">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" debug="true" />
+ </target>
+
+ <!-- =================================
+ target: run
+ ================================= -->
+ <target name="run" depends="version, compile" description="--> compile and run the project">
+ <java classpathref="run.path.id" classname="${main.class.name}"/>
+ </target>
+
+ <target name="ivy-new-version" depends="load-ivy" unless="ivy.new.revision">
+ <!-- default module version prefix value -->
+ <property name="module.version.prefix" value="${module.version.target}-dev-b" />
+
+ <!-- asks to ivy an available version number -->
+ <ivy:info file="${ivy.file}" />
+ <ivy:buildnumber
+ organisation="${ivy.organisation}" module="${ivy.module}"
+ revision="${module.version.prefix}" defaultBuildNumber="1" revSep=""/>
+ </target>
+
+ <target name="local-version">
+ <tstamp>
+ <format property="now" pattern="yyyyMMddHHmmss"/>
+ </tstamp>
+ <property name="ivy.new.revision" value="${module.version.target}-local-${now}"/>
+ </target>
+
+ <target name="version" depends="ivy-new-version">
+ <!-- create version file in classpath for later inclusion in jar -->
+ <mkdir dir="${classes.dir}"/>
+ <echo message="version=${ivy.new.revision}" file="${classes.dir}/${ant.project.name}.properties" append="false" />
+
+ <!-- load generated version properties file -->
+ <property file="${classes.dir}/${ant.project.name}.properties" />
+ </target>
+
+ <!-- =================================
+ target: jar
+ ================================= -->
+ <target name="jar" depends="version, compile" description="--> make a jar file for this project">
+
+ <!--
+ <jar destfile="${jar.file}">
+ <fileset dir="${classes.dir}" />
+ <manifest>
+ <attribute name="Built-By" value="${user.name}"/>
+ <attribute name="Build-Version" value="${version}" />
+ </manifest>
+ </jar>
+ -->
+
+ <sigil.bundle destpattern="${build.dir}/[id].[ext]"
+ classpathref="run.path.id"/>
+ </target>
+
+ <!-- =================================
+ target: publish
+ ================================= -->
+ <target name="publish" depends="clean-build, jar" description="--> publish this project in the ivy repository">
+ <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
+ resolver="shared"
+ pubrevision="${version}"
+ status="release"
+ />
+ <echo message="project ${ant.project.name} released with version ${version}" />
+ </target>
+
+ <!-- =================================
+ target: publish-local
+ ================================= -->
+ <target name="publish-local" depends="local-version, jar" description="--> publish this project in the local ivy repository">
+ <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
+ resolver="local"
+ pubrevision="${version}"
+ pubdate="${now}"
+ status="integration"
+ forcedeliver="true"
+ />
+ <echo message="project ${ant.project.name} published locally with version ${version}" />
+ </target>
+
+ <!-- =================================
+ target: clean-local
+ ================================= -->
+ <target name="clean-local" description="--> cleans the local repository for the current module">
+ <delete dir="${ivy.local.default.root}/${ant.project.name}"/>
+ </target>
+
+ <!-- =================================
+ target: clean-lib
+ ================================= -->
+ <target name="clean-lib" description="--> clean the project libraries directory (dependencies)">
+ <delete includeemptydirs="true" dir="${lib.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: clean-build
+ ================================= -->
+ <target name="clean-build" description="--> clean the project built files">
+ <delete includeemptydirs="true" dir="${build.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" depends="clean-build, clean-lib" description="--> clean the project" />
+</project>
diff --git a/sigil/bld-ivy/example/multi-project/common/ivysettings.xml b/sigil/bld-ivy/example/multi-project/common/ivysettings.xml
new file mode 100644
index 0000000..614aa0e
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/common/ivysettings.xml
@@ -0,0 +1,50 @@
+<?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.
+-->
+<ivysettings>
+ <properties file="${ivy.settings.dir}/build.properties"/>
+ <caches defaultCacheDir="${ivy.settings.dir}/../ivy-cache" />
+
+ <settings defaultResolver="shared" circularDependencyStrategy="error" />
+
+ <classpath file="${ivy.settings.dir}/../../../lib/sigil-ivy-plugin.jar" />
+ <typedef name="sigil-parser" classname="org.cauldron.bld.ivy.SigilParser" />
+ <typedef name="sigil-resolver" classname="org.cauldron.bld.ivy.SigilResolver" />
+
+ <parsers>
+ <sigil-parser quiet="true"/>
+ </parsers>
+
+ <resolvers>
+ <sigil-resolver name="sigil" config="${ivy.settings.dir}/sigil-repos.properties" />
+ <filesystem name="local">
+ <ivy pattern="${repository.dir}/local/[module]-[revision].xml" />
+ <artifact pattern="${repository.dir}/local/[artifact]-[revision].[ext]" />
+ </filesystem>
+ <filesystem name="shared">
+ <ivy pattern="${repository.dir}/shared/[module]-[revision].xml" />
+ <artifact pattern="${repository.dir}/shared/[module]/[artifact]-[revision].[ext]" />
+ </filesystem>
+ </resolvers>
+ <modules>
+ <!--<module organisation="org.apache.ivy.example" name=".*" resolver="shared"/>
+ -->
+ <module organisation="sigil" resolver="sigil"/>
+ </modules>
+</ivysettings>
diff --git a/sigil/bld-ivy/example/multi-project/common/sigil-repos.properties b/sigil/bld-ivy/example/multi-project/common/sigil-repos.properties
new file mode 100644
index 0000000..bd711fa
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/common/sigil-repos.properties
@@ -0,0 +1,20 @@
+
+# repository config
+
+-repositories: system, project, spring
+
+system;provider: system
+system;level: -1
+#system;framework: osgi.core.jar
+#system;profile: J2SE-1.5
+
+project;provider: project
+project;level: 0
+project;pattern: ../projects/**/[sigilproject]
+
+spring;provider: obr
+spring;level: 2
+spring;url: http://sigil.codecauldron.org/spring-external.obr
+spring;index: ../common/spring-external.obr
+
+# end
diff --git a/sigil/bld-ivy/example/multi-project/projects/console/build.properties b/sigil/bld-ivy/example/multi-project/projects/console/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/console/build.properties
@@ -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
diff --git a/sigil/bld-ivy/example/multi-project/projects/console/build.xml b/sigil/bld-ivy/example/multi-project/projects/console/build.xml
new file mode 100644
index 0000000..5c02cba
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/console/build.xml
@@ -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="console" default="compile">
+ <property file="build.properties"/>
+
+ <import file="${common.dir}/common.xml"/>
+</project>
diff --git a/sigil/bld-ivy/example/multi-project/projects/console/ivy.xml b/sigil/bld-ivy/example/multi-project/projects/console/ivy.xml
new file mode 100644
index 0000000..b1eb4f4
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/console/ivy.xml
@@ -0,0 +1,31 @@
+<?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="console"
+ status="integration"/>
+ <dependencies>
+ <dependency name="version" rev="latest.integration" conf="default" />
+ <dependency name="list" rev="latest.integration" conf="default->standalone" />
+ <dependency name="find" rev="latest.integration" conf="default->standalone" />
+ <dependency name="sizewhere" rev="latest.integration" conf="default->standalone" />
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/example/multi-project/projects/console/sigil.properties b/sigil/bld-ivy/example/multi-project/projects/console/sigil.properties
new file mode 100644
index 0000000..dea089f
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/console/sigil.properties
@@ -0,0 +1,6 @@
+
+-bundles: console
+
+-exports: console
+
+-imports: list
diff --git a/sigil/bld-ivy/example/multi-project/projects/console/src/console/Main.java b/sigil/bld-ivy/example/multi-project/projects/console/src/console/Main.java
new file mode 100644
index 0000000..678f3ca
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/console/src/console/Main.java
@@ -0,0 +1,79 @@
+/*
+ * 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 console;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.Arrays;
+import java.lang.reflect.Method;
+
+
+public class Main {
+ private static Collection QUIT_COMMANDS = Arrays.asList(new String[] {"quit", "q", "exit"});
+ private static Collection HELP_COMMANDS = Arrays.asList(new String[] {"help", "h", "?"});
+
+ public static void main(String[] a) throws Exception {
+ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ while (true) {
+ System.out.print("> ");
+ String command = in.readLine().trim();
+ if (QUIT_COMMANDS.contains(command)) {
+ return;
+ }
+ if (HELP_COMMANDS.contains(command)) {
+ help();
+ continue;
+ }
+ String[] split = command.split(" ");
+ if (split.length == 0) {
+ error(command);
+ continue;
+ }
+
+ try {
+ String[] args = new String[split.length - 1];
+ System.arraycopy(split, 1, args, 0, args.length);
+ Class cl = Class.forName(split[0]+".Main");
+ Method m = cl.getMethod("main", new Class[] {String[].class});
+ m.invoke(null, new Object[] {args});
+ } catch (Exception ex) {
+ error(command);
+ continue;
+ }
+ }
+ }
+
+ private static void help() {
+ System.out.println("available commands:");
+ System.out.println("\tquit: quit the console");
+ System.out.println("\thelp: displays this message");
+ System.out.println("\tlist -dir <dir>: list files in given directory");
+ System.out.println("\tfind -dir <dir> -name <name>: list files with given name in given dir");
+ System.out.println("\tsizewhere -dir <dir> -name <name>: compute total size of files with given name in given dir");
+ System.out.println("\thelp: displays this message");
+ }
+
+ private static void error(String command) {
+ System.out.println("unknown command "+command);
+ System.out.println("type ? for help");
+ }
+
+}
diff --git a/sigil/bld-ivy/example/multi-project/projects/find/build.properties b/sigil/bld-ivy/example/multi-project/projects/find/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/find/build.properties
@@ -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
diff --git a/sigil/bld-ivy/example/multi-project/projects/find/build.xml b/sigil/bld-ivy/example/multi-project/projects/find/build.xml
new file mode 100644
index 0000000..4d23bf5
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/find/build.xml
@@ -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="find" default="compile">
+ <property file="build.properties"/>
+
+ <import file="${common.dir}/common.xml"/>
+</project>
diff --git a/sigil/bld-ivy/example/multi-project/projects/find/ivy.xml b/sigil/bld-ivy/example/multi-project/projects/find/ivy.xml
new file mode 100644
index 0000000..b7f1bc1
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/find/ivy.xml
@@ -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="find"
+ status="integration"/>
+ <configurations>
+ <conf name="core"/>
+ <conf name="standalone" extends="core"/>
+ </configurations>
+ <publications>
+ <artifact name="find" type="jar" conf="core" />
+ </publications>
+ <dependencies>
+ <dependency name="version" rev="latest.integration" conf="core->default" />
+ <dependency name="list" rev="latest.integration" conf="core" />
+ <dependency org="commons-collections" name="commons-collections" rev="3.1" conf="core->default" />
+ <dependency org="commons-cli" name="commons-cli" rev="1.0" conf="standalone->default" />
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/example/multi-project/projects/find/sigil.properties b/sigil/bld-ivy/example/multi-project/projects/find/sigil.properties
new file mode 100644
index 0000000..30c10a7
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/find/sigil.properties
@@ -0,0 +1,10 @@
+
+-bundles: find
+
+-exports: find
+
+-imports:\
+ version, \
+ list, \
+ org.apache.commons.collections, \
+ org.apache.commons.cli
diff --git a/sigil/bld-ivy/example/multi-project/projects/find/src/find/FindFile.java b/sigil/bld-ivy/example/multi-project/projects/find/src/find/FindFile.java
new file mode 100644
index 0000000..25fa1af
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/find/src/find/FindFile.java
@@ -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 find;
+
+import version.Version;
+import list.ListFile;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.io.File;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+
+public class FindFile {
+ static {
+ Version.register("find");
+ }
+
+ public static Collection find(File dir, String name) {
+ return find(ListFile.list(dir), name);
+ }
+
+ private static Collection find(Collection files, final String name) {
+ return CollectionUtils.select(files, new Predicate() {
+ public boolean evaluate(Object o) {
+ return ((File)o).getName().indexOf(name) != -1;
+ }
+ });
+ }
+}
diff --git a/sigil/bld-ivy/example/multi-project/projects/find/src/find/Main.java b/sigil/bld-ivy/example/multi-project/projects/find/src/find/Main.java
new file mode 100644
index 0000000..a41c136
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/find/src/find/Main.java
@@ -0,0 +1,76 @@
+/*
+ * 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 find;
+
+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");
+ Option name = OptionBuilder.withArgName("name")
+ .hasArg()
+ .withDescription("list 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");
+ Collection files = FindFile.find(dir, name);
+ System.out.println("listing files in " + dir + " containing " + name);
+ 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("find", options);
+ }
+ }
+
+}
diff --git a/sigil/bld-ivy/example/multi-project/projects/list/build.properties b/sigil/bld-ivy/example/multi-project/projects/list/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/list/build.properties
@@ -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
diff --git a/sigil/bld-ivy/example/multi-project/projects/list/build.xml b/sigil/bld-ivy/example/multi-project/projects/list/build.xml
new file mode 100644
index 0000000..3926148
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/list/build.xml
@@ -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="list" default="compile">
+ <property file="build.properties"/>
+
+ <import file="${common.dir}/common.xml"/>
+</project>
diff --git a/sigil/bld-ivy/example/multi-project/projects/list/ivy.xml b/sigil/bld-ivy/example/multi-project/projects/list/ivy.xml
new file mode 100644
index 0000000..6593fb7
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/list/ivy.xml
@@ -0,0 +1,36 @@
+<?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="list"
+ status="integration"/>
+ <configurations>
+ <conf name="core"/>
+ <conf name="standalone" extends="core"/>
+ </configurations>
+ <publications>
+ <artifact name="list" type="jar" conf="core" />
+ </publications>
+ <dependencies>
+ <dependency name="version" rev="latest.integration" conf="core->default" />
+ <dependency org="commons-cli" name="commons-cli" rev="1.0" conf="standalone->default" />
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/example/multi-project/projects/list/sigil.properties b/sigil/bld-ivy/example/multi-project/projects/list/sigil.properties
new file mode 100644
index 0000000..302cba7
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/list/sigil.properties
@@ -0,0 +1,14 @@
+
+# requirements
+
+-imports:\
+ version, \
+ org.apache.commons.cli
+
+# exports
+
+-bundles: list
+
+list;name: org.example.list
+list;-exports: list.*
+
diff --git a/sigil/bld-ivy/example/multi-project/projects/list/src/list/ListFile.java b/sigil/bld-ivy/example/multi-project/projects/list/src/list/ListFile.java
new file mode 100644
index 0000000..7467152
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/list/src/list/ListFile.java
@@ -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;
+ }
+}
diff --git a/sigil/bld-ivy/example/multi-project/projects/list/src/list/Main.java b/sigil/bld-ivy/example/multi-project/projects/list/src/list/Main.java
new file mode 100644
index 0000000..0f8cb14
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/list/src/list/Main.java
@@ -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 );
+ }
+ }
+
+}
diff --git a/sigil/bld-ivy/example/multi-project/projects/sigil-defaults.properties b/sigil/bld-ivy/example/multi-project/projects/sigil-defaults.properties
new file mode 100644
index 0000000..d61df45
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/sigil-defaults.properties
@@ -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)
diff --git a/sigil/bld-ivy/example/multi-project/projects/size/build.properties b/sigil/bld-ivy/example/multi-project/projects/size/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/size/build.properties
@@ -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
diff --git a/sigil/bld-ivy/example/multi-project/projects/size/build.xml b/sigil/bld-ivy/example/multi-project/projects/size/build.xml
new file mode 100644
index 0000000..2a75fe5
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/size/build.xml
@@ -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>
diff --git a/sigil/bld-ivy/example/multi-project/projects/size/ivy.xml b/sigil/bld-ivy/example/multi-project/projects/size/ivy.xml
new file mode 100644
index 0000000..7112b7f
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/size/ivy.xml
@@ -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>
diff --git a/sigil/bld-ivy/example/multi-project/projects/size/sigil.properties b/sigil/bld-ivy/example/multi-project/projects/size/sigil.properties
new file mode 100644
index 0000000..cf239af
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/size/sigil.properties
@@ -0,0 +1,8 @@
+
+-bundles: size
+
+-exports: size
+
+-imports:\
+ list, \
+ version
diff --git a/sigil/bld-ivy/example/multi-project/projects/size/src/size/FileSize.java b/sigil/bld-ivy/example/multi-project/projects/size/src/size/FileSize.java
new file mode 100644
index 0000000..dcd4a1c
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/size/src/size/FileSize.java
@@ -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;
+ }
+}
diff --git a/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.properties b/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.properties
@@ -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
diff --git a/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.xml b/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.xml
new file mode 100644
index 0000000..0b8ab4c
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/sizewhere/build.xml
@@ -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>
diff --git a/sigil/bld-ivy/example/multi-project/projects/sizewhere/ivy.xml b/sigil/bld-ivy/example/multi-project/projects/sizewhere/ivy.xml
new file mode 100644
index 0000000..d50bddb
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/sizewhere/ivy.xml
@@ -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>
diff --git a/sigil/bld-ivy/example/multi-project/projects/sizewhere/sigil.properties b/sigil/bld-ivy/example/multi-project/projects/sizewhere/sigil.properties
new file mode 100644
index 0000000..c272f9b
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/sizewhere/sigil.properties
@@ -0,0 +1,10 @@
+
+-bundles: sizewhere
+
+-exports: sizewhere
+
+-imports:\
+ find, \
+ size, \
+ version, \
+ org.apache.commons.cli
diff --git a/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/Main.java b/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/Main.java
new file mode 100644
index 0000000..131af66
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/Main.java
@@ -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 );
+ }
+ }
+
+}
diff --git a/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java b/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java
new file mode 100644
index 0000000..3594bd9
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java
@@ -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));
+ }
+}
diff --git a/sigil/bld-ivy/example/multi-project/projects/version/build.properties b/sigil/bld-ivy/example/multi-project/projects/version/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/version/build.properties
@@ -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
diff --git a/sigil/bld-ivy/example/multi-project/projects/version/build.xml b/sigil/bld-ivy/example/multi-project/projects/version/build.xml
new file mode 100644
index 0000000..375db20
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/version/build.xml
@@ -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>
diff --git a/sigil/bld-ivy/example/multi-project/projects/version/ivy.xml b/sigil/bld-ivy/example/multi-project/projects/version/ivy.xml
new file mode 100644
index 0000000..16e08f3
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/version/ivy.xml
@@ -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>
diff --git a/sigil/bld-ivy/example/multi-project/projects/version/sigil.properties b/sigil/bld-ivy/example/multi-project/projects/version/sigil.properties
new file mode 100644
index 0000000..a940ffd
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/version/sigil.properties
@@ -0,0 +1,4 @@
+
+-bundles: version
+
+-exports: version
diff --git a/sigil/bld-ivy/example/multi-project/projects/version/src/version/Version.java b/sigil/bld-ivy/example/multi-project/projects/version/src/version/Version.java
new file mode 100644
index 0000000..0c69bc5
--- /dev/null
+++ b/sigil/bld-ivy/example/multi-project/projects/version/src/version/Version.java
@@ -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();
+ }
+ }
+}
diff --git a/sigil/bld-ivy/sigil-ivy-plugin.bnd b/sigil/bld-ivy/sigil-ivy-plugin.bnd
new file mode 100644
index 0000000..7fb4156
--- /dev/null
+++ b/sigil/bld-ivy/sigil-ivy-plugin.bnd
@@ -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
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleInfoTask.java b/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleInfoTask.java
new file mode 100644
index 0000000..572b64f
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleInfoTask.java
@@ -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;
+ }
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleTask.java b/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleTask.java
new file mode 100644
index 0000000..f8ab762
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ant/BundleTask.java
@@ -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;
+ }
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldRepositoryManager.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldRepositoryManager.java
new file mode 100644
index 0000000..ce5d9db
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldRepositoryManager.java
@@ -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);
+ }
+ }
+ }
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldResolver.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldResolver.java
new file mode 100644
index 0000000..f29f656
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/BldResolver.java
@@ -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);
+ }
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/FindUtil.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/FindUtil.java
new file mode 100644
index 0000000..e914172
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/FindUtil.java
@@ -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);
+ }
+ }
+ }
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/IBldResolver.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/IBldResolver.java
new file mode 100644
index 0000000..35ff995
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/IBldResolver.java
@@ -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);
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/Log.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/Log.java
new file mode 100644
index 0000000..6724063
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/Log.java
@@ -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);
+ }
+
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepository.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepository.java
new file mode 100644
index 0000000..8dbca34
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepository.java
@@ -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;
+ }
+ }
+
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepositoryProvider.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepositoryProvider.java
new file mode 100644
index 0000000..e04dc60
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/ProjectRepositoryProvider.java
@@ -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;
+ }
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilParser.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilParser.java
new file mode 100644
index 0000000..1ab3772
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilParser.java
@@ -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);
+ }
+}
diff --git a/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilResolver.java b/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilResolver.java
new file mode 100644
index 0000000..596aaba
--- /dev/null
+++ b/sigil/bld-ivy/src/org/cauldron/bld/ivy/SigilResolver.java
@@ -0,0 +1,383 @@
+/*
+ * 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 static java.lang.String.format;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.resolve.ResolveData;
+import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.repository.url.URLResource;
+import org.apache.ivy.plugins.resolver.BasicResolver;
+import org.apache.ivy.plugins.resolver.util.ResolvedResource;
+import org.apache.ivy.util.FileUtil;
+import org.cauldron.bld.config.BldFactory;
+import org.cauldron.bld.core.internal.model.osgi.RequiredBundle;
+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.repository.IResolution;
+import org.cauldron.sigil.repository.ResolutionException;
+
+/**
+ * This resolver is able to work with Sigil repositories.
+ * It does not allow publishing.
+ */
+public class SigilResolver extends BasicResolver implements IBldResolver {
+ /** the sigil-injected dependency organisation name */
+ static final String ORG_SIGIL = "sigil";
+
+ private IBldResolver resolver;
+ private String config;
+ private boolean extractBCP = false;
+ private Map<String, Resource> resourcesCache = new HashMap<String, Resource>();
+
+ /**
+ * no-args constructor required by Ivy.
+ *
+ * XXX: It doesn't currently seem to matter that Ivy instantiates this many times,
+ * since SigilParser caches it, and the ProjectRepositoryProvider static cache
+ * prevents it being re-loaded unnecessarily.
+ *
+ * If this should become a problem, then we will need to delegate to a singleton instance,
+ * as we have done in SigilParser.
+ */
+ public SigilResolver() {
+ }
+
+ public void setConfig(String config) {
+ this.config = config;
+ }
+
+ /**
+ * if true, resolver extracts any jars embedded in Bundle-ClassPath.
+ */
+ public void setExtractBCP(String extract) {
+ this.extractBCP = Boolean.parseBoolean(extract);
+ }
+
+ private IBldResolver getResolver() {
+ if (resolver == null) {
+ if (config == null) {
+ throw new Error("SigilResolver: not configured. Specify config=\"PATH\" in ivysettings.xml.");
+ }
+ try {
+ URI uri;
+ File file = new File(config);
+
+ if (file.isAbsolute()) {
+ uri = file.toURI();
+ } else {
+ URI cwd = new File(".").toURI();
+ uri = cwd.resolve(config);
+ }
+
+ Map<String, Properties> repositories = BldFactory.getConfig(uri).getRepositoryConfig();
+ resolver = new BldResolver(repositories);
+ } catch (IOException e) {
+ throw new Error("SigilResolver: failed to configure: " + e);
+ }
+ }
+ return resolver;
+ }
+
+ public IResolution resolveOrFail(IModelElement element, boolean transitive) throws ResolutionException {
+ return getResolver().resolveOrFail(element, transitive);
+ }
+
+ public IResolution resolve(IModelElement element, boolean transitive) {
+ return getResolver().resolve(element, transitive);
+ }
+
+ public String getTypeName() {
+ return "sigil";
+ }
+
+ /*
+ * synthesize an ivy descriptor for a Sigil dependency. called after Sigil
+ * resolution, so descriptor already contains resolved version.
+ */
+ public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
+ ResolvedResource ref = null;
+
+ ModuleRevisionId id = dd.getDependencyRevisionId();
+
+ if (!id.getOrganisation().equals(ORG_SIGIL)) {
+ return null;
+ }
+
+ ISigilBundle bundle = resolve(id);
+ if (bundle == null) {
+ return null;
+ }
+
+ String symbolicName = id.getName();
+ String version = bundle.getVersion().toString();
+
+ Resource res = new SigilIvy(extractBCP ? bundle : null, symbolicName, version);
+ ref = new ResolvedResource(res, version);
+
+ Log.debug(format("findIvyFileRef: dd=%s => ref=%s", dd, ref));
+ return ref;
+ }
+
+ @Override
+ protected ResolvedResource findArtifactRef(Artifact artifact, Date date) {
+ String name = artifact.getName();
+ ModuleRevisionId id = artifact.getModuleRevisionId();
+
+ if (!id.getOrganisation().equals(ORG_SIGIL)) {
+ return null;
+ }
+
+ ISigilBundle bundle = resolve(id);
+ if (bundle == null) {
+ return null;
+ }
+
+ IBundleModelElement info = bundle.getBundleInfo();
+ URI uri = info.getUpdateLocation();
+ Resource res = null;
+
+ try {
+ URL url = (uri != null) ? uri.toURL() : bundle.getLocation().toFile().toURL();
+ if (name.contains("!")) {
+ String[] split = name.split("!");
+ url = new URL("jar:" + url + "!/" + split[1] + "." + artifact.getExt());
+ }
+ res = new URLResource(url);
+ } catch (MalformedURLException e) {
+ System.out.println("Oops! " + e);
+ }
+
+ String version = bundle.getVersion().toString();
+ ResolvedResource ref = new ResolvedResource(res, version);
+
+ Log.debug(format("findArtifactRef: artifact=%s, date=%s => ref=%s", artifact, date, ref));
+ return ref;
+ }
+
+ private ISigilBundle resolve(ModuleRevisionId id) {
+ String revision = id.getRevision();
+ String range = revision;
+
+ if (revision.indexOf(',') < 0) {
+ // SigilParser has already resolved the revision from the import
+ // version range.
+ // We now need to locate the same bundle to get its download URL.
+ // We must use an OSGi version range to specify the exact version,
+ // otherwise it will resolve to "specified version or above".
+ range = "[" + revision + "," + revision + "]";
+ }
+
+ RequiredBundle bundle = new RequiredBundle();
+ bundle.setSymbolicName(id.getName());
+ bundle.setVersions(VersionRange.parseVersionRange(range));
+
+ try {
+ IResolution resolution = resolveOrFail(bundle, false);
+ ISigilBundle[] bundles = resolution.getBundles().toArray(new ISigilBundle[0]);
+ if (bundles.length == 1) {
+ return bundles[0];
+ }
+ } catch (ResolutionException e) {
+ return null;
+ }
+ return null;
+ }
+
+ /*
+ * Implement BasicResolver abstract methods
+ */
+
+ @Override
+ protected long get(Resource res, File dest) throws IOException {
+ FileUtil.copy(res.openStream(), dest, null);
+ long len = res.getContentLength();
+ Log.debug(format("get(%s, %s) = %d", res, dest, len));
+ return len;
+ }
+
+
+ @Override
+ public Resource getResource(String source) throws IOException {
+ source = encode(source);
+ Resource res = resourcesCache.get(source);
+ if (res == null) {
+ res = new URLResource(new URL(source));
+ resourcesCache.put(source, res);
+ }
+ Log.debug(format("SIGIL: getResource(%s) = %d", source, res));
+ return res;
+ }
+
+ private static String encode(String source) {
+ return source.trim().replaceAll(" ", "%20");
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Collection findNames(Map tokenValues, String token) {
+ throw new Error("SigilResolver: findNames not supported.");
+ }
+
+ public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {
+ throw new Error("SigilResolver: publish not supported.");
+ }
+
+ public void beginPublishTransaction(ModuleRevisionId module, boolean overwrite) throws IOException {
+ // stop publish attempts being silently ignored.
+ throw new Error("SigilResolver: publish not supported.");
+ }
+
+ /*
+ * Synthesize a virtual ivy file for a Sigil dependency.
+ */
+ static class SigilIvy implements Resource {
+ private StringBuilder content = new StringBuilder();
+ private String name;
+ private boolean exists = true;
+
+ private SigilIvy() {
+ }
+
+ public SigilIvy(ISigilBundle bundle, String module, String rev) {
+ this.name = "sigil!" + module + "#" + rev;
+
+ String org = ORG_SIGIL;
+ // FIXME: make status and pub configurable
+ String status = "release";
+ String pub = "20080912162859";
+
+ content.append("<ivy-module version=\"1.0\">\n");
+
+ content.append(format(
+ "<info organisation=\"%s\" module=\"%s\" revision=\"%s\" status=\"%s\" publication=\"%s\"/>\n",
+ org, module, rev, status, pub));
+
+ String bcp = readBundleClassPath(bundle);
+ if (bcp != null) {
+ content.append("<publications>\n");
+ for (String j : bcp.split(",\\s*")) {
+ if (j.equals(".")) {
+ content.append("<artifact/>\n");
+ } else if (!j.endsWith("component-activator.jar")) {
+ if (j.endsWith(".jar"))
+ j = j.substring(0, j.length() - 4);
+ content.append(format("<artifact name=\"%s!%s\"/>\n", module, j));
+ }
+ }
+ content.append("</publications>\n");
+ }
+
+ // TODO: add dependencies?
+ // <dependencies>
+ // <dependency org="org.apache" name="log4j" rev="1.2.12"
+ // revConstraint="[1.2,1.3)"/>
+ // </dependencies>
+
+ content.append("</ivy-module>\n");
+ }
+
+ private String readBundleClassPath(ISigilBundle bundle) {
+ if (bundle == null)
+ return null;
+
+ URI uri = bundle.getBundleInfo().getUpdateLocation();
+ InputStream is = null;
+ try {
+ URL url = (uri != null) ? uri.toURL() : bundle.getLocation().toFile().toURL();
+ is = url.openStream();
+ JarInputStream js = new JarInputStream(is, false);
+ Manifest m = js.getManifest();
+ if (m != null)
+ return (String) m.getMainAttributes().getValue("Bundle-ClassPath");
+ } catch (IOException e) {
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e2) {
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public String toString() {
+ return "SigilIvy[" + name + "]";
+ }
+
+ // clone is used to read checksum files
+ // so clone(getName() + ".sha1").exists() should be false
+ public Resource clone(String cloneName) {
+ Log.debug("SigilIvy: clone: " + cloneName);
+ SigilIvy clone = new SigilIvy();
+ clone.name = cloneName;
+ clone.exists = false;
+ return clone;
+ }
+
+ public boolean exists() {
+ return exists;
+ }
+
+ public long getContentLength() {
+ return content.length();
+ }
+
+ public long getLastModified() {
+ // TODO Auto-generated method stub
+ Log.debug("NOT IMPLEMENTED: getLastModified");
+ return 0;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean isLocal() {
+ return false;
+ }
+
+ @SuppressWarnings("deprecation")
+ public InputStream openStream() throws IOException {
+ return new java.io.StringBufferInputStream(content.toString());
+ }
+ }
+}
diff --git a/sigil/bld-ivy/test/config/proj1/newton-project.xml b/sigil/bld-ivy/test/config/proj1/newton-project.xml
new file mode 100644
index 0000000..98a52cd
--- /dev/null
+++ b/sigil/bld-ivy/test/config/proj1/newton-project.xml
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ 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.
+-->
+<sigil:bundle xmlns:sigil="http://sigil.codecauldron.org/xml/sigil-namespace">
+<classpathEntry><classpathentry kind="lib" path="lib/dependee.jar"/></classpathEntry>
+<classpathEntry><classpathentry kind="src" path="src"/></classpathEntry>
+<bundle>
+<bundle-version>0.0.0</bundle-version>
+<bundle-vendor>Paremus Limited</bundle-vendor>
+<bundle-symbolicName>org.example.helloworld</bundle-symbolicName>
+<fragment-host bundle="com.springsource.org.apache.commons.lang" version="[2.0.0,2.4.0)"/>
+<export-package package="org.example.helloworld.api" version="0.0.0"/><import-package package="org.cauldron.newton.command" version="1.2.0"/><import-package package="org.apache.log4j" version="[1.2.14,1.3)"/><import-package package="org.example.helloworld.api" version="0"/><import-package package="org.cauldron.newton.command.console" version="1.2.0"/></bundle>
+<sigil:composite xmlns:sigil="http://sigil.codecauldron.org/xml/sigil-namespace">
+<location>sca/org.example.helloworld.service.composite</location>
+</sigil:composite>
+<sigil:composite xmlns:sigil="http://sigil.codecauldron.org/xml/sigil-namespace">
+<location>sca/org.example.helloworld.cli.composite</location>
+</sigil:composite>
+</sigil:bundle>
diff --git a/sigil/bld-ivy/test/config/proj1/sigil.properties b/sigil/bld-ivy/test/config/proj1/sigil.properties
new file mode 100644
index 0000000..424cd8d
--- /dev/null
+++ b/sigil/bld-ivy/test/config/proj1/sigil.properties
@@ -0,0 +1,33 @@
+# proj1 sigil.properties
+
+version: 1.2.3.beta1
+
+-bundles: main
+
+-exports: standalone
+
+-imports: \
+ javax.swing, \
+ javax.servlet, \
+ org.apache.commons.logging, \
+ org.apache.commons.lang, \
+ org.apache.log4j, \
+
+ximports: \
+ !org.cauldron.newton.framework, \
+ !org.osgi.*, \
+ org.apache.log4j;version="1.2.3", \
+
+-fragment: \
+ com.springsource.org.apache.commons.lang;version="[2.0.0,2.4.0)"
+
+-composites: \
+ ivy.xml
+
+-resources: \
+ version.properties
+
+header;Bundle-Vendor: Paremus Limited
+header;Random-Heading: this header is a bit like random
+
+# end
diff --git a/sigil/bld-ivy/test/config/sigil-defaults.properties b/sigil/bld-ivy/test/config/sigil-defaults.properties
new file mode 100644
index 0000000..784ef8e
--- /dev/null
+++ b/sigil/bld-ivy/test/config/sigil-defaults.properties
@@ -0,0 +1,6 @@
+# sigil defaults
+
+package;javax.servlet: (2.4,3.0]
+package;org.apache.log4j: [1.2.14,1.3)
+package;org.apache.commons.lang: [2.0.0,2.4.0)
+
diff --git a/sigil/bld-ivy/test/dependence/build.xml b/sigil/bld-ivy/test/dependence/build.xml
new file mode 100644
index 0000000..acb37e9
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/build.xml
@@ -0,0 +1,43 @@
+<?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="dependence" default="clean">
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" description="--> clean directories">
+ <delete includeemptydirs="true">
+ <fileset dir="settings" excludes="ivysettings.*, sigil*.properties" />
+ </delete>
+ <ant dir="dependee" antfile="build.xml" target="clean" inheritall="false" inheritrefs="false" />
+ <ant dir="depender" antfile="build.xml" target="clean" inheritall="false" inheritrefs="false" />
+ </target>
+
+ <!-- =================================
+ target: all
+ ================================= -->
+ <target name="all" depends="clean" description="--> make the whole example of dependency">
+ <ant dir="dependee" antfile="build.xml" target="publish" inheritall="false" inheritrefs="false" />
+ <ant dir="depender" antfile="build.xml" inheritall="false" inheritrefs="false" />
+ <ant dir="dependee" antfile="build.xml" target="publish" inheritall="false" inheritrefs="false" />
+ <ant dir="depender" antfile="build.xml" inheritall="false" inheritrefs="false" />
+ </target>
+
+</project>
diff --git a/sigil/bld-ivy/test/dependence/dependee/build.xml b/sigil/bld-ivy/test/dependence/dependee/build.xml
new file mode 100644
index 0000000..925d95a
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/dependee/build.xml
@@ -0,0 +1,135 @@
+<?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="dependee" default="run" xmlns:ivy="antlib:org.apache.ivy.ant">
+ <!-- some variables used -->
+ <property name="lib.dir" value="${basedir}/lib" />
+ <property name="build.dir" value="${basedir}/build" />
+ <property name="classes.dir" value="${build.dir}/classes" />
+ <property name="src.dir" value="${basedir}/src" />
+
+ <!-- ivy properties used -->
+ <property name="ivy.settings.dir" value="../settings" />
+ <property file="${ivy.settings.dir}/ivysettings.properties" />
+
+ <!-- paths used for compilation and run -->
+ <path id="lib.path.id">
+ <fileset dir="${lib.dir}" />
+ </path>
+ <path id="run.path.id">
+ <path refid="lib.path.id" />
+ <path location="${classes.dir}" />
+ </path>
+
+ <property name="ivy.jar.file"
+ value="/opt/apache-ivy-2.0.0/ivy-2.0.0.jar"/>
+
+ <!-- =================================
+ target: init
+ ================================= -->
+ <target name="init">
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant"
+ classpath="${ivy.jar.file}"/>
+ <ivy:settings file="${ivy.settings.dir}/ivysettings.xml" />
+
+ <taskdef name="sigil.bundle"
+ classname="org.cauldron.bld.ant.BundleTask"
+ classpath="${basedir}/../../../target/sigil-ivy-plugin.jar"/>
+ </target>
+
+ <!-- =================================
+ target: resolve
+ ================================= -->
+ <target name="resolve" depends="init"
+ description="--> resolve and retrieve dependencies with ivy">
+ <ivy:retrieve />
+ </target>
+
+ <!-- =================================
+ target: report
+ ================================= -->
+ <target name="report" depends="resolve" description="--> generates a report of dependencies">
+ <ivy:report todir="${build.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: compile
+ ================================= -->
+ <target name="compile" depends="resolve" description="--> description">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" />
+ </target>
+
+ <!-- =================================
+ target: run
+ ================================= -->
+ <target name="run" depends="compile" description="--> compile and run the project">
+ <java classpathref="run.path.id" classname="standalone.Main"/>
+ </target>
+
+ <!-- =================================
+ target: jar
+ ================================= -->
+ <target name="jar" depends="compile" description="--> make a jar file for this project">
+ <propertyfile file="${classes.dir}/version.properties">
+ <entry key="version" type="int" operation="+" default="0" />
+ </propertyfile>
+ <property file="${classes.dir}/version.properties" />
+
+ <!--
+ <jar destfile="${build.dir}/${ant.project.name}.jar">
+ <fileset dir="${classes.dir}" />
+ </jar>
+ -->
+
+ <sigil.bundle destpattern="${build.dir}/[id].[ext]"
+ classpathref="run.path.id" />
+
+ </target>
+
+ <!-- =================================
+ target: publish
+ ================================= -->
+ <target name="publish" depends="jar" description="--> publish this project in the ivy repository">
+ <property name="revision" value="${version}"/>
+ <delete file="${build.dir}/ivy.xml"/>
+ <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
+ resolver="projects"
+ pubrevision="${revision}"
+ status="release"
+ />
+ <echo message="project ${ant.project.name} released with version ${revision}" />
+ </target>
+
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" description="--> clean the project">
+ <delete includeemptydirs="true">
+ <fileset dir="${basedir}">
+ <exclude name="src/**" />
+ <exclude name="build.xml" />
+ <exclude name="ivy.xml" />
+ <exclude name="sigil.properties" />
+ </fileset>
+ </delete>
+ </target>
+</project>
diff --git a/sigil/bld-ivy/test/dependence/dependee/ivy.xml b/sigil/bld-ivy/test/dependence/dependee/ivy.xml
new file mode 100644
index 0000000..b250663
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/dependee/ivy.xml
@@ -0,0 +1,27 @@
+<?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" module="dependee"/>
+ <dependencies>
+ <!--
+ <dependency org="sigil" name="com.springsource.org.apache.log4j" rev="[1.2,1.3)"/>
+ -->
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/test/dependence/dependee/sigil.properties b/sigil/bld-ivy/test/dependence/dependee/sigil.properties
new file mode 100644
index 0000000..9dd7d8a
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/dependee/sigil.properties
@@ -0,0 +1,25 @@
+# dependee sigil.properties
+# all initial comments are retained.
+
+version: 1.2.3.beta1
+
+-bundles: dependee
+
+-exports: standalone
+
+-imports: \
+ org.apache.commons.lang;version="[2.0.0,2.4.0)";resolve=compile;resolution=optional, \
+ org.apache.commons.logging, \
+ javax.servlet;version="(2.4,3.0]", \
+ org.apache.log4j;version="[1.2.14,1.3)", \
+ javax.swing, \
+
+-resources: \
+ version.properties
+
+header;Hello: World
+
+X-requires: \
+ com.springsource.org.apache.commons.lang;version="[2.0.0,2.4.0)", \
+
+# end
diff --git a/sigil/bld-ivy/test/dependence/dependee/src/standalone/Main.java b/sigil/bld-ivy/test/dependence/dependee/src/standalone/Main.java
new file mode 100644
index 0000000..12ffa27
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/dependee/src/standalone/Main.java
@@ -0,0 +1,62 @@
+/*
+ * 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 standalone;
+
+import java.util.Properties;
+
+import org.apache.commons.lang.WordUtils;
+
+/**
+ * TODO write javadoc
+ */
+public class Main {
+ /**
+ * Returns the version of the project
+ * @return a string representation of the version, null if the version could not be retreived
+ */
+ public static String getVersion() {
+ Properties p = new Properties();
+ try {
+ p.load(Main.class.getResourceAsStream("/version.properties"));
+ String version = p.getProperty("version");
+ if (version != null) {
+ return String.valueOf(Integer.parseInt(version));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Return the same string with all words capitalized.
+ * @param str the string conatining the words to capitalize
+ * @return null if the string was null, the string with all words capitalized otherwise
+ */
+ public static String capitalizeWords(String str) {
+ System.out.println(" [" + Main.class.getName() + "] capitalizing string \"" + str + "\" using " + WordUtils.class.getName());
+ return WordUtils.capitalizeFully(str);
+ }
+ public static void main(String[] args) {
+ String message="sentence to capitalize";
+ System.out.println("standard message : " + message);
+ System.out.println("capitalized message : " + capitalizeWords(message));
+ }
+}
diff --git a/sigil/bld-ivy/test/dependence/depender/build.xml b/sigil/bld-ivy/test/dependence/depender/build.xml
new file mode 100644
index 0000000..01216b7
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/depender/build.xml
@@ -0,0 +1,107 @@
+<?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="depender" default="run" xmlns:ivy="antlib:org.apache.ivy.ant">
+ <!-- some variables used -->
+ <property name="lib.dir" value="${basedir}/lib" />
+ <property name="build.dir" value="${basedir}/build" />
+ <property name="classes.dir" value="${build.dir}/classes" />
+ <property name="src.dir" value="${basedir}/src" />
+
+ <!-- ivy properties used -->
+ <property name="ivy.settings.dir" value="../settings" />
+ <property file="${ivy.settings.dir}/ivysettings.properties" />
+
+ <!-- paths used for compilation and run -->
+ <path id="lib.path.id">
+ <fileset dir="${lib.dir}" />
+ </path>
+ <path id="run.path.id">
+ <path refid="lib.path.id" />
+ <path location="${classes.dir}" />
+ </path>
+
+ <property name="ivy.jar.file"
+ value="/opt/apache-ivy-2.0.0/ivy-2.0.0.jar"/>
+
+ <!-- =================================
+ target: init
+ ================================= -->
+ <target name="init">
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant"
+ classpath="${ivy.jar.file}"/>
+ <ivy:settings file="${ivy.settings.dir}/ivysettings.xml" />
+ </target>
+
+ <!-- =================================
+ target: resolve
+ ================================= -->
+ <target name="resolve" depends="init"
+ description="--> resolve and retrieve dependencies with ivy">
+ <ivy:retrieve />
+ </target>
+
+ <!-- =================================
+ target: report
+ ================================= -->
+ <target name="report" depends="resolve" description="--> generates a report of dependencies">
+ <ivy:report todir="${build.dir}" dot="true"/>
+ </target>
+
+ <!-- =================================
+ target: gen-graph
+ ================================= -->
+ <target name="gen-graph" depends="report" description="--> generates a graph of dependencies (requires dot in your path - see http://www.graphviz.org/)">
+ <property name="dot.file" value="${build.dir}/apache-depending-default.dot" />
+ <property name="ivygraph.output.file" value="${build.dir}/graph.png" />
+ <exec executable="dot">
+ <arg line="-T png -o ${ivygraph.output.file} ${dot.file}" />
+ </exec>
+ </target>
+
+ <!-- =================================
+ target: compile
+ ================================= -->
+ <target name="compile" depends="resolve" description="--> description">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" />
+ </target>
+
+ <!-- =================================
+ target: run
+ ================================= -->
+ <target name="run" depends="clean, compile" description="--> compile and run the project">
+ <java classpathref="run.path.id" classname="depending.Main"/>
+ </target>
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" description="--> clean the project">
+ <delete includeemptydirs="true">
+ <fileset dir="${basedir}">
+ <exclude name="src/**" />
+ <exclude name="build.xml" />
+ <exclude name="ivy.xml" />
+ <exclude name="sigil.properties" />
+ </fileset>
+ </delete>
+ </target>
+</project>
diff --git a/sigil/bld-ivy/test/dependence/depender/ivy.xml b/sigil/bld-ivy/test/dependence/depender/ivy.xml
new file mode 100644
index 0000000..f825b21
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/depender/ivy.xml
@@ -0,0 +1,30 @@
+<?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" module="depender"/>
+ <dependencies>
+ <!--
+ <dependency name="dependee" rev="latest.integration" />
+ -->
+ </dependencies>
+ <conflicts>
+ <manager name="latest-compatible"/>
+ </conflicts>
+</ivy-module>
diff --git a/sigil/bld-ivy/test/dependence/depender/sigil.properties b/sigil/bld-ivy/test/dependence/depender/sigil.properties
new file mode 100644
index 0000000..e76ec83
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/depender/sigil.properties
@@ -0,0 +1,7 @@
+# depender sigil.properties
+
+-bundles: depender
+
+-imports: standalone
+
+# end
diff --git a/sigil/bld-ivy/test/dependence/depender/src/depending/Main.java b/sigil/bld-ivy/test/dependence/depender/src/depending/Main.java
new file mode 100644
index 0000000..db1b208
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/depender/src/depending/Main.java
@@ -0,0 +1,37 @@
+/*
+ * 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 depending;
+
+/**
+ * TODO write javadoc
+ */
+public class Main {
+ public static void main(String[] args) {
+ String standaloneVersion = standalone.Main.getVersion();
+ if (standaloneVersion!=null) {
+ System.out.println("you are using version " + standaloneVersion + " of class " + standalone.Main.class.getName());
+ } else {
+ System.err.println("failed to get version of " + standalone.Main.class.getName());
+ }
+ String message = "i am " + Main.class.getName() + " and " + standalone.Main.class.getName() + " will do the job for me";
+ System.out.println("standard message : " + message);
+ System.out.println("capitalized message : " + standalone.Main.capitalizeWords(message));
+ }
+}
diff --git a/sigil/bld-ivy/test/dependence/settings/ivysettings.properties b/sigil/bld-ivy/test/dependence/settings/ivysettings.properties
new file mode 100644
index 0000000..f68f415
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/settings/ivysettings.properties
@@ -0,0 +1,19 @@
+# ***************************************************************
+# * 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.
+# ***************************************************************
+repository.dir=${ivy.settings.dir}/repository
diff --git a/sigil/bld-ivy/test/dependence/settings/ivysettings.xml b/sigil/bld-ivy/test/dependence/settings/ivysettings.xml
new file mode 100644
index 0000000..9312a85
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/settings/ivysettings.xml
@@ -0,0 +1,48 @@
+<?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.
+-->
+<ivysettings>
+ <properties file="${ivy.settings.dir}/ivysettings.properties"/>
+ <settings defaultResolver="sigil-libs"/>
+
+ <!--<caches defaultCacheDir="${ivy.settings.dir}/ivy-cache" />
+ -->
+ <caches default="mycache" checkUpToDate="false">
+ <cache name="mycache" basedir="${ivy.settings.dir}/ivy-cache" useOrigin="true"/>
+ </caches>
+
+ <classpath file="${ivy.settings.dir}/../../../target/sigil-ivy-plugin.jar" />
+ <typedef name="sigil-parser" classname="org.cauldron.bld.ivy.SigilParser" />
+ <typedef name="sigil" classname="org.cauldron.bld.ivy.SigilResolver" />
+
+ <parsers>
+ <sigil-parser/>
+ </parsers>
+
+ <resolvers>
+ <sigil name="sigil-libs" config="${ivy.settings.dir}/sigil-repos.properties" />
+ <filesystem name="projects">
+ <ivy pattern="${repository.dir}/[module]-[revision].xml" />
+ <artifact pattern="${repository.dir}/[artifact]-[revision].[ext]" />
+ </filesystem>
+</resolvers>
+<modules>
+ <module organisation="org.apache" name="dependee" resolver="projects"/>
+</modules>
+</ivysettings>
diff --git a/sigil/bld-ivy/test/dependence/settings/sigil-repos.properties b/sigil/bld-ivy/test/dependence/settings/sigil-repos.properties
new file mode 100644
index 0000000..f00cfaf
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/settings/sigil-repos.properties
@@ -0,0 +1,17 @@
+# repository config
+
+-repositories: system, project, spring
+
+system;provider: system
+system;level: -1
+
+project;provider: project
+project;level: 0
+project;pattern: ${..}/*/[sigilproject]
+
+spring;provider: obr
+spring;level: 2
+spring;url: http://sigil.codecauldron.org/spring-external.obr
+spring;index: ${..}/settings/spring-external.obr
+
+# end
diff --git a/sigil/bld-ivy/test/dependence/sigil-defaults.properties b/sigil/bld-ivy/test/dependence/sigil-defaults.properties
new file mode 100644
index 0000000..2bc4bc9
--- /dev/null
+++ b/sigil/bld-ivy/test/dependence/sigil-defaults.properties
@@ -0,0 +1,2 @@
+header;Bundle-Vendor: Paremus Limited
+version: 1.2.3.parent
diff --git a/sigil/bld-ivy/test/multi-project/build.xml b/sigil/bld-ivy/test/multi-project/build.xml
new file mode 100644
index 0000000..fd2d774
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/build.xml
@@ -0,0 +1,59 @@
+<?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="all" default="order" xmlns:ivy="antlib:org.apache.ivy.ant">
+ <property name="common.dir" value="${basedir}/common" />
+ <import file="${common.dir}/common.xml"/>
+
+ <fileset id="projects" dir="projects" includes="**/build.xml"/>
+
+ <path id="unordered-list">
+ <fileset refid="projects"/>
+ </path>
+
+ <target name="buildlist" depends="load-ivy">
+ <ivy:buildlist reference="ordered-list">
+ <fileset refid="projects"/>
+ </ivy:buildlist>
+ </target>
+
+ <target name="publish" depends="buildlist"
+ description="compile, jar and publish all projects in the right order">
+ <subant target="publish" buildpathref="ordered-list">
+ <propertyset>
+ <propertyref name="ivy.loaded" />
+ </propertyset>
+ </subant>
+ </target>
+
+ <target name="clean" description="clean all projects">
+ <subant target="clean" buildpathref="unordered-list" />
+ </target>
+
+ <target name="fullclean" depends="clean, load-ivy"
+ description="clean tutorial: delete repository, ivy cache, and all projects">
+ <delete dir="repository"/>
+ <ivy:cleancache />
+ </target>
+
+ <target name="order" depends="buildlist">
+ <subant target="hello" buildpathref="ordered-list" />
+ </target>
+
+</project>
diff --git a/sigil/bld-ivy/test/multi-project/common/build.properties b/sigil/bld-ivy/test/multi-project/common/build.properties
new file mode 100644
index 0000000..9552b4a
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/common/build.properties
@@ -0,0 +1,30 @@
+# ***************************************************************
+# * 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.
+# ***************************************************************
+lib.dir = ${basedir}/lib
+build.dir = ${basedir}/build
+classes.dir = ${build.dir}/classes
+src.dir = ${basedir}/src
+repository.dir=${common.dir}/../repository
+
+ivy.file = ${basedir}/ivy.xml
+
+jar.file = ${build.dir}/${ant.project.name}.jar
+main.class.name = ${ant.project.name}.Main
+
+module.version.target = 1.0
diff --git a/sigil/bld-ivy/test/multi-project/common/common.xml b/sigil/bld-ivy/test/multi-project/common/common.xml
new file mode 100644
index 0000000..4e54d1d
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/common/common.xml
@@ -0,0 +1,232 @@
+<?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="common"
+ xmlns:ivy="antlib:org.apache.ivy.ant">
+ <!-- a sample common ant build file, used for ivy multi-project tutorial
+ feel free to copy and adapt it to your own needs
+ Note that the only targets specific to ivy are:
+ load-ivy
+ resolve
+ report
+ ivy-new-version
+ publish
+ publish-local
+
+ All other targets are usual ant based targets, which could have been written
+ in a build not depending at all on ivy:
+ resolve constructs a lib directory based upon ivy dependencies, and then the lib dir
+ is used as in any classical ant build
+ -->
+
+ <property file="${common.dir}/build.properties"/>
+
+ <property name="ivy.jar.dir" value="/opt/apache-ivy-2.0.0-rc2" />
+ <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy-2.0.0-rc2.jar" />
+ <property name="sigil-ivy-plugin.jar" value="${common.dir}/../../../target/sigil-ivy-plugin.jar"/>
+
+ <target name="hello">
+ <echo message="${ant.project.name}"/>
+ </target>
+
+ <!-- =================================
+ target: load-ivy
+ this target is not necessary if you put ivy.jar in your ant lib directory
+ if you already have ivy 2.0 in your ant lib, you can simply remove this
+ target
+ ================================= -->
+ <path id="ivy.lib.path">
+ <path location="${ivy.jar.file}"/>
+ <path location="${sigil-ivy-plugin.jar}"/>
+ <!--
+ <path location="${user.home}/src/tmp/ivy/build/ivy.jar"/>
+ -->
+ </path>
+
+ <target name="load-ivy" depends="ivy-taskdefs">
+ <ivy:settings file="${common.dir}/ivysettings.xml" />
+ </target>
+
+ <target name="ivy-taskdefs" unless="ivy.loaded">
+ <property name="ivy.loaded" value="true"/>
+ <echo message="Loading Ivy ..."/>
+ <!--
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant" classpath="${ivy.jar.file}"/>
+ -->
+ <taskdef resource="org/apache/ivy/ant/antlib.xml"
+ uri="antlib:org.apache.ivy.ant"
+ loaderRef="ivyLoader"
+ classpath="${ivy.jar.file}"/>
+
+ <taskdef name="sigil.bundle"
+ classname="org.cauldron.bld.ant.BundleTask"
+ classpath="${sigil-ivy-plugin.jar}:${bndlib.jar}"/>
+ </target>
+
+ <path id="lib.path.id">
+ <fileset dir="${lib.dir}" />
+ </path>
+
+ <path id="run.path.id">
+ <path refid="lib.path.id" />
+ <path location="${classes.dir}" />
+ </path>
+
+
+ <!-- setup ivy default configuration with some custom info -->
+ <property name="ivy.local.default.root" value="${repository.dir}/local"/>
+ <property name="ivy.shared.default.root" value="${repository.dir}/shared"/>
+
+ <!-- here is how we would have configured ivy if we had our own ivysettings file
+ <ivy:settings file="${common.dir}/ivysettings.xml" />
+ -->
+
+
+ <!-- =================================
+ target: resolve
+ ================================= -->
+ <target name="resolve" depends="clean-lib, load-ivy" description="--> resolve and retrieve dependencies with ivy">
+ <mkdir dir="${lib.dir}"/> <!-- not usually necessary, ivy creates the directory IF there are dependencies -->
+
+ <!-- the call to resolve is not mandatory, retrieve makes an implicit call if we don't -->
+ <ivy:resolve file="${ivy.file}"/>
+ <ivy:retrieve pattern="${lib.dir}/[artifact].[ext]" />
+ </target>
+
+ <!-- =================================
+ target: report
+ ================================= -->
+ <target name="report" depends="resolve" description="--> generates a report of dependencies">
+ <ivy:report todir="${build.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: compile
+ ================================= -->
+ <target name="compile" depends="resolve" description="--> compile the project">
+ <mkdir dir="${classes.dir}" />
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="lib.path.id" debug="true" />
+ </target>
+
+ <!-- =================================
+ target: run
+ ================================= -->
+ <target name="run" depends="version, compile" description="--> compile and run the project">
+ <java classpathref="run.path.id" classname="${main.class.name}"/>
+ </target>
+
+ <target name="ivy-new-version" depends="load-ivy" unless="ivy.new.revision">
+ <!-- default module version prefix value -->
+ <property name="module.version.prefix" value="${module.version.target}-dev-b" />
+
+ <!-- asks to ivy an available version number -->
+ <ivy:info file="${ivy.file}" />
+ <ivy:buildnumber
+ organisation="${ivy.organisation}" module="${ivy.module}"
+ revision="${module.version.prefix}" defaultBuildNumber="1" revSep=""/>
+ </target>
+
+ <target name="local-version">
+ <tstamp>
+ <format property="now" pattern="yyyyMMddHHmmss"/>
+ </tstamp>
+ <property name="ivy.new.revision" value="${module.version.target}-local-${now}"/>
+ </target>
+
+ <target name="version" depends="ivy-new-version">
+ <!-- create version file in classpath for later inclusion in jar -->
+ <mkdir dir="${classes.dir}"/>
+ <echo message="version=${ivy.new.revision}" file="${classes.dir}/${ant.project.name}.properties" append="false" />
+
+ <!-- load generated version properties file -->
+ <property file="${classes.dir}/${ant.project.name}.properties" />
+ </target>
+
+ <!-- =================================
+ target: jar
+ ================================= -->
+ <target name="jar" depends="version, compile" description="--> make a jar file for this project">
+
+ <!--
+ <jar destfile="${jar.file}">
+ <fileset dir="${classes.dir}" />
+ <manifest>
+ <attribute name="Built-By" value="${user.name}"/>
+ <attribute name="Build-Version" value="${version}" />
+ </manifest>
+ </jar>
+ -->
+
+ <sigil.bundle destpattern="${build.dir}/[id].[ext]"
+ classpathref="run.path.id"/>
+ </target>
+
+ <!-- =================================
+ target: publish
+ ================================= -->
+ <target name="publish" depends="clean-build, jar" description="--> publish this project in the ivy repository">
+ <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
+ resolver="shared"
+ pubrevision="${version}"
+ status="release"
+ />
+ <echo message="project ${ant.project.name} released with version ${version}" />
+ </target>
+
+ <!-- =================================
+ target: publish-local
+ ================================= -->
+ <target name="publish-local" depends="local-version, jar" description="--> publish this project in the local ivy repository">
+ <ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
+ resolver="local"
+ pubrevision="${version}"
+ pubdate="${now}"
+ status="integration"
+ forcedeliver="true"
+ />
+ <echo message="project ${ant.project.name} published locally with version ${version}" />
+ </target>
+
+ <!-- =================================
+ target: clean-local
+ ================================= -->
+ <target name="clean-local" description="--> cleans the local repository for the current module">
+ <delete dir="${ivy.local.default.root}/${ant.project.name}"/>
+ </target>
+
+ <!-- =================================
+ target: clean-lib
+ ================================= -->
+ <target name="clean-lib" description="--> clean the project libraries directory (dependencies)">
+ <delete includeemptydirs="true" dir="${lib.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: clean-build
+ ================================= -->
+ <target name="clean-build" description="--> clean the project built files">
+ <delete includeemptydirs="true" dir="${build.dir}"/>
+ </target>
+
+ <!-- =================================
+ target: clean
+ ================================= -->
+ <target name="clean" depends="clean-build, clean-lib" description="--> clean the project" />
+</project>
diff --git a/sigil/bld-ivy/test/multi-project/common/ivysettings.xml b/sigil/bld-ivy/test/multi-project/common/ivysettings.xml
new file mode 100644
index 0000000..03440c4
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/common/ivysettings.xml
@@ -0,0 +1,62 @@
+<?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.
+-->
+<ivysettings>
+ <properties file="${ivy.settings.dir}/build.properties"/>
+ <caches defaultCacheDir="${ivy.settings.dir}/../ivy-cache" />
+
+ <settings defaultResolver="shared"
+ circularDependencyStrategy="error" />
+
+ <classpath file="${ivy.settings.dir}/../../../target/sigil-ivy-plugin.jar" />
+ <!--
+ Ant tasks "subant" and "ant" cause IvySettings to be re-loaded,
+ which then re-loads SigilParser in a new URLClassLoader,
+ which causes ProjectRepository to be re-initialised. Outch!
+
+ Better if Ivy classpath cached its classloader, or provided a
+ loaderRef attribute, like ant does.
+
+ Loading sigil-ivy-plugin.jar in ivy-taskdefs, uses the same ClassLoader
+ to load sigil-ivy-plugin, and thus avoids re-initialising ProjectRepositiory.
+ -->
+ <typedef name="sigil-parser" classname="org.cauldron.bld.ivy.SigilParser" />
+ <typedef name="sigil" classname="org.cauldron.bld.ivy.SigilResolver" />
+
+ <parsers>
+ <sigil-parser quiet="true"/>
+ </parsers>
+
+ <resolvers>
+ <sigil name="sigil" config="${ivy.settings.dir}/sigil-repos.properties" />
+ <filesystem name="local">
+ <ivy pattern="${repository.dir}/local/[module]-[revision].xml" />
+ <artifact pattern="${repository.dir}/local/[artifact]-[revision].[ext]" />
+ </filesystem>
+ <filesystem name="shared">
+ <ivy pattern="${repository.dir}/shared/[module]-[revision].xml" />
+ <artifact pattern="${repository.dir}/shared/[module]/[artifact]-[revision].[ext]" />
+ </filesystem>
+ </resolvers>
+ <modules>
+ <!--<module organisation="org.apache.ivy.example" name=".*" resolver="shared"/>
+ -->
+ <module organisation="sigil" resolver="sigil"/>
+ </modules>
+</ivysettings>
diff --git a/sigil/bld-ivy/test/multi-project/common/sigil-gen.sh b/sigil/bld-ivy/test/multi-project/common/sigil-gen.sh
new file mode 100755
index 0000000..2f7e184
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/common/sigil-gen.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+# 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.
+
+# sigilgen build.xml ..
+
+function a2s() {
+ find ${1:?} -name '*.java' -o -name '*.spring' -o -name '*.sca' |
+ perl -e '
+ use strict;
+ use FileHandle;
+
+ my %imports;
+ my %exports;
+
+ while (<>) {
+ chomp($_);
+ my $path = $_;
+ my $fh = new FileHandle($path);
+
+ my $testFile = ($path =~ m!Test[^/]+$!);
+
+ while (my $line = <$fh>) {
+ chomp($line);
+
+ if ($line =~ /^\s*package\s+([\w.]+)\s*;\s*$/) {
+ my $exp = $1;
+ if (!($testFile && ($exp !~ /^test[.]/))) {
+ $exports{$exp} = 1;
+ }
+ }
+ elsif ($line =~ /^\s*import\s+([a-z_0-9.]+)([.][A-Z][^.]+)+;\s*$/) {
+ my $imp = $1;
+ $imports{$imp} = 1 unless ($imp =~ /^java[.]/);
+ }
+ elsif (($line !~ m!^\s*(//|\*|\@)!) &&
+ ($line =~ /(\W)((([a-z0-9]{2,})[.]){3,})[A-Z]/)) {
+ my $quot = $1;
+ my $imp = $2;
+ $imp =~ s/.$//;
+
+ if (($imp !~ /^java[.]/) &&
+ ($quot ne "\"" || ($path !~ /[.]java$/))) {
+ $imports{$imp} = 1;
+ }
+ }
+ }
+ $fh->close();
+ }
+
+ if (keys(%exports) == () && keys(%imports) == ()) {
+ exit(1);
+ }
+
+ print "-exports: \\\n";
+ foreach my $key (sort keys(%exports)) {
+ print "\t$key, \\\n";
+ }
+ print "\n";
+
+ print "-imports: \\\n";
+ foreach my $key (sort keys(%imports)) {
+ print "\t$key, \\\n";
+ }
+ print "\n";
+
+ exit(0);
+ '
+ return $?
+}
+
+for file in $*; do
+ echo "converting $file"
+ name=$(perl -ne 'print $1 if (/project name="([^"]*)"/);' $file)
+ dir=$(dirname $file)
+
+ if [ -f $dir/sigil.properties ]; then
+ rm -f $dir/sigil.properties.old
+ mv $dir/sigil.properties $dir/sigil.properties.old
+ fi
+
+ (
+ echo "# generated by sigilgen on $(date)"
+ echo
+ echo "-bundles: $name"
+ echo
+ a2s $dir && mv $dir/sigil.properties-part $dir/sigil.properties
+ ) > $dir/sigil.properties-part
+
+ rm -f $dir/sigil.properties-part
+
+done
diff --git a/sigil/bld-ivy/test/multi-project/common/sigil-repos.properties b/sigil/bld-ivy/test/multi-project/common/sigil-repos.properties
new file mode 100644
index 0000000..d98b618
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/common/sigil-repos.properties
@@ -0,0 +1,26 @@
+
+# repository config
+
+-repositories: system, project, newton, spring
+
+system;provider: system
+system;level: -1
+#system;framework: osgi.core.jar
+#system;profile: J2SE-1.5
+
+project;provider: project
+project;level: 0
+project;pattern: ../projects/**/[sigilproject]
+
+newton;provider: filesystem
+newton;level: 1
+newton;recurse: true
+#newton;dir: /opt/newton-1.2.5/lib
+newton;dir: /Users/derek/devl/Newton/src/target/newton-dist.dir/lib
+
+spring;provider: obr
+spring;level: 2
+spring;url: http://sigil.codecauldron.org/spring-external.obr
+spring;index: ../settings/spring-external.obr
+
+# end
diff --git a/sigil/bld-ivy/test/multi-project/projects/console/build.properties b/sigil/bld-ivy/test/multi-project/projects/console/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/console/build.properties
@@ -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
diff --git a/sigil/bld-ivy/test/multi-project/projects/console/build.xml b/sigil/bld-ivy/test/multi-project/projects/console/build.xml
new file mode 100644
index 0000000..5c02cba
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/console/build.xml
@@ -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="console" default="compile">
+ <property file="build.properties"/>
+
+ <import file="${common.dir}/common.xml"/>
+</project>
diff --git a/sigil/bld-ivy/test/multi-project/projects/console/ivy.xml b/sigil/bld-ivy/test/multi-project/projects/console/ivy.xml
new file mode 100644
index 0000000..93b5ee5
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/console/ivy.xml
@@ -0,0 +1,33 @@
+<?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="console"
+ status="integration"/>
+ <dependencies>
+ <!--
+ <dependency name="version" rev="latest.integration" conf="default" />
+ <dependency name="list" rev="latest.integration" conf="default->standalone" />
+ <dependency name="find" rev="latest.integration" conf="default->standalone" />
+ <dependency name="sizewhere" rev="latest.integration" conf="default->standalone" />
+ -->
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/test/multi-project/projects/console/sigil.properties b/sigil/bld-ivy/test/multi-project/projects/console/sigil.properties
new file mode 100644
index 0000000..1d4bb13
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/console/sigil.properties
@@ -0,0 +1,6 @@
+
+-bundles: console
+
+-exports: console
+
+-requires: org.example.list
diff --git a/sigil/bld-ivy/test/multi-project/projects/console/src/console/Main.java b/sigil/bld-ivy/test/multi-project/projects/console/src/console/Main.java
new file mode 100644
index 0000000..678f3ca
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/console/src/console/Main.java
@@ -0,0 +1,79 @@
+/*
+ * 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 console;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.Arrays;
+import java.lang.reflect.Method;
+
+
+public class Main {
+ private static Collection QUIT_COMMANDS = Arrays.asList(new String[] {"quit", "q", "exit"});
+ private static Collection HELP_COMMANDS = Arrays.asList(new String[] {"help", "h", "?"});
+
+ public static void main(String[] a) throws Exception {
+ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ while (true) {
+ System.out.print("> ");
+ String command = in.readLine().trim();
+ if (QUIT_COMMANDS.contains(command)) {
+ return;
+ }
+ if (HELP_COMMANDS.contains(command)) {
+ help();
+ continue;
+ }
+ String[] split = command.split(" ");
+ if (split.length == 0) {
+ error(command);
+ continue;
+ }
+
+ try {
+ String[] args = new String[split.length - 1];
+ System.arraycopy(split, 1, args, 0, args.length);
+ Class cl = Class.forName(split[0]+".Main");
+ Method m = cl.getMethod("main", new Class[] {String[].class});
+ m.invoke(null, new Object[] {args});
+ } catch (Exception ex) {
+ error(command);
+ continue;
+ }
+ }
+ }
+
+ private static void help() {
+ System.out.println("available commands:");
+ System.out.println("\tquit: quit the console");
+ System.out.println("\thelp: displays this message");
+ System.out.println("\tlist -dir <dir>: list files in given directory");
+ System.out.println("\tfind -dir <dir> -name <name>: list files with given name in given dir");
+ System.out.println("\tsizewhere -dir <dir> -name <name>: compute total size of files with given name in given dir");
+ System.out.println("\thelp: displays this message");
+ }
+
+ private static void error(String command) {
+ System.out.println("unknown command "+command);
+ System.out.println("type ? for help");
+ }
+
+}
diff --git a/sigil/bld-ivy/test/multi-project/projects/find/build.properties b/sigil/bld-ivy/test/multi-project/projects/find/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/find/build.properties
@@ -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
diff --git a/sigil/bld-ivy/test/multi-project/projects/find/build.xml b/sigil/bld-ivy/test/multi-project/projects/find/build.xml
new file mode 100644
index 0000000..4d23bf5
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/find/build.xml
@@ -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="find" default="compile">
+ <property file="build.properties"/>
+
+ <import file="${common.dir}/common.xml"/>
+</project>
diff --git a/sigil/bld-ivy/test/multi-project/projects/find/ivy.xml b/sigil/bld-ivy/test/multi-project/projects/find/ivy.xml
new file mode 100644
index 0000000..8026113
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/find/ivy.xml
@@ -0,0 +1,40 @@
+<?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="find"
+ status="integration"/>
+ <configurations>
+ <conf name="core"/>
+ <conf name="standalone" extends="core"/>
+ </configurations>
+ <publications>
+ <artifact name="find" type="jar" conf="core" />
+ </publications>
+ <dependencies>
+ <!--
+ <dependency name="version" rev="latest.integration" conf="core->default" />
+ <dependency name="list" rev="latest.integration" conf="core" />
+ <dependency org="commons-collections" name="commons-collections" rev="3.1" conf="core->default" />
+ <dependency org="commons-cli" name="commons-cli" rev="1.0" conf="standalone->default" />
+ -->
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/test/multi-project/projects/find/sigil.properties b/sigil/bld-ivy/test/multi-project/projects/find/sigil.properties
new file mode 100644
index 0000000..30c10a7
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/find/sigil.properties
@@ -0,0 +1,10 @@
+
+-bundles: find
+
+-exports: find
+
+-imports:\
+ version, \
+ list, \
+ org.apache.commons.collections, \
+ org.apache.commons.cli
diff --git a/sigil/bld-ivy/test/multi-project/projects/find/src/find/FindFile.java b/sigil/bld-ivy/test/multi-project/projects/find/src/find/FindFile.java
new file mode 100644
index 0000000..25fa1af
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/find/src/find/FindFile.java
@@ -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 find;
+
+import version.Version;
+import list.ListFile;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.io.File;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+
+public class FindFile {
+ static {
+ Version.register("find");
+ }
+
+ public static Collection find(File dir, String name) {
+ return find(ListFile.list(dir), name);
+ }
+
+ private static Collection find(Collection files, final String name) {
+ return CollectionUtils.select(files, new Predicate() {
+ public boolean evaluate(Object o) {
+ return ((File)o).getName().indexOf(name) != -1;
+ }
+ });
+ }
+}
diff --git a/sigil/bld-ivy/test/multi-project/projects/find/src/find/Main.java b/sigil/bld-ivy/test/multi-project/projects/find/src/find/Main.java
new file mode 100644
index 0000000..a41c136
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/find/src/find/Main.java
@@ -0,0 +1,76 @@
+/*
+ * 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 find;
+
+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");
+ Option name = OptionBuilder.withArgName("name")
+ .hasArg()
+ .withDescription("list 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");
+ Collection files = FindFile.find(dir, name);
+ System.out.println("listing files in " + dir + " containing " + name);
+ 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("find", options);
+ }
+ }
+
+}
diff --git a/sigil/bld-ivy/test/multi-project/projects/list/build.properties b/sigil/bld-ivy/test/multi-project/projects/list/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/list/build.properties
@@ -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
diff --git a/sigil/bld-ivy/test/multi-project/projects/list/build.xml b/sigil/bld-ivy/test/multi-project/projects/list/build.xml
new file mode 100644
index 0000000..3926148
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/list/build.xml
@@ -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="list" default="compile">
+ <property file="build.properties"/>
+
+ <import file="${common.dir}/common.xml"/>
+</project>
diff --git a/sigil/bld-ivy/test/multi-project/projects/list/ivy.xml b/sigil/bld-ivy/test/multi-project/projects/list/ivy.xml
new file mode 100644
index 0000000..7fca587
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/list/ivy.xml
@@ -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="list"
+ status="integration"/>
+ <configurations>
+ <conf name="core"/>
+ <conf name="standalone" extends="core"/>
+ </configurations>
+ <publications>
+ <artifact name="list" type="jar" conf="core" />
+ </publications>
+ <dependencies>
+ <!--
+ <dependency name="version" rev="latest.integration" conf="core->default" />
+ <dependency org="commons-cli" name="commons-cli" rev="1.0" conf="standalone->default" />
+ -->
+ </dependencies>
+</ivy-module>
diff --git a/sigil/bld-ivy/test/multi-project/projects/list/sigil.properties b/sigil/bld-ivy/test/multi-project/projects/list/sigil.properties
new file mode 100644
index 0000000..302cba7
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/list/sigil.properties
@@ -0,0 +1,14 @@
+
+# requirements
+
+-imports:\
+ version, \
+ org.apache.commons.cli
+
+# exports
+
+-bundles: list
+
+list;name: org.example.list
+list;-exports: list.*
+
diff --git a/sigil/bld-ivy/test/multi-project/projects/list/src/list/ListFile.java b/sigil/bld-ivy/test/multi-project/projects/list/src/list/ListFile.java
new file mode 100644
index 0000000..7467152
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/list/src/list/ListFile.java
@@ -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;
+ }
+}
diff --git a/sigil/bld-ivy/test/multi-project/projects/list/src/list/Main.java b/sigil/bld-ivy/test/multi-project/projects/list/src/list/Main.java
new file mode 100644
index 0000000..0f8cb14
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/list/src/list/Main.java
@@ -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 );
+ }
+ }
+
+}
diff --git a/sigil/bld-ivy/test/multi-project/projects/sigil-defaults.properties b/sigil/bld-ivy/test/multi-project/projects/sigil-defaults.properties
new file mode 100644
index 0000000..0000617
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/sigil-defaults.properties
@@ -0,0 +1,6 @@
+
+header;Bundle-Vendor: Paremus Limited
+
+package;org.osgi.framework: 1.7.1
+
+bad-key: wibble
diff --git a/sigil/bld-ivy/test/multi-project/projects/size/build.properties b/sigil/bld-ivy/test/multi-project/projects/size/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/size/build.properties
@@ -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
diff --git a/sigil/bld-ivy/test/multi-project/projects/size/build.xml b/sigil/bld-ivy/test/multi-project/projects/size/build.xml
new file mode 100644
index 0000000..2a75fe5
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/size/build.xml
@@ -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>
diff --git a/sigil/bld-ivy/test/multi-project/projects/size/ivy.xml b/sigil/bld-ivy/test/multi-project/projects/size/ivy.xml
new file mode 100644
index 0000000..33e9995
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/size/ivy.xml
@@ -0,0 +1,31 @@
+<?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>
diff --git a/sigil/bld-ivy/test/multi-project/projects/size/sigil.properties b/sigil/bld-ivy/test/multi-project/projects/size/sigil.properties
new file mode 100644
index 0000000..cf239af
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/size/sigil.properties
@@ -0,0 +1,8 @@
+
+-bundles: size
+
+-exports: size
+
+-imports:\
+ list, \
+ version
diff --git a/sigil/bld-ivy/test/multi-project/projects/size/src/size/FileSize.java b/sigil/bld-ivy/test/multi-project/projects/size/src/size/FileSize.java
new file mode 100644
index 0000000..dcd4a1c
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/size/src/size/FileSize.java
@@ -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;
+ }
+}
diff --git a/sigil/bld-ivy/test/multi-project/projects/sizewhere/build.properties b/sigil/bld-ivy/test/multi-project/projects/sizewhere/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/sizewhere/build.properties
@@ -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
diff --git a/sigil/bld-ivy/test/multi-project/projects/sizewhere/build.xml b/sigil/bld-ivy/test/multi-project/projects/sizewhere/build.xml
new file mode 100644
index 0000000..0b8ab4c
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/sizewhere/build.xml
@@ -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>
diff --git a/sigil/bld-ivy/test/multi-project/projects/sizewhere/ivy.xml b/sigil/bld-ivy/test/multi-project/projects/sizewhere/ivy.xml
new file mode 100644
index 0000000..6b86af0
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/sizewhere/ivy.xml
@@ -0,0 +1,40 @@
+<?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>
diff --git a/sigil/bld-ivy/test/multi-project/projects/sizewhere/sigil.properties b/sigil/bld-ivy/test/multi-project/projects/sizewhere/sigil.properties
new file mode 100644
index 0000000..c272f9b
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/sizewhere/sigil.properties
@@ -0,0 +1,10 @@
+
+-bundles: sizewhere
+
+-exports: sizewhere
+
+-imports:\
+ find, \
+ size, \
+ version, \
+ org.apache.commons.cli
diff --git a/sigil/bld-ivy/test/multi-project/projects/sizewhere/src/sizewhere/Main.java b/sigil/bld-ivy/test/multi-project/projects/sizewhere/src/sizewhere/Main.java
new file mode 100644
index 0000000..131af66
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/sizewhere/src/sizewhere/Main.java
@@ -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 );
+ }
+ }
+
+}
diff --git a/sigil/bld-ivy/test/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java b/sigil/bld-ivy/test/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java
new file mode 100644
index 0000000..3594bd9
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/sizewhere/src/sizewhere/SizeWhere.java
@@ -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));
+ }
+}
diff --git a/sigil/bld-ivy/test/multi-project/projects/version/build.properties b/sigil/bld-ivy/test/multi-project/projects/version/build.properties
new file mode 100644
index 0000000..1b54925
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/version/build.properties
@@ -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
diff --git a/sigil/bld-ivy/test/multi-project/projects/version/build.xml b/sigil/bld-ivy/test/multi-project/projects/version/build.xml
new file mode 100644
index 0000000..375db20
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/version/build.xml
@@ -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>
diff --git a/sigil/bld-ivy/test/multi-project/projects/version/ivy.xml b/sigil/bld-ivy/test/multi-project/projects/version/ivy.xml
new file mode 100644
index 0000000..16e08f3
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/version/ivy.xml
@@ -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>
diff --git a/sigil/bld-ivy/test/multi-project/projects/version/sigil.properties b/sigil/bld-ivy/test/multi-project/projects/version/sigil.properties
new file mode 100644
index 0000000..a940ffd
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/version/sigil.properties
@@ -0,0 +1,4 @@
+
+-bundles: version
+
+-exports: version
diff --git a/sigil/bld-ivy/test/multi-project/projects/version/src/version/Version.java b/sigil/bld-ivy/test/multi-project/projects/version/src/version/Version.java
new file mode 100644
index 0000000..0c69bc5
--- /dev/null
+++ b/sigil/bld-ivy/test/multi-project/projects/version/src/version/Version.java
@@ -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();
+ }
+ }
+}