Search in sources :

Example 1 with Category

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

the class CategoryXmlManipulator method writeMetadata.

@Override
public void writeMetadata(ProjectMetadata project) throws IOException {
    File basedir = project.getBasedir();
    Category categoryXml = project.getMetadata(Category.class);
    if (categoryXml != null) {
        Category.write(categoryXml, new File(basedir, Category.CATEGORY_XML));
    }
}
Also used : Category(org.eclipse.tycho.model.Category) PomFile(org.eclipse.tycho.versions.pom.PomFile) File(java.io.File)

Example 2 with Category

use of org.eclipse.tycho.model.Category 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 3 with Category

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

the class CategoryXmlManipulator method getCategoryXml.

private Category getCategoryXml(ProjectMetadata project) {
    Category categoryXml = project.getMetadata(Category.class);
    if (categoryXml == null) {
        File file = new File(project.getBasedir(), Category.CATEGORY_XML);
        if (!file.isFile()) {
            return null;
        }
        try {
            categoryXml = Category.read(file);
            project.putMetadata(categoryXml);
        } catch (IOException e) {
            throw new IllegalArgumentException("Could not read categories from " + file, e);
        }
    }
    return categoryXml;
}
Also used : Category(org.eclipse.tycho.model.Category) IOException(java.io.IOException) PomFile(org.eclipse.tycho.versions.pom.PomFile) File(java.io.File)

Example 4 with Category

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

Example 5 with Category

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

the class CategoryXmlManipulator method updatePluginReferences.

private void updatePluginReferences(PomVersionChange pluginVersionChange, ProjectMetadata project) {
    Category categoryXml = getCategoryXml(project);
    if (categoryXml == null) {
        return;
    }
    for (PluginRef plugin : categoryXml.getPlugins()) {
        if (pluginVersionChange.getArtifactId().equals(plugin.getId()) && pluginVersionChange.getVersion().equals(plugin.getVersion())) {
            logger.info("  category.xml//site/bundle[@id=" + plugin.getId() + "]/@version: " + pluginVersionChange.getVersion() + " => " + pluginVersionChange.getNewVersion());
            plugin.setVersion(pluginVersionChange.getNewVersion());
        }
    }
}
Also used : Category(org.eclipse.tycho.model.Category) PluginRef(org.eclipse.tycho.model.PluginRef)

Aggregations

Category (org.eclipse.tycho.model.Category)6 File (java.io.File)3 PomFile (org.eclipse.tycho.versions.pom.PomFile)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ArtifactDependencyVisitor (org.eclipse.tycho.core.ArtifactDependencyVisitor)1 DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)1 FeatureRef (org.eclipse.tycho.model.FeatureRef)1 PluginRef (org.eclipse.tycho.model.PluginRef)1 ProductConfiguration (org.eclipse.tycho.model.ProductConfiguration)1 SiteFeatureRef (org.eclipse.tycho.model.UpdateSite.SiteFeatureRef)1 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)1 PublisherService (org.eclipse.tycho.p2.tools.publisher.facade.PublisherService)1