Search in sources :

Example 1 with SiteFeatureRef

use of org.eclipse.tycho.model.UpdateSite.SiteFeatureRef 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 2 with SiteFeatureRef

use of org.eclipse.tycho.model.UpdateSite.SiteFeatureRef 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)

Example 3 with SiteFeatureRef

use of org.eclipse.tycho.model.UpdateSite.SiteFeatureRef in project tycho by eclipse.

the class CategoryXmlManipulator method updateFeatureReferences.

private void updateFeatureReferences(PomVersionChange featureVersionChange, ProjectMetadata project) {
    Category categoryXml = getCategoryXml(project);
    if (categoryXml == null) {
        return;
    }
    for (SiteFeatureRef feature : categoryXml.getFeatures()) {
        String featureId = featureVersionChange.getArtifactId();
        String srcFeatureId = featureId + SOURCE_FEATURE_SUFFIX;
        if ((featureId.equals(feature.getId()) || srcFeatureId.equals(feature.getId())) && featureVersionChange.getVersion().equals(feature.getVersion())) {
            logger.info("  category.xml//site/feature[@id=" + feature.getId() + "]/@version: " + featureVersionChange.getVersion() + " => " + featureVersionChange.getNewVersion());
            feature.setVersion(featureVersionChange.getNewVersion());
            String oldUrl = feature.getUrl();
            if (oldUrl != null) {
                String newUrl = rewriteFeatureUrl(oldUrl, featureVersionChange);
                logger.info("  category.xml//site/feature[@id=" + feature.getId() + "]/@url: " + oldUrl + " => " + newUrl);
                feature.setUrl(newUrl);
            }
        }
    }
}
Also used : SiteFeatureRef(org.eclipse.tycho.model.UpdateSite.SiteFeatureRef) Category(org.eclipse.tycho.model.Category)

Aggregations

SiteFeatureRef (org.eclipse.tycho.model.UpdateSite.SiteFeatureRef)3 FeatureRef (org.eclipse.tycho.model.FeatureRef)2 UpdateSite (org.eclipse.tycho.model.UpdateSite)2 File (java.io.File)1 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 ArtifactDependencyVisitor (org.eclipse.tycho.core.ArtifactDependencyVisitor)1 FeatureDescription (org.eclipse.tycho.core.FeatureDescription)1 Category (org.eclipse.tycho.model.Category)1 PomVersionChange (org.eclipse.tycho.versions.engine.PomVersionChange)1