Class Project

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

public class Project extends Processor
This class is NOT threadsafe
  • Field Details

  • Constructor Details

  • Method Details

    • getUnparented

      public static Project getUnparented(File propertiesFile) throws Exception
      Throws:
      Exception
    • isValid

      public boolean isValid()
    • getBuilder

      public ProjectBuilder getBuilder(ProjectBuilder parent) throws Exception
      Return a new builder that is nicely setup for this project. Please close this builder after use.
      Parameters:
      parent - The project builder to use as parent, use this project if null
      Throws:
      Exception
    • getChanged

      public int getChanged()
    • setChanged

      public void setChanged()
    • getWorkspace

      public Workspace getWorkspace()
    • toString

      public String toString()
      Description copied from class: Processor
      Printout of the status of this processor for toString()
      Overrides:
      toString in class Processor
    • prepare

      public void prepare() throws Exception
      Set up all the paths
      Throws:
      Exception
    • getSrc

      @Deprecated public File getSrc() throws Exception
      Deprecated.
      This method is deprecated because this can handle only one source dir. Use getSourcePath. For backward compatibility we will return the first entry on the source path.
      Returns:
      first entry on the getSourcePath()
      Throws:
      Exception
    • getSrcOutput

      public File getSrcOutput()
    • getTestSrc

      public File getTestSrc()
    • getTestOutput

      public File getTestOutput()
    • getTargetDir

      public File getTargetDir()
    • parseRunbundles

      protected List<Container> parseRunbundles(String spec) throws Exception
      Throws:
      Exception
    • getBundles

      public List<Container> getBundles(Strategy strategyx, String spec, String source) throws Exception
      Analyze the header and return a list of files that should be on the build, test or some other path. The list is assumed to be a list of bsns with a version specification. The special case of version=project indicates there is a project in the same workspace. The path to the output directory is calculated. The default directory ${bin} can be overridden with the output attribute.
      Parameters:
      strategyx - STRATEGY_LOWEST or STRATEGY_HIGHEST
      spec - The header
      Throws:
      Exception
    • getBundlesWildcard

      public List<Container> getBundlesWildcard(String bsnPattern, String range, Strategy strategyx, Map<String,String> attrs) throws Exception
      Get all bundles matching a wildcard expression.
      Parameters:
      bsnPattern - A bsn wildcard, e.g. "osgi*" or just "*".
      range - A range to narrow the versions of bundles found, or null to return any version.
      strategyx - The version selection strategy, which may be 'HIGHEST' or 'LOWEST' only -- 'EXACT' is not permitted.
      attrs - Additional search attributes.
      Throws:
      Exception
    • doMavenPom

      public void doMavenPom(Strategy strategyx, List<Container> result, String action) throws Exception
      The user selected pom in a path. This will place the pom as well as its dependencies on the list
      Parameters:
      strategyx - the strategy to use.
      result - The list of result containers
      Throws:
      Exception - anything goes wrong
    • getDependson

      public Collection<Project> getDependson() throws Exception
      Return the full transitive dependencies of this project.
      Returns:
      A set of the full transitive dependencies of this project.
      Throws:
      Exception
    • getBuildDependencies

      public Set<Project> getBuildDependencies() throws Exception
      Return the direct build dependencies of this project.
      Returns:
      A set of the direct build dependencies of this project.
      Throws:
      Exception
    • getTestDependencies

      public Set<Project> getTestDependencies() throws Exception
      Return the direct test dependencies of this project.

      The result includes the direct build dependencies of this project as well, so the result is a super set of getBuildDependencies().

      Returns:
      A set of the test build dependencies of this project.
      Throws:
      Exception
    • getDependents

      public Set<Project> getDependents() throws Exception
      Return the full transitive dependents of this project.

      The result includes projects which have build and test dependencies on this project.

      Since the full transitive dependents of this project is updated during the computation of other project dependencies, until all projects are prepared, the dependents result may be partial.

      Returns:
      A set of the transitive set of projects which depend on this project.
      Throws:
      Exception
    • getBuildpath

      public Collection<Container> getBuildpath() throws Exception
      Throws:
      Exception
    • getTestpath

      public Collection<Container> getTestpath() throws Exception
      Throws:
      Exception
    • getRunpath

      public Collection<Container> getRunpath() throws Exception
      Throws:
      Exception
    • getRunbundles

      public Collection<Container> getRunbundles() throws Exception
      Throws:
      Exception
    • getRunFw

      public Collection<Container> getRunFw() throws Exception
      Return the run framework
      Throws:
      Exception
    • getRunStorage

      public File getRunStorage() throws Exception
      Throws:
      Exception
    • getRunBuilds

      public boolean getRunBuilds()
    • getSourcePath

      public Collection<File> getSourcePath() throws Exception
      Throws:
      Exception
    • getAllsourcepath

      public Collection<File> getAllsourcepath() throws Exception
      Throws:
      Exception
    • getBootclasspath

      public Collection<Container> getBootclasspath() throws Exception
      Throws:
      Exception
    • getOutput

      public File getOutput() throws Exception
      Throws:
      Exception
    • _p_dependson

      public String _p_dependson(String[] args) throws Exception
      Throws:
      Exception
    • _p_buildpath

      public String _p_buildpath(String[] args) throws Exception
      Throws:
      Exception
    • _p_testpath

      public String _p_testpath(String[] args) throws Exception
      Throws:
      Exception
    • _p_sourcepath

      public String _p_sourcepath(String[] args) throws Exception
      Throws:
      Exception
    • _p_allsourcepath

      public String _p_allsourcepath(String[] args) throws Exception
      Throws:
      Exception
    • _p_bootclasspath

      public String _p_bootclasspath(String[] args) throws Exception
      Throws:
      Exception
    • _p_output

      public String _p_output(String[] args) throws Exception
      Throws:
      Exception
    • getMacroDomains

      protected Object[] getMacroDomains()
      Description copied from class: Processor
      This should be overridden by subclasses to add extra macro command domains on the search list.
      Overrides:
      getMacroDomains in class Processor
    • release

      public File release(String jarName, InputStream jarStream) throws Exception
      Throws:
      Exception
    • releaseURI

      public URI releaseURI(String jarName, InputStream jarStream) throws Exception
      Throws:
      Exception
    • release

      public File release(String name, String jarName, InputStream jarStream) throws Exception
      Release
      Parameters:
      name - The repository name
      jarName -
      jarStream -
      Throws:
      Exception
    • releaseURI

      public URI releaseURI(String name, String jarName, InputStream jarStream) throws Exception
      Throws:
      Exception
    • release

      public void release(boolean test) throws Exception
      Throws:
      Exception
    • release

      public void release(String name, boolean test) throws Exception
      Release
      Parameters:
      name - The respository name
      test - Run testcases
      Throws:
      Exception
    • getBundle

      public Container getBundle(String bsn, String range, Strategy strategy, Map<String,String> attrs) throws Exception
      Get a bundle from one of the plugin repositories. If an exact version is required we just return the first repository found (in declaration order in the build.bnd file).
      Parameters:
      bsn - The bundle symbolic name
      range - The version range
      strategy - set to LOWEST or HIGHEST
      Returns:
      the file object that points to the bundle or null if not found
      Throws:
      Exception - when something goes wrong
    • overrideStrategy

      protected Strategy overrideStrategy(Map<String,String> attrs, Strategy useStrategy)
      Parameters:
      attrs -
      useStrategy -
    • parseRepoFilter

      protected aQute.bnd.build.Project.RepoFilter parseRepoFilter(Map<String,String> attrs)
    • toContainer

      protected Container toContainer(String bsn, String range, Map<String,String> attrs, File result, DownloadBlocker db)
      Parameters:
      bsn -
      range -
      attrs -
      result -
    • deploy

      public void deploy(String name, File file) throws Exception
      Deploy the file (which must be a bundle) into the repository.
      Parameters:
      name - The repository name
      file - bundle
      Throws:
      Exception
    • deploy

      public void deploy(File file) throws Exception
      Deploy the file (which must be a bundle) into the repository.
      Parameters:
      file - bundle
      Throws:
      Exception
    • deploy

      public void deploy() throws Exception
      Deploy the current project to a repository
      Throws:
      Exception
    • _repo

      public String _repo(String[] args) throws Exception
      Throws:
      Exception
    • getTarget

      public File getTarget() throws Exception
      Throws:
      Exception
    • build

      public File[] build(boolean underTest) throws Exception
      This is the external method that will pre-build any dependencies if it is out of date.
      Parameters:
      underTest -
      Throws:
      Exception
    • getInstallRepositories

      public Parameters getInstallRepositories()
    • getFiles

      public File[] getFiles()
      Return the files
    • isStale

      public boolean isStale() throws Exception
      Check if this project needs building. This is defined as:
      Throws:
      Exception
    • getBuildFiles

      public File[] getBuildFiles() throws Exception
      This method must only be called when it is sure that the project has been build before in the same session. It is a bit yucky, but ant creates different class spaces which makes it hard to detect we already build it. This method remembers the files in the appropriate instance vars.
      Throws:
      Exception
    • getBuildFiles

      public File[] getBuildFiles(boolean buildIfAbsent) throws Exception
      Throws:
      Exception
    • buildLocal

      public File[] buildLocal(boolean underTest) throws Exception
      Build without doing any dependency checking. Make sure any dependent projects are built first.
      Parameters:
      underTest -
      Throws:
      Exception
    • isNoBundles

      public boolean isNoBundles()
      Answer if this project does not have any output
    • saveBuild

      public File saveBuild(Jar jar) throws Exception
      Throws:
      Exception
    • getOutputFile

      public File getOutputFile(String bsn, String version) throws Exception
      Calculate the file for a JAR. The default name is bsn.jar, but this can be overridden with an
      Throws:
      Exception
    • getOutputFile

      public File getOutputFile(String bsn) throws Exception
      Throws:
      Exception
    • refresh

      public boolean refresh()
      Refresh if we are based on stale data. This also implies our workspace.
      Overrides:
      refresh in class Processor
    • isCnf

      public boolean isCnf()
    • propertiesChanged

      public void propertiesChanged()
      Overrides:
      propertiesChanged in class Processor
    • getName

      public String getName()
    • getActions

      public Map<String,Action> getActions()
    • fillActions

      public void fillActions(Map<String,Action> all)
    • release

      public void release() throws Exception
      Throws:
      Exception
    • export

      public Map.Entry<String,Resource> export(String type, Map<String,String> options) throws Exception
      Export this project via the exporters. The return is the calculated name (can be overridden with the option `name`, which must be the basename since the extension is defined by the exporter)
      Parameters:
      type - an exporter type like `bnd.executablejar` or null as default `bnd.executablejar.pack`, the original export function
      options - parameters to the exporters
      Returns:
      and entry with the name and resource for the export
      Throws:
      Exception
    • export

      @Deprecated public void export(String runFilePath, boolean keep, File output) throws Exception
      Deprecated.
      The keep flag is really awkward since it overrides the -runkeep flag in the file. Use doExport instead
      Throws:
      Exception
    • exportRunbundles

      public void exportRunbundles(String runFilePath, File outputDir) throws Exception
      Throws:
      Exception
      Since:
      2.4
    • release

      public void release(String name) throws Exception
      Release.
      Parameters:
      name - The repository name
      Throws:
      Exception
    • clean

      public void clean() throws Exception
      Throws:
      Exception
    • build

      public File[] build() throws Exception
      Throws:
      Exception
    • run

      public void run() throws Exception
      Throws:
      Exception
    • isRunTrace

      public boolean isRunTrace()
    • runLocal

      public void runLocal() throws Exception
      Throws:
      Exception
    • test

      public void test() throws Exception
      Throws:
      Exception
    • test

      public void test(List<String> tests) throws Exception
      Throws:
      Exception
    • test

      public void test(File reportDir, List<String> tests) throws Exception
      Throws:
      Exception
    • junit

      public void junit() throws Exception
      Run JUnit
      Throws:
      Exception
    • getValidJar

      public Jar getValidJar(File f) throws Exception
      This methods attempts to turn any jar into a valid jar. If this is a bundle with manifest, a manifest is added based on defaults. If it is a bundle, but not r4, we try to add the r4 headers.
      Throws:
      Exception
    • getValidJar

      public Jar getValidJar(URL url) throws Exception
      Throws:
      Exception
    • getValidJar

      public Jar getValidJar(Jar jar, String id) throws Exception
      Throws:
      Exception
    • _project

      public String _project(String[] args)
    • bump

      public void bump(String mask) throws Exception
      Bump the version of this project. First check the main bnd file. If this does not contain a version, check the include files. If they still do not contain a version, then check ALL the sub builders. If not, add a version to the main bnd file.
      Parameters:
      mask - the mask for bumping, see Macro._version(String[])
      Throws:
      Exception
    • bump

      public void bump() throws Exception
      Throws:
      Exception
    • action

      public void action(String command) throws Exception
      Throws:
      Exception
    • action

      public void action(String command, Object... args) throws Exception
      Throws:
      Exception
    • refreshAll

      public void refreshAll()
    • script

      public void script(String type, String script) throws Exception
      Throws:
      Exception
    • script

      public void script(String type, String script, Object... args) throws Exception
      Throws:
      Exception
    • _repos

      public String _repos(String[] args) throws Exception
      Throws:
      Exception
    • _help

      public String _help(String[] args) throws Exception
      Throws:
      Exception
    • getDeliverables

      public Collection<Container> getDeliverables() throws Exception
      Returns containers for the deliverables of this project. The deliverables is the project builder for this project if no -sub is specified. Otherwise it contains all the sub bnd files.
      Returns:
      A collection of containers
      Throws:
      Exception
    • getSubBuilder

      public Builder getSubBuilder(File bndFile) throws Exception
      Return a builder associated with the give bnd file or null. The bnd.bnd file can contain -sub option. This option allows specifying files in the same directory that should drive the generation of multiple deliverables. This method figures out if the bndFile is actually one of the bnd files of a deliverable.
      Parameters:
      bndFile - A file pointing to a bnd file.
      Returns:
      null or a builder for a sub file, the caller must close this builder
      Throws:
      Exception
    • getSubBuilder

      public ProjectBuilder getSubBuilder(String string) throws Exception
      Return a build that maps to the sub file.
      Parameters:
      string -
      Throws:
      Exception
    • getDeliverable

      public Container getDeliverable(String bsn, Map<String,String> attrs) throws Exception
      Answer the container associated with a given bsn.
      Throws:
      Exception
    • getRunVM

      public Collection<String> getRunVM()
    • getRunProgramArgs

      public Collection<String> getRunProgramArgs()
    • getRunProperties

      public Map<String,String> getRunProperties()
    • getProjectLauncher

      public ProjectLauncher getProjectLauncher() throws Exception
      Get a launcher.
      Throws:
      Exception
    • getProjectTester

      public ProjectTester getProjectTester() throws Exception
      Throws:
      Exception
    • setDelayRunDependencies

      public void setDelayRunDependencies(boolean x)
      Make this project delay the calculation of the run dependencies. The run dependencies calculation can be done in prepare or until the dependencies are actually needed.
    • addClasspath

      public void addClasspath(File f)
      bnd maintains a class path that is set by the environment, i.e. bnd is not in charge of it.
    • clearClasspath

      public void clearClasspath()
    • getClasspath

      public Collection<Container> getClasspath()
    • pack

      public Jar pack(String profile) throws Exception
      Pack the project (could be a bndrun file) and save it on disk. Report errors if they happen. Caller must close this JAR
      Parameters:
      profile -
      Returns:
      a jar with the executable code
      Throws:
      Exception
    • baseline

      public void baseline() throws Exception
      Do a baseline for this project
      Throws:
      Exception
    • verifyDependencies

      public void verifyDependencies(boolean test) throws Exception
      Method to verify that the paths are correct, ie no missing dependencies
      Parameters:
      test - for test cases, also adds -testpath
      Throws:
      Exception
    • report

      public void report(Map<String,Object> table) throws Exception
      Report detailed info from this project
      Overrides:
      report in class Processor
      Throws:
      Exception
    • report

      protected void report(Map<String,Object> table, boolean isProject) throws Exception
      Throws:
      Exception
    • compile

      public void compile(boolean test) throws Exception
      Throws:
      Exception
    • _ide

      public String _ide(String[] args) throws IOException
      Throws:
      IOException
    • getVersions

      public Map<String,Version> getVersions() throws Exception
      Throws:
      Exception
    • getBsns

      public Collection<String> getBsns() throws Exception
      Throws:
      Exception
    • getVersion

      public Version getVersion(String bsn) throws Exception
      Throws:
      Exception
    • getExports

      public Packages getExports()
      Get the exported packages form all builders calculated from the last build
    • getImports

      public Packages getImports()
      Get the imported packages from all builders calculated from the last build
    • getContained

      public Packages getContained()
      Get the contained packages calculated from all builders from the last build
    • remove

      public void remove() throws Exception
      Throws:
      Exception
    • getRunKeep

      public boolean getRunKeep()
    • setPackageInfo

      public void setPackageInfo(String packageName, Version newVersion) throws Exception
      Throws:
      Exception
    • getPackageInfo

      public Version getPackageInfo(String packageName) throws Exception
      Throws:
      Exception
    • preRelease

      public void preRelease()
      Actions to perform before a full workspace release. This is executed for projects that describe the distribution
    • postRelease

      public void postRelease()
      Actions to perform after a full workspace release. This is executed for projects that describe the distribution
    • copy

      public void copy(RepositoryPlugin source, String filter, RepositoryPlugin destination) throws Exception
      Copy a repository to another repository
      Throws:
      Exception
    • copy

      public void copy(RepositoryPlugin source, Instructions filter, RepositoryPlugin destination) throws Exception
      Throws:
      Exception
    • isInteractive

      public boolean isInteractive()
      Description copied from class: Processor
      Return if this is an interactive environment like Eclipse or runs in batch mode. If interactive, things can get refreshed.
      Overrides:
      isInteractive in class Processor
    • getSpecification

      public RunSpecification getSpecification()
      Return a basic type only specification of the run aspect of this project
    • getRunSystemPackages

      public Parameters getRunSystemPackages()
    • getRunSystemCapabilities

      public Parameters getRunSystemCapabilities()
    • preBuildChecks

      protected void preBuildChecks()
      Check prebuild things.
    • getBundle

      public Container getBundle(org.osgi.resource.Resource r) throws Exception
      Throws:
      Exception
    • isStandalone

      public boolean isStandalone()
    • getChecksum

      public String getChecksum()
      Description copied from class: Processor
      A checksum based on the values of the properties
      Overrides:
      getChecksum in class Processor
      Returns:
      A checksum based on the values of the properties
    • getGenerate

      public ProjectGenerate getGenerate()
      Get the object responsible for source code generation. This object should not be stored, a new one is created if the properties of this project change.
      Returns:
      a fresh ProjectGenerate object
    • getResources

      public List<org.osgi.resource.Resource> getResources()