Package org.apache.maven.archetype

Examples of org.apache.maven.archetype.Archetype


    protected void createTestProject(String archetypeArtifactId, String archetypeVersion) throws Exception {
        MavenProject project = getMavenProject();
        FileUtils.deleteDirectory(getTestFile("target/" + project.getArtifactId()));

        Archetype archetype = (Archetype) lookup(Archetype.ROLE);

        String localRepoPath = System.getProperty( "localRepoPath" );

        if (StringUtils.isEmpty(localRepoPath)) {
            localRepoPath =  System.getProperty("user.home") + System.getProperty("file.separator") +
                            ".m2" + System.getProperty("file.separator") + "repository";
        }

        String mavenRepoLocal = "file://" + localRepoPath;

        ArtifactRepositoryLayout layout =
                (ArtifactRepositoryLayout) container.lookup(ArtifactRepositoryLayout.ROLE, "default");
       
        ArtifactRepository localRepository = new DefaultArtifactRepository("local", mavenRepoLocal, layout);

        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

TOP

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

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.