use of org.eclipse.tycho.p2.tools.FacadeException in project tycho by eclipse.
the class MirrorApplicationServiceImpl method toInstallableUnitList.
private static List<IInstallableUnit> toInstallableUnitList(Collection<DependencySeed> seeds, IMetadataRepository sourceRepository, RepositoryReferences sourceRepositoryNames) throws FacadeException {
List<IInstallableUnit> result = new ArrayList<>(seeds.size());
for (DependencySeed seed : seeds) {
if (seed.getInstallableUnit() == null) {
// TODO 372780 drop this when getInstallableUnit can no longer be null
String unitId = seed.getId() + (ArtifactType.TYPE_ECLIPSE_FEATURE.equals(seed.getType()) ? ".feature.group" : "");
result.addAll(querySourceIus(Collections.singletonList(new IUDescription(unitId, null)), sourceRepository, sourceRepositoryNames));
} else {
result.add((IInstallableUnit) seed.getInstallableUnit());
}
}
if (result.isEmpty()) {
throw new IllegalArgumentException("List of seed units for repository aggregation must not be empty");
}
return result;
}
use of org.eclipse.tycho.p2.tools.FacadeException in project tycho by eclipse.
the class MirrorApplicationServiceImpl method recreateArtifactRepository.
private void recreateArtifactRepository(DestinationRepositoryDescriptor destination) throws FacadeException {
// create the missing md5 checksums
if (destination.isMetaDataOnly()) {
return;
}
RepositoryDescriptor descriptor = new RepositoryDescriptor();
descriptor.setAppend(true);
descriptor.setFormat(null);
// $NON-NLS-1$
descriptor.setKind("artifact");
descriptor.setLocation(destination.getLocation().toURI());
RecreateRepositoryApplication application = new RecreateRepositoryApplication();
application.setArtifactRepository(descriptor);
try {
application.run(new NullProgressMonitor());
} catch (ProvisionException e) {
throw new FacadeException("Recreate artifact repository failed", e);
}
}
use of org.eclipse.tycho.p2.tools.FacadeException in project tycho by eclipse.
the class MirrorApplicationServiceImpl method querySourceIus.
private static List<IInstallableUnit> querySourceIus(Collection<IUDescription> sourceIUs, IMetadataRepository repository, RepositoryReferences sources) throws FacadeException {
if (sourceIUs == null || sourceIUs.isEmpty()) {
return null;
}
List<IInstallableUnit> result = new ArrayList<>();
for (IUDescription iu : sourceIUs) {
IQuery<IInstallableUnit> iuQuery = createQuery(iu);
Iterator<IInstallableUnit> queryResult = repository.query(iuQuery, null).iterator();
if (!queryResult.hasNext()) {
throw new FacadeException("Could not find IU " + iu.toString() + " in any of the source repositories " + sources.getMetadataRepositories(), null);
}
while (queryResult.hasNext()) {
result.add(queryResult.next());
}
}
return result;
}
use of org.eclipse.tycho.p2.tools.FacadeException in project tycho by eclipse.
the class MirrorApplicationServiceImpl method xzCompress.
private void xzCompress(DestinationRepositoryDescriptor destination) throws FacadeException {
if (!destination.isXZCompress()) {
return;
}
try {
XZCompressor xzCompressor = new XZCompressor();
xzCompressor.setPreserveOriginalFile(destination.shouldKeepNonXzIndexFiles());
xzCompressor.setRepoFolder(destination.getLocation().getAbsolutePath());
xzCompressor.compressRepo();
} catch (IOException e) {
throw new FacadeException("XZ compression failed", e);
}
}
use of org.eclipse.tycho.p2.tools.FacadeException in project tycho by eclipse.
the class MirrorApplicationServiceImpl method mirrorReactor.
@Override
public void mirrorReactor(RepositoryReferences sources, DestinationRepositoryDescriptor destination, Collection<DependencySeed> projectSeeds, BuildContext context, boolean includeAllDependencies, boolean includePacked, Map<String, String> filterProperties) throws FacadeException {
IProvisioningAgent agent = Activator.createProvisioningAgent(context.getTargetDirectory());
try {
final MirrorApplication mirrorApp = createMirrorApplication(sources, destination, agent, includePacked);
// mirror scope: seed units...
mirrorApp.setSourceIUs(toInstallableUnitList(projectSeeds, mirrorApp.getCompositeMetadataRepository(), sources));
// TODO the p2 mirror tool should support mirroring multiple environments at once
for (TargetEnvironment environment : context.getEnvironments()) {
SlicingOptions options = new SlicingOptions();
options.considerStrictDependencyOnly(!includeAllDependencies);
Map<String, String> filter = options.getFilter();
addFilterForFeatureJARs(filter);
if (filterProperties != null) {
filter.putAll(filterProperties);
}
filter.putAll(environment.toFilterProperties());
mirrorApp.setSlicingOptions(options);
try {
LogListener logListener = new LogListener(mavenContext.getLogger());
mirrorApp.setLog(logListener);
IStatus returnStatus = mirrorApp.run(null);
checkStatus(returnStatus, false);
logListener.showHelpForLoggedMessages();
} catch (ProvisionException e) {
throw new FacadeException(MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(e.getStatus()), e);
}
}
recreateArtifactRepository(destination);
xzCompress(destination);
} finally {
agent.stop();
}
}
Aggregations