findArchetype( archetypes, request.getArchetypeGroupId(), request.getArchetypeArtifactId() );
if ( found != null )
{
String catalogKey = found.getKey();
Archetype archetype = found.getValue();
updateRepository( definition, archetype, catalogKey );
getLogger().info( "Archetype repository missing. Using the one from " + archetype + " found in catalog "
+ catalogKey );
}
else
{
getLogger().warn(
"Archetype not found in any catalog. Falling back to central repository (http://repo1.maven.org/maven2)." );
getLogger().warn(
"Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere." );
definition.setRepository( "http://repo1.maven.org/maven2" );
}
}
if ( !definition.isDefined() && definition.isPartiallyDefined() )
{
Map.Entry<String, Archetype> found =
findArchetype( archetypes, request.getArchetypeGroupId(), request.getArchetypeArtifactId() );
if ( found != null )
{
String catalogKey = found.getKey();
Archetype archetype = found.getValue();
updateDefinition( definition, archetype, catalogKey );
getLogger().info( "Archetype " + archetype + " found in catalog " + catalogKey );
}
else
{
getLogger().warn( "Specified archetype not found." );
if ( interactiveMode.booleanValue() )
{
definition.setVersion( null );
definition.setGroupId( null );
definition.setArtifactId( null );
}
}
}
// set the defaults - only group and version can be auto-defaulted
if ( definition.getGroupId() == null )
{
definition.setGroupId( DEFAULT_ARCHETYPE_GROUPID );
}
if ( definition.getVersion() == null )
{
definition.setVersion( DEFAULT_ARCHETYPE_VERSION );
}
if ( !definition.isPartiallyDefined() )
{
// if artifact ID is set to its default, we still prompt to confirm
if ( definition.getArtifactId() == null )
{
getLogger().info(
"No archetype defined. Using " + DEFAULT_ARCHETYPE_ARTIFACTID + " (" + definition.getGroupId() + ":"
+ DEFAULT_ARCHETYPE_ARTIFACTID + ":" + definition.getVersion() + ")" );
definition.setArtifactId( DEFAULT_ARCHETYPE_ARTIFACTID );
}
if ( interactiveMode.booleanValue() && ( archetypes.size() > 0 ) )
{
Archetype selectedArchetype = archetypeSelectionQueryer.selectArchetype( archetypes, definition );
String catalogKey = getCatalogKey( archetypes, selectedArchetype );
updateDefinition( definition, selectedArchetype, catalogKey );
}