Search in sources :

Example 81 with Repository

use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.

the class ArchetypeInfoAction method doExecute.

@Override
protected Object doExecute() throws Exception {
    // try artifact first
    Archetype archetype = archetypeService.getArchetypeByArtifact(archetypeGAV);
    if (archetype == null) {
        // then by coordinate
        archetypeService.getArchetype(archetypeGAV);
    }
    if (archetype != null) {
        System.out.println(String.format(FORMAT, "GroupId:", archetype.groupId));
        System.out.println(String.format(FORMAT, "ArtifactId:", archetype.artifactId));
        System.out.println(String.format(FORMAT, "Version:", archetype.version));
        System.out.println(String.format(FORMAT, "Coordinate:", toMavenCoordinate(archetype)));
        System.out.println(String.format(FORMAT, "Description:", emptyIfNull(archetype.description)));
        System.out.println(String.format(FORMAT, "Repository:", emptyIfNull(archetype.repository)));
    } else {
        System.err.println("No archetype found for: " + archetypeGAV);
    }
    return null;
}
Also used : Archetype(io.fabric8.tooling.archetype.catalog.Archetype)

Example 82 with Repository

use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.

the class AbstractManagedContainer method create.

@Override
public final synchronized void create(T configuration) throws LifecycleException {
    if (state != null)
        throw new IllegalStateException("Cannot create container in state: " + state);
    this.configuration = configuration;
    // [TODO] [FABRIC-929] No connector available to access repository jboss-public-repository-group
    // Remove this hack. It shouldbe possible to use the shrinkwrap maven resolver
    boolean useShrinkwrap = System.getProperty("shrinkwrap.resolver") != null;
    for (MavenCoordinates artefact : configuration.getMavenCoordinates()) {
        File zipfile = useShrinkwrap ? shrinkwrapResolve(artefact) : localResolve(artefact);
        GenericArchive archive = ShrinkWrap.createFromZipFile(GenericArchive.class, zipfile);
        ExplodedExporter exporter = archive.as(ExplodedExporter.class);
        File targetdir = configuration.getTargetDirectory();
        if (!targetdir.isDirectory() && !targetdir.mkdirs())
            throw new IllegalStateException("Cannot create target dir: " + targetdir);
        if (containerHome == null) {
            exporter.exportExploded(targetdir, "");
            File[] childDirs = targetdir.listFiles();
            if (childDirs.length != 1)
                throw new IllegalStateException("Expected one child directory, but was: " + Arrays.asList(childDirs));
            containerHome = childDirs[0];
        } else {
            exporter.exportExploded(containerHome, "");
        }
    }
    state = State.CREATED;
    try {
        doConfigure(configuration);
    } catch (Exception ex) {
        throw new LifecycleException("Cannot configure container", ex);
    }
}
Also used : MavenCoordinates(io.fabric8.api.gravia.MavenCoordinates) LifecycleException(io.fabric8.runtime.container.LifecycleException) GenericArchive(org.jboss.shrinkwrap.api.GenericArchive) ExplodedExporter(org.jboss.shrinkwrap.api.exporter.ExplodedExporter) File(java.io.File) LifecycleException(io.fabric8.runtime.container.LifecycleException) IOException(java.io.IOException)

Example 83 with Repository

use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.

the class Agent method provision.

public void provision(Set<String> repositories, Set<String> features, Set<String> bundles, Set<String> reqs, Set<String> overrides, Set<String> optionals, Map<String, Map<VersionRange, Map<String, String>>> metadata) throws Exception {
    updateStatus("downloading");
    Callable<Map<String, Repository>> repos = downloadRepositories(manager, repositories);
    Map<String, Feature> allFeatures = new HashMap<>();
    for (Repository repository : repos.call().values()) {
        for (Feature f : repository.getFeatures()) {
            String id = f.getId();
            if (allFeatures.put(id, f) != null) {
                throw new IllegalStateException("Duplicate feature found: " + id);
            }
        }
    }
    provision(allFeatures, features, bundles, reqs, overrides, optionals, metadata);
}
Also used : StaticRepository(io.fabric8.agent.repository.StaticRepository) Repository(io.fabric8.agent.model.Repository) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Feature(io.fabric8.agent.model.Feature)

Example 84 with Repository

use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.

the class AgentUtils method getMavenProxy.

public static Mirror getMavenProxy(FabricService fabricService) {
    try {
        if (fabricService != null) {
            String httpUrl = fabricService.getCurrentContainer().getHttpUrl();
            // Do not use getMavenRepoURI() as it may return the default repository
            List<URI> uris = fabricService.getMavenRepoURIs();
            if (uris == null || uris.isEmpty()) {
                return null;
            }
            URI uri = uris.get(0);
            // Bypass the proxy if on our own container
            if (uri.toString().startsWith(httpUrl)) {
                return null;
            }
            Mirror mirror = new Mirror();
            mirror.setName("fabric-maven-proxy");
            mirror.setUrl(uri.toURL().toExternalForm());
            mirror.setMirrorOf("*");
            return mirror;
        }
    } catch (Exception e) {
        LOGGER.warn("Unable to retrieve maven proxy urls: " + e.getMessage());
        LOGGER.debug("Unable to retrieve maven proxy urls: " + e.getMessage(), e);
    }
    return null;
}
Also used : URI(java.net.URI) Mirror(org.apache.maven.settings.Mirror) MalformedURLException(java.net.MalformedURLException) MultiException(io.fabric8.common.util.MultiException)

Example 85 with Repository

use of io.fabric8.agent.model.Repository in project fabric8 by jboss-fuse.

the class AgentUtils method addFeatures.

/**
 * Adds the set of features to the given set for the given profile
 *
 * @param features
 * @param fabricService
 *@param downloadManager
 * @param profile   @throws Exception
 */
public static void addFeatures(Set<Feature> features, FabricService fabricService, DownloadManager downloadManager, Profile profile) throws Exception {
    List<String> featureNames = profile.getFeatures();
    Map<String, Repository> repositories = getRepositories(fabricService, downloadManager, profile);
    for (String featureName : featureNames) {
        Feature feature = FeatureUtils.search(featureName, repositories.values());
        if (feature == null) {
            LOGGER.warn("Could not find feature " + featureName + " for profile " + profile.getId() + " in repositories " + repositories.keySet());
        } else {
            features.addAll(expandFeature(feature, repositories));
        }
    }
}
Also used : Repository(io.fabric8.agent.model.Repository) Feature(io.fabric8.agent.model.Feature)

Aggregations

File (java.io.File)49 Test (org.junit.Test)32 Git (org.eclipse.jgit.api.Git)30 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)27 IOException (java.io.IOException)24 GitPatchManagementServiceImpl (io.fabric8.patch.management.impl.GitPatchManagementServiceImpl)20 HashMap (java.util.HashMap)15 ObjectId (org.eclipse.jgit.lib.ObjectId)13 MalformedURLException (java.net.MalformedURLException)11 Map (java.util.Map)11 ArrayList (java.util.ArrayList)10 PatchException (io.fabric8.patch.management.PatchException)9 RevCommit (org.eclipse.jgit.revwalk.RevCommit)8 Bundle (org.osgi.framework.Bundle)8 Version (org.osgi.framework.Version)8 MavenResolver (io.fabric8.maven.MavenResolver)7 HashSet (java.util.HashSet)7 Repository (io.fabric8.agent.model.Repository)6 BundleContext (org.osgi.framework.BundleContext)6 Feature (io.fabric8.agent.model.Feature)5