Search in sources :

Example 16 with ArtifactDescriptor

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

the class AbstractArtifactDependencyWalker method traversePlugin.

private void traversePlugin(PluginRef ref, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    if (!matchTargetEnvironment(ref)) {
        return;
    }
    ArtifactDescriptor artifact = artifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, ref.getId(), ref.getVersion());
    if (artifact != null) {
        ArtifactKey key = artifact.getKey();
        if (visited.visited(key)) {
            return;
        }
        File location = artifact.getLocation();
        ReactorProject project = artifact.getMavenProject();
        String classifier = artifact.getClassifier();
        Set<Object> installableUnits = artifact.getInstallableUnits();
        PluginDescription description = new DefaultPluginDescription(key, location, project, classifier, ref, installableUnits);
        visited.enter(description);
        try {
            visitor.visitPlugin(description);
        } finally {
            visited.leave(description);
        }
    } else {
        visitor.missingPlugin(ref, visited.getWalkback());
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ReactorProject(org.eclipse.tycho.ReactorProject) File(java.io.File) PluginDescription(org.eclipse.tycho.core.PluginDescription)

Example 17 with ArtifactDescriptor

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

the class OsgiBundleProject method getDependencyWalker.

@Override
public ArtifactDependencyWalker getDependencyWalker(MavenProject project) {
    final DependencyArtifacts artifacts = getDependencyArtifacts(project);
    final List<ClasspathEntry> cp = getClasspath(project);
    return new ArtifactDependencyWalker() {

        @Override
        public void walk(ArtifactDependencyVisitor visitor) {
            for (ClasspathEntry entry : cp) {
                ArtifactDescriptor artifact = artifacts.getArtifact(entry.getArtifactKey());
                ArtifactKey key = artifact.getKey();
                File location = artifact.getLocation();
                ReactorProject project = artifact.getMavenProject();
                String classifier = artifact.getClassifier();
                Set<Object> installableUnits = artifact.getInstallableUnits();
                PluginDescription plugin = new DefaultPluginDescription(key, location, project, classifier, null, installableUnits);
                visitor.visitPlugin(plugin);
            }
        }

        @Override
        public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) {
        }

        @Override
        public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor artifactDependencyVisitor) {
        }

        @Override
        public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) {
        }
    };
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ArtifactKey(org.eclipse.tycho.ArtifactKey) ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) ReactorProject(org.eclipse.tycho.ReactorProject) ArtifactDependencyWalker(org.eclipse.tycho.core.ArtifactDependencyWalker) Feature(org.eclipse.tycho.model.Feature) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ClasspathEntry(org.eclipse.tycho.classpath.ClasspathEntry) File(java.io.File) PluginDescription(org.eclipse.tycho.core.PluginDescription) UpdateSite(org.eclipse.tycho.model.UpdateSite)

Example 18 with ArtifactDescriptor

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

the class GeneratePomsMojo method generatePluginPom.

private void generatePluginPom(Model parent, File basedir) throws MojoExecutionException {
    ArtifactDescriptor bundle = getArtifact(basedir);
    ArtifactKey key = bundle.getKey();
    Model model;
    if ((testSuffix != null && basedir.getName().endsWith(testSuffix)) || (testSuite != null && key.getId().equals(testSuite))) {
        model = readPomTemplate("test-plugin-pom.xml");
    } else {
        model = readPomTemplate("plugin-pom.xml");
    }
    String groupId = this.groupId;
    if (groupId == null) {
        groupId = key.getId();
    }
    setParentOrAddTychoExtension(basedir, model, parent);
    model.setGroupId(groupId);
    model.setArtifactId(key.getId());
    model.setVersion(toMavenVersion(key.getVersion().toString()));
    writePom(basedir, model);
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) Model(org.apache.maven.model.Model)

Example 19 with ArtifactDescriptor

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

the class BuildQualifierTest method testAggregateAttachedFeatureQualifier.

public void testAggregateAttachedFeatureQualifier() throws Exception {
    File basedir = getBasedir("projects/stablebuildqualifier/attachedfeature");
    List<MavenProject> projects = getSortedProjects(basedir, new File(basedir, "targetplatform"));
    MavenProject project = getProject(projects, "attachedfeature");
    ReactorProject reactorProject = DefaultReactorProject.adapt(project);
    DefaultDependencyArtifacts dependencyArtifacts = (DefaultDependencyArtifacts) TychoProjectUtils.getDependencyArtifacts(project);
    // replace target platform dependencies with fake attached feature and bundle atrifacts
    ArtifactDescriptor attachedFeature = dependencyArtifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_FEATURE, "attachedfeature.attached.feature", null);
    dependencyArtifacts.removeAll(attachedFeature.getKey().getType(), attachedFeature.getKey().getId());
    dependencyArtifacts.addReactorArtifact(attachedFeature.getKey(), reactorProject, "attached-feature", attachedFeature.getInstallableUnits());
    ArtifactDescriptor attachedBundle = dependencyArtifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, "attachedfeature.attached.bundle", null);
    dependencyArtifacts.removeAll(attachedBundle.getKey().getType(), attachedBundle.getKey().getId());
    dependencyArtifacts.addReactorArtifact(attachedBundle.getKey(), reactorProject, "attached-bundle", attachedBundle.getInstallableUnits());
    MavenSession session = newMavenSession(projects.get(0), projects);
    executeMojo(session, project, "build-qualifier-aggregator");
    assertQualifier("201206180600", projects, "attachedfeature");
}
Also used : DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) File(java.io.File)

Example 20 with ArtifactDescriptor

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

the class PublishProductMojo method getExpandedLauncherBinaries.

private File getExpandedLauncherBinaries() throws MojoExecutionException, MojoFailureException {
    // TODO 364134 take the executable feature from the target platform instead
    DependencyArtifacts dependencyArtifacts = TychoProjectUtils.getDependencyArtifacts(getProject());
    ArtifactDescriptor artifact = dependencyArtifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_FEATURE, "org.eclipse.equinox.executable", null);
    if (artifact == null) {
        throw new MojoExecutionException("Unable to locate feature 'org.eclipse.equinox.executable'. This feature is required for native product launchers.");
    }
    checkMacOSLauncherCompatibility(artifact);
    File equinoxExecFeature = artifact.getLocation();
    if (equinoxExecFeature.isDirectory()) {
        return equinoxExecFeature.getAbsoluteFile();
    } else {
        File unzipped = new File(getProject().getBuild().getDirectory(), artifact.getKey().getId() + "-" + artifact.getKey().getVersion());
        if (unzipped.exists()) {
            return unzipped.getAbsoluteFile();
        }
        try {
            FileLocker locker = fileLockService.getFileLocker(equinoxExecFeature);
            locker.lock();
            try {
                // unzip now then:
                unzipped.mkdirs();
                deflater.setSourceFile(equinoxExecFeature);
                deflater.setDestDirectory(unzipped);
                deflater.extract();
                return unzipped.getAbsoluteFile();
            } finally {
                locker.release();
            }
        } catch (ArchiverException e) {
            throw new MojoFailureException("Unable to unzip the eqiuinox executable feature", e);
        }
    }
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) FileLocker(org.eclipse.tycho.locking.facade.FileLocker) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) File(java.io.File)

Aggregations

ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)32 File (java.io.File)20 ArtifactKey (org.eclipse.tycho.ArtifactKey)13 ReactorProject (org.eclipse.tycho.ReactorProject)10 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 IOException (java.io.IOException)4 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)4 DefaultArtifactDescriptor (org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor)4 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)4 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 PluginDescription (org.eclipse.tycho.core.PluginDescription)3 Version (org.osgi.framework.Version)3 FileOutputStream (java.io.FileOutputStream)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 Properties (java.util.Properties)2 ZipFile (java.util.zip.ZipFile)2