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/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