Package org.apache.maven.archetype

Examples of org.apache.maven.archetype.ArchetypeGenerationRequest


            FileUtils.deleteDirectory( basedir );

            FileUtils.mkdir( basedir );

            ArchetypeGenerationRequest request =
                new ArchetypeGenerationRequest().setArchetypeGroupId( project.getGroupId() ).setArchetypeArtifactId(
                    project.getArtifactId() ).setArchetypeVersion( project.getVersion() ).setGroupId(
                    properties.getProperty( Constants.GROUP_ID ) ).setArtifactId(
                    properties.getProperty( Constants.ARTIFACT_ID ) ).setVersion(
                    properties.getProperty( Constants.VERSION ) ).setPackage(
                    properties.getProperty( Constants.PACKAGE ) ).setOutputDirectory( basedir ).setProperties(
                    properties );

            ArchetypeGenerationResult result = new ArchetypeGenerationResult();

            archetypeGenerator.generateArchetype( request, archetypeFile, result );

            if ( result.getCause() != null )
            {
                if ( result.getCause() instanceof ArchetypeNotConfigured )
                {
                    ArchetypeNotConfigured anc = (ArchetypeNotConfigured) result.getCause();

                    throw new IntegrationTestFailure(
                        "Missing required properties in archetype.properties: " + StringUtils.join(
                            anc.getMissingProperties().iterator(), ", " ), anc );
                }

                throw new IntegrationTestFailure( result.getCause().getMessage(), result.getCause() );
            }

            File reference = new File( goalFile.getParentFile(), "reference" );

            if ( reference.exists() )
            {
                // compare generated project with reference
                getLog().info( "Comparing generated project with reference content: " + reference );

                assertDirectoryEquals( reference, new File( basedir, request.getArtifactId() ) );
            }

            String goals = FileUtils.fileRead( goalFile );

            invokePostArchetypeGenerationGoals( goals, new File( basedir, request.getArtifactId() ), goalFile );
        }
        catch ( IOException ioe )
        {
            throw new IntegrationTestFailure( ioe );
        }
View Full Code Here


        assert context != null;
        IO io = context.getIo();
        Variables vars = context.getVariables();

        RepositorySystem rsys = plexus.lookup(RepositorySystem.class);
        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest()
            .setLocalRepository(rsys.createDefaultLocalRepository())
            .setRemoteArtifactRepositories(Collections.singletonList(rsys.createDefaultRemoteRepository()));

        if (outputDirectory == null) {
            outputDirectory = new File(vars.get(SHELL_USER_DIR, String.class));
        }
        request.setOutputDirectory(outputDirectory.getAbsolutePath());

        if (archetypeId != null) {
            String[] items = archetypeId.split(":", 3);
            if (items.length != 3) {
                io.error("Invalid archetype id: {}", archetypeId); // TODO: i18n
                return Result.FAILURE;
            }

            request.setArchetypeGroupId(items[0])
                .setArchetypeArtifactId(items[1])
                .setArchetypeVersion(items[2]);
        }

        ArchetypeSelector selector = plexus.lookup(ArchetypeSelector.class);
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.