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;
}
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);
}
}
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);
}
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;
}
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));
}
}
}
Aggregations