Package org.apache.maven.archetype.old.descriptor

Examples of org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor


        control.setReturnValue( false );
        manager.isOldArchetype( "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null, null, null );
        control.setReturnValue( true );
        manager.getOldArchetypeDescriptor( "archetypeGroupId", "archetypeArtifactId", "archetypeVersion", null,
                                               null, null );
        control.setReturnValue( new ArchetypeDescriptor() );
        control.replay();
        configurator.setArchetypeArtifactManager( manager );
    }
View Full Code Here


        // Load the descriptor
        // ----------------------------------------------------------------------

        ArchetypeDescriptorBuilder builder = new ArchetypeDescriptorBuilder();

        ArchetypeDescriptor descriptor;

        URLClassLoader archetypeJarLoader;

        InputStream is = null;

        try
        {
            URL[] urls = new URL[1];

            urls[0] = archetypeFile.toURL();

            archetypeJarLoader = new URLClassLoader( urls );

            is = getStream( ARCHETYPE_DESCRIPTOR, archetypeJarLoader );

            if ( is == null )
            {
                is = getStream( ARCHETYPE_OLD_DESCRIPTOR, archetypeJarLoader );
            }

            if ( is == null )
            {
                throw new ArchetypeDescriptorException( "The " + ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." );
            }

            descriptor = builder.build( new XmlStreamReader( is ) );
        }
        catch ( IOException e )
        {
            throw new ArchetypeDescriptorException( "Error reading the " + ARCHETYPE_DESCRIPTOR + " descriptor.", e );
        }
        catch ( XmlPullParserException e )
        {
            throw new ArchetypeDescriptorException( "Error reading the " + ARCHETYPE_DESCRIPTOR + " descriptor.", e );
        }
        finally
        {
            IOUtil.close( is );
        }

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        String artifactId = request.getArtifactId();

        File parentPomFile = new File( request.getOutputDirectory(), ARCHETYPE_POM );

        File outputDirectoryFile;

        boolean creating;
        File pomFile;
        if ( parentPomFile.exists() && descriptor.isAllowPartial() && artifactId == null )
        {
            outputDirectoryFile = new File( request.getOutputDirectory() );
            creating = false;
            pomFile = parentPomFile;
        }
        else
        {
            if ( artifactId == null )
            {
                throw new ArchetypeTemplateProcessingException(
                    "Artifact ID must be specified when creating a new project from an archetype." );
            }

            outputDirectoryFile = new File( request.getOutputDirectory(), artifactId );
            creating = true;

            if ( outputDirectoryFile.exists() )
            {
                if ( descriptor.isAllowPartial() )
                {
                    creating = false;
                }
                else
                {
View Full Code Here

TOP

Related Classes of org.apache.maven.archetype.old.descriptor.ArchetypeDescriptor

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.