Search in sources :

Example 6 with FeatureRef

use of org.eclipse.tycho.model.FeatureRef in project tycho by eclipse.

the class AbstractArtifactDependencyWalker method traverseProduct.

protected void traverseProduct(ProductConfiguration product, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    if (product.useFeatures()) {
        for (FeatureRef ref : product.getFeatures()) {
            traverseFeature(ref, visitor, visited);
        }
    } else {
        for (PluginRef ref : product.getPlugins()) {
            traversePlugin(ref, visitor, visited);
        }
    }
    Set<String> bundles = new HashSet<>();
    for (ArtifactDescriptor artifact : visited.getVisited()) {
        ArtifactKey key = artifact.getKey();
        if (ArtifactType.TYPE_ECLIPSE_PLUGIN.equals(key.getType())) {
            bundles.add(key.getId());
        }
    }
    if (environments != null && product.includeLaunchers()) {
        for (TargetEnvironment environment : environments) {
            String os = environment.getOs();
            String ws = environment.getWs();
            String arch = environment.getArch();
            String id;
            // see http://jira.codehaus.org/browse/MNGECLIPSE-1075
            if (PlatformPropertiesUtils.OS_MACOSX.equals(os) && (PlatformPropertiesUtils.ARCH_X86.equals(arch) || PlatformPropertiesUtils.ARCH_PPC.equals(arch))) {
                id = "org.eclipse.equinox.launcher." + ws + "." + os;
            } else {
                id = "org.eclipse.equinox.launcher." + ws + "." + os + "." + arch;
            }
            if (!bundles.contains(id)) {
                PluginRef ref = new PluginRef("plugin");
                ref.setId(id);
                ref.setOs(os);
                ref.setWs(ws);
                ref.setArch(arch);
                ref.setUnpack(true);
                traversePlugin(ref, visitor, visited);
            }
        }
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) HashSet(java.util.HashSet)

Example 7 with FeatureRef

use of org.eclipse.tycho.model.FeatureRef in project tycho by eclipse.

the class GeneratePomsMojo method getFeatureFeaturesAndPlugins.

private Set<File> getFeatureFeaturesAndPlugins(File basedir) throws MojoExecutionException {
    try {
        Set<File> result = new LinkedHashSet<>();
        Feature feature = Feature.read(new File(basedir, "feature.xml"));
        for (PluginRef plugin : feature.getPlugins()) {
            addPlugin(result, plugin.getId());
        }
        for (FeatureRef includedFeature : feature.getIncludedFeatures()) {
            addFeature(result, includedFeature.getId());
        }
        for (Feature.RequiresRef require : feature.getRequires()) {
            for (Feature.ImportRef imp : require.getImports()) {
                addPlugin(result, imp.getPlugin());
                addFeature(result, imp.getFeature());
            }
        }
        return result;
    } catch (IOException e) {
        throw new MojoExecutionException("Exception processing feature " + toString(basedir), e);
    } catch (XmlPullParserException e) {
        throw new MojoExecutionException("Exception processing feature " + toString(basedir), e);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) PluginRef(org.eclipse.tycho.model.PluginRef) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) FeatureRef(org.eclipse.tycho.model.FeatureRef) IOException(java.io.IOException) File(java.io.File) Feature(org.eclipse.tycho.model.Feature)

Example 8 with FeatureRef

use of org.eclipse.tycho.model.FeatureRef in project tycho by eclipse.

the class UpdateSiteMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    target.mkdirs();
    try {
        // remove content collected in former builds.
        // Even without clean goal the build result must not assembly out dated content
        FileUtils.cleanDirectory(target);
    } catch (IOException e) {
        throw new MojoFailureException("Unable to delete old update site content: " + target.getAbsolutePath(), e);
    }
    try {
        UpdateSite site = UpdateSite.read(new File(basedir, UpdateSite.SITE_XML));
        UpdateSiteAssembler assembler = new UpdateSiteAssembler(session, target);
        if (inlineArchives) {
            assembler.setArchives(site.getArchives());
        }
        getDependencyWalker().walk(assembler);
        getDependencyWalker().traverseUpdateSite(site, new ArtifactDependencyVisitor() {

            @Override
            public boolean visitFeature(FeatureDescription feature) {
                FeatureRef featureRef = feature.getFeatureRef();
                String id = featureRef.getId();
                ReactorProject otherProject = feature.getMavenProject();
                String version;
                if (otherProject != null) {
                    version = otherProject.getExpandedVersion();
                } else {
                    version = feature.getKey().getVersion();
                }
                String url = UpdateSiteAssembler.FEATURES_DIR + id + "_" + version + ".jar";
                ((SiteFeatureRef) featureRef).setUrl(url);
                featureRef.setVersion(version);
                // don't traverse included features
                return false;
            }
        });
        if (inlineArchives) {
            site.removeArchives();
        }
        File file = new File(target, "site.xml");
        UpdateSite.write(site, file);
        // Copy the associate sites file, if necessary
        if (site.getAssociateSitesUrl() != null) {
            File srcAssociateSitesFile = new File(basedir, site.getAssociateSitesUrl());
            if (srcAssociateSitesFile.exists()) {
                FileUtils.copyFile(srcAssociateSitesFile, new File(target + File.separator + site.getAssociateSitesUrl()));
            }
        }
    } catch (Exception e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}
Also used : FeatureDescription(org.eclipse.tycho.core.FeatureDescription) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ReactorProject(org.eclipse.tycho.ReactorProject) IOException(java.io.IOException) SiteFeatureRef(org.eclipse.tycho.model.UpdateSite.SiteFeatureRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) UpdateSite(org.eclipse.tycho.model.UpdateSite) File(java.io.File)

Example 9 with FeatureRef

use of org.eclipse.tycho.model.FeatureRef in project tycho by eclipse.

the class EclipseRepositoryProject method newDependencyWalker.

@Override
protected ArtifactDependencyWalker newDependencyWalker(MavenProject project, TargetEnvironment environment) {
    final List<ProductConfiguration> products = loadProducts(project);
    final List<Category> categories = loadCategories(project);
    return new AbstractArtifactDependencyWalker(getDependencyArtifacts(project, environment), getEnvironments(project, environment)) {

        @Override
        public void walk(ArtifactDependencyVisitor visitor) {
            WalkbackPath visited = new WalkbackPath();
            for (ProductConfiguration product : products) {
                traverseProduct(product, visitor, visited);
            }
            for (Category category : categories) {
                for (FeatureRef feature : category.getFeatures()) {
                    traverseFeature(feature, visitor, visited);
                }
            }
        }
    };
}
Also used : ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) Category(org.eclipse.tycho.model.Category) FeatureRef(org.eclipse.tycho.model.FeatureRef) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor)

Example 10 with FeatureRef

use of org.eclipse.tycho.model.FeatureRef in project tycho by eclipse.

the class SiteXmlManipulator method applyChanges.

@Override
public void applyChanges(ProjectMetadata project, VersionChangesDescriptor versionChangeContext) {
    if (isSite(project)) {
        for (PomVersionChange change : versionChangeContext.getVersionChanges()) {
            if (isFeature(change.getProject().getPackaging())) {
                UpdateSite site = getSiteXml(project);
                for (FeatureRef feature : site.getFeatures()) {
                    if (change.getArtifactId().equals(feature.getId()) && change.getVersion().equals(feature.getVersion())) {
                        logger.info("  site.xml//site/feature/@id=" + feature.getId() + "/@version: " + change.getVersion() + " => " + change.getNewVersion());
                        feature.setVersion(change.getNewVersion());
                        SiteFeatureRef siteFeature = (SiteFeatureRef) feature;
                        String oldUrl = siteFeature.getUrl();
                        String newUrl = rewriteFeatureUrl(oldUrl, change);
                        logger.info("  site.xml//site/feature/@id=" + feature.getId() + "/@url: " + oldUrl + " => " + newUrl);
                        siteFeature.setUrl(newUrl);
                    }
                }
            }
        }
    }
}
Also used : SiteFeatureRef(org.eclipse.tycho.model.UpdateSite.SiteFeatureRef) SiteFeatureRef(org.eclipse.tycho.model.UpdateSite.SiteFeatureRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) UpdateSite(org.eclipse.tycho.model.UpdateSite) PomVersionChange(org.eclipse.tycho.versions.engine.PomVersionChange)

Aggregations

FeatureRef (org.eclipse.tycho.model.FeatureRef)12 PluginRef (org.eclipse.tycho.model.PluginRef)7 File (java.io.File)5 IOException (java.io.IOException)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 ArtifactKey (org.eclipse.tycho.ArtifactKey)3 UpdateSite (org.eclipse.tycho.model.UpdateSite)3 LinkedHashSet (java.util.LinkedHashSet)2 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)2 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)2 ReactorProject (org.eclipse.tycho.ReactorProject)2 ArtifactDependencyVisitor (org.eclipse.tycho.core.ArtifactDependencyVisitor)2 Feature (org.eclipse.tycho.model.Feature)2 ProductConfiguration (org.eclipse.tycho.model.ProductConfiguration)2 SiteFeatureRef (org.eclipse.tycho.model.UpdateSite.SiteFeatureRef)2 HashSet (java.util.HashSet)1 JarFile (java.util.jar.JarFile)1 FeatureDescription (org.eclipse.tycho.core.FeatureDescription)1 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)1