Search in sources :

Example 6 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class FileBasedTychoRepositoryIndex method reconcile.

private synchronized void reconcile() throws IOException {
    // processes which happened in the meantime are not discarded
    if (indexFile.isFile()) {
        gavs = read(new FileInputStream(indexFile));
        for (GAV addedGav : addedGavs) {
            addGav(addedGav);
        }
        for (GAV removedGav : removedGavs) {
            removeGav(removedGav);
        }
    }
    addedGavs.clear();
    removedGavs.clear();
}
Also used : GAV(org.eclipse.tycho.p2.repository.GAV) FileInputStream(java.io.FileInputStream)

Example 7 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class FileBasedTychoRepositoryIndex method write.

private void write(OutputStream outStream) throws IOException {
    Writer out = new OutputStreamWriter(new BufferedOutputStream(outStream), ENCODING);
    try {
        for (GAV gav : getProjectGAVs()) {
            out.write(gav.toExternalForm());
            out.write(EOL);
        }
        out.flush();
    } finally {
        out.close();
    }
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) BufferedOutputStream(java.io.BufferedOutputStream) GAV(org.eclipse.tycho.p2.repository.GAV) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Example 8 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class GAVArtifactDescriptorBase method readMavenCoordinateProperties.

/**
 * @return the Maven coordinates stored in the properties of the given descriptor, or
 *         <code>null</code>
 */
public static MavenRepositoryCoordinates readMavenCoordinateProperties(IArtifactDescriptor descriptor) {
    GAV gav = RepositoryLayoutHelper.getGAV(descriptor.getProperties());
    if (gav == null) {
        return null;
    }
    String classifier = RepositoryLayoutHelper.getClassifier(descriptor.getProperties());
    String extension = RepositoryLayoutHelper.getExtension(descriptor.getProperties());
    return new MavenRepositoryCoordinates(gav, classifier, extension);
}
Also used : MavenRepositoryCoordinates(org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates) GAV(org.eclipse.tycho.p2.repository.GAV)

Example 9 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class AbstractMavenMetadataRepository method load.

protected void load() {
    MetadataIO io = new MetadataIO();
    for (GAV gav : metadataIndex.getProjectGAVs()) {
        try {
            File localArtifactFileLocation = contentLocator.getLocalArtifactLocation(gav, RepositoryLayoutHelper.CLASSIFIER_P2_METADATA, RepositoryLayoutHelper.EXTENSION_P2_METADATA);
            if (!localArtifactFileLocation.exists()) {
                // if files have been manually removed from the repository, simply remove them from the index (bug 351080)
                metadataIndex.removeGav(gav);
            } else {
                InputStream is = new FileInputStream(localArtifactFileLocation);
                try {
                    Set<IInstallableUnit> gavUnits = io.readXML(is);
                    unitsMap.put(gav, gavUnits);
                    units.addAll(gavUnits);
                } finally {
                    is.close();
                }
            }
        } catch (IOException e) {
            // TODO throw properly typed exception if repository cannot be loaded
            e.printStackTrace();
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) MetadataIO(org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IOException(java.io.IOException) GAV(org.eclipse.tycho.p2.repository.GAV) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 10 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class RepositoryLayoutHelperTest method testRelpath.

@Test
public void testRelpath() {
    GAV gav = new GAV("a.b.c", "d.e.f", "1.0.0");
    Assert.assertEquals("a/b/c/d.e.f/1.0.0/d.e.f-1.0.0-foo.bar", RepositoryLayoutHelper.getRelativePath(gav, "foo", "bar"));
    Assert.assertEquals("a/b/c/d.e.f/1.0.0/d.e.f-1.0.0.jar", RepositoryLayoutHelper.getRelativePath(gav, null, null));
}
Also used : GAV(org.eclipse.tycho.p2.repository.GAV) Test(org.junit.Test)

Aggregations

GAV (org.eclipse.tycho.p2.repository.GAV)15 IOException (java.io.IOException)6 File (java.io.File)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)5 FileInputStream (java.io.FileInputStream)4 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)4 TychoRepositoryIndex (org.eclipse.tycho.p2.repository.TychoRepositoryIndex)4 Test (org.junit.Test)4 ArtifactsIO (org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO)3 BufferedOutputStream (java.io.BufferedOutputStream)2 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 MetadataIO (org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO)2 MavenRepositoryCoordinates (org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates)2 BufferedReader (java.io.BufferedReader)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1