Class Project

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

    public class Project
    extends Processor
    This class is NOT threadsafe
    • Constructor Detail

      • Project

        public Project​(Workspace workspace,
                       java.io.File unused,
                       java.io.File buildFile)
      • Project

        public Project​(Workspace workspace,
                       java.io.File buildDir)
    • Method Detail

      • getUnparented

        public static Project getUnparented​(java.io.File propertiesFile)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • isValid

        public boolean isValid()
      • getBuilder

        public ProjectBuilder getBuilder​(ProjectBuilder parent)
                                  throws java.lang.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:
        java.lang.Exception
      • getChanged

        public int getChanged()
      • setChanged

        public void setChanged()
      • getWorkspace

        public Workspace getWorkspace()
      • toString

        public java.lang.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 java.lang.Exception
        Set up all the paths
        Throws:
        java.lang.Exception
      • getSrc

        @Deprecated
        public java.io.File getSrc()
                            throws java.lang.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:
        java.lang.Exception
      • getSrcOutput

        public java.io.File getSrcOutput()
      • getTestSrc

        public java.io.File getTestSrc()
      • getTestOutput

        public java.io.File getTestOutput()
      • getTargetDir

        public java.io.File getTargetDir()
      • parseRunbundles

        protected java.util.List<Container> parseRunbundles​(java.lang.String spec)
                                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getBundles

        public java.util.List<Container> getBundles​(Strategy strategyx,
                                                    java.lang.String spec,
                                                    java.lang.String source)
                                             throws java.lang.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:
        java.lang.Exception
      • getBundlesWildcard

        public java.util.List<Container> getBundlesWildcard​(java.lang.String bsnPattern,
                                                            java.lang.String range,
                                                            Strategy strategyx,
                                                            java.util.Map<java.lang.String,​java.lang.String> attrs)
                                                     throws java.lang.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:
        java.lang.Exception
      • doMavenPom

        public void doMavenPom​(Strategy strategyx,
                               java.util.List<Container> result,
                               java.lang.String action)
                        throws java.lang.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:
        java.lang.Exception - anything goes wrong
      • getDependson

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

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

        public java.util.Set<Project> getTestDependencies()
                                                   throws java.lang.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:
        java.lang.Exception
      • getDependents

        public java.util.Set<Project> getDependents()
                                             throws java.lang.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:
        java.lang.Exception
      • getBuildpath

        public java.util.Collection<Container> getBuildpath()
                                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getTestpath

        public java.util.Collection<Container> getTestpath()
                                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getRunpath

        public java.util.Collection<Container> getRunpath()
                                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getRunbundles

        public java.util.Collection<Container> getRunbundles()
                                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getRunFw

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

        public java.io.File getRunStorage()
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getRunBuilds

        public boolean getRunBuilds()
      • getSourcePath

        public java.util.Collection<java.io.File> getSourcePath()
                                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getAllsourcepath

        public java.util.Collection<java.io.File> getAllsourcepath()
                                                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getBootclasspath

        public java.util.Collection<Container> getBootclasspath()
                                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getOutput

        public java.io.File getOutput()
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _p_dependson

        public java.lang.String _p_dependson​(java.lang.String[] args)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _p_buildpath

        public java.lang.String _p_buildpath​(java.lang.String[] args)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _p_testpath

        public java.lang.String _p_testpath​(java.lang.String[] args)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _p_sourcepath

        public java.lang.String _p_sourcepath​(java.lang.String[] args)
                                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _p_allsourcepath

        public java.lang.String _p_allsourcepath​(java.lang.String[] args)
                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _p_bootclasspath

        public java.lang.String _p_bootclasspath​(java.lang.String[] args)
                                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _p_output

        public java.lang.String _p_output​(java.lang.String[] args)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getMacroDomains

        protected java.lang.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 java.io.File release​(java.lang.String jarName,
                                    java.io.InputStream jarStream)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • releaseURI

        public java.net.URI releaseURI​(java.lang.String jarName,
                                       java.io.InputStream jarStream)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • release

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

        public java.net.URI releaseURI​(java.lang.String name,
                                       java.lang.String jarName,
                                       java.io.InputStream jarStream)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • release

        public void release​(boolean test)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • release

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

        public Container getBundle​(java.lang.String bsn,
                                   java.lang.String range,
                                   Strategy strategy,
                                   java.util.Map<java.lang.String,​java.lang.String> attrs)
                            throws java.lang.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:
        java.lang.Exception - when something goes wrong
      • overrideStrategy

        protected Strategy overrideStrategy​(java.util.Map<java.lang.String,​java.lang.String> attrs,
                                            Strategy useStrategy)
        Parameters:
        attrs -
        useStrategy -
      • parseRepoFilter

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

        protected Container toContainer​(java.lang.String bsn,
                                        java.lang.String range,
                                        java.util.Map<java.lang.String,​java.lang.String> attrs,
                                        java.io.File result,
                                        DownloadBlocker db)
        Parameters:
        bsn -
        range -
        attrs -
        result -
      • deploy

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

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

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

        public java.lang.String _repo​(java.lang.String[] args)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getTarget

        public java.io.File getTarget()
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • build

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

        public Parameters getInstallRepositories()
      • getFiles

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

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

        public java.io.File[] getBuildFiles()
                                     throws java.lang.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:
        java.lang.Exception
      • getBuildFiles

        public java.io.File[] getBuildFiles​(boolean buildIfAbsent)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • buildLocal

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

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

        public java.io.File saveBuild​(Jar jar)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getOutputFile

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

        public java.io.File getOutputFile​(java.lang.String bsn)
                                   throws java.lang.Exception
        Throws:
        java.lang.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()
      • getName

        public java.lang.String getName()
      • getActions

        public java.util.Map<java.lang.String,​Action> getActions()
      • fillActions

        public void fillActions​(java.util.Map<java.lang.String,​Action> all)
      • release

        public void release()
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • export

        public java.util.Map.Entry<java.lang.String,​Resource> export​(java.lang.String type,
                                                                           java.util.Map<java.lang.String,​java.lang.String> options)
                                                                    throws java.lang.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:
        java.lang.Exception
      • export

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

        public void exportRunbundles​(java.lang.String runFilePath,
                                     java.io.File outputDir)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
        Since:
        2.4
      • release

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

        public void clean()
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • build

        public java.io.File[] build()
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • run

        public void run()
                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • isRunTrace

        public boolean isRunTrace()
      • runLocal

        public void runLocal()
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • test

        public void test()
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • test

        public void test​(java.util.List<java.lang.String> tests)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • test

        public void test​(java.io.File reportDir,
                         java.util.List<java.lang.String> tests)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • junit

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

        public Jar getValidJar​(java.io.File f)
                        throws java.lang.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:
        java.lang.Exception
      • getValidJar

        public Jar getValidJar​(java.net.URL url)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getValidJar

        public Jar getValidJar​(Jar jar,
                               java.lang.String id)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _project

        public java.lang.String _project​(java.lang.String[] args)
      • bump

        public void bump​(java.lang.String mask)
                  throws java.lang.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:
        java.lang.Exception
      • bump

        public void bump()
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • action

        public void action​(java.lang.String command)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • action

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

        public void refreshAll()
      • script

        public void script​(java.lang.String type,
                           java.lang.String script)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • script

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

        public java.lang.String _repos​(java.lang.String[] args)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _help

        public java.lang.String _help​(java.lang.String[] args)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getDeliverables

        public java.util.Collection<Container> getDeliverables()
                                                        throws java.lang.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:
        java.lang.Exception
      • getSubBuilder

        public Builder getSubBuilder​(java.io.File bndFile)
                              throws java.lang.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:
        java.lang.Exception
      • getSubBuilder

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

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

        public java.util.Collection<java.lang.String> getRunVM()
      • getRunProgramArgs

        public java.util.Collection<java.lang.String> getRunProgramArgs()
      • getRunProperties

        public java.util.Map<java.lang.String,​java.lang.String> getRunProperties()
      • getProjectLauncher

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

        public ProjectTester getProjectTester()
                                       throws java.lang.Exception
        Throws:
        java.lang.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​(java.io.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 java.util.Collection<Container> getClasspath()
      • pack

        public Jar pack​(java.lang.String profile)
                 throws java.lang.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:
        java.lang.Exception
      • baseline

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

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

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

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

        public void compile​(boolean test)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _ide

        public java.lang.String _ide​(java.lang.String[] args)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • getVersions

        public java.util.Map<java.lang.String,​Version> getVersions()
                                                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getBsns

        public java.util.Collection<java.lang.String> getBsns()
                                                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getVersion

        public Version getVersion​(java.lang.String bsn)
                           throws java.lang.Exception
        Throws:
        java.lang.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 java.lang.Exception
        Throws:
        java.lang.Exception
      • getRunKeep

        public boolean getRunKeep()
      • setPackageInfo

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

        public Version getPackageInfo​(java.lang.String packageName)
                               throws java.lang.Exception
        Throws:
        java.lang.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,
                         java.lang.String filter,
                         RepositoryPlugin destination)
                  throws java.lang.Exception
        Copy a repository to another repository
        Throws:
        java.lang.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 java.lang.Exception
        Throws:
        java.lang.Exception
      • isStandalone

        public boolean isStandalone()
      • getChecksum

        public java.lang.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 java.util.List<org.osgi.resource.Resource> getResources()