CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-biz-a-qute-bnd--biz-a-qute-bndlib

bndlib: A Swiss Army Knife for OSGi providing comprehensive bundle manipulation and analysis capabilities

Pending
Overview
Eval results
Files

workspace-project-management.mddocs/

Workspace and Project Management

Multi-project workspace management for organizing and building OSGi bundles in enterprise environments.

Capabilities

Workspace

Represents a BND workspace containing multiple projects, providing centralized configuration and project management.

/**
 * Represents a BND workspace containing multiple projects
 */
public class Workspace extends Processor {
    // Constructors
    public Workspace(File workspaceDir) throws Exception;
    public Workspace(File workspaceDir, String bndDir) throws Exception;
    
    // Static Factory Methods
    public static Workspace getWorkspace(File workspaceDir) throws Exception;
    public static Workspace findWorkspace(File base) throws Exception;
    public static Workspace getWorkspace(String path) throws Exception;
    public static Workspace createDefaultWorkspace() throws Exception;
    public static Workspace createWorkspace(File wsdir) throws Exception;
    public static Project getProject(File projectDir) throws Exception;
    
    // Project Management
    public Project getProject(String bsn);
    public Project getProjectFromFile(File projectDir);
    public Collection<Project> getAllProjects();
    public Collection<Project> getCurrentProjects();
    public Collection<Project> getBuildOrder() throws Exception;
    public boolean isPresent(String name);
    public Project createProject(String name) throws Exception;
    
    // Workspace Configuration
    public boolean refresh();
    public void refreshProjects();
    public void forceRefreshProjects();
    public void propertiesChanged();
    public boolean isValid();
    public void checkStructure();
    
    // Repository Management
    public List<RepositoryPlugin> getRepositories();
    public Promise<List<RepositoryPlugin>> getInitializedRepositories();
    public RepositoryPlugin getRepository(String repo) throws Exception;
    public WorkspaceRepository getWorkspaceRepository();
    public void refresh(RepositoryPlugin repo);
    
    // File System
    public File getBuildDir();
    public void setBuildDir(File buildDir);
    public File getCache(String name);
    public WorkspaceLayout getLayout();
    
    // Build and Dependencies
    public Maven getMaven();
    public boolean isOffline();
    public AtomicBoolean getOffline();
    public Workspace setOffline(boolean on);
    
    // Search and Resources  
    public Result<Map<String, List<BundleId>>> search(String partialFqn) throws Exception;
    public Result<Map<String, List<BundleId>>> search(String packageName, String className) throws Exception;
    public Stream<Capability> findProviders(String namespace, String filter) throws Exception;
    public Repository getResourceRepository(ResourceRepositoryStrategy strategy) throws Exception;
    public Result<File> getBundle(org.osgi.resource.Resource resource);
    public Result<File> getBundle(String bsn, Version version, Map<String, String> attrs);
    
    // Thread Safety
    public <T> T readLocked(Callable<T> callable) throws Exception;
    public <T> T readLocked(Callable<T> callable, long timeoutInMs) throws Exception;
    public <T> T writeLocked(Callable<T> callable) throws Exception;
    public <T> T writeLocked(Callable<T> callable, long timeoutInMs) throws Exception;
    public void writeLocked(Runnable runnable) throws Exception;
    
    // Gestalts and Configuration
    public static void addGestalt(String part, Attrs attrs);
    public Attrs getGestalt(String part);
    public Parameters getGestalt();
    
    // Workspace State
    public boolean isDefaultWorkspace();
    public boolean isInteractive();
    public String getDriver();
    public void signal();
    public void signal(Reporter reporter);
}

Usage Examples:

import aQute.bnd.build.Workspace;
import aQute.bnd.build.Project;

// Open workspace
Workspace workspace = Workspace.getWorkspace(new File("."));
if (workspace.isValid()) {
    System.out.println("Workspace: " + workspace.getBase());
    
    // List all projects
    for (Project project : workspace.getProjects()) {
        System.out.println("Project: " + project.getName());
    }
    
    // Get specific project
    Project myProject = workspace.getProject("com.example.bundle");
    if (myProject != null) {
        System.out.println("Found project: " + myProject.getName());
    }
}

workspace.close();

Project

Represents a BND project within a workspace, managing build configuration and dependencies.

/**
 * Represents a BND project within a workspace
 */
public class Project extends Processor {
    // Constructors
    public Project(Workspace workspace, File buildDir);
    public Project(Workspace workspace, File unused, File buildFile);
    
    // Static Factory Methods
    public static Project getUnparented(File propertiesFile) throws Exception;
    
    // Project Identity and State
    public String getName();
    public boolean isValid();
    public boolean isCnf();
    public Workspace getWorkspace();
    public int getChanged();
    public void setChanged();
    public boolean refresh();
    public void propertiesChanged();
    
    // Project Builder Management
    public ProjectBuilder getBuilder(ProjectBuilder parent) throws Exception;
    public Builder getSubBuilder(File bndFile) throws Exception;
    public ProjectBuilder getSubBuilder(String string) throws Exception;
    
    // Bundle and Container Management
    public List<Container> getBundles(Strategy strategyx, String spec, String source) throws Exception;
    public List<Container> getBundlesWildcard(String bsnPattern, String range, Strategy strategyx, Map<String, String> attrs) throws Exception;
    public Container getBundle(String bsn, String range, Strategy strategy, Map<String, String> attrs) throws Exception;
    public Container getBundle(org.osgi.resource.Resource r) throws Exception;
    public Container getDeliverable(String bsn, Map<String, String> attrs) throws Exception;
    public Collection<Container> getDeliverables() throws Exception;
    
    // Path Management
    public Collection<Container> getBuildpath() throws Exception;
    public Collection<Container> getTestpath() throws Exception;
    public Collection<Container> getRunpath() throws Exception;
    public Collection<Container> getRunbundles() throws Exception;
    public Collection<Container> getRunFw() throws Exception;
    public Collection<Container> getBootclasspath() throws Exception;
    public Collection<Container> getClasspath();
    public Collection<File> getSourcePath() throws Exception;
    public Collection<File> getAllsourcepath() throws Exception;
    
    // File System and Directories
    public File getTarget() throws Exception;
    public File getTargetDir();
    public File getSrc() throws Exception; // @Deprecated
    public File getSrcOutput();
    public File getTestSrc();
    public File getTestOutput();
    public File getOutput() throws Exception;
    public File getRunStorage() throws Exception;
    
    // Build Operations
    public void prepare() throws Exception;
    public File[] build() throws Exception;
    public File[] build(boolean underTest) throws Exception;
    public File[] buildLocal(boolean underTest) throws Exception;
    public File[] getBuildFiles() throws Exception;
    public File[] getBuildFiles(boolean buildIfAbsent) throws Exception;
    public boolean isStale() throws Exception;
    public boolean getRunBuilds();
    public void clean() throws Exception;
    
    // Dependencies and Projects
    public Collection<Project> getDependson() throws Exception;
    public Set<Project> getBuildDependencies() throws Exception;
    public Set<Project> getTestDependencies() throws Exception;
    public Set<Project> getDependents() throws Exception;
    
    // Release and Deployment
    public File release(String jarName, InputStream jarStream) throws Exception;
    public URI releaseURI(String jarName, InputStream jarStream) throws Exception;
    public File release(String name, String jarName, InputStream jarStream) throws Exception;
    public void release() throws Exception;
    public void release(String name) throws Exception;
    public void release(boolean test) throws Exception;
    public void deploy(File file) throws Exception;
    public void deploy(String name, File file) throws Exception;
    public void deploy() throws Exception;
    
    // Testing and Running
    public void run() throws Exception;
    public void runLocal() throws Exception;
    public void test() throws Exception;
    public void test(List<String> tests) throws Exception;
    public void test(File reportDir, List<String> tests) throws Exception;
    public void junit() throws Exception;
    public ProjectLauncher getProjectLauncher() throws Exception;
    public ProjectTester getProjectTester() throws Exception;
    public boolean isRunTrace();
    public boolean getRunKeep();
    public Collection<String> getRunVM();
    public Collection<String> getRunProgramArgs();
    public Map<String, String> getRunProperties();
    
    // File and Output Management
    public File[] getFiles();
    public File getOutputFile(String bsn, String version) throws Exception;
    public File getOutputFile(String bsn) throws Exception;
    public File saveBuild(Jar jar) throws Exception;
    
    // Versioning and Packages
    public void bump(String mask) throws Exception;
    public void bump() throws Exception;
    public Map<String, Version> getVersions() throws Exception;
    public Collection<String> getBsns() throws Exception;
    public Version getVersion(String bsn) throws Exception;
    public Packages getExports();
    public Packages getImports();
    public Packages getContained();
    public void setPackageInfo(String packageName, Version newVersion) throws Exception;
    public Version getPackageInfo(String packageName) throws Exception;
    
    // Actions and Commands
    public Map<String, Action> getActions();
    public void action(String command) throws Exception;
    public void action(String command, Object... args) throws Exception;
    public void script(String type, String script) throws Exception;
    public void script(String type, String script, Object... args) throws Exception;
    
    // Validation and Analysis
    public Jar getValidJar(File f) throws Exception;
    public Jar getValidJar(URL url) throws Exception;
    public Jar getValidJar(Jar jar, String id) throws Exception;
    public void baseline() throws Exception;
    public void verifyDependencies(boolean test) throws Exception;
    public void compile(boolean test) throws Exception;
    
    // Utility and Miscellaneous
    public boolean isNoBundles();
    public boolean isInteractive();
    public boolean isStandalone();
    public String getChecksum();
    public void remove() throws Exception;
    public void addClasspath(File f);
    public void clearClasspath();
    public Jar pack(String profile) throws Exception;
    public void setDelayRunDependencies(boolean x);
    public List<org.osgi.resource.Resource> getResources();
    public RunSpecification getSpecification();
    public Parameters getRunSystemPackages();
    public Parameters getRunSystemCapabilities();
    public ProjectGenerate getGenerate();
    public Optional<Processor> findProcessor(File file);
    public List<SubProject> getSubProjects();
}

Usage Examples:

import aQute.bnd.build.Project;
import aQute.bnd.build.Container;
import aQute.bnd.osgi.Jar;

// Work with project
Project project = workspace.getProject("my.bundle");
if (project != null) {
    // Get dependencies
    Collection<Container> dependencies = project.getDependencies();
    for (Container dep : dependencies) {
        System.out.println("Dependency: " + dep.getBundleSymbolicName() + 
                         " v" + dep.getVersion());
    }
    
    // Build project
    try {
        project.prepare();
        File[] deliverables = project.build();
        for (File deliverable : deliverables) {
            System.out.println("Built: " + deliverable);
        }
    } catch (Exception e) {
        System.err.println("Build failed: " + e.getMessage());
    }
    
    // Get project builder for custom builds
    ProjectBuilder builder = project.getBuilder(null);
    Jar jar = builder.build();
    if (builder.isOk()) {
        jar.write(new File("custom-build.jar"));
    }
    builder.close();
}

Container

Represents a dependency container (JAR, bundle, etc.) with metadata and file access.

/**
 * Represents a dependency container (JAR, bundle, etc.)
 */
public class Container {
    /** Get container file */
    public File getFile();
    
    /** Get bundle symbolic name */
    public String getBundleSymbolicName();
    
    /** Get container version */
    public Version getVersion();
    
    /** Get error message if container is invalid */
    public String getError();
    
    /** Get container type */
    public TYPE getType();
    
    /** Get container manifest */
    public Manifest getManifest() throws Exception;
    
    /** Get container attributes */
    public Map<String,String> getAttributes();
    
    /** Check if container contributes to classpath */
    public boolean contributeToClasspath();
    
    /** Get project reference if container is a project */
    public Project getProject();
    
    /** Get repository plugin that provides this container */
    public RepositoryPlugin getRepository();
}

/**
 * Container types
 */
public enum TYPE {
    REPO,       // From repository
    PROJECT,    // From workspace project  
    EXTERNAL,   // External JAR
    LIBRARY,    // Library definition
    ERROR       // Error container
}

ProjectBuilder

Specialized builder for project-based bundle creation.

/**
 * Specialized builder for project-based bundle creation
 */
public class ProjectBuilder extends Builder {
    /** Get associated project */
    public Project getProject();
    
    /** Build with project configuration */
    public Jar build() throws Exception;
    
    /** Get project dependencies as containers */
    public Collection<Container> getClasspath() throws Exception;
    
    /** Check if dependencies have changed */
    public boolean hasSources();
    
    /** Get last build time */
    public long lastModified();
}

Build Strategies

/**
 * Strategies for obtaining bundles
 */
public enum Strategy {
    LOWEST,     // Get lowest version
    HIGHEST,    // Get highest version
    EXACT       // Get exact version match
}

Complete Project Workflow Example:

import aQute.bnd.build.Workspace;
import aQute.bnd.build.Project;
import aQute.bnd.build.Container;
import aQute.bnd.osgi.Jar;

// Complete project workflow
try {
    // Open workspace
    Workspace workspace = Workspace.getWorkspace(new File("."));
    
    // Get project
    Project project = workspace.getProject("com.example.mybundle");
    if (project == null) {
        throw new RuntimeException("Project not found");
    }
    
    // Analyze dependencies
    Collection<Container> buildPath = project.getBuildpath();
    System.out.println("Build dependencies:");
    for (Container container : buildPath) {
        if (container.getError() != null) {
            System.err.println("Dependency error: " + container.getError());
        } else {
            System.out.println("- " + container.getBundleSymbolicName() + 
                             " v" + container.getVersion());
        }
    }
    
    // Build project
    project.prepare();
    File[] deliverables = project.build();
    
    // Verify build results
    for (File deliverable : deliverables) {
        System.out.println("Built: " + deliverable);
        
        // Analyze built bundle
        try (Jar jar = new Jar(deliverable)) {
            System.out.println("Bundle-SymbolicName: " + 
                             jar.getBsn());
            System.out.println("Bundle-Version: " + 
                             jar.getVersion());
        }
    }
    
    workspace.close();
    
} catch (Exception e) {
    System.err.println("Build failed: " + e.getMessage());
    e.printStackTrace();
}

Install with Tessl CLI

npx tessl i tessl/maven-biz-a-qute-bnd--biz-a-qute-bndlib

docs

api-comparison-diffing.md

core-osgi-processing.md

header-processing.md

index.md

jar-resource-management.md

plugin-architecture.md

repository-system.md

version-management.md

workspace-project-management.md

tile.json