Search in sources :

Example 31 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class AttachPublishedArtifactsMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    ReactorRepositoryManagerFacade reactorRepoManager = osgiServices.getService(ReactorRepositoryManagerFacade.class);
    PublishingRepositoryFacade publishingRepo = reactorRepoManager.getPublishingRepository(getProjectIdentities());
    Map<String, File> artifacts = publishingRepo.getArtifactLocations();
    for (Entry<String, File> entry : artifacts.entrySet()) {
        String classifier = entry.getKey();
        File artifactLocation = entry.getValue();
        if (classifier == null) {
            getProject().getArtifact().setFile(artifactLocation);
        } else {
            String type = getExtension(artifactLocation);
            projectHelper.attachArtifact(getProject(), type, classifier, artifactLocation);
        }
    }
    ReactorProject reactorProject = getReactorProject();
    reactorProject.setDependencyMetadata(true, publishingRepo.getInstallableUnits());
    reactorProject.setDependencyMetadata(false, Collections.emptySet());
}
Also used : ReactorRepositoryManagerFacade(org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManagerFacade) ReactorProject(org.eclipse.tycho.ReactorProject) PublishingRepositoryFacade(org.eclipse.tycho.repository.registry.facade.PublishingRepositoryFacade) File(java.io.File)

Example 32 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class BuildQualifierAggregatorMojo method getBuildTimestamp.

@Override
protected Date getBuildTimestamp() throws MojoExecutionException {
    Date timestamp = super.getBuildTimestamp();
    if (timestampProvider == null) {
        // no included bundle/feature can have more recent timestamp
        return timestamp;
    }
    final Date[] latestTimestamp = new Date[] { timestamp };
    TychoProject projectType = projectTypes.get(project.getPackaging());
    if (projectType == null) {
        throw new IllegalStateException("Unknown or unsupported packaging type " + packaging);
    }
    final ReactorProject thisProject = DefaultReactorProject.adapt(project);
    projectType.getDependencyWalker(project).walk(new ArtifactDependencyVisitor() {

        @Override
        public boolean visitFeature(FeatureDescription feature) {
            if (feature.getFeatureRef() == null || thisProject.equals(feature.getMavenProject())) {
                // visit immediately included features
                return true;
            }
            visitArtifact(feature);
            // do not visit indirectly included features/bundles
            return false;
        }

        @Override
        public void visitPlugin(PluginDescription plugin) {
            if (plugin.getPluginRef() == null || thisProject.equals(plugin.getMavenProject())) {
                // 'this' bundle
                return;
            }
            visitArtifact(plugin);
        }

        private void visitArtifact(ArtifactDescriptor artifact) {
            ReactorProject otherProject = artifact.getMavenProject();
            String otherVersion = (otherProject != null) ? otherProject.getExpandedVersion() : artifact.getKey().getVersion();
            Version v = Version.parseVersion(otherVersion);
            String otherQualifier = v.getQualifier();
            if (otherQualifier != null) {
                Date timestamp = parseQualifier(otherQualifier);
                if (timestamp != null) {
                    if (latestTimestamp[0].compareTo(timestamp) < 0) {
                        if (getLog().isDebugEnabled()) {
                            getLog().debug("Found '" + format.format(timestamp) + "' from qualifier '" + otherQualifier + "' for artifact " + artifact);
                        }
                        latestTimestamp[0] = timestamp;
                    }
                } else {
                    getLog().debug("Could not parse qualifier timestamp " + otherQualifier);
                }
            }
        }

        private Date parseQualifier(String qualifier) {
            Date timestamp = parseQualifier(qualifier, format);
            if (timestamp != null) {
                return timestamp;
            }
            return discoverTimestamp(qualifier);
        }

        private Date parseQualifier(String qualifier, SimpleDateFormat format) {
            ParsePosition pos = new ParsePosition(0);
            Date timestamp = format.parse(qualifier, pos);
            if (timestamp != null && pos.getIndex() == qualifier.length()) {
                return timestamp;
            }
            return null;
        }

        private Date discoverTimestamp(String qualifier) {
            return timestampFinder.findInString(qualifier);
        }
    });
    return latestTimestamp[0];
}
Also used : FeatureDescription(org.eclipse.tycho.core.FeatureDescription) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) Date(java.util.Date) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor) TychoProject(org.eclipse.tycho.core.TychoProject) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) Version(org.osgi.framework.Version) PluginDescription(org.eclipse.tycho.core.PluginDescription) SimpleDateFormat(java.text.SimpleDateFormat) ParsePosition(java.text.ParsePosition)

Aggregations

ReactorProject (org.eclipse.tycho.ReactorProject)32 File (java.io.File)20 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)16 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)10 ArtifactKey (org.eclipse.tycho.ArtifactKey)8 MavenProject (org.apache.maven.project.MavenProject)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 LinkedHashSet (java.util.LinkedHashSet)4 Artifact (org.apache.maven.artifact.Artifact)4 Dependency (org.apache.maven.model.Dependency)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)4 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)4 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3