You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by hu...@apache.org on 2009/10/01 19:19:21 UTC
svn commit: r820722 [2/8] - in /incubator/aries/contrib: ./ ibm/
ibm/aries.image/ ibm/build/ ibm/build/buildtasks/ ibm/build/buildtasks/src/
ibm/build/buildtasks/src/com/ ibm/build/buildtasks/src/com/ibm/
ibm/build/buildtasks/src/com/ibm/aries/ ibm/bui...
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/RegExp.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/RegExp.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/RegExp.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/RegExp.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class RegExp extends Task
+{
+ private Pattern p;
+ private String toMatchOn;
+
+ public void execute()
+ {
+ if (p == null) throw new BuildException("You must specify a pattern");
+
+ Matcher m = p.matcher(toMatchOn);
+
+ if (m.matches()) {
+ for (int i = 0; i < m.groupCount() + 1; i++) {
+ getProject().setProperty("group" + i, m.group(i));
+ }
+ } else {
+ throw new BuildException("The string: " + toMatchOn + " does not match the pattern: " + p);
+ }
+ }
+
+ public void setPattern(String regExpPattern)
+ {
+ p = Pattern.compile(regExpPattern);
+ }
+
+ public void setString(String match)
+ {
+ toMatchOn = match;
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/ValidateClassPath.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/ValidateClassPath.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/ValidateClassPath.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/ValidateClassPath.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,113 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks;
+
+import java.io.File;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * This ant task checks that the correct build directory is specified in the
+ * .classpath. This is needed because if eclipse compiles to one place and
+ * the build to another horrible things go wrong.
+ */
+public class ValidateClassPath extends Task
+{
+ /** The place classes are compiled to */
+ private File _buildOutput;
+ /** The build phase type */
+ private String _buildType;
+
+ @Override
+ public void execute()
+ {
+ if ("build".equals(_buildType)) {
+ File cp = new File(getProject().getBaseDir(), ".classpath");
+
+ if (cp.exists() && cp.isFile()) {
+ String classesDir = getClassesDir(cp);
+
+ File baseDir = getProject().getBaseDir();
+
+ File cpBuildDir = new File(baseDir, classesDir);
+
+ String desiredDir = _buildOutput.getAbsolutePath();
+
+ desiredDir = getProject().getName() + desiredDir.substring((int) baseDir.getAbsolutePath().length());
+
+ if (!!!cpBuildDir.equals(_buildOutput))
+ throw new BuildException("The eclipse Default output folder for this project is: " + getProject().getName() + "/" + classesDir + ", it should be: " + desiredDir);
+ }
+ }
+ }
+
+ /**
+ * @param path the path to compile to.
+ */
+ public void setBuildDir(File path)
+ {
+ _buildOutput = path;
+ }
+
+ /**
+ * @param type the build phase type.
+ */
+ public void setType(String type)
+ {
+ _buildType = type;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* parse method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method parses the current projects .classpath to get the output
+ * directory.
+ * @param cp the classpath file
+ *
+ * @return where classes are compiled to.
+ */
+ private String getClassesDir(File cp)
+ {
+ try
+ {
+ // Create a document builder used to parse the .classpath xml files
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ // Parse the .classpath and get the Document for it
+ Document doc = builder.parse(cp);
+ // get the root element in this case <classpath>
+ Element root = doc.getDocumentElement();
+ // Get all the <classpathentry> elements
+ NodeList elements = root.getElementsByTagName("classpathentry");
+
+ // loop around the <classpathentries>
+ for (int i = 0; i < elements.getLength(); i++)
+ {
+ Element entry = (Element)elements.item(i);
+
+ // get the kind attribute
+ String kind = entry.getAttribute("kind");
+
+ if ("output".equals(kind))
+ {
+ return entry.getAttribute("path");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // if we get an error (related to parsing the file) then fail the build
+ throw new BuildException(e);
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/ValidateProject.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/ValidateProject.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/ValidateProject.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/ValidateProject.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,69 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.jar.Manifest;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * This task validates the project. Currently it just checks that the build.xml
+ * name, the directory containing the build.xml matches. It also checks that
+ * the project name matches the symbolic name and version.
+ */
+public class ValidateProject extends Task
+{
+ public void execute()
+ {
+ // projectName is specified in the project's build.xml file
+ String projectName = getProject().getName();
+ String baseDir = getProject().getBaseDir().getName();
+ String symbolicName = null;
+ String version = null;
+
+ File manifest = new File(getProject().getBaseDir(), "META-INF/MANIFEST.MF");
+
+ if (manifest.exists()) {
+ Manifest man;
+ try {
+ man = new Manifest(new FileInputStream(manifest));
+ symbolicName = (String) man.getMainAttributes().getValue("Bundle-SymbolicName");
+ version = (String) man.getMainAttributes().getValue("Bundle-Version");
+ } catch (Exception e) {
+ throw new BuildException("Unable to load the manifest for this project", e);
+ }
+ }
+
+ boolean projAndBaseOk = projectName.equals(baseDir);
+ boolean projAndSymbolicOk = matchSymbolicName(symbolicName, version, projectName);
+
+ if (!!!projAndBaseOk || !!!projAndSymbolicOk) {
+ throw new BuildException(
+ "The project directory name, Ant project name, and symbolic name do not match. \r\n"
+ + "Dir name: " + baseDir + "\r\n"
+ + "Ant Project name: " + projectName + "\r\n"
+ + "Symbolic name:" + symbolicName + "\r\n"
+ + "If the baseDir and the project name do not match and you just renamed the project in eclipse you probably "
+ + "need to right click on the project and go Team > Rename in Repository... \r\n"
+ + "Also, verify the project name that you specified in the project's build.xml is correct.");
+ }
+
+ }
+
+ private boolean matchSymbolicName(String symbolicName, String version, String projectName)
+ {
+ if (symbolicName == null) return true;
+
+ if (symbolicName.indexOf(';') != -1) symbolicName = symbolicName.substring(0, symbolicName.indexOf(';'));
+
+ if (symbolicName.equals(projectName)) return true;
+
+ if (projectName.startsWith(symbolicName) && projectName.endsWith(version)) return true;
+
+ return false;
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/buildtasks.properties
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/buildtasks.properties?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/buildtasks.properties (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/buildtasks.properties Thu Oct 1 17:19:13 2009
@@ -0,0 +1,8 @@
+buildProjects=com.ibm.aries.buildtasks.BuildProjects
+findImage=com.ibm.aries.buildtasks.FindImage
+foreach=com.ibm.aries.buildtasks.ForEach
+generateClassPath=com.ibm.aries.buildtasks.GenerateClassPath
+if=com.ibm.aries.buildtasks.If
+validateProject=com.ibm.aries.buildtasks.ValidateProject
+validateBuildDir=com.ibm.aries.buildtasks.ValidateClassPath
+regexp=com.ibm.aries.buildtasks.RegExp
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/AbstractDependency.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/AbstractDependency.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/AbstractDependency.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/AbstractDependency.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,35 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+import java.util.Set;
+
+import org.apache.tools.ant.types.Path;
+
+/**
+ * A base class for dependencies.
+ */
+public abstract class AbstractDependency implements Dependency
+{
+ public void addProjectDependencies(Set<String> deps)
+ {
+ }
+
+ public void addClassPath(File f, Path p)
+ {
+ }
+
+ public void addExportPath(File f, Path p)
+ {
+ }
+
+ public void addUnittestClassPath(File f, Path p)
+ {
+ }
+
+ public void addUnittestExportPath(File baseDir, Path p)
+ {
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/Dependency.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/Dependency.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/Dependency.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/Dependency.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,59 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+import java.util.Set;
+
+import org.apache.tools.ant.types.Path;
+
+/**
+ * <p>A marker interface that indicates the implementation represents a
+ * dependency.
+ * </p>
+ */
+public interface Dependency
+{
+ /**
+ * This method is called to get the dependency to add all the projects
+ * this project needs before it can be built.
+ *
+ * @param deps the set to update.
+ */
+ public void addProjectDependencies(Set<String> deps);
+ /**
+ * This method is called to update the path with any jars and directories
+ * that other components depending on this one should build against. The
+ * base directory provided is the project directory.
+ *
+ * @param baseDir the directory the project is in.
+ * @param p the path to update.
+ */
+ public void addExportPath(File baseDir, Path p);
+ /**
+ * This method is called to update the class-path that this project will build
+ * against.
+ *
+ * @param baseDir the directory the project is in.
+ * @param p the path to update.
+ */
+ public void addClassPath(File baseDir, Path p);
+ /**
+ * This method adds all the code in the dependency to the path, not just
+ * the classes that have been exposed.
+ *
+ * @param location
+ * @param path
+ */
+ public void addUnittestClassPath(File location, Path path);
+ /**
+ * This method is called to update the path with any jars and directories
+ * that other components depending on this one should run their unittests
+ * using. The base directory provided is the project directory.
+ *
+ * @param baseDir the directory the project is in.
+ * @param p the path to update.
+ */
+ public void addUnittestExportPath(File baseDir, Path p);
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/DirectoryDependency.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/DirectoryDependency.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/DirectoryDependency.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/DirectoryDependency.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,71 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Path.PathElement;
+
+/**
+ * <p>This classs represents a dependency that is a directory containing
+ * classes. This class is used to represent a classpathentry of kind output.
+ * </p>
+ */
+public class DirectoryDependency extends AbstractDependency implements Dependency
+{
+ /** The path within the project */
+ private String _path;
+
+ /* ------------------------------------------------------------------------ */
+ /* DirectoryDependency method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @param path the path in the path attribute
+ */
+ public DirectoryDependency(String path)
+ {
+ _path = path;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* getPath method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @return the value of the path attribute from the classpathentry.
+ */
+ public String getPath()
+ {
+ return _path;
+ }
+
+ @Override
+ public void addExportPath(File f, Path p)
+ {
+ PathElement pe = p.createPathElement();
+ pe.setLocation(new File(f, _path));
+ }
+
+ @Override
+ public void addUnittestExportPath(File baseDir, Path p)
+ {
+ addExportPath(baseDir, p);
+ }
+
+ /**
+ * @param f the base dir for the project
+ * @return the location of the directory the classes are in.
+ */
+ public File getLocation(File f)
+ {
+ return new File(f, _path);
+ }
+
+ @Override
+ public String toString()
+ {
+ return _path;
+ }
+
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/IgnoreList.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/IgnoreList.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/IgnoreList.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/IgnoreList.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,23 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class IgnoreList
+{
+ private static List<String> _excludedJars = new ArrayList<String>();
+
+ public static boolean isFileIgnored(File f)
+ {
+ return _excludedJars.contains(f.getName());
+ }
+
+ public static void addExcludedJar(String name)
+ {
+ _excludedJars.add(name);
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/JarDependency.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/JarDependency.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/JarDependency.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/JarDependency.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,100 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Path.PathElement;
+
+/**
+ * <p>This class represents a jar file. It is used to represent a classpathentry
+ * whose kind is lib.
+ * </p>
+ */
+public class JarDependency extends AbstractDependency implements Dependency
+{
+ /** the path from the classpathentry */
+ private String _path;
+ /** A boolean indicating whether the jar was exposed outside the project */
+ private boolean _exported;
+ /** Indicates whether the path is absolute or relative */
+ private boolean _absolute;
+
+ /* ------------------------------------------------------------------------ */
+ /* JarDependency method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @param libPath the path to the lib relative to the project
+ * @param exported true if projects depending on this project see the content
+ * of this jar on their classpath.
+ */
+ public JarDependency(String libPath, boolean exported)
+ {
+ _path = libPath;
+ _exported = exported;
+ }
+
+ /**
+ * @param jar the path to the jar
+ * @param b true if projects depending on this project see the content
+ * of this jar on their classpath.
+ */
+ public JarDependency(File jar, boolean b)
+ {
+ _path = jar.getAbsolutePath();
+ _exported = b;
+ _absolute = true;
+ }
+
+ @Override
+ public void addClassPath(File baseDir, Path p)
+ {
+ PathElement pe = p.createPathElement();
+ if (_absolute)
+ {
+ pe.setLocation(new File(_path));
+ }
+ else
+ {
+ pe.setLocation(new File(baseDir, _path));
+ }
+ }
+
+ @Override
+ public void addUnittestClassPath(File f, Path p)
+ {
+ addClassPath(f, p);
+ }
+
+ @Override
+ public void addExportPath(File baseDir, Path p)
+ {
+ if (_exported)
+ {
+ PathElement pe = p.createPathElement();
+ if (_absolute)
+ {
+ pe.setLocation(new File(_path));
+ }
+ else
+ {
+ pe.setLocation(new File(baseDir, _path));
+ }
+ }
+ }
+
+ @Override
+ public void addUnittestExportPath(File baseDir, Path p)
+ {
+ addExportPath(baseDir, p);
+ }
+
+ @Override
+ public String toString()
+ {
+ return _path;
+ }
+
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/OSGiDependency.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/OSGiDependency.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/OSGiDependency.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/OSGiDependency.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,624 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Path.PathElement;
+
+/**
+ * This dependency handles all the OSGi related stuff. It works out what projects
+ * are needed by looking at the imports and exports, it also sorts out the classpath
+ * handling.
+ */
+public class OSGiDependency extends AbstractDependency implements Dependency
+{
+ /**
+ * A package declaration from an Import-Package or Export-Package.
+ */
+ private final static class PackageDeclaration
+ {
+ /** The package to import */
+ private String packageName;
+ /** The attributes for the package */
+ private Map<String, String> attributes = new HashMap<String, String>();
+ /** Indicates if it is a package import, rather than an export */
+ private boolean isImport;
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (other == this) return true;
+ if (other == null) return false;
+
+ if (other instanceof PackageDeclaration) {
+ PackageDeclaration otherPackage = (PackageDeclaration)other;
+
+ if (packageName.equals(otherPackage.packageName) && isImport != otherPackage.isImport) {
+ String version = attributes.get("version");
+
+ VersionMatch match = null;
+ Version exportedVersion = null;
+
+ if (isImport && version != null) {
+ match = new VersionMatch(version);
+ } else if (version != null) {
+ exportedVersion = new Version(version);
+ }
+
+ version = otherPackage.attributes.get("version");
+
+ if (match == null && otherPackage.isImport && version != null) {
+ match = new VersionMatch(version);
+ } else if (version != null && exportedVersion == null) {
+ exportedVersion = new Version(version);
+ }
+
+ if (match == null) return true;
+
+ if (exportedVersion == null) exportedVersion = new Version(0, 0, 0);
+
+ return match.matches(exportedVersion);
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return packageName.hashCode();
+ }
+ }
+
+ /** The project this dependency is for */
+ private String _projectName;
+ /** The list of package imports */
+ private List<PackageDeclaration> _packageImports = new ArrayList<PackageDeclaration>();
+ /** The list of package exports */
+ private List<PackageDeclaration> _packageExports = new ArrayList<PackageDeclaration>();
+ /** A cache of the project dependencies */
+ private Set<String> _projectDependencies;
+ /** Jar files in the bundle to check for */
+ private List<File> _files = new ArrayList<File>();
+ /** The plugin dir to look in for binary dependencies */
+ private List<File> _pluginDirs;
+
+ /**
+ * @param projectName the project name.
+ * @param file the manifest file for the project.
+ * @param dirs
+ */
+ public OSGiDependency(String projectName, File file, List<File> dirs)
+ {
+ _pluginDirs = dirs;
+ _projectName = projectName;
+ try {
+ Manifest man = new Manifest(new FileInputStream(file));
+ _packageImports = getPackages(man, "Import-Package");
+ _packageExports = getPackages(man, "Export-Package");
+
+ String cp = man.getMainAttributes().getValue("Bundle-ClassPath");
+
+ if (cp != null) {
+
+ String[] cpEntries = cp.split(",");
+
+ for (String cpEntry : cpEntries) {
+ File f = new File("../" + _projectName + "/" + cpEntry.trim());
+ if (f.exists() && f.isFile())
+ _files.add(f);
+ }
+ }
+ } catch (IOException e) {
+ throw new BuildException("Could not read manifest.mf", e);
+ }
+ }
+
+ @Override
+ public void addProjectDependencies(Set<String> deps)
+ {
+ if (_projectDependencies == null) {
+ _projectDependencies = new HashSet<String>();
+ Collection<ProjectClassPath> cps = ProjectClassPathManager.getClassPaths();
+ List<OSGiDependency> osgiDeps = new ArrayList<OSGiDependency>();
+
+ for (ProjectClassPath pcp : cps) {
+ OSGiDependency dep = pcp.getOSGiDependency();
+
+ if (dep != null && !!!_projectName.equals(dep._projectName)) {
+ osgiDeps.add(dep);
+ }
+ }
+
+ for (PackageDeclaration pack : _packageImports) {
+ for (OSGiDependency osgi : osgiDeps) {
+ if (osgi.importMatches(pack)) _projectDependencies.add(osgi._projectName);
+ }
+ }
+ }
+
+ deps.addAll(_projectDependencies);
+ }
+
+ /**
+ * This method is invoked to build the classpath for another component. It
+ * prepares a directory containing the union of the packages exported by
+ * this component (as denoted by the Manifest.mf Export-Package directive)
+ * and the imported packages desired. It then puts the directory on the path.
+ *
+ * @param f the components root directory.
+ * @param classes the classes directory for the component.
+ * @param importList the list of packages needed by the component being built.
+ * @param p the path to append to.
+ */
+ public void addExportPath(File f, File classes, List<PackageDeclaration> importList, Path p)
+ {
+ File osgiTmp = new File(f, "build/tmp/osgi");
+
+ if (osgiTmp.exists()) deleteDir(osgiTmp);
+
+ if (!!!osgiTmp.mkdirs()) throw new BuildException("Unable to create " + osgiTmp);
+
+ Iterator<PackageDeclaration> it = importList.iterator();
+
+ while (it.hasNext()) {
+ PackageDeclaration pack = it.next();
+ if (_packageExports.contains(pack)) {
+ String packageName = pack.packageName.replaceAll("\\.", "/");
+ File classesDir = new File(classes, packageName);
+
+ if (classesDir.exists()) {
+ File target = new File(osgiTmp, packageName);
+ if (!!!target.mkdirs()) throw new BuildException("Unable to create " + target);
+ copy(classesDir, target);
+ it.remove();
+ } else if (!!!_files.isEmpty()) {
+ for (File nestedJar : _files) {
+ try {
+ JarFile jarFile = new JarFile(nestedJar);
+ Enumeration<JarEntry> entries =jarFile.entries();
+
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+
+ String entryName = entry.getName();
+ if (entryName.endsWith(".class")) {
+ String targetPathName = packageName.replaceAll("\\.", "/");
+ if (entryName.startsWith(targetPathName) &&
+ entryName.substring(targetPathName.length() + 2).indexOf('/') == -1) {
+ InputStream is = jarFile.getInputStream(entry);
+ File outFile = new File(osgiTmp, entryName);
+
+ File parent = outFile.getParentFile();
+ if (!!!parent.exists() && !!!parent.mkdirs())
+ throw new BuildException("Unable to create directory " + outFile.getParentFile());
+
+ FileOutputStream os = new FileOutputStream(outFile);
+ copy(is, os);
+ }
+ }
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ PathElement pe = p.createPathElement();
+ pe.setLocation(osgiTmp);
+ }
+
+
+ @Override
+ public void addUnittestExportPath(File baseDir, Path p)
+ {
+ File aries = new File(baseDir, ".aries");
+
+ Properties props = new Properties();
+ try {
+ props.load(new FileReader(aries));
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ String unittestIgnore = props.getProperty("ignore.unittest");
+
+ if (!!!Boolean.valueOf(unittestIgnore)) {
+ ProjectClassPath cp = ProjectClassPathManager.getClassPath(_projectName);
+
+ cp.getOutput().addUnittestExportPath(baseDir, p);
+
+ if (!!!_files.isEmpty()) {
+ for (File jar : _files) {
+ PathElement pe = p.createPathElement();
+ pe.setLocation(jar);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void addClassPath(File f, Path p)
+ {
+ File osgiTmp = new File(f, "build/tmp/osgi");
+
+ if (osgiTmp.exists()) deleteDir(osgiTmp);
+
+ if (!!!osgiTmp.mkdirs()) throw new BuildException("Unable to create " + osgiTmp);
+
+ // first of all get hold of the projects we depend on after looking at
+ // imports and exports.
+ Set<String> deps = new HashSet<String>();
+ addProjectDependencies(deps);
+
+ // now get a copy of the imports (add the addExportPath removes packages
+ // once they have been provided to the class path)
+ List<PackageDeclaration> localPackages = new ArrayList<PackageDeclaration>();
+ localPackages.addAll(_packageImports);
+
+ // loop around all the projects we depend on and add the OSGi dependencies.
+ for (String projectName : deps) {
+ // get the project classpath
+ ProjectClassPath cp = ProjectClassPathManager.getClassPath(projectName);
+ // now we work out where it compiles files to
+ File classes = cp.getOutput().getLocation(cp.getRoot());
+ // and finally we call addExportPath on the OSGi dependency. This is not
+ // the normal Dependency varient because we need more information in this
+ // case
+ cp.getOSGiDependency().addExportPath(cp.getRoot(), classes, localPackages, p);
+ }
+
+ if (!!!localPackages.isEmpty()) {
+ // if we still have packages we have to look elsewhere.
+ // right now I will look in prereqs/equinox/lib and prereq/alpine/lib
+ // and pull the relevant classes. At some point we should have another
+ // mechanism for working out where to look for plugins for this.
+
+ for (File plugins : _pluginDirs) {
+ extractFromDir(osgiTmp, plugins, localPackages);
+
+ if (localPackages.isEmpty()) break;
+ }
+ }
+
+ PathElement pe = p.createPathElement();
+ pe.setLocation(osgiTmp);
+ }
+
+ @Override
+ public void addUnittestClassPath(File f, Path p)
+ {
+ Set<String> deps = new HashSet<String>();
+ addProjectDependencies(deps);
+
+ // loop around all the projects we depend on and add the OSGi dependencies.
+ for (String projectName : deps) {
+ // get the project classpath
+ ProjectClassPath cp = ProjectClassPathManager.getClassPath(projectName);
+ // and finally we call addExportPath on the OSGi dependency. This is not
+ // the normal Dependency varient because we need more information in this
+ // case
+ cp.getOSGiDependency().addUnittestExportPath(cp.getRoot(), p);
+ }
+
+ PathElement pe = p.createPathElement();
+ pe.setLocation(ProjectClassPathManager.getClassPath(_projectName).getOutput().getLocation(f));
+
+ // now we should add equinox and alpine in
+
+ for (File dir : _pluginDirs) {
+ addJarsToPath(p, dir);
+ }
+ }
+
+ /**
+ * Add all the jars in the given directory to the class path.
+ *
+ * @param p
+ * @param prereqDir
+ */
+ private void addJarsToPath(Path p, File prereqDir)
+ {
+ File[] jars = prereqDir.listFiles(new FileFilter(){
+ public boolean accept(File pathname)
+ {
+ return pathname.isFile() && pathname.getName().endsWith(".jar");
+ }
+ });
+
+ if (jars != null) {
+ for (File jar : jars) {
+ if (!!!IgnoreList.isFileIgnored(jar)) {
+ PathElement pe = p.createPathElement();
+ pe.setLocation(jar);
+ }
+ }
+ }
+ }
+
+ /**
+ * This method looks for jars in the prereq dir and extracts any relevant
+ * class files to the osgiTmp dir. Relevant classes are in the packages
+ * in the packageNames parameter which are listed in the Export-Package
+ * directive of the jar.
+ *
+ * @param osgiTmp The osgi temp location to extract classes to.
+ * @param prereqDir The prereq directory the jars are found in.
+ * @param packages The package names we need.
+ */
+ private void extractFromDir(File osgiTmp, File prereqDir, Collection<PackageDeclaration> packages)
+ {
+ File[] jarsArray = prereqDir.listFiles(new FileFilter(){
+ public boolean accept(File pathname)
+ {
+ return pathname.isFile() && pathname.getName().endsWith(".jar");
+ }
+ });
+
+ if (jarsArray != null) {
+ for (File jar : jarsArray) {
+ extractRelevantFilesFromJar(jar, packages, osgiTmp);
+ }
+ }
+ }
+
+ /**
+ * This method extracts relevant classes to the specified temporary directory.
+ * Relevant classes are exported from the jar and in a package listed in
+ * packageName. Once packages have been extracted they are removed from the
+ * set.
+ *
+ * @param jar The jar file to look at.
+ * @param requiredPackage The list of package names to look in.
+ * @param osgiTmp The directory to extract files to.
+ */
+ private void extractRelevantFilesFromJar(File jar, Collection<PackageDeclaration> requiredPackage, File osgiTmp)
+ {
+ try {
+ JarFile jarFile = new JarFile(jar);
+
+ Manifest man = jarFile.getManifest();
+ List<PackageDeclaration> packages = getPackages(man, "Export-Package");
+
+ Iterator<PackageDeclaration> it = packages.iterator();
+ List<String> packagesToGrab = new ArrayList<String>();
+
+ while (it.hasNext()) {
+ PackageDeclaration pack = it.next();
+
+ if (requiredPackage.contains(pack)) packagesToGrab.add(pack.packageName);
+ }
+
+ requiredPackage.removeAll(packagesToGrab);
+
+ if (!!!packages.isEmpty()) {
+ Enumeration<JarEntry> entries = jarFile.entries();
+
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+
+ String entryName = entry.getName();
+ if (entryName.endsWith(".class")) {
+ for (String packageName : packagesToGrab) {
+ String targetPathName = packageName.replaceAll("\\.", "/");
+ if (entryName.startsWith(targetPathName) &&
+ entryName.substring(targetPathName.length() + 2).indexOf('/') == -1) {
+ InputStream is = jarFile.getInputStream(entry);
+ File outFile = new File(osgiTmp, entryName);
+
+ File parent = outFile.getParentFile();
+ if (!!!parent.exists() && !!!parent.mkdirs())
+ throw new BuildException("Unable to create directory " + outFile.getParentFile());
+
+ FileOutputStream os = new FileOutputStream(outFile);
+ copy(is, os);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ } catch (IOException e) {
+ throw new BuildException("Unable to process " + jar, e);
+ }
+ }
+
+ /**
+ * This method copies from the input stream to the output stream.
+ *
+ * @param is the input stream.
+ * @param os the output stream.
+ * @throws IOException if something went wrong.
+ */
+ private void copy(InputStream is, OutputStream os)
+ throws IOException
+ {
+ try
+ {
+ byte[] buffer = new byte[1024];
+ int len;
+
+ while ((len = is.read(buffer)) != -1) {
+ os.write(buffer, 0, len);
+ }
+ }
+ finally
+ {
+ os.flush();
+ is.close();
+ os.close();
+ }
+ }
+
+ /**
+ * Extract the packages from the manifest.
+ *
+ * @param man the manifest.
+ * @param declaration the attribute name the packages are in
+ * @return the list of package declarations
+ */
+ private List<PackageDeclaration> getPackages(Manifest man, String declaration)
+ {
+ List<PackageDeclaration> packages = new ArrayList<PackageDeclaration>();
+ if(man==null) return packages;
+
+ String allPackages = man.getMainAttributes().getValue(declaration);
+
+ if (allPackages != null) {
+
+ List<String> packagesWithAttributes = new ArrayList<String>();
+
+ String[] thePackages = allPackages.split(",");
+
+ // we may have split up with a comma in quotes as the delimiter, so we undo that here.
+ for (int i = 0; i < thePackages.length; ) {
+ String tmp = thePackages[i++].trim();
+ if (unbalancedQuotes(tmp)) {
+ for (;!!!thePackages[i].contains("\"");)
+ tmp = tmp + "," + thePackages[i++].trim();
+
+ tmp = tmp + "," + thePackages[i++].trim();
+ }
+
+ packagesWithAttributes.add(tmp);
+ }
+
+ for (String aPackage : packagesWithAttributes) {
+ String[] attributes = aPackage.split(";");
+ PackageDeclaration dec = new PackageDeclaration();
+ dec.packageName = attributes[0];
+
+ if ("Import-Package".equals(declaration)) dec.isImport = true;
+
+ for (int i = 1; i < attributes.length; i++) {
+ String[] attribParts = attributes[i].split("=");
+ String attribValue = attribParts[1];
+ if (attribValue.startsWith("\"") && attribValue.endsWith("\""))
+ attribValue = attribValue.substring(1, attribValue.length() - 1);
+
+ dec.attributes.put(attribParts[0].trim(), attribValue.trim());
+ }
+ packages.add(dec);
+ }
+ }
+
+ return packages;
+ }
+
+ /**
+ * Returns true if the provided string contains an odd number of " characters.
+ * @param tmp the string to check.
+ * @return true if the number of " is odd.
+ */
+ private boolean unbalancedQuotes(String tmp)
+ {
+ int count = 0;
+
+ int index = tmp.indexOf('"');
+
+ while (index != -1) {
+ count++;
+ index = tmp.indexOf('"', index + 1);
+ }
+
+ return (count % 2) == 1;
+ }
+
+ /**
+ * This method copies a class files from the first file directory to the
+ * target directory.
+ *
+ * @param classesDir the classes dir to copy from.
+ * @param target the target dir.
+ */
+ private void copy(File classesDir, File target)
+ {
+ File[] classes = classesDir.listFiles(new FileFilter()
+ {
+ public boolean accept(File pathname)
+ {
+ return (pathname.isFile() && pathname.getName().endsWith(".class"));
+ }
+ });
+
+ for (File classfile : classes) {
+ File targetFile = new File(target, classfile.getName());
+
+ try {
+ FileInputStream fileIn = new FileInputStream(classfile);
+ FileOutputStream fileOut = new FileOutputStream(targetFile);
+
+ copy(fileIn, fileOut);
+ } catch (IOException e) {
+ throw new BuildException("Unable to cope file from " + classfile + " to " + targetFile, e);
+ }
+ }
+ }
+
+ /**
+ * This method deletes the specified directory and all files inside.
+ *
+ * @param osgiTmp the directory to delete.
+ */
+ private void deleteDir(File osgiTmp)
+ {
+ File[] filesInDir = osgiTmp.listFiles();
+
+ for (File f : filesInDir) {
+ if (f.isDirectory()) deleteDir(f);
+ else if (!!!f.delete()) throw new BuildException("Unable to delete " + f);
+ }
+
+ if (!!!osgiTmp.delete()) throw new BuildException("Unable to delete " + osgiTmp);
+ }
+
+ /**
+ * Returns true if the bundle this OSGi dependency is for has an export that
+ * matches the provided import.
+ *
+ * @param pack a package import directive.
+ * @return true if this project exports a matching package.
+ */
+ private boolean importMatches(PackageDeclaration pack)
+ {
+ for (PackageDeclaration export : _packageExports) {
+ if (pack.packageName.equals(export.packageName)) return true;
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectClassPath.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectClassPath.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectClassPath.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectClassPath.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,316 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Path;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * <p>This class is created by loading the data from the .classpath. It has
+ * helper methods for generating information for this project and other
+ * projects classpath.
+ * </p>
+ */
+public class ProjectClassPath
+{
+ /** The location of the project on the classpath */
+ private File _projectLocation;
+ /** the list of dependencies */
+ private List<Dependency> _dependencies;
+ /** The OSGi dependency */
+ private OSGiDependency _osgi;
+ /** The directory the project built into */
+ private DirectoryDependency _output;
+ /** The plugin dirs */
+ private List<File> _pluginDirs;
+
+ /**
+ * Default constructor.
+ */
+ protected ProjectClassPath()
+ {
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* ProjectClassPath method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @param projectLocation the projects location on the file system.
+ * @param dirs
+ */
+ public ProjectClassPath(File projectLocation, List<File> dirs)
+ {
+ // store the data away and create the dependencies list
+ _projectLocation = projectLocation;
+ _dependencies = new ArrayList<Dependency>();
+
+ _pluginDirs = dirs;
+
+ // parse the .classpath file
+ parse();
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* getProjectClassPath method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * Generates and returns a Path object representing the directories, and jar
+ * files that are required in order to build the project.
+ *
+ * @param projectBeingRun The ant project being run
+ * @return the path
+ */
+ public Path getProjectClassPath(Project projectBeingRun)
+ {
+ // create the path object
+ Path path = new Path(projectBeingRun);
+
+ for (Dependency dep : _dependencies)
+ {
+ projectBeingRun.log("Adding dependency type " + dep.getClass().getSimpleName() + " info: " + dep, Project.MSG_DEBUG);
+ dep.addClassPath(_projectLocation, path);
+ }
+
+ return path;
+ }
+
+ /**
+ * Generate and return a path suitable for running unittests. This does not
+ * limit the class-path to just the required packages, but instead includes
+ * everything in bundles that are depended on.
+ *
+ * @param project the project the class-path is for.
+ * @return the configured path.
+ */
+ public Path getUnittestClassPath(Project project)
+ {
+ // create the path object
+ Path path = new Path(project);
+
+ for (Dependency dep : _dependencies)
+ {
+ project.log("Adding dependency type " + dep.getClass().getSimpleName() + " info: " + dep, Project.MSG_DEBUG);
+ dep.addUnittestClassPath(_projectLocation, path);
+ }
+
+ return path;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* addProjectExportPath method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method updates the Path object with directories and jar files that
+ * are exported by the project for other projects to build against.
+ *
+ * @param path the path to augment
+ */
+ public void addProjectExportPath(Path path)
+ {
+ for (Dependency dep : _dependencies)
+ {
+// if (_osgi == null || !!!(dep instanceof DirectoryDependency))
+// {
+ dep.addExportPath(_projectLocation, path);
+// }
+ }
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* addUnittestExportPath method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method updates the Path object with directories and jar files that
+ * are exported by the project for other projects to run tests against.
+ *
+ * @param path the path to augment
+ */
+ public void addUnittestExportPath(Path path)
+ {
+ for (Dependency dep : _dependencies)
+ {
+ if (_osgi == null || !!!(dep instanceof DirectoryDependency))
+ {
+ dep.addUnittestExportPath(_projectLocation, path);
+ }
+ }
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* getProjectDependencies method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method returns the list of projects this project depends on.
+ *
+ * @return A list of strings that contain the names of projects this project
+ * depends on.
+ */
+ public Set<String> getProjectDependencies()
+ {
+ Set<String> deps = new HashSet<String>();
+
+ // loop around the dependencies
+ for (Dependency obj : _dependencies)
+ {
+ obj.addProjectDependencies(deps);
+ }
+
+ return deps;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* getRoot method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @return the location of the project on the path.
+ */
+ public File getRoot()
+ {
+ return _projectLocation;
+ }
+
+ /**
+ * @return the name of the project this class-path is for
+ */
+ public String getProjectName()
+ {
+ return _projectLocation.getName();
+ }
+
+ /**
+ * @return the possibly null OSGi dependency for this component.
+ */
+ public OSGiDependency getOSGiDependency()
+ {
+ return _osgi;
+ }
+
+ /**
+ * @return the output location for classes in the project.
+ */
+ public DirectoryDependency getOutput()
+ {
+ return _output;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* parse method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method parses the current projects .classpath
+ */
+ private void parse()
+ {
+ try
+ {
+ // Create a document builder used to parse the .classpath xml files
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ // Parse the .classpath and get the Document for it
+ Document doc = builder.parse(new File(_projectLocation, ".classpath"));
+ // get the root element in this case <classpath>
+ Element root = doc.getDocumentElement();
+ // Get all the <classpathentry> elements
+ NodeList elements = root.getElementsByTagName("classpathentry");
+
+ // loop around the <classpathentries>
+ for (int i = 0; i < elements.getLength(); i++)
+ {
+ Element entry = (Element)elements.item(i);
+
+ // get the kind attribute
+ String kind = entry.getAttribute("kind");
+
+ // if the kind is lib, then this is a jar file to be added to the
+ // classpath.
+ if ("lib".equals(kind))
+ {
+ // Handle case where it is a jar file
+ // Get the path and add it as a pathelement to the path
+ String libPath = entry.getAttribute("path");
+ boolean exported = Boolean.valueOf(entry.getAttribute("exported")).booleanValue();
+
+ if (libPath.charAt(0) == '/')
+ {
+ libPath = "../" + libPath;
+ }
+
+ _dependencies.add(new JarDependency(libPath, exported));
+ }
+ // if the kind is src then it is either another project, or a source
+ // folder. We ignore source folders, but need to include projects
+ else if ("src".equals(kind))
+ {
+ // Need to look here to see if this is a project or not
+ // project dependencies start with a /
+ String srcPath = entry.getAttribute("path");
+ if (srcPath.startsWith("/"))
+ {
+ // it is a project then call getDependent path to find get the
+ // exposed externals of the other project.
+ _dependencies.add(new ProjectDependency(srcPath.substring(1)));
+ }
+ }
+ else if ("output".equals(kind))
+ {
+ _output = new DirectoryDependency(entry.getAttribute("path"));
+ _dependencies.add(_output);
+ }
+ else if ("con".equals(kind))
+ {
+ String path = entry.getAttribute("path");
+
+ if ("org.eclipse.jdt.junit.JUNIT_CONTAINER/4".equals(path))
+ {
+ addJarsInDir("../prereqs/junit/lib/");
+ }
+ else if ("org.eclipse.pde.core.requiredPlugins".equals(path))
+ {
+ _osgi = new OSGiDependency(_projectLocation.getName(), new File(_projectLocation, "META-INF/MANIFEST.MF"), _pluginDirs);
+ _dependencies.add(_osgi);
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // if we get an error (related to parsing the file) then fail the build
+ throw new BuildException(e);
+ }
+ }
+
+ /**
+ * @param dirName the name of the directory to look for jars in
+ */
+ private void addJarsInDir(String dirName)
+ {
+ File f = new File(dirName);
+ File[] jars = f.listFiles(new FileFilter()
+ {
+ public boolean accept(File pathname)
+ {
+ return pathname.isFile() && pathname.getName().endsWith(".jar");
+ }
+ });
+ if(jars!=null){
+ for (File jar : jars)
+ {
+ _dependencies.add(new JarDependency(jar, false));
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectClassPathManager.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectClassPathManager.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectClassPathManager.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectClassPathManager.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,142 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * <p>This class manages ProjectClassPath objects, it caches ClassPaths already
+ * determined by previous calls to this class.
+ * </p>
+ */
+public class ProjectClassPathManager
+{
+ /**
+ * This extension of ProjectClassPath does nothing interesting.
+ */
+ public static class NullClassPath extends ProjectClassPath
+ {
+ /** The path to the .classpath */
+ private File classPath;
+ /**
+ * @param path the .classpath file
+ */
+ public NullClassPath(File path) { this.classPath = path; }
+ @Override public void addProjectExportPath(Path path) { }
+ @Override public void addUnittestExportPath(Path path) { }
+ @Override public OSGiDependency getOSGiDependency() { return null; }
+ @Override public DirectoryDependency getOutput() { return null; }
+ @Override public Path getProjectClassPath(Project projectBeingRun) { return new Path(projectBeingRun); }
+ @Override public Set<String> getProjectDependencies() { return new HashSet<String>(); }
+ @Override public Path getUnittestClassPath(Project project) { return new Path(project); }
+ @Override public String getProjectName() { return classPath.getName(); }
+ @Override public File getRoot() { return classPath; }
+ }
+
+ /** The root of the build */
+ private static File _buildRoot = new File("..");
+ /** A cache of ProjectClassPaths already calculated */
+ private static Map<String, ProjectClassPath> _projectData = new HashMap<String, ProjectClassPath>();
+ /** A list of plugin dirs */
+ private static List<File> _pluginDirs;
+
+ /* ------------------------------------------------------------------------ */
+ /* getClassPath method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method returns the ProjectClassPath for the same project, two serial
+ * calls to this method will return the same object, two calls in parallel
+ * may return different objects.
+ *
+ * @param projectName The name of the project
+ * @return the ProjectClassPath
+ */
+ public static final ProjectClassPath getClassPath(String projectName)
+ {
+ ProjectClassPath cp;
+ // if the ProjectClassPath has already been calculated and saved return
+ // the cached one
+ if (_projectData.containsKey(projectName))
+ {
+ cp = _projectData.get(projectName);
+ }
+ // otherwise construct a new ProjectClassPath and cache it away.
+ else
+ {
+ File cpFile = new File(_buildRoot, projectName);
+ if (new File(cpFile, ".classpath").exists()) {
+ cp = new ProjectClassPath(cpFile, _pluginDirs);
+ _projectData.put(projectName, cp);
+ } else {
+ return new NullClassPath(cpFile);
+ }
+ }
+
+ return cp;
+ }
+
+ /**
+ * This method is used to initialize the projects class-paths in the cache.
+ * This needs to be done otherwise the OSGi dependencies cannot be handled
+ * correctly.
+ *
+ * @param projectNames the list of project names.
+ */
+ public static final void initClassPath(List<String> projectNames)
+ {
+ for (String projectName : projectNames) {
+ getClassPath(projectName);
+ }
+ }
+
+ /**
+ * @return all the cached classpaths
+ */
+ public static final Collection<ProjectClassPath> getClassPaths()
+ {
+ return _projectData.values();
+ }
+
+ /**
+ * This method initializes the classpath for all Aries projects. It is only
+ * called if the "aries.projects.we.are.building" property does not exist.
+ */
+ public static final void initClasspaths()
+ {
+ File f = new File("..");
+ File[] dirs = f.listFiles(new FileFilter() {
+
+ public boolean accept(File pathname)
+ {
+ return pathname.isDirectory() && new File(pathname, ".aries").exists();
+ }
+
+ });
+
+ if (dirs != null) {
+ List<String> projectNames = new ArrayList<String>();
+ for (File dir : dirs) {
+ projectNames.add(dir.getName());
+ }
+
+ ProjectClassPathManager.initClassPath(projectNames);
+ }
+ }
+
+ public static void setPluginDirs(List<File> dirs)
+ {
+ _pluginDirs = dirs;
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectDependency.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectDependency.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectDependency.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/ProjectDependency.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,59 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.File;
+import java.util.Set;
+
+import org.apache.tools.ant.types.Path;
+
+/**
+ * <p>This class represents a dependency on another project.</p>
+ */
+public class ProjectDependency extends AbstractDependency implements Dependency
+{
+ /** the name of the project */
+ private String _projectName;
+
+ /* ------------------------------------------------------------------------ */
+ /* ProjectDependency method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @param projName the name of the project
+ */
+ public ProjectDependency(String projName)
+ {
+ _projectName = projName;
+ }
+
+ @Override
+ public void addProjectDependencies(Set<String> deps)
+ {
+ deps.add(_projectName);
+ }
+
+ @Override
+ public void addClassPath(File f, Path p)
+ {
+ // get the other projects class path
+ ProjectClassPath cp = ProjectClassPathManager.getClassPath(_projectName);
+ // add the projects exported class-path to the path
+ cp.addProjectExportPath(p);
+ }
+
+ @Override
+ public void addUnittestClassPath(File f, Path p)
+ {
+ // get the other projects class path
+ ProjectClassPath cp = ProjectClassPathManager.getClassPath(_projectName);
+ // add the projects exported class-path to the path
+ cp.addUnittestExportPath(p);
+ }
+
+ @Override
+ public String toString()
+ {
+ return _projectName;
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/Version.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/Version.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/Version.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/Version.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,345 @@
+/*
+ * (C) Copyright IBM Corp. 2005, 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * <p>This class implements a version scheme of the form n.n.n.n where each
+ * n is a number. This implementation was derived from the version in
+ * messaging.impl which itself was derived from a class in the config service.
+ * </p>
+ *
+ * <p>This class differs in several ways:
+ * <ul>
+ * <li>It is Serializable.</li>
+ * <li>It correctly implements hashCode and equals, so it can be added to a Map or Set.</li>
+ * <li>It is Cloneable.</li>
+ * </ul>
+ * </p>
+ *
+ * <p>This class is immutable</p>
+ */
+public final class Version implements Comparable<Version>, Externalizable, Cloneable
+{
+ /** The serial version UID of this class */
+ private static final long serialVersionUID = 918567830801402389L;
+ /** The components of the version */
+ private int[] _components;
+ /** indicates whether calls to readExternal should work (defaults to true) */
+ private boolean _readOnly = true;
+
+ /* ---------------------------------------------------------------------- */
+ /* Version method
+ /* ---------------------------------------------------------------------- */
+ /**
+ * This constructors reads a string into a version object. An empty string produces
+ * and undefined behaviour.
+ *
+ * @param ver the string version spec.
+ * @throws NumberFormatException if a version component contains a non-number
+ */
+ public Version(String ver)
+ {
+ String quote = "\"";
+ // Replace all quotes in the version. This is for cases where the version
+ // has been enclosed in quotes.
+ ver = ver.replace(quote, "");
+
+ // split the version up with a period as the delimiter.
+ String[] componentsOfVersion = ver.trim().split("\\.");
+ _components = new int[componentsOfVersion.length];
+
+ // convert the period separated strings into ints.
+ for (int i = 0; i < componentsOfVersion.length; i++)
+ {
+ _components[i] = Integer.parseInt(componentsOfVersion[i]);
+ }
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* Version method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This constructor creates the version from the specified component versions.
+ * An array of length zero produces an undefined behaviour.
+ *
+ * @param ver the version components in int form.
+ */
+ public Version(int ... ver)
+ {
+ _components = new int[ver.length];
+
+ // Note an array copy is required in order to ensure that this class is immutable.
+ System.arraycopy(ver, 0, _components, 0, ver.length);
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* Version method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * <p>This constructor should only be used during deserialization. It allows
+ * readExternal to update the contents of this Version once and once only.
+ * </p>
+ *
+ * <p>The behaviour of a Version constructed using this constructor is undefined
+ * until the readExternal method is called.
+ * </p>
+ */
+ public Version()
+ {
+ _readOnly = false;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* compareTo method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method works as follows:
+ *
+ * <p>If this version is 6.1.0.0 the following would result in 0 being returned:
+ * <ul>
+ * <li>6.1.0.0</li>
+ * <li>6.1</li>
+ * </ul>
+ * </p>
+ *
+ * <p>If this version is 6.1.0.0 the following would result in 1 being returned:
+ * <ul>
+ * <li>6.0.2</li>
+ * <li>6.0.2.17</li>
+ * </ul>
+ * </p>
+ *
+ * <p>If this version is 6.1.0.0 the following would result in -1 being returned:
+ * <ul>
+ * <li>6.1.0.3</li>
+ * <li>7.0.0.0</li>
+ * </ul>
+ * </p>
+ *
+ * @param ver The version
+ * @return 0 if they are equal, -1 if this is less than the other, and 1
+ * if this is greater than the other.
+ *
+ * @see java.lang.Comparable#compareTo(Object)
+ */
+ public int compareTo(Version ver)
+ {
+ int[] otherComponents = ver._components;
+
+ // work out the minimum length of the components for each version.
+ int mylen = _components.length;
+ int otherlen = otherComponents.length;
+ // work out if the other one is longer than this one.
+ boolean longer = (mylen < otherlen);
+ int minLen = (longer ? mylen : otherlen);
+
+ // loop around all the entries up to the minimum length
+ int i = 0;
+ for ( i=0; i < minLen; i++ )
+ {
+ int firstVal = _components[i];
+ int secondVal = otherComponents[i];
+ if ( firstVal < secondVal ) return -1;
+ if ( firstVal > secondVal ) return 1;
+ }
+
+
+ if (mylen != otherlen)
+ {
+ // if we are here then we know that so far they are equal.
+ // In order for them to be truly equal the longer one must
+ // contain only zeros. Otherwise the longer version is
+ // higher than the shorter version.
+ if (longer)
+ {
+ for (int j = i+1; j<otherlen; j++)
+ {
+ if (otherComponents[j] != 0) return -1;
+ }
+ }
+ else
+ {
+ for (int j = i+1; j<mylen; j++)
+ {
+ if (_components[j] != 0) return 1;
+ }
+ }
+ }
+
+ // if we get here then they are equal.
+ return 0;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* hashCode method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method returns the sun of the components as the hashCode. This is
+ * because 6.1 and 6.1.0.0 need to have the same hashCode as they are equal.
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ int result = 0;
+
+ for (int i : _components)
+ {
+ result += i;
+ }
+
+ return result;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* equals method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this) return true;
+ if (obj == null) return false;
+
+ if (obj instanceof Version)
+ {
+ return (compareTo((Version)obj) == 0);
+ }
+
+ return false;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* getMajorVersion method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @return the major version represented by this version number.
+ */
+ public int getMajorVersion()
+ {
+ return _components[0];
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* toString method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method returns the string form of this version. The result of this method
+ * can be used to create a new Version object, such that:
+ *
+ * <pre>
+ * Version v = new Version(old.toString());
+ * </pre>
+ *
+ * works.
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+
+ for (int i : _components)
+ {
+ builder.append(i);
+ builder.append('.');
+ }
+
+ builder.deleteCharAt(builder.length() - 1);
+
+ return builder.toString();
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* toComponents method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * This method returns the components of this version as an array of ints.
+ * The result of this method can be used to create a new Version object, such that:
+ * <pre>
+ * Version v = new Version(old.toComponentns());</pre>
+ * works.
+ *
+ * @return the version components.
+ */
+ public int[] toComponents()
+ {
+ int[] ver = new int[_components.length];
+
+ // Note an array copy is required in order to ensure that this class is immutable.
+ System.arraycopy(_components, 0, ver, 0, _components.length);
+
+ return ver;
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* clone method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Version clone()
+ {
+ return new Version(_components);
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* writeExternal method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeLong(serialVersionUID);
+
+ out.writeInt(_components.length);
+
+ for (int i : _components)
+ {
+ out.writeInt(i);
+ }
+
+ out.flush();
+ }
+
+ /* ------------------------------------------------------------------------ */
+ /* readExternal method
+ /* ------------------------------------------------------------------------ */
+ /**
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ if (_readOnly)
+ {
+ throw new IOException();
+ }
+
+ _readOnly = true;
+
+ in.readLong(); // Read the serial version UID.
+
+ int length = in.readInt();
+
+ int[] components = new int[length];
+
+ for (int i = 0; i < components.length; i++)
+ {
+ components[i] = in.readInt();
+ }
+
+ _components = components;
+ }
+}
Added: incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/VersionMatch.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/VersionMatch.java?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/VersionMatch.java (added)
+++ incubator/aries/contrib/ibm/build/buildtasks/src/com/ibm/aries/buildtasks/classpath/VersionMatch.java Thu Oct 1 17:19:13 2009
@@ -0,0 +1,103 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.aries.buildtasks.classpath;
+
+
+/**
+ * This class determines whether a version is contained within a version range.
+ */
+public class VersionMatch
+{
+ /** The minimum desired version for the bundle */
+ private Version minimumVersion;
+ /** The maximum desired version for the bundle */
+ private Version maximumVersion;
+ /** True if the match is exclusive of the minimum version */
+ private boolean minimumExclusive;
+ /** True if the match is exclusive of the maximum version */
+ private boolean maximumExclusive;
+
+ /**
+ * @param versions the version spec
+ */
+ public VersionMatch(String versions)
+ {
+ int index;
+
+ if ((versions.startsWith("[") || versions.startsWith("(")) &&
+ (versions.endsWith("]") || versions.endsWith(")"))) {
+ if (versions.startsWith("[")) minimumExclusive = false;
+ else if (versions.startsWith("(")) minimumExclusive = true;
+
+ if (versions.endsWith("]")) maximumExclusive = false;
+ else if (versions.endsWith(")")) maximumExclusive = true;
+
+ index = versions.indexOf(',');
+ String minVersion = versions.substring(1, index);
+ String maxVersion = versions.substring(index + 1, versions.length() - 1);
+
+ try {
+ minimumVersion = new Version(minVersion);
+ maximumVersion = new Version(maxVersion);
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException("Failed to parse " + versions + ".", nfe);
+ }
+ } else {
+ try {
+ minimumVersion = new Version(versions);
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException("Failed to parse " + versions + ".", nfe);
+ }
+ }
+ }
+
+ /**
+ * This toString will return a String identical to the one originally used to
+ * construct this BundleMatchImpl
+ *
+ * @return a string representing this BundleMatchImpl
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+
+ if (maximumVersion == null) {
+ builder.append(minimumVersion);
+ } else {
+ if (minimumExclusive) builder.append('(');
+ else builder.append('[');
+ builder.append(minimumVersion);
+ builder.append(',');
+ builder.append(maximumVersion);
+ if (maximumExclusive) builder.append(')');
+ else builder.append(']');
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * This method checks that the provided version matches the desired version.
+ *
+ * @param version the version.
+ * @return true if the version matches, false otherwise.
+ */
+ public boolean matches(Version version)
+ {
+ boolean result;
+
+ // if max is null then no maximum has been specified.
+ if (maximumVersion == null) {
+ result = minimumVersion.compareTo(version) <= 0;
+ } else {
+ int minN = minimumExclusive ? 0 : 1;
+ int maxN = maximumExclusive ? 0 : 1;
+
+ result = (minimumVersion.compareTo(version) < minN) &&
+ (version.compareTo(maximumVersion) < maxN);
+ }
+ return result;
+ }
+}
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/imports/begin.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/imports/begin.xml?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/imports/begin.xml (added)
+++ incubator/aries/contrib/ibm/build/imports/begin.xml Thu Oct 1 17:19:13 2009
@@ -0,0 +1,22 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="begin">
+ <dirname property="imports.dir" file="${ant.file.begin}"/>
+ <import file="${imports.dir}/standard_properties.xml"/>
+ <property name="pattern" value="'Time stamp:' EEE MMM d yyyy 'at' hh:mm:ss"/>
+
+ <tstamp><format property="project.start.time" pattern="${pattern}"/></tstamp>
+ <echo message="Started building ${ant.project.name} at ${project.start.time}"/>
+ <taskdef resource="com/ibm/aries/buildtasks/buildtasks.properties" classpath="../build/build/lib/buildtasks.jar"/>
+
+ <property name="thePluginDirs" value="${pluginDirs}:../prereqs/osgi/lib/"/>
+
+ <validateProject />
+
+ <validateBuildDir type="${build.type}" buildDir="${classes.dir}"/>
+
+ <generateClassPath type="${build.type}" pluginDirs="${thePluginDirs}">
+ <!-- Jar excludes only apply in the unittest build phase -->
+ <exclude jar="prereq.asm_3.1.jar"/>
+ </generateClassPath>
+</project>
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/imports/clean.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/imports/clean.xml?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/imports/clean.xml (added)
+++ incubator/aries/contrib/ibm/build/imports/clean.xml Thu Oct 1 17:19:13 2009
@@ -0,0 +1,8 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="clean">
+ <import file="standard_properties.xml" />
+ <target name="clean">
+ <delete dir="${build.dir}" excludes="tmp/osgi/**/*.*"/>
+ </target>
+</project>
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/imports/compile.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/imports/compile.xml?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/imports/compile.xml (added)
+++ incubator/aries/contrib/ibm/build/imports/compile.xml Thu Oct 1 17:19:13 2009
@@ -0,0 +1,13 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="compile">
+ <import file="standard_properties.xml" />
+ <target name="compile">
+ <mkdir dir="${build.dir}" />
+ <mkdir dir="${classes.dir}" />
+
+ <pathconvert property="pcp" refid="project.class.path"/>
+ <echo message="${pcp}"/>
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="project.class.path" debuglevel="${javac.debug.level}" includeAntRuntime="no" debug="true"/>
+ </target>
+</project>
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/imports/download.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/imports/download.xml?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/imports/download.xml (added)
+++ incubator/aries/contrib/ibm/build/imports/download.xml Thu Oct 1 17:19:13 2009
@@ -0,0 +1,22 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="download">
+ <import file="standard_properties.xml" />
+
+ <property name="download.dir" value="../download/${ant.project.name}/"/>
+
+ <target name="shouldDownload" unless="force.download">
+ <available property="skipDownload" file="${download.dir}/${file.name}"/>
+ </target>
+
+ <target name="download" unless="skipDownload">
+ <mkdir dir="${download.dir}"/>
+ <get dest="${download.dir}/${file.name}" src="${file.url}" usetimestamp="true"/>
+ </target>
+
+ <target name="copy" depends="shouldDownload, download">
+ <mkdir dir="lib"/>
+ <copy todir="./lib" file="${download.dir}/${file.name}"/>
+ </target>
+
+</project>
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/imports/findbugs.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/imports/findbugs.xml?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/imports/findbugs.xml (added)
+++ incubator/aries/contrib/ibm/build/imports/findbugs.xml Thu Oct 1 17:19:13 2009
@@ -0,0 +1,56 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="findbugs">
+ <target name="findbugs">
+ <dirname property="imports.dir" file="${ant.file.findbugs}"/>
+
+ <taskdef name="if" classname="com.ibm.aries.buildtasks.If" classpath="${imports.dir}/../build/lib/buildtasks.jar"/>
+
+ <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
+ classpath="${imports.dir}/../../prereqs/findbugs/findbugs-1.3.8/lib/findbugs-ant.jar"/>
+
+ <property name="findbugs.report.dir" value="${report.dir}/findbugs"/>
+ <property name="findbugs.home" value="${imports.dir}/../../prereqs/findbugs/findbugs-1.3.8/"/>
+ <property name="findbugs.report.xml" value="${findbugs.report.dir}/${ant.project.name}-findbugs.xml"/>
+ <property name="findbugs.report.html" value="${findbugs.report.dir}/${ant.project.name}-findbugs.html"/>
+
+ <mkdir dir="${findbugs.report.dir}"/>
+
+ <pathconvert property="cp" refid="unittest.class.path" />
+
+ <available property="excludesAvailable" file="${basedir}/findbugs.exclude.xml"/>
+
+ <if if="excludesAvailable">
+ <findbugs home="${findbugs.home}"
+ projectName="${ant.project.name}"
+ output="xml:withMessages"
+ outputFile="${findbugs.report.xml}"
+ excludeFilter="${basedir}/findbugs.exclude.xml">
+ <auxClasspath path="${cp}" />
+ <sourcePath path="${src.dir}" />
+ <class location="${lib.dir}/${output.jar}" />
+ </findbugs>
+ <else>
+ <findbugs home="${findbugs.home}"
+ projectName="${ant.project.name}"
+ output="xml:withMessages"
+ outputFile="${findbugs.report.xml}">
+ <auxClasspath path="${cp}" />
+ <sourcePath path="${src.dir}" />
+ <class location="${lib.dir}/${output.jar}" />
+ </findbugs>
+ </else>
+ </if>
+
+ <condition property="process.findbugs.file">
+ <length file="${findbugs.report.xml}" when="greater" length="0"/>
+ </condition>
+
+ <if if="process.findbugs.file">
+ <xslt in="${findbugs.report.xml}"
+ out="${findbugs.report.html}"
+ style="${findbugs.home}/src/xsl/fancy.xsl"/>
+
+ </if>
+ </target>
+</project>
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/imports/package.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/imports/package.xml?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/imports/package.xml (added)
+++ incubator/aries/contrib/ibm/build/imports/package.xml Thu Oct 1 17:19:13 2009
@@ -0,0 +1,27 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="package">
+ <import file="standard_properties.xml" />
+ <available property="manifest.exists" file="META-INF/MANIFEST.MF" />
+ <target name="package" unless="manifest.exists" depends="packageWithManifest">
+ <mkdir dir="${lib.dir}" />
+ <jar destfile="${lib.dir}/${output.jar}">
+ <fileset dir="${src.dir}" includes="**/*.properties"/>
+ <fileset dir="${classes.dir}" includes="**/*.class"/>
+ </jar>
+ </target>
+ <target name="packageWithManifest" if="manifest.exists">
+ <mkdir dir="${lib.dir}" />
+ <jar destfile="${lib.dir}/${output.jar}" manifest="META-INF/MANIFEST.MF">
+ <fileset dir="${classes.dir}" includes="**/*.class"/>
+ <fileset dir="${src.dir}">
+ <exclude name="**/*.nlsprops"/>
+ <exclude name="**/*.java"/>
+ </fileset>
+ <fileset dir="${basedir}" includes="META-INF/*" excludes="META-INF/MANIFEST.MF"/>
+ <fileset dir="${basedir}" includes="OSGI-INF/**"/>
+ <fileset dir="${basedir}" includes="schemas/**"/>
+ <fileset dir="${basedir}" includes="plugin.xml"/>
+ </jar>
+ </target>
+</project>
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/imports/publish.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/imports/publish.xml?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/imports/publish.xml (added)
+++ incubator/aries/contrib/ibm/build/imports/publish.xml Thu Oct 1 17:19:13 2009
@@ -0,0 +1,34 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="publish" default="publish">
+ <import file="standard_properties.xml" />
+
+ <target name="publish" depends="publishToImage"/>
+
+ <!-- Automatically detect if the project goes to an image and copy it there.
+ We do this by looking for a property that ends '.image' and if we find
+ it we assume the property name is an image project copy the jar to the
+ lib directory of the project.
+ -->
+ <target name="publishToImage">
+ <dirname property="imports.dir" file="${ant.file.publish}"/>
+ <taskdef name="findImage" classname="com.ibm.aries.buildtasks.FindImage" classpath="${imports.dir}/../build/lib/buildtasks.jar"/>
+ <taskdef name="for" classname="com.ibm.aries.buildtasks.ForEach" classpath="${imports.dir}/../build/lib/buildtasks.jar"/>
+
+ <findImage />
+
+ <property name="image.dir" value="lib"/>
+ <if if="image.project">
+ <for param="image.name" in="${image.project}">
+ <echo message="@{image.name}"/>
+ <copy file="${lib.dir}/${output.jar}" todir="../@{image.name}/${image.dir}"/>
+ </for>
+ </if>
+
+ <condition property="skipUpload">
+ <not>
+ <isset property="publish.jar"/>
+ </not>
+ </condition>
+ </target>
+</project>
\ No newline at end of file
Added: incubator/aries/contrib/ibm/build/imports/standard_imports.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/build/imports/standard_imports.xml?rev=820722&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/build/imports/standard_imports.xml (added)
+++ incubator/aries/contrib/ibm/build/imports/standard_imports.xml Thu Oct 1 17:19:13 2009
@@ -0,0 +1,8 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="standard_imports">
+ <import file="clean.xml"/>
+ <import file="standard_targets.xml"/>
+ <import file="unittest.xml"/>
+ <import file="findbugs.xml"/>
+</project>
\ No newline at end of file