Class Builder

All Implemented Interfaces:
Constants, Registry, aQute.service.reporter.Report, aQute.service.reporter.Reporter, Closeable, AutoCloseable, Iterable<String>
Direct Known Subclasses:
JUnitFramework.BundleBuilder, ProjectBuilder

public class Builder extends Analyzer
Include-Resource: ( [name '=' ] file )+ Private-Package: package-decl ( ',' package-decl )* Export-Package: package-decl ( ',' package-decl )* Import-Package: package-decl ( ',' package-decl )* @version $Revision: 1.27 $
  • Constructor Details

    • Builder

      public Builder(Processor parent)
    • Builder

      public Builder(Builder parent)
    • Builder

      public Builder()
  • Method Details

    • build

      public Jar build() throws Exception
      Throws:
      Exception
    • init

      public void init() throws Exception
      Allow any local initialization by subclasses before we build.
      Throws:
      Exception
    • changedFile

      protected void changedFile(File f)
    • hasSources

      public boolean hasSources()
    • getExtra

      protected Jar getExtra() throws Exception
      Answer extra packages. In this case we implement conditional package. Any
      Overrides:
      getExtra in class Analyzer
      Throws:
      Exception
    • analyze

      public void analyze() throws Exception
      Intercept the call to analyze and cleanup versions after we have analyzed the setup. We do not want to cleanup if we are going to verify.
      Overrides:
      analyze in class Analyzer
      Throws:
      IOException
      Exception
    • cleanupVersion

      public void cleanupVersion(Packages packages, String defaultVersion)
    • cleanupVersion

      public void cleanupVersion(Packages packages, String defaultVersion, String what)
    • getSourcePath

      public Collection<File> getSourcePath()
    • addAll

      public boolean addAll(Jar to, Jar sub, Instruction filter)
      Add all the resources in the given jar that match the given filter.
      Parameters:
      sub - the jar
      filter - a pattern that should match the resoures in sub to be added
    • addAll

      public boolean addAll(Jar to, Jar sub, Instruction filter, String destination)
      Add all the resources in the given jar that match the given filter.
      Parameters:
      sub - the jar
      filter - a pattern that should match the resoures in sub to be added
    • setSourcepath

      public void setSourcepath(File[] files)
    • addSourcepath

      public void addSourcepath(File cp)
    • builds

      public Jar[] builds() throws Exception
      Build Multiple jars. If the -sub command is set, we filter the file with the given patterns.
      Throws:
      Exception
    • startBuild

      protected void startBuild(Builder builder) throws Exception
      Called when we start to build a builder
      Throws:
      Exception
    • doneBuild

      protected void doneBuild(Builder builder) throws Exception
      Called when we're done with a builder
      Throws:
      Exception
    • getSubBuilders

      public List<Builder> getSubBuilders() throws Exception
      Answer a list of builders that represent this file or a list of files specified in -sub. This list can be empty. These builders represents to be created artifacts and are each scoped to such an artifacts. The builders can be used to build the bundles or they can be used to find out information about the to be generated bundles.
      Returns:
      List of 0..n builders representing artifacts.
      Throws:
      Exception
    • getSubBuilder

      public Builder getSubBuilder(File file) throws Exception
      Throws:
      Exception
    • getSubBuilder

      public Builder getSubBuilder() throws Exception
      Throws:
      Exception
    • _maven_version

      public String _maven_version(String[] args)
      A macro to convert a maven version to an OSGi version
    • _permissions

      public String _permissions(String[] args)
    • removeBundleSpecificHeaders

      public void removeBundleSpecificHeaders()
    • isInScope

      public boolean isInScope(Collection<File> resources) throws Exception
      Check if the given resource is in scope of this bundle. That is, it checks if the Include-Resource includes this resource or if it is a class file it is on the class path and the Export-Package or Private-Package include this resource.
      Throws:
      Exception
    • getClasspathEntrySuffix

      public String getClasspathEntrySuffix(File resource) throws Exception
      Answer the string of the resource that it has in the container. It is possible that the resource is a classpath entry. In that case an empty string is returned.
      Parameters:
      resource - The resource to look for
      Returns:
      A suffix on the classpath or "" if the resource is a class path entry
      Throws:
      Exception
    • doNotCopy

      public boolean doNotCopy(String v)
      doNotCopy The doNotCopy variable maintains a patter for files that should not be copied. There is a default Constants.DEFAULT_DO_NOT_COPY but this ca be overridden with the Constants.DONOTCOPY property.
    • doNotCopy

      public boolean doNotCopy(File from)
    • getDoNotCopy

      public Pattern getDoNotCopy()
    • setTypeSpecificPlugins

      protected void setTypeSpecificPlugins(Set<Object> list)
      Overrides:
      setTypeSpecificPlugins in class Analyzer
    • doDiff

      public void doDiff(Jar dot) throws Exception
      Diff this bundle to another bundle for the given packages.
      Throws:
      Exception
    • addSourcepath

      public void addSourcepath(Collection<File> sourcepath)
    • doBaseline

      protected void doBaseline(Jar dot) throws Exception
      Base line against a previous version. Should be overridden in the ProjectBuilder where we have access to the repos
      Throws:
      Exception
    • _githead

      public String _githead(String[] args) throws IOException
      Throws:
      IOException
    • report

      public void report(Map<String,Object> table) throws Exception
      Create a report of the settings
      Overrides:
      report in class Analyzer
      Throws:
      Exception
    • from

      public Builder from(BuilderSpecification spec) throws IOException
      Collect the information from the BuilderSpecification
      Throws:
      IOException
    • system

      public String system(boolean allowFail, String command, String input) throws IOException, InterruptedException
      We override system so that, for the duration of a build operation, we may cache the result of a given system call. In a large build with many 'make' build jars, such as some OSGi CT build projects, we may call system hundreds of time to compute headers based upon git information such as 'git describe'. Since this information will not change during the course of a single build operation, we cache results to only call once.
      Overrides:
      system in class Processor
      Throws:
      IOException
      InterruptedException