List<String> languages )
throws IOException, ArchetypeNotDefined, ArchetypeNotConfigured, PrompterException, TemplateCreationException
{
Properties properties = initialiseArchetypeProperties( commandLineProperties, propertyFile );
ArchetypeDefinition archetypeDefinition = archetypeFactory.createArchetypeDefinition( properties );
if ( !archetypeDefinition.isDefined() )
{
archetypeDefinition = defineDefaultArchetype( project, properties );
}
ArchetypeConfiguration archetypeConfiguration =
archetypeFactory.createArchetypeConfiguration( project, archetypeDefinition, properties );
String resolvedPackage = archetypeFilesResolver.resolvePackage( project.getBasedir(), languages );
if ( !archetypeConfiguration.isConfigured() )
{
archetypeConfiguration =
defineDefaultConfiguration( project, archetypeDefinition, resolvedPackage, properties );
}
if ( interactiveMode.booleanValue() )
{
getLogger().debug( "Entering interactive mode" );
boolean confirmed = false;
while ( !confirmed )
{
if ( !archetypeDefinition.isDefined() )// <editor-fold text="...">
{
getLogger().debug( "Archetype is yet not defined" );
if ( !archetypeDefinition.isGroupDefined() )
{
getLogger().debug( "Asking for archetype's groupId" );
archetypeDefinition.setGroupId( archetypeCreationQueryer.getArchetypeGroupId( project.getGroupId() ) );
}
if ( !archetypeDefinition.isArtifactDefined() )
{
getLogger().debug( "Asking for archetype's artifactId" );
archetypeDefinition.setArtifactId( archetypeCreationQueryer.getArchetypeArtifactId( project.getArtifactId()
+ Constants.ARCHETYPE_SUFFIX ) );
}
if ( !archetypeDefinition.isVersionDefined() )
{
getLogger().debug( "Asking for archetype's version" );
archetypeDefinition.setVersion( archetypeCreationQueryer.getArchetypeVersion( project.getVersion() ) );
}
archetypeFactory.updateArchetypeConfiguration( archetypeConfiguration, archetypeDefinition );
} // </editor-fold>
if ( !archetypeConfiguration.isConfigured() )// <editor-fold text="...">
{
getLogger().debug( "Archetype is not yet configured" );
if ( !archetypeConfiguration.isConfigured( Constants.GROUP_ID ) )
{
getLogger().debug( "Asking for project's groupId" );
archetypeConfiguration.setProperty(
Constants.GROUP_ID,
archetypeCreationQueryer.getGroupId( archetypeConfiguration.getDefaultValue( Constants.GROUP_ID ) ) );
}
if ( !archetypeConfiguration.isConfigured( Constants.ARTIFACT_ID ) )
{
getLogger().debug( "Asking for project's artifactId" );
archetypeConfiguration.setProperty(
Constants.ARTIFACT_ID,
archetypeCreationQueryer.getArtifactId( archetypeConfiguration.getDefaultValue( Constants.ARTIFACT_ID ) ) );
}
if ( !archetypeConfiguration.isConfigured( Constants.VERSION ) )
{
getLogger().debug( "Asking for project's version" );
archetypeConfiguration.setProperty(
Constants.VERSION,
archetypeCreationQueryer.getVersion( archetypeConfiguration.getDefaultValue( Constants.VERSION ) ) );
}
if ( !archetypeConfiguration.isConfigured( Constants.PACKAGE ) )
{
getLogger().debug( "Asking for project's package" );
archetypeConfiguration.setProperty(
Constants.PACKAGE,
archetypeCreationQueryer.getPackage( StringUtils.isEmpty( resolvedPackage ) ? archetypeConfiguration.getDefaultValue( Constants.PACKAGE )
: resolvedPackage ) );
}
} // </editor-fold>
boolean stopAddingProperties = false;
while ( !stopAddingProperties )
{
getLogger().debug( "Asking for another required property" );
stopAddingProperties = !archetypeCreationQueryer.askAddAnotherProperty();
if ( !stopAddingProperties )
{
getLogger().debug( "Asking for required property key" );
String propertyKey = archetypeCreationQueryer.askNewPropertyKey();
getLogger().debug( "Asking for required property value" );
String replacementValue =
archetypeCreationQueryer.askReplacementValue(
propertyKey,
archetypeConfiguration.getDefaultValue( propertyKey ) );
archetypeConfiguration.setDefaultProperty( propertyKey, replacementValue );
archetypeConfiguration.setProperty( propertyKey, replacementValue );
}
}
getLogger().debug( "Asking for configuration confirmation" );
if ( archetypeCreationQueryer.confirmConfiguration( archetypeConfiguration ) )
{
confirmed = true;
}
else
{
getLogger().debug( "Reseting archetype's definition and configuration" );
archetypeConfiguration.reset();
archetypeDefinition.reset();
}
} // end while
}
else
{
getLogger().debug( "Entering batch mode" );
if ( !archetypeDefinition.isDefined() )
{
throw new ArchetypeNotDefined( "The archetype is not defined" );
}
else if ( !archetypeConfiguration.isConfigured() )
{