当前位置: 首页>>代码示例>>Java>>正文


Java MetadataXpp3Reader类代码示例

本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader的典型用法代码示例。如果您正苦于以下问题:Java MetadataXpp3Reader类的具体用法?Java MetadataXpp3Reader怎么用?Java MetadataXpp3Reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MetadataXpp3Reader类属于org.apache.maven.artifact.repository.metadata.io.xpp3包,在下文中一共展示了MetadataXpp3Reader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
public Metadata read( Reader input, Map<String, ?> options )
    throws IOException
{
    if ( input == null )
    {
        throw new IllegalArgumentException( "input reader missing" );
    }

    try
    {
        MetadataXpp3Reader r = new MetadataXpp3Reader();
        return r.read( input, isStrict( options ) );
    }
    catch ( XmlPullParserException e )
    {
        throw new MetadataParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e );
    }
    finally
    {
        IOUtil.close( input );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:23,代码来源:DefaultMetadataReader.java

示例2: getMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
@Nullable
@Contract("null, null -> fail")
static Metadata getMetadata(OkHttpClient client, URI url) throws IOException {
    Request request = new Request.Builder()
            .url(HttpUrl.get(url))
            .build();
    try(Response response = client.newCall(request).execute()) {
        if(response.isSuccessful())
            return new MetadataXpp3Reader().read(response.body().charStream());
    } catch (XmlPullParserException e) {
        throw new IOException(e);
    }
    return null;
}
 
开发者ID:mikroskeem,项目名称:PicoMaven,代码行数:15,代码来源:DataProcessor.java

示例3: testArtifactMetadataUriBuilding

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
@Test
public void testArtifactMetadataUriBuilding() throws Exception {
    Metadata metadata = new MetadataXpp3Reader().read(new StringReader(SAMPLE_METADATA));

    URI artifactMetaUri = UrlUtils.buildArtifactMetaURI(DEFAULT_REPOSITORY, metadata, SAMPLE_DEPENDENCY);
    Assertions.assertEquals("https://repo.maven.apache.org/maven2/org/ow2/asm/asm-all/5.2/maven-metadata.xml",
            artifactMetaUri.toString());
}
 
开发者ID:mikroskeem,项目名称:PicoMaven,代码行数:9,代码来源:UriUtilsTest.java

示例4: testArtifactJarUriBuilding

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
@Test
public void testArtifactJarUriBuilding() throws Exception {
    Metadata metadata = new MetadataXpp3Reader().read(new StringReader(SAMPLE_ARTIFACT_METADATA));
    URI artifactUri = UrlUtils.buildArtifactJarURI(DEFAULT_REPOSITORY2, metadata, SAMPLE_DEPENDENCY2);
    String exp = "https://repo.spongepowered.org/maven/org/spongepowered/mixin/0.6.8-SNAPSHOT/mixin-0.6.8-20170320.130808-7.jar";
    Assertions.assertEquals(exp, artifactUri.toString());
}
 
开发者ID:mikroskeem,项目名称:PicoMaven,代码行数:8,代码来源:UriUtilsTest.java

示例5: readMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
private Metadata readMetadata( File file )
    throws ArtifactConversionException
{
    MetadataXpp3Reader reader = new MetadataXpp3Reader();

    try (Reader fileReader = Files.newBufferedReader( file.toPath(), Charset.defaultCharset() ))
    {
        return reader.read( fileReader );
    }
    catch ( IOException | XmlPullParserException e )
    {
        throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ),
                                               e ); //$NON-NLS-1$
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:16,代码来源:LegacyToDefaultConverter.java

示例6: load

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
public static void load() throws IOException, ParserConfigurationException, SAXException, XmlPullParserException {
	String baseMavenMeta = IOUtils.toString(new URL("http://maven.fabricmc.net/net/fabricmc/fabric-base/maven-metadata.xml"), "UTF-8");
	Metadata metadata = new MetadataXpp3Reader().read(new StringReader(baseMavenMeta));
	latestVersion = metadata.getVersioning().getRelease();
	versions = metadata.getVersioning().getVersions();
	Collections.reverse(versions);
}
 
开发者ID:FabricMC,项目名称:fabric-installer,代码行数:8,代码来源:VersionInfo.java

示例7: getMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public Metadata getMetadata( String path )
    throws IOException, MetadataNotFoundException
{
    File file = root;
    String[] parts = StringUtils.strip( path, "/" ).split( "/" );
    for ( int i = 0; i < parts.length; i++ )
    {
        file = new File( file, parts[i] );
    }
    file = new File( file, "maven-metadata.xml" );
    if ( !file.isFile() )
    {
        throw new MetadataNotFoundException( path );
    }
    MetadataXpp3Reader reader = new MetadataXpp3Reader();
    InputStream inputStream = null;
    try
    {
        inputStream = new FileInputStream( file );
        return reader.read( inputStream );
    }
    catch ( XmlPullParserException e )
    {
        IOException ioe = new IOException( e.getMessage() );
        ioe.initCause( e );
        throw ioe;
    }
    finally
    {
        IOUtils.closeQuietly( inputStream );
    }
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:36,代码来源:DiskArtifactStore.java

示例8: getMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public Metadata getMetadata( String path )
    throws IOException, MetadataNotFoundException
{
    Entry entry = backing.get(
        StringUtils.join( StringUtils.split( StringUtils.strip( path, "/" ), "/" ), "/" ) + "/maven-metadata.xml" );
    if ( !( entry instanceof FileEntry ) )
    {
        throw new MetadataNotFoundException( path );
    }
    MetadataXpp3Reader reader = new MetadataXpp3Reader();
    InputStream inputStream = null;
    try
    {
        inputStream = ( (FileEntry) entry ).getInputStream();
        return reader.read( inputStream );
    }
    catch ( XmlPullParserException e )
    {
        IOException ioe = new IOException( e.getMessage() );
        ioe.initCause( e );
        throw ioe;
    }
    finally
    {
        IOUtils.closeQuietly( inputStream );
    }
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:31,代码来源:FileSystemArtifactStore.java

示例9: toMavenMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
/**
 * Creates a maven <code>Metadata</code> out of a <code>java.io.Reader</code> and will close the reader.
 *
 * @param reader Reader representing content of maven-metadata.xml
 * @return Metadata object created from the reader
 * @throws java.io.IOException If the input reader doesn't holds a valid maven metadata
 */
public static Metadata toMavenMetadata(Reader reader) throws IOException {
    MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
    try {
        return metadataReader.read(reader, false);
    } catch (XmlPullParserException e) {
        throw new IOException("Failed to parse metadata: " + e.getMessage());
    } finally {
        IOUtils.closeQuietly(reader);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:18,代码来源:MavenModelUtils.java

示例10: readMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
private Metadata readMetadata( Path file )
    throws ArtifactConversionException
{
    MetadataXpp3Reader reader = new MetadataXpp3Reader();

    try (Reader fileReader = Files.newBufferedReader( file, Charset.defaultCharset() ))
    {
        return reader.read( fileReader );
    }
    catch ( IOException | XmlPullParserException e )
    {
        throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ),
                                               e ); //$NON-NLS-1$
    }
}
 
开发者ID:apache,项目名称:archiva,代码行数:16,代码来源:LegacyToDefaultConverter.java

示例11: readVersions

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
                                 ArtifactRepository repository, VersionResult result )
{
    Versioning versioning = null;

    FileInputStream fis = null;
    try
    {
        if ( metadata != null )
        {
            SyncContext syncContext = syncContextFactory.newInstance( session, true );

            try
            {
                syncContext.acquire( null, Collections.singleton( metadata ) );

                if ( metadata.getFile() != null && metadata.getFile().exists() )
                {
                    fis = new FileInputStream( metadata.getFile() );
                    org.apache.maven.artifact.repository.metadata.Metadata m =
                        new MetadataXpp3Reader().read( fis, false );
                    versioning = m.getVersioning();

                    /*
                     * NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata
                     * of the local repository. This is especially troublesome during snapshot resolution so we try
                     * to handle that gracefully.
                     */
                    if ( versioning != null && repository instanceof LocalRepository)
                    {
                        if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 )
                        {
                            Versioning repaired = new Versioning();
                            repaired.setLastUpdated( versioning.getLastUpdated() );
                            Snapshot snapshot = new Snapshot();
                            snapshot.setLocalCopy( true );
                            repaired.setSnapshot( snapshot );
                            versioning = repaired;

                            throw new IOException( "Snapshot information corrupted with remote repository data"
                                + ", please verify that no remote repository uses the id '" + repository.getId()
                                + "'" );
                        }
                    }
                }
            }
            finally
            {
                syncContext.release();
            }
        }
    }
    catch ( Exception e )
    {
        invalidMetadata( session, trace, metadata, repository, e );
        result.addException( e );
    }
    finally
    {
        IOUtil.close(fis);
    }

    return ( versioning != null ) ? versioning : new Versioning();
}
 
开发者ID:cloudbees,项目名称:bees-maven-components,代码行数:65,代码来源:VersionResolverImpl.java

示例12: testMetadataXmlObjectMapping

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
@Test
public void testMetadataXmlObjectMapping() throws Exception {
    Metadata metadata = new MetadataXpp3Reader().read(new StringReader(SAMPLE_METADATA));
}
 
开发者ID:mikroskeem,项目名称:PicoMaven,代码行数:5,代码来源:UriUtilsTest.java

示例13: testArtifactMetadataXmlObjectMapping

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
@Test
public void testArtifactMetadataXmlObjectMapping() throws Exception {
    Metadata metadata = new MetadataXpp3Reader().read(new StringReader(SAMPLE_ARTIFACT_METADATA));
}
 
开发者ID:mikroskeem,项目名称:PicoMaven,代码行数:5,代码来源:UriUtilsTest.java

示例14: put

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
@Override
public FileEntry put( DirectoryEntry parent, String name, InputStream content )
    throws IOException
{
    String path = "/";
    if ( StringUtils.isNotEmpty( parent.toPath()  ) )
    {
        path += parent.toPath() + "/";
    }

    if ( "maven-metadata.xml".equals( name ) )
    {
        MetadataXpp3Reader reader = new MetadataXpp3Reader();
        try
        {
            Metadata metadata = reader.read( content );
            
            if ( metadata == null )
            {
                return null;
            }
            
            store.setMetadata( path, metadata );
        }
        catch ( XmlPullParserException e1 )
        {
            throw new IOException();
        }
        
        return new MetadataFileEntry( this, parent, path, store );
    }
    
    Artifact artifact = getArtifact( parent, name );
    
    if ( artifact == null )
    {
        return null;
    }
    
    store.set( artifact , content );
    
    return new ArtifactFileEntry( this, parent, artifact, store );
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:44,代码来源:ArtifactStoreFileSystem.java

示例15: readVersions

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入依赖的package包/类
private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
                                 ArtifactRepository repository, VersionRangeResult result )
{
    Versioning versioning = null;

    FileInputStream fis = null;
    try
    {
        if ( metadata != null )
        {
            SyncContext syncContext = syncContextFactory.newInstance( session, true );

            try
            {
                syncContext.acquire( null, Collections.singleton( metadata ) );

                if ( metadata.getFile() != null && metadata.getFile().exists() )
                {
                    fis = new FileInputStream( metadata.getFile() );
                    org.apache.maven.artifact.repository.metadata.Metadata m =
                        new MetadataXpp3Reader().read( fis, false );
                    versioning = m.getVersioning();
                }
            }
            finally
            {
                syncContext.release();
            }
        }
    }
    catch ( Exception e )
    {
        invalidMetadata( session, trace, metadata, repository, e );
        result.addException( e );
    }
    finally
    {
        IOUtil.close( fis );
    }

    return ( versioning != null ) ? versioning : new Versioning();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:43,代码来源:DefaultVersionRangeResolver.java


注:本文中的org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。