Package org.apache.maven.archetype

Examples of org.apache.maven.archetype.ArchetypeGenerationRequest


        List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();

        String archetypeGroupId = "org.appfuse.archetypes";

        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
        request.setGroupId(project.getGroupId()).setArtifactId(project.getArtifactId()).setVersion("1.0-SNAPSHOT");
        request.setArchetypeGroupId(archetypeGroupId).setArchetypeArtifactId(archetypeArtifactId);
        request.setArchetypeVersion(archetypeVersion);
        request.setLocalRepository(localRepository);
        request.setRemoteArtifactRepositories(remoteRepositories);
        request.setOutputDirectory(getTestFile("target").getAbsolutePath());

        archetype.generateProjectFromArchetype(request);
    }
View Full Code Here


    public void testOldArchetypeGeneratedFieldsInRequestBatchMode()
        throws PrompterException, ArchetypeGenerationConfigurationFailure, IOException, ArchetypeNotConfigured,
        UnknownArchetype, ArchetypeNotDefined
    {
        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
        request.setArchetypeGroupId( "archetypeGroupId" );
        request.setArchetypeArtifactId( "archetypeArtifactId" );
        request.setArchetypeVersion( "archetypeVersion" );
        Properties properties = new Properties();
        properties.setProperty( "groupId", "preset-groupId" );
        properties.setProperty( "artifactId", "preset-artifactId" );
        properties.setProperty( "version", "preset-gen-version" );
        properties.setProperty( "package", "preset-gen-package" );

        configurator.configureArchetype( request, Boolean.FALSE, properties );

        assertEquals( "preset-groupId", request.getGroupId() );
        assertEquals( "preset-artifactId", request.getArtifactId() );
        assertEquals( "preset-gen-version", request.getVersion() );
        assertEquals( "preset-gen-package", request.getPackage() );
    }
View Full Code Here

    public void testOldArchetypeGeneratedFieldsDefaultsBatchMode()
        throws PrompterException, IOException, UnknownGroup, ArchetypeSelectionFailure, UnknownArchetype,
        ArchetypeNotDefined, ArchetypeGenerationConfigurationFailure, ArchetypeNotConfigured
    {
        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
        request.setArchetypeGroupId( "archetypeGroupId" );
        request.setArchetypeArtifactId( "archetypeArtifactId" );
        request.setArchetypeVersion( "archetypeVersion" );
        Properties properties = new Properties();
        properties.setProperty( "groupId", "preset-groupId" );
        properties.setProperty( "artifactId", "preset-artifactId" );

        configurator.configureArchetype( request, Boolean.FALSE, properties );

        assertEquals( "preset-groupId", request.getGroupId() );
        assertEquals( "preset-artifactId", request.getArtifactId() );
        assertEquals( "1.0-SNAPSHOT", request.getVersion() );
        assertEquals( "preset-groupId", request.getPackage() );
    }
View Full Code Here

    // TODO: should test this in interactive mode to check for prompting
    public void testOldArchetypeGeneratedFieldsDefaultsMissingGroupId()
        throws PrompterException, IOException, UnknownGroup, ArchetypeSelectionFailure, UnknownArchetype,
        ArchetypeNotDefined, ArchetypeGenerationConfigurationFailure, ArchetypeNotConfigured
    {
        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
        request.setArchetypeGroupId( "archetypeGroupId" );
        request.setArchetypeArtifactId( "archetypeArtifactId" );
        request.setArchetypeVersion( "archetypeVersion" );
        Properties properties = new Properties();
        properties.setProperty( "artifactId", "preset-artifactId" );

        try
        {
View Full Code Here

    public void testArchetypeCoordinatesInRequest()
        throws PrompterException, IOException, UnknownGroup, ArchetypeSelectionFailure, UnknownArchetype,
        ArchetypeNotDefined
    {
        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
        request.setArchetypeArtifactId( "preset-artifactId" );
        request.setArchetypeGroupId( "preset-groupId" );
        request.setArchetypeVersion( "preset-version" );

        MockControl control = MockControl.createControl( ArchetypeSelectionQueryer.class );

        ArchetypeSelectionQueryer queryer = (ArchetypeSelectionQueryer) control.getMock();
        // expect it to not be called

        control.replay();

        selector.setArchetypeSelectionQueryer( queryer );

        selector.selectArchetype( request, Boolean.TRUE, "" );

        control.verify();

        assertEquals( "preset-groupId", request.getArchetypeGroupId() );
        assertEquals( "preset-artifactId", request.getArchetypeArtifactId() );
        assertEquals( "preset-version", request.getArchetypeVersion() );
    }
View Full Code Here

        String outputDirectory = new File( getBasedir(),
                                           "target" + File.separator + "test-classes" + File.separator + "projects"
                                               + File.separator + "roundtrip-1-recreatedproject" ).getAbsolutePath();
        FileUtils.forceDelete( outputDirectory );

        ArchetypeGenerationRequest agr =
            new ArchetypeGenerationRequest().setArchetypeGroupId( generatedArchetypeProject.getGroupId() ).
                setArchetypeArtifactId( generatedArchetypeProject.getArtifactId() ).
                setArchetypeVersion( generatedArchetypeProject.getVersion() ).
                setGroupId( "com.mycompany" ).setArtifactId( "myapp" ).setVersion( "1.0-SNAPSHOT" ).
                setPackage( "com.mycompany.myapp" ).setProperties( properties ).
                setOutputDirectory( outputDirectory ).setLocalRepository( localRepository ).
View Full Code Here

        FileUtils.forceDelete( outputDirectory );

        WagonManager manager = (WagonManager) lookup( WagonManager.class.getName() );
        manager.addProxy( "http", "localhost", proxyPort, null, null, null );

        ArchetypeGenerationRequest agr =
            new ArchetypeGenerationRequest().setArchetypeGroupId( generatedArchetypeProject.getGroupId() ).
                setArchetypeArtifactId( generatedArchetypeProject.getArtifactId() ).
                setArchetypeVersion( generatedArchetypeProject.getVersion() ).
                setGroupId( "com.mycompany" ).setArtifactId( "myapp" ).setVersion( "1.0-SNAPSHOT" ).
                setPackage( "com.mycompany.myapp" ).setOutputDirectory( outputDirectory ).
                setLocalRepository( localRepository ).setArchetypeRepository( "http://localhost:" + port + "/repo" );
View Full Code Here

        ArtifactRepository remoteRepository = new DefaultArtifactRepository( "remote", mavenRepoRemote, layout );

        remoteRepositories.add( remoteRepository );

        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest()
            .setPackage( "org.apache.maven.quickstart" )
            .setGroupId( "maven" )
            .setArtifactId( "quickstart" )
            .setVersion( "1.0-alpha-1-SNAPSHOT" )
            .setArchetypeGroupId( "org.apache.maven.archetypes" )
            .setArchetypeArtifactId( "maven-archetype-quickstart" )
            .setArchetypeVersion( "1.0-alpha-1-SNAPSHOT" )
            .setLocalRepository( localRepository )
            .setRemoteArtifactRepositories( remoteRepositories )
            .setOutputDirectory( getTestFile( "target" ).getAbsolutePath() );
        //parameters.put( "name", "jason" );

        archetype.createArchetype( request, remoteRepository );

        // ----------------------------------------------------------------------
        // Set up the Velocity context
        // ----------------------------------------------------------------------

        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put( "basedir", request.getOutputDirectory() );
        parameters.put( "package", request.getPackage() );
        parameters.put( "packageName", request.getPackage() );
        parameters.put( "groupId", request.getGroupId() );
        parameters.put( "artifactId", request.getArtifactId() );
        parameters.put( "version", request.getVersion() );

        Context context = new VelocityContext();

        for ( Map.Entry<String, Object> entry : parameters.entrySet() )
        {
            context.put( entry.getKey(), entry.getValue() );
        }

        // ----------------------------------------------------------------------
        // Validate POM generation
        // ----------------------------------------------------------------------

        ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.class.getName() );
        Artifact archetypeArtifact = artifactFactory.createArtifact( request.getArchetypeGroupId(), request.getArchetypeArtifactId(),
                                                                     request.getArchetypeVersion(), Artifact.SCOPE_RUNTIME, "jar" );

        StringWriter writer = new StringWriter();

        ClassLoader old = Thread.currentThread().getContextClassLoader();
View Full Code Here

    {
        System.out.println( "testArchetypeNotDefined" );

        Archetype archetype = new Archetype( "archetypes", null, "1.0" );

        ArchetypeGenerationRequest request = createArchetypeGenerationRequest( "generate-2", archetype );

        ArchetypeGenerationResult result = generateProjectFromArchetypeWithFailure( request );

        assertEquals( "Exception not correct", "The archetype is not defined", result.getCause().getMessage() );
    }
View Full Code Here

    public void testGenerateArchetypeCompleteWithoutParent()
        throws Exception
    {
        System.out.println( "testGenerateArchetypeCompleteWithoutParent" );

        ArchetypeGenerationRequest request = createArchetypeGenerationRequest( "generate-4", ARCHETYPE_BASIC );

        FileUtils.forceDelete( projectDirectory );

        generateProjectFromArchetype( request );
View Full Code Here

TOP

Related Classes of org.apache.maven.archetype.ArchetypeGenerationRequest

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.