You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/07/13 15:26:06 UTC
svn commit: r793581 [23/23] - in /felix/trunk/sigil: ./ bld-ivy/
bld-ivy/example/ bld-ivy/example/dependence/
bld-ivy/example/dependence/dependee/ bld-ivy/example/dependence/dependee/src/
bld-ivy/example/dependence/dependee/src/standalone/ bld-ivy/exam...
Added: felix/trunk/sigil/sigil-builder/site.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/sigil-builder/site.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/sigil-builder/site.xml (added)
+++ felix/trunk/sigil/sigil-builder/site.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,26 @@
+<?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.
+-->
+<site>
+ <category-def name="Sigil" label="Sigil Core">
+ <description>
+ Sigil is an SDK for developing applications to be deployed on the Newton framework (http://newton.codecauldron.org)
+ </description>
+ </category-def>
+</site>
Added: felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/Feature.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/Feature.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/Feature.java (added)
+++ felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/Feature.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,27 @@
+/*
+ * 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.sigil.build;
+
+class Feature {
+ String id, version, url;
+ String[] categories;
+}
Added: felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/FindBundlesTask.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/FindBundlesTask.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/FindBundlesTask.java (added)
+++ felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/FindBundlesTask.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,101 @@
+/*
+ * 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.sigil.build;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.osgi.framework.Version;
+
+public class FindBundlesTask extends Task {
+
+ private File dir;
+ private String symbolicName;
+ private String property;
+
+ public File getDir() {
+ return dir;
+ }
+
+ public void setDir(File dir) {
+ this.dir = dir;
+ }
+
+ public String getSymbolicName() {
+ return symbolicName;
+ }
+
+ public void setSymbolicName(String symbolicName) {
+ this.symbolicName = symbolicName;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ @Override
+ public void execute() throws BuildException {
+ System.out.println("Searching " + dir + " for bundle '" + symbolicName + "'");
+ final String prefix = symbolicName + "_";
+ String[] files = dir.list(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.startsWith(prefix);
+ }
+ });
+ if (files == null)
+ files = new String[0];
+
+ System.out.println("Found " + files.length + " file(s) starting with " + symbolicName);
+
+ Version highest = null;
+ for (String filename : files) {
+ System.out.println("Testing " + filename);
+ // Drop the prefix
+ int startIndex = prefix.length();
+
+ // Drop the ".jar" suffix if present
+ int endIndex = filename.length();
+ if (filename.toLowerCase().endsWith(".jar")) {
+ endIndex -= 4;
+ }
+
+ String versionString = filename.substring(startIndex, endIndex);
+ System.out.println("Version string is '" + versionString + "'");
+
+ Version version = new Version(versionString);
+ if (highest == null || version.compareTo(highest) > 0) {
+ highest = version;
+ }
+ }
+
+ if (highest == null) {
+ throw new BuildException("No matches for symbolic name '"
+ + symbolicName + "'");
+ }
+
+ getProject().setNewProperty(property, highest.toString());
+ }
+
+}
Added: felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/SiteInsertFeatureContentHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/SiteInsertFeatureContentHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/SiteInsertFeatureContentHandler.java (added)
+++ felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/SiteInsertFeatureContentHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,104 @@
+/*
+ * 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.sigil.build;
+
+import java.util.List;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+class SiteInsertFeatureContentHandler implements ContentHandler {
+
+ private final ContentHandler output;
+ private final List<org.cauldron.sigil.build.Feature> featureList;
+
+ public SiteInsertFeatureContentHandler(ContentHandler output,
+ List<Feature> featureList) {
+ this.output = output;
+ this.featureList = featureList;
+ }
+
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ output.characters(ch, start, length);
+ }
+
+ public void endDocument() throws SAXException {
+ output.endDocument();
+ }
+
+ public void endElement(String uri, String localName, String name) throws SAXException {
+ output.endElement(uri, localName, name);
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ output.endPrefixMapping(prefix);
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ //output.ignorableWhitespace(ch, start, length);
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException {
+ output.processingInstruction(target, data);
+ }
+
+ public void setDocumentLocator(Locator locator) {
+ output.setDocumentLocator(locator);
+ }
+
+ public void skippedEntity(String name) throws SAXException {
+ output.skippedEntity(name);
+ }
+
+ public void startDocument() throws SAXException {
+ output.startDocument();
+ }
+
+ public void startElement(String uri, String localName, String name, Attributes atts)
+ throws SAXException {
+ output.startElement(uri, localName, name, atts);
+
+ if("site".equals(name)) {
+ for (Feature feature : featureList) {
+ AttributesImpl featureAtts = new AttributesImpl();
+ featureAtts.addAttribute("", "", "url", "CDATA", feature.url);
+ featureAtts.addAttribute("", "", "id", "CDATA", feature.id);
+ featureAtts.addAttribute("", "", "version", "CDATA", feature.version);
+ output.startElement("", "", "feature", featureAtts);
+
+ for (int i = 0; i < feature.categories.length; i++) {
+ AttributesImpl categoryAtts = new AttributesImpl();
+ categoryAtts.addAttribute("", "", "name", "CDATA", feature.categories[i]);
+ output.startElement("", "", "category", categoryAtts);
+ output.endElement("", "", "category");
+ }
+
+ output.endElement("", "", "feature");
+ }
+ }
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ output.startPrefixMapping(prefix, uri);
+ }
+
+}
Added: felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/SiteInsertFeatures.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/SiteInsertFeatures.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/SiteInsertFeatures.java (added)
+++ felix/trunk/sigil/sigil-builder/src/org/cauldron/sigil/build/SiteInsertFeatures.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,179 @@
+/*
+ * 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.sigil.build;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+public class SiteInsertFeatures extends Task {
+
+ private File siteXmlFile;
+ private String features;
+ private String versionPropPrefix;
+ private String categoryPropPrefix;
+
+ public File getSiteXmlFile() {
+ return siteXmlFile;
+ }
+ public void setSiteXmlFile(File siteXmlFile) {
+ this.siteXmlFile = siteXmlFile;
+ }
+ public String getFeatures() {
+ return features;
+ }
+ public void setFeatures(String features) {
+ this.features = features;
+ }
+ public String getVersionPropPrefix() {
+ return versionPropPrefix;
+ }
+ public void setVersionPropPrefix(String versionPropPrefix) {
+ this.versionPropPrefix = versionPropPrefix;
+ }
+ public String getCategoryPropPrefix() {
+ return categoryPropPrefix;
+ }
+ public void setCategoryPropPrefix(String categoryPropPrefix) {
+ this.categoryPropPrefix = categoryPropPrefix;
+ }
+
+ @Override
+ public void execute() throws BuildException {
+ Project project = getProject();
+
+ List<Feature> featureList = new ArrayList<Feature>();
+ StringTokenizer tokenizer = new StringTokenizer(features, ",");
+ while(tokenizer.hasMoreTokens()) {
+ Feature feature = new Feature();
+ feature.id = tokenizer.nextToken().trim();
+
+ // Find the version property
+ String versionProp;
+ if(versionPropPrefix == null) {
+ versionProp = feature.id;
+ } else {
+ versionProp = versionPropPrefix + "." + feature.id;
+ }
+ feature.version = project.getProperty(versionProp);
+
+ // Find the categories for this feature
+ feature.categories = new String[0];
+ if(categoryPropPrefix != null) {
+ String categoriesStr = project.getProperty(categoryPropPrefix + "." + feature.id);
+ if(categoriesStr != null) {
+ StringTokenizer categoriesTokenizer = new StringTokenizer(categoriesStr, ",");
+ feature.categories = new String[categoriesTokenizer.countTokens()];
+ for(int i=0; i<feature.categories.length; i++) {
+ feature.categories[i] = categoriesTokenizer.nextToken();
+ }
+ }
+ }
+
+ if(feature.version != null) {
+ feature.url = "features/" + feature.id + "_" + feature.version + ".jar";
+ featureList.add(feature);
+ } else {
+ System.out.println("Skipping feature " + feature.id);
+ }
+ }
+
+ if(!siteXmlFile.isFile()) {
+ throw new BuildException(siteXmlFile + " does not exist or is not a normal file");
+ }
+ try {
+ // Generate new XML into a temporary file
+ File tempFile = File.createTempFile("tmp", ".xml", siteXmlFile.getParentFile());
+ tempFile.deleteOnExit();
+
+ SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ TransformerHandler transformerHandler = transformerFactory.newTransformerHandler();
+ transformerHandler.setResult(new StreamResult(tempFile));
+
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ SAXParser parser = parserFactory.newSAXParser();
+
+ SiteInsertFeatureContentHandler contentHandler = new SiteInsertFeatureContentHandler(transformerHandler, featureList);
+
+ XMLReader reader = parser.getXMLReader();
+ reader.setContentHandler(contentHandler);
+ reader.parse(new InputSource(new FileInputStream(siteXmlFile)));
+
+ // Backup original file
+ File backup = new File(siteXmlFile.getParentFile(), siteXmlFile.getName() + ".bak");
+ copyFile(siteXmlFile, backup);
+
+ // Replace original file
+ copyFile(tempFile, siteXmlFile);
+
+ } catch (IOException e) {
+ throw new BuildException(e);
+ } catch (TransformerConfigurationException e) {
+ throw new BuildException(e);
+ } catch (IllegalArgumentException e) {
+ throw new BuildException(e);
+ } catch (TransformerFactoryConfigurationError e) {
+ throw new BuildException(e);
+ } catch (ParserConfigurationException e) {
+ throw new BuildException(e);
+ } catch (SAXException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ private void copyFile(File source, File dest) throws IOException {
+ FileInputStream in = null;
+ FileOutputStream out = null;
+ try {
+ in = new FileInputStream(source);
+ out = new FileOutputStream(dest);
+
+ byte[] buffer = new byte[1024];
+
+ int read;
+ while((read = in.read(buffer, 0, 1024)) > -1) {
+ out.write(buffer, 0, read);
+ }
+ } finally {
+ try { if(in != null) in.close(); } catch(IOException e) {}
+ try { if(out != null) out.close(); } catch(IOException e) {}
+ }
+
+ }
+}
Added: felix/trunk/sigil/sigil-builder/template.user.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/sigil-builder/template.user.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/sigil-builder/template.user.properties (added)
+++ felix/trunk/sigil/sigil-builder/template.user.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,14 @@
+#
+source.dir=${basedir}/..
+
+#
+target.platform=/path/to/target
+
+# path to eclipse sdk
+eclipse.install.dir=/path/to/sdk/eclipse
+
+# The URL of the Update Site, for insertion into each feature.xml
+updateUrl=http://sigil.codecauldron.org/update-site-nightly
+
+# The path to an Update Site directory on the local filesystem
+updateSiteDir=/opt/development/sigil-trunk/update-site-nightly