use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class P2DependencyResolver method getThisReactorProject.
private ReactorProject getThisReactorProject(MavenSession session, MavenProject project, TargetPlatformConfiguration configuration) {
// 'this' project should obey optionalDependencies configuration
final List<TargetEnvironment> environments = configuration.getEnvironments();
final OptionalResolutionAction optionalAction = configuration.getDependencyResolverConfiguration().getOptionalResolutionAction();
Map<String, IDependencyMetadata> dependencyMetadata = getDependencyMetadata(session, project, environments, optionalAction);
final Set<Object> metadata = new LinkedHashSet<>();
final Set<Object> secondaryMetadata = new LinkedHashSet<>();
for (Map.Entry<String, IDependencyMetadata> entry : dependencyMetadata.entrySet()) {
metadata.addAll(entry.getValue().getMetadata(true));
secondaryMetadata.addAll(entry.getValue().getMetadata(false));
}
ReactorProject reactorProjet = new DefaultReactorProject(project) {
@Override
public Set<?> getDependencyMetadata(boolean primary) {
return primary ? metadata : secondaryMetadata;
}
};
return reactorProjet;
}
use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class ProductArchiverMojoTest method testGetArtifactClassifier.
@Test
public void testGetArtifactClassifier() {
TargetEnvironment env = new TargetEnvironment("os", "ws", "arch");
Product product = new Product("product.id");
String classifier = ProductArchiverMojo.getArtifactClassifier(product, env);
assertEquals("os.ws.arch", classifier);
}
use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class ProductArchiverMojoTest method testGetArtifactClassifierWithAttachId.
@Test
public void testGetArtifactClassifierWithAttachId() {
TargetEnvironment env = new TargetEnvironment("os", "ws", "arch");
Product product = new Product("product.id", "attachId");
String classifier = ProductArchiverMojo.getArtifactClassifier(product, env);
assertEquals("attachId-os.ws.arch", classifier);
}
use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class ProductArchiverMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
ProductConfig config = getProductConfig();
if (!config.uniqueAttachIds()) {
throw new MojoFailureException("Artifact file names for the archived products are not unique. " + "Configure the attachId or select a subset of products. Current configuration: " + config.getProducts());
}
for (Product product : config.getProducts()) {
for (TargetEnvironment env : getEnvironments()) {
String format = getArchiveFormat(env);
ProductArchiver productArchiver = productArchivers.get(format);
if (productArchiver == null) {
throw new MojoExecutionException("Unknown or unsupported archive format os=" + env.getOs() + " format=" + format);
}
File productArchive = new File(getProductsBuildDirectory(), getArchiveFileName(product) + "-" + getOsWsArch(env, '.') + "." + format);
try {
final File sourceDir = getProductMaterializeDirectory(product, env);
if (TAR_GZ_ARCHIVE_FORMAT.equals(format) && !"plexus".equals(getSession().getUserProperties().getProperty("tycho.tar"))) {
getLog().debug("Using commons-compress tar");
createCommonsCompressTarGz(productArchive, sourceDir);
} else {
Archiver archiver = productArchiver.getArchiver();
archiver.setDestFile(productArchive);
DefaultFileSet fileSet = new DefaultFileSet(sourceDir);
fileSet.setUsingDefaultExcludes(false);
archiver.addFileSet(fileSet);
archiver.createArchive();
}
} catch (ArchiverException e) {
throw new MojoExecutionException("Error packing product", e);
} catch (IOException e) {
throw new MojoExecutionException("Error packing product", e);
}
final String artifactClassifier = getArtifactClassifier(product, env);
helper.attachArtifact(getProject(), format, artifactClassifier, productArchive);
}
}
}
use of org.eclipse.tycho.core.shared.TargetEnvironment 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