Search in sources :

Example 31 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bnd by bndtools.

the class Project method releaseURI.

public URI releaseURI(String name, String jarName, InputStream jarStream) throws Exception {
    List<RepositoryPlugin> releaseRepos = getReleaseRepos(name);
    if (releaseRepos.isEmpty()) {
        return null;
    }
    // use only first
    RepositoryPlugin releaseRepo = releaseRepos.get(0);
    // release repo
    return releaseRepo(releaseRepo, jarName, jarStream);
}
Also used : RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 32 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.

the class AvailableBundlesPart method getRepositories.

@Override
public List<RepositoryPlugin> getRepositories() {
    List<String> tmp = model.getRunRepos();
    includedRepos = (tmp == null) ? null : new HashSet<String>(tmp);
    Workspace workspace = model.getWorkspace();
    List<RepositoryPlugin> repos;
    try {
        repos = RepositoryUtils.listRepositories(workspace, true);
    } catch (Exception e) {
        repos = Collections.emptyList();
    }
    return repos;
}
Also used : RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) HashSet(java.util.HashSet) Workspace(aQute.bnd.build.Workspace)

Example 33 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.

the class BndContainerSourceManager method getSourceBundle.

private static File getSourceBundle(IPath path, Map<String, String> props) {
    Workspace bndWorkspace;
    try {
        bndWorkspace = Central.getWorkspace();
        if (bndWorkspace == null) {
            return null;
        }
    } catch (final Exception e) {
        return null;
    }
    IPath bundlePath = path;
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IResource resource = root.findMember(path);
    if (resource != null) {
        bundlePath = resource.getLocation();
    }
    try (JarInputStream jarStream = new JarInputStream(IO.stream(bundlePath.toFile()), false)) {
        Manifest manifest = jarStream.getManifest();
        if (manifest == null) {
            return null;
        }
        Domain domain = Domain.domain(manifest);
        Entry<String, Attrs> bsnAttrs = domain.getBundleSymbolicName();
        if (bsnAttrs == null) {
            return null;
        }
        String bsn = bsnAttrs.getKey();
        String version = domain.getBundleVersion();
        if (version == null) {
            version = props.get("version");
        }
        for (RepositoryPlugin repo : RepositoryUtils.listRepositories(true)) {
            if (repo == null) {
                continue;
            }
            if (repo instanceof WorkspaceRepository) {
                continue;
            }
            File sourceBundle = repo.get(bsn + ".source", new Version(version), props);
            if (sourceBundle != null) {
                return sourceBundle;
            }
        }
    } catch (final Exception e) {
    // Ignore, something went wrong, or we could not find the source bundle
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) JarInputStream(java.util.jar.JarInputStream) Attrs(aQute.bnd.header.Attrs) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) Manifest(java.util.jar.Manifest) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) Version(aQute.bnd.version.Version) WorkspaceRepository(aQute.bnd.build.WorkspaceRepository) IWorkspace(org.eclipse.core.resources.IWorkspace) Domain(aQute.bnd.osgi.Domain) File(java.io.File) IResource(org.eclipse.core.resources.IResource) IWorkspace(org.eclipse.core.resources.IWorkspace) Workspace(aQute.bnd.build.Workspace)

Example 34 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.

the class WorkspaceReleaseJob method run.

@Override
protected IStatus run(IProgressMonitor monitor) {
    monitor.beginTask(Messages.releasingProjects, projectDiffs.size());
    for (ProjectDiff projectDiff : projectDiffs) {
        if (projectDiff.isRelease()) {
            RepositoryPlugin release = null;
            if (projectDiff.getReleaseRepository() != null) {
                release = Activator.getRepositoryPlugin(projectDiff.getReleaseRepository());
            }
            ReleaseContext context = new ReleaseContext(projectDiff.getProject(), projectDiff.getBaselines(), release, releaseOption);
            ReleaseJob job = new ReleaseJob(context, showMessage);
            job.setRule(ResourcesPlugin.getWorkspace().getRoot());
            job.run(new SubProgressMonitor(monitor, 1));
        }
        monitor.worked(1);
    }
    monitor.done();
    return Status.OK_STATUS;
}
Also used : ReleaseContext(bndtools.release.api.ReleaseContext) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 35 with RepositoryPlugin

use of aQute.bnd.service.RepositoryPlugin in project bndtools by bndtools.

the class ReleaseHelper method getReleaseRepositories.

public static String[] getReleaseRepositories() {
    List<RepositoryPlugin> repos = Activator.getRepositories();
    List<String> ret = new ArrayList<String>();
    for (RepositoryPlugin repo : repos) {
        if (repo.canWrite()) {
            if (repo.getName() != null) {
                ret.add(repo.getName());
            } else {
                ret.add(repo.toString());
            }
        }
    }
    return ret.toArray(new String[0]);
}
Also used : ArrayList(java.util.ArrayList) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Aggregations

RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)62 Version (aQute.bnd.version.Version)25 File (java.io.File)24 Workspace (aQute.bnd.build.Workspace)12 IOException (java.io.IOException)10 Project (aQute.bnd.build.Project)9 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 Jar (aQute.bnd.osgi.Jar)7 CoreException (org.eclipse.core.runtime.CoreException)7 RemoteRepositoryPlugin (aQute.bnd.service.RemoteRepositoryPlugin)5 VersionRange (aQute.bnd.version.VersionRange)5 Description (aQute.lib.getopt.Description)5 Parameters (aQute.bnd.header.Parameters)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 PartInitException (org.eclipse.ui.PartInitException)4 Attrs (aQute.bnd.header.Attrs)3