Search in sources :

Example 41 with RepositoryPlugin

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

the class RepoPluginsBundleLocator method locate.

@Override
public File locate(String bsn, String hash, String algo, URI location) throws Exception {
    Map<String, String> searchProps = new HashMap<>();
    searchProps.put("version", "hash");
    searchProps.put("hash", algo + ":" + hash);
    for (RepositoryPlugin plugin : plugins) {
        try {
            File file = plugin.get(bsn, null, searchProps);
            if (file != null) {
                return file;
            }
        } catch (Exception e) {
        // ignore
        }
    }
    // Fall back to direct download
    // TODO: need some kind of download/cache service to avoid repeated downloads
    File tempFile = File.createTempFile("download", "jar");
    tempFile.deleteOnExit();
    IO.copy(location.toURL(), tempFile);
    return tempFile;
}
Also used : HashMap(java.util.HashMap) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) File(java.io.File)

Example 42 with RepositoryPlugin

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

the class AetherRepsitoryTests method testStrategyExactVersion.

public void testStrategyExactVersion() throws Exception {
    RepositoryPlugin repo = createRepo();
    Map<String, String> attrs = new HashMap<String, String>();
    attrs.put("version", "2.5");
    attrs.put("strategy", "exact");
    File file = repo.get("javax.servlet:servlet-api", new Version(2, 5, 0), attrs, listener);
    assertNotNull(file);
    assertEquals("servlet-api-2.5.jar", file.getName());
}
Also used : HashMap(java.util.HashMap) Version(aQute.bnd.version.Version) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) File(java.io.File)

Example 43 with RepositoryPlugin

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

the class AetherRepsitoryTests method testStrategyExactVersionBadGAV.

public void testStrategyExactVersionBadGAV() throws Exception {
    RepositoryPlugin repo = createRepo();
    Map<String, String> attrs = new HashMap<String, String>();
    attrs.put("version", "1.0");
    attrs.put("strategy", "exact");
    File file = repo.get("foo.bar:foobar-api", new Version(1, 0, 0), attrs, listener);
    assertNull(file);
}
Also used : HashMap(java.util.HashMap) Version(aQute.bnd.version.Version) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) File(java.io.File)

Example 44 with RepositoryPlugin

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

the class AetherRepsitoryTests method testVersionsBadBsn.

public void testVersionsBadBsn() throws Exception {
    RepositoryPlugin repo = createRepo();
    SortedSet<Version> versions = repo.versions("foo.bar.foobar");
    assertNull(versions);
}
Also used : Version(aQute.bnd.version.Version) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin)

Example 45 with RepositoryPlugin

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

the class RepositoryBundlesContentProvider method getChildren.

@Override
public Object[] getChildren(Object parentElement) {
    RepositoryPlugin repoPlugin = (RepositoryPlugin) parentElement;
    List<String> bsns;
    try {
        bsns = repoPlugin.list(null);
    } catch (Exception e) {
        logger.logError("Error querying repository " + repoPlugin.getName(), e);
        bsns = Collections.emptyList();
    }
    return bsns.toArray(new String[0]);
}
Also used : 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