Search in sources :

Example 1 with MavenBackingRepository

use of aQute.maven.provider.MavenBackingRepository in project bnd by bndtools.

the class PomRepositoryTest method getRepo.

MavenRepository getRepo() throws Exception {
    List<MavenBackingRepository> central = MavenBackingRepository.create("https://repo1.maven.org/maven2/", reporter, localRepo, client);
    List<MavenBackingRepository> apache = MavenBackingRepository.create("https://repository.apache.org/content/groups/snapshots/", reporter, localRepo, client);
    MavenRepository mr = new MavenRepository(localRepo, "test", central, apache, Processor.getExecutor(), reporter, null);
    return mr;
}
Also used : MavenBackingRepository(aQute.maven.provider.MavenBackingRepository) MavenRepository(aQute.maven.provider.MavenRepository)

Example 2 with MavenBackingRepository

use of aQute.maven.provider.MavenBackingRepository in project bnd by bndtools.

the class MavenBndRepository method init.

private synchronized void init() {
    try {
        if (inited)
            return;
        client = registry.getPlugin(HttpClient.class);
        inited = true;
        name = configuration.name("Maven");
        localRepo = IO.getFile(configuration.local(MAVEN_REPO_LOCAL));
        List<MavenBackingRepository> release = MavenBackingRepository.create(configuration.releaseUrl(), reporter, localRepo, client);
        List<MavenBackingRepository> snapshot = MavenBackingRepository.create(configuration.snapshotUrl(), reporter, localRepo, client);
        storage = new MavenRepository(localRepo, getName(), release, snapshot, Processor.getExecutor(), reporter, getRefreshCallback());
        File base = IO.work;
        if (registry != null) {
            Workspace ws = registry.getPlugin(Workspace.class);
            if (ws != null)
                base = ws.getBuildDir();
        }
        File indexFile = IO.getFile(base, configuration.index(name.toLowerCase() + ".mvn"));
        IndexFile ixf = new IndexFile(reporter, indexFile, storage);
        ixf.open();
        this.index = ixf;
        startPoll(index);
        logger.debug("initing {}", this);
    } catch (Exception e) {
        reporter.exception(e, "Init for maven repo failed %s", configuration);
        throw new RuntimeException(e);
    }
}
Also used : MavenBackingRepository(aQute.maven.provider.MavenBackingRepository) MavenRepository(aQute.maven.provider.MavenRepository) HttpClient(aQute.bnd.http.HttpClient) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) Workspace(aQute.bnd.build.Workspace)

Example 3 with MavenBackingRepository

use of aQute.maven.provider.MavenBackingRepository in project bnd by bndtools.

the class MavenBndRepository method tooltip.

@Override
public String tooltip(Object... target) throws Exception {
    switch(target.length) {
        case 0:
            try (Formatter f = new Formatter()) {
                f.format("%s\n", getName());
                f.format("Revisions %s\n", index.descriptors.size());
                for (MavenBackingRepository mbr : storage.getReleaseRepositories()) f.format("Release %s  (%s)\n", mbr, getUser(mbr));
                for (MavenBackingRepository mbr : storage.getSnapshotRepositories()) f.format("Snapshot %s (%s)\n", mbr, getUser(mbr));
                f.format("Storage %s\n", localRepo);
                f.format("Index %s\n", index.indexFile);
                f.format("Index Cache %s\n", index.cacheDir);
                return f.toString();
            }
        case 1:
            try (Formatter f = new Formatter()) {
                String name = (String) target[0];
                Set<aQute.maven.api.Program> programs = index.getProgramsForBsn(name);
                return programs.toString();
            }
        case 2:
            BundleDescriptor bd = getBundleDescriptor(target);
            try (Formatter f = new Formatter()) {
                f.format("%s\n", bd.archive);
                f.format("Bundle-Version %s\n", bd.version);
                f.format("Last Modified %s\n", new Date(bd.lastModified));
                f.format("URL %s\n", bd.url);
                f.format("SHA-1 %s\n", Hex.toHexString(bd.id).toLowerCase());
                f.format("SHA-256 %s\n", Hex.toHexString(bd.sha256).toLowerCase());
                File localFile = storage.toLocalFile(bd.archive);
                f.format("Local %s%s\n", localFile, localFile.isFile() ? "" : " ?");
                if (bd.description != null)
                    f.format("Description\n%s", bd.description);
                return f.toString();
            }
        default:
    }
    return null;
}
Also used : MavenBackingRepository(aQute.maven.provider.MavenBackingRepository) BundleDescriptor(aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor) Formatter(java.util.Formatter) File(java.io.File) Date(java.util.Date)

Example 4 with MavenBackingRepository

use of aQute.maven.provider.MavenBackingRepository in project bnd by bndtools.

the class BndPomRepository method init.

public synchronized void init() {
    try {
        if (inited)
            return;
        inited = true;
        Workspace workspace = registry.getPlugin(Workspace.class);
        HttpClient client = registry.getPlugin(HttpClient.class);
        File localRepo = IO.getFile(configuration.local(MAVEN_REPO_LOCAL));
        File location = workspace.getFile(getLocation());
        List<MavenBackingRepository> release = MavenBackingRepository.create(configuration.releaseUrls(), reporter, localRepo, client);
        List<MavenBackingRepository> snapshot = MavenBackingRepository.create(configuration.snapshotUrls(), reporter, localRepo, client);
        MavenRepository repository = new MavenRepository(localRepo, name, release, snapshot, Processor.getExecutor(), reporter, null);
        boolean transitive = configuration.transitive(true);
        if (pomFiles != null) {
            repoImpl = new PomRepository(repository, client, location, transitive).uris(pomFiles);
        } else if (revisions != null) {
            repoImpl = new PomRepository(repository, client, location, transitive).revisions(revisions);
        } else if (query != null) {
            repoImpl = new SearchRepository(repository, location, query, queryUrl, workspace, client, transitive);
        } else {
            repository.close();
            throw new IllegalStateException("We have neither a pom, revision, or query set!");
        }
        bridge = new BridgeRepository(repoImpl);
    } catch (Exception e) {
        throw Exceptions.duck(e);
    }
}
Also used : BridgeRepository(aQute.bnd.osgi.repository.BridgeRepository) MavenBackingRepository(aQute.maven.provider.MavenBackingRepository) MavenRepository(aQute.maven.provider.MavenRepository) HttpClient(aQute.bnd.http.HttpClient) File(java.io.File) Workspace(aQute.bnd.build.Workspace)

Aggregations

MavenBackingRepository (aQute.maven.provider.MavenBackingRepository)4 MavenRepository (aQute.maven.provider.MavenRepository)3 File (java.io.File)3 Workspace (aQute.bnd.build.Workspace)2 HttpClient (aQute.bnd.http.HttpClient)2 BridgeRepository (aQute.bnd.osgi.repository.BridgeRepository)1 BundleDescriptor (aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Date (java.util.Date)1 Formatter (java.util.Formatter)1