Search in sources :

Example 1 with TychoProject

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.");
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) TychoProject(org.eclipse.tycho.core.TychoProject) Version(org.osgi.framework.Version)

Example 2 with TychoProject

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();
            }
        }
    }
}
Also used : DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) MavenProject(org.apache.maven.project.MavenProject) AbstractTychoProject(org.eclipse.tycho.core.osgitools.AbstractTychoProject) TychoProject(org.eclipse.tycho.core.TychoProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ReactorProject(org.eclipse.tycho.ReactorProject) File(java.io.File)

Example 3 with TychoProject

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;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TychoProject(org.eclipse.tycho.core.TychoProject) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Properties(java.util.Properties) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Plugin(org.apache.maven.model.Plugin)

Example 4 with TychoProject

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));
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) MavenProject(org.apache.maven.project.MavenProject) TychoProject(org.eclipse.tycho.core.TychoProject) File(java.io.File)

Example 5 with TychoProject

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;
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Dependency(org.apache.maven.model.Dependency) Artifact(org.apache.maven.artifact.Artifact) ProjectArtifact(org.apache.maven.project.artifact.ProjectArtifact) DefaultClasspathEntry(org.eclipse.tycho.core.osgitools.DefaultClasspathEntry) MavenProject(org.apache.maven.project.MavenProject) TychoProject(org.eclipse.tycho.core.TychoProject) ArtifactResolutionRequest(org.apache.maven.artifact.resolver.ArtifactResolutionRequest) ArtifactResolutionResult(org.apache.maven.artifact.resolver.ArtifactResolutionResult) ProjectArtifact(org.apache.maven.project.artifact.ProjectArtifact) DefaultClasspathEntry(org.eclipse.tycho.core.osgitools.DefaultClasspathEntry) ClasspathEntry(org.eclipse.tycho.classpath.ClasspathEntry) File(java.io.File)

Aggregations

TychoProject (org.eclipse.tycho.core.TychoProject)6 File (java.io.File)3 MavenProject (org.apache.maven.project.MavenProject)3 ArtifactKey (org.eclipse.tycho.ArtifactKey)2 ReactorProject (org.eclipse.tycho.ReactorProject)2 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)2 Version (org.osgi.framework.Version)2 ParsePosition (java.text.ParsePosition)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Properties (java.util.Properties)1 Artifact (org.apache.maven.artifact.Artifact)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 ArtifactResolutionRequest (org.apache.maven.artifact.resolver.ArtifactResolutionRequest)1 ArtifactResolutionResult (org.apache.maven.artifact.resolver.ArtifactResolutionResult)1 Dependency (org.apache.maven.model.Dependency)1 Plugin (org.apache.maven.model.Plugin)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ProjectArtifact (org.apache.maven.project.artifact.ProjectArtifact)1