use of org.eclipse.tycho.core.TychoProject in project tycho by eclipse.
the class OsgiSourceMojo method addSourceBundleManifestEntries.
private void addSourceBundleManifestEntries(MavenArchiveConfiguration mavenArchiveConfiguration) {
TychoProject projectType = projectTypes.get(project.getPackaging());
ArtifactKey artifactKey = projectType.getArtifactKey(DefaultReactorProject.adapt(project));
String symbolicName = artifactKey.getId();
String version = artifactKey.getVersion();
if (symbolicName != null && version != null) {
mavenArchiveConfiguration.addManifestEntry(BUNDLE_MANIFESTVERSION, "2");
mavenArchiveConfiguration.addManifestEntry(BUNDLE_SYMBOLICNAME, symbolicName + sourceBundleSuffix);
Version expandedVersion = getExpandedVersion(version);
mavenArchiveConfiguration.addManifestEntry(BUNDLE_VERSION, expandedVersion.toString());
mavenArchiveConfiguration.addManifestEntry(MANIFEST_HEADER_ECLIPSE_SOURCE_BUNDLE, symbolicName + ";version=\"" + expandedVersion + "\";roots:=\"" + getEclipseHeaderSourceRoots() + "\"");
mavenArchiveConfiguration.addManifestEntry(BUNDLE_NAME, I18N_KEY_PREFIX + I18N_KEY_BUNDLE_NAME);
mavenArchiveConfiguration.addManifestEntry(BUNDLE_VENDOR, I18N_KEY_PREFIX + I18N_KEY_BUNDLE_VENDOR);
mavenArchiveConfiguration.addManifestEntry(BUNDLE_LOCALIZATION, MANIFEST_BUNDLE_LOCALIZATION_BASENAME);
} else {
getLog().info("NOT adding source bundle manifest entries. Incomplete or no bundle information available.");
}
}
use of org.eclipse.tycho.core.TychoProject in project tycho by eclipse.
the class LocalDependencyResolver method addProjects.
private void addProjects(MavenSession session, DefaultDependencyArtifacts platform) {
File parentDir = null;
for (MavenProject project : session.getProjects()) {
ReactorProject projectProxy = DefaultReactorProject.adapt(project);
TychoProject dr = projectTypes.get(project.getPackaging());
if (dr != null) {
ArtifactKey key = dr.getArtifactKey(projectProxy);
platform.removeAll(key.getType(), key.getId());
platform.addReactorArtifact(key, projectProxy, null, null);
if (parentDir == null || isSubdir(project.getBasedir(), parentDir)) {
parentDir = project.getBasedir();
}
}
}
}
use of org.eclipse.tycho.core.TychoProject in project tycho by eclipse.
the class DefaultTargetPlatformConfigurationReader method getTargetPlatformConfiguration.
public TargetPlatformConfiguration getTargetPlatformConfiguration(MavenSession session, MavenProject project) throws BuildFailureException {
TargetPlatformConfiguration result = new TargetPlatformConfiguration();
// Use org.eclipse.tycho:target-platform-configuration/configuration/environment, if provided
Plugin plugin = project.getPlugin("org.eclipse.tycho:target-platform-configuration");
if (plugin != null) {
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
if (configuration != null) {
if (logger.isDebugEnabled()) {
logger.debug("target-platform-configuration for " + project.toString() + ":\n" + configuration.toString());
}
addTargetEnvironments(result, project, configuration);
setTargetPlatformResolver(result, configuration);
setTarget(result, session, project, configuration);
setPomDependencies(result, configuration);
setAllowConflictingDependencies(result, configuration);
setDisableP2Mirrors(result, configuration);
setExecutionEnvironment(result, configuration);
setExecutionEnvironmentDefault(result, configuration);
setBREEHeaderSelectionPolicy(result, configuration);
setResolveWithEEContraints(result, configuration);
readFilters(result, configuration);
readDependencyResolutionConfiguration(result, configuration);
setIncludePackedArtifacts(result, configuration);
setTargetDefinitionIncludeSources(result, configuration);
}
}
if (result.getEnvironments().isEmpty()) {
TychoProject projectType = projectTypes.get(project.getPackaging());
if (projectType != null) {
TargetEnvironment env = projectType.getImplicitTargetEnvironment(project);
if (env != null) {
if (logger.isDebugEnabled()) {
logger.debug("Implicit target environment for " + project.toString() + ": " + env.toString());
}
result.addEnvironment(env);
}
}
}
if (result.getEnvironments().isEmpty()) {
// applying defaults
logger.warn("No explicit target runtime environment configuration. Build is platform dependent.");
// Otherwise, use project or execution properties, if provided
Properties properties = (Properties) project.getContextValue(TychoConstants.CTX_MERGED_PROPERTIES);
// Otherwise, use current system os/ws/nl/arch
String os = PlatformPropertiesUtils.getOS(properties);
String ws = PlatformPropertiesUtils.getWS(properties);
String arch = PlatformPropertiesUtils.getArch(properties);
result.addEnvironment(new TargetEnvironment(os, ws, arch));
result.setImplicitTargetEnvironment(true);
} else {
result.setImplicitTargetEnvironment(false);
}
return result;
}
use of org.eclipse.tycho.core.TychoProject in project tycho by eclipse.
the class TychoTest method testMNGECLIPSE942.
public void testMNGECLIPSE942() throws Exception {
File basedir = getBasedir("projects/dummy");
File platformLocation = new File("src/test/resources/targetplatforms/MNGECLIPSE-942");
MavenProject project = getSortedProjects(basedir, platformLocation).get(0);
TychoProject projectType = lookup(TychoProject.class, project.getPackaging());
DependencyArtifacts platform = projectType.getDependencyArtifacts(project);
assertEquals(2, platform.getArtifacts(ArtifactType.TYPE_ECLIPSE_PLUGIN).size());
assertNotNull(platform.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, "org.junit4.nl_ru", null));
}
use of org.eclipse.tycho.core.TychoProject in project tycho by eclipse.
the class AbstractOsgiCompilerMojo method getClasspath.
@Override
public List<ClasspathEntry> getClasspath() throws MojoExecutionException {
TychoProject projectType = getBundleProject();
ArrayList<ClasspathEntry> classpath = new ArrayList<>(((BundleProject) projectType).getClasspath(project));
if (extraClasspathElements != null) {
ArtifactRepository localRepository = session.getLocalRepository();
List<ArtifactRepository> remoteRepositories = project.getRemoteArtifactRepositories();
for (Dependency extraDependency : extraClasspathElements) {
Artifact artifact = repositorySystem.createDependencyArtifact(extraDependency);
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
request.setLocalRepository(localRepository);
request.setRemoteRepositories(remoteRepositories);
request.setResolveRoot(true);
request.setResolveTransitively(true);
ArtifactResolutionResult result = repositorySystem.resolve(request);
if (result.hasExceptions()) {
throw new MojoExecutionException("Could not resolve extra classpath entry", result.getExceptions().get(0));
}
for (Artifact b : result.getArtifacts()) {
MavenProject bProject = null;
if (b instanceof ProjectArtifact) {
bProject = ((ProjectArtifact) b).getProject();
}
ArrayList<File> bLocations = new ArrayList<>();
// TODO properly handle multiple project locations maybe
bLocations.add(b.getFile());
classpath.add(new DefaultClasspathEntry(DefaultReactorProject.adapt(bProject), null, bLocations, null));
}
}
}
return classpath;
}
Aggregations