public void execute()
throws MojoExecutionException, MojoFailureException
{
Properties executionProperties = session.getExecutionProperties();
ArchetypeGenerationRequest request = new ArchetypeGenerationRequest()
.setArchetypeGroupId( archetypeGroupId )
.setArchetypeArtifactId( archetypeArtifactId )
.setArchetypeVersion( archetypeVersion )
.setOutputDirectory( basedir.getAbsolutePath() )
.setLocalRepository( localRepository )
.setArchetypeRepository( archetypeRepository )
.setRemoteArtifactRepositories( remoteArtifactRepositories )
.setFilter( filter );
try
{
if ( interactiveMode.booleanValue() )
{
getLog().info( "Generating project in Interactive mode" );
}
else
{
getLog().info( "Generating project in Batch mode" );
}
selector.selectArchetype( request, interactiveMode, archetypeCatalog );
if ( StringUtils.isBlank( request.getArchetypeArtifactId() ) )
{
// no archetype found: stopping
return;
}
configurator.configureArchetype( request, interactiveMode, executionProperties );
ArchetypeGenerationResult generationResult = manager.generateProjectFromArchetype( request );
if ( generationResult.getCause() != null )
{
throw new MojoFailureException( generationResult.getCause(), generationResult.getCause().getMessage(),
generationResult.getCause().getMessage() );
}
}
catch ( MojoFailureException ex )
{
throw ex;
}
catch ( Exception ex )
{
throw (MojoFailureException) new MojoFailureException( ex.getMessage() ).initCause( ex );
}
String artifactId = request.getArtifactId();
String postArchetypeGenerationGoals = request.getArchetypeGoals();
if ( StringUtils.isEmpty( postArchetypeGenerationGoals ) )
{
postArchetypeGenerationGoals = goals;
}