Package org.apache.maven.shared.io.location

Examples of org.apache.maven.shared.io.location.Location


    public void testResolvePrefixWithLeadingSlashAndWithTrailingSlash()
    {
        MessageHolder mh = new DefaultMessageHolder();

        LocatorStrategy ls = new PrefixedClasspathLocatorStrategy( "/assemblies/" );
        Location location = ls.resolve( "empty.xml", mh );

        assertNotNull( location );
        assertEquals( 0, mh.size() );
    }
View Full Code Here


    public void testResolvePrefixWithLeadingSlashAndWithoutTrailingSlash()
    {
        MessageHolder mh = new DefaultMessageHolder();

        LocatorStrategy ls = new PrefixedClasspathLocatorStrategy( "/assemblies" );
        Location location = ls.resolve( "empty.xml", mh );

        assertNotNull( location );
        assertEquals( 0, mh.size() );
    }
View Full Code Here

    public void testResolvePrefixWithoutLeadingSlashAndWithTrailingSlash()
    {
        MessageHolder mh = new DefaultMessageHolder();

        LocatorStrategy ls = new PrefixedClasspathLocatorStrategy( "assemblies/" );
        Location location = ls.resolve( "empty.xml", mh );

        assertNotNull( location );
        assertEquals( 0, mh.size() );
    }
View Full Code Here

    public void testResolvePrefixWithoutLeadingSlashAndWithoutTrailingSlash()
    {
        MessageHolder mh = new DefaultMessageHolder();

        LocatorStrategy ls = new PrefixedClasspathLocatorStrategy( "assemblies" );
        Location location = ls.resolve( "empty.xml", mh );

        assertNotNull( location );
        assertEquals( 0, mh.size() );
    }
View Full Code Here

    public Location resolve( String locationSpecification, MessageHolder messageHolder )
    {
        File file = new File( basedir, locationSpecification );
        messageHolder.addInfoMessage( "Searching for file location: " + file.getAbsolutePath() );

        Location location = null;

        if ( file.exists() )
        {
            location = new FileLocation( file, locationSpecification );
        }
View Full Code Here

    private Assembly addAssemblyFromDescriptor( final String spec, final Locator locator,
                                                final AssemblerConfigurationSource configSource,
                                                final List<Assembly> assemblies )
        throws AssemblyReadException, InvalidAssemblerConfigurationException
    {
        final Location location = locator.resolve( spec );

        if ( location == null )
        {
            if ( configSource.isIgnoreMissingDescriptor() )
            {
                getLogger().debug( "Ignoring missing assembly descriptor with ID '" + spec
                                       + "' per configuration.\nLocator output was:\n\n"
                                       + locator.getMessageHolder().render() );
                return null;
            }
            else
            {
                throw new AssemblyReadException( "Error locating assembly descriptor: " + spec + "\n\n"
                    + locator.getMessageHolder().render() );
            }
        }

        Reader r = null;
        try
        {
            // TODO use ReaderFactory.newXmlReader() when plexus-utils is upgraded to 1.4.5+
            r = new InputStreamReader( location.getInputStream(), "UTF-8" );

            File dir = null;
            if ( location.getFile() != null )
            {
                dir = location.getFile().getParentFile();
            }

            final Assembly assembly = readAssembly( r, spec, dir, configSource );

            assemblies.add( assembly );
View Full Code Here

            catch ( final Exception eee )
            {
                getLogger().error( "Error interpolating componentDescriptor: " + location, eee );
            }

            final Location resolvedLocation = locator.resolve( location );

            if ( resolvedLocation == null )
            {
                throw new AssemblyReadException( "Failed to locate component descriptor: " + location );
            }

            Component component = null;
            Reader reader = null;
            try
            {
                reader = new InputStreamReader( resolvedLocation.getInputStream() );
                component = new ComponentXpp3Reader().read( reader );
            }
            catch ( final IOException e )
            {
                throw new AssemblyReadException( "Error reading component descriptor: " + location + " (resolved to: "
                    + resolvedLocation.getSpecification() + ")", e );
            }
            catch ( final XmlPullParserException e )
            {
                throw new AssemblyReadException( "Error reading component descriptor: " + location + " (resolved to: "
                    + resolvedLocation.getSpecification() + ")", e );
            }
            finally
            {
                IOUtil.close( reader );
            }
View Full Code Here

    private Assembly addAssemblyFromDescriptor( final String spec, final Locator locator,
                                                final AssemblerConfigurationSource configSource,
                                                final List<Assembly> assemblies )
        throws AssemblyReadException, InvalidAssemblerConfigurationException
    {
        final Location location = locator.resolve( spec );

        if ( location == null )
        {
            if ( configSource.isIgnoreMissingDescriptor() )
            {
                getLogger().debug( "Ignoring missing assembly descriptor with ID '" + spec
                                       + "' per configuration.\nLocator output was:\n\n"
                                       + locator.getMessageHolder().render() );
                return null;
            }
            else
            {
                throw new AssemblyReadException( "Error locating assembly descriptor: " + spec + "\n\n"
                    + locator.getMessageHolder().render() );
            }
        }

        Reader r = null;
        try
        {
            // TODO use ReaderFactory.newXmlReader() when plexus-utils is upgraded to 1.4.5+
            r = new InputStreamReader( location.getInputStream(), "UTF-8" );

            File dir = null;
            if ( location.getFile() != null )
            {
                dir = location.getFile().getParentFile();
            }

            final Assembly assembly = readAssembly( r, spec, dir, configSource );

            assemblies.add( assembly );
View Full Code Here

                location = aee.evaluate(location).toString();
            } catch (final Exception eee) {
                getLogger().error("Error interpolating componentDescriptor: " + location, eee);
            }

            final Location resolvedLocation = locator.resolve(location);

            if (resolvedLocation == null) {
                throw new AssemblyReadException("Failed to locate component descriptor: " + location);
            }

            Component component = null;
            Reader reader = null;
            try {
                reader = new InputStreamReader(resolvedLocation.getInputStream());
                component = new ComponentXpp3Reader().read(reader);
            } catch (final IOException e) {
                throw new AssemblyReadException("Error reading component descriptor: " + location + " (resolved to: "
                        + resolvedLocation.getSpecification() + ")", e);
            } catch (final XmlPullParserException e) {
                throw new AssemblyReadException("Error reading component descriptor: " + location + " (resolved to: "
                        + resolvedLocation.getSpecification() + ")", e);
            } finally {
                IOUtil.close(reader);
            }

            mergeComponentWithAssembly(component, assembly);
View Full Code Here

    private Assembly addAssemblyFromDescriptor( final String spec, final Locator locator,
                                                final AssemblerConfigurationSource configSource,
                                                final List<Assembly> assemblies )
        throws AssemblyReadException, InvalidAssemblerConfigurationException
    {
        final Location location = locator.resolve( spec );

        if ( location == null )
        {
            if ( configSource.isIgnoreMissingDescriptor() )
            {
                getLogger().debug( "Ignoring missing assembly descriptor with ID '" + spec
                                       + "' per configuration.\nLocator output was:\n\n"
                                       + locator.getMessageHolder().render() );
                return null;
            }
            else
            {
                throw new AssemblyReadException( "Error locating assembly descriptor: " + spec + "\n\n"
                    + locator.getMessageHolder().render() );
            }
        }

        Reader r = null;
        try
        {
            // TODO use ReaderFactory.newXmlReader() when plexus-utils is upgraded to 1.4.5+
            r = new InputStreamReader( location.getInputStream(), "UTF-8" );

            File dir = null;
            if ( location.getFile() != null )
            {
                dir = location.getFile().getParentFile();
            }

            final Assembly assembly = readAssembly( r, spec, dir, configSource );

            assemblies.add( assembly );
View Full Code Here

TOP

Related Classes of org.apache.maven.shared.io.location.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.