List<String> availableVersions = new ArrayList<String>();
String latestVersion = version;
String projectPath = targetPath.substring( 0, targetPath.lastIndexOf( File.separatorChar ) );
File projectMetadataFile = getMetadata( projectPath );
ArchivaRepositoryMetadata projectMetadata = getMetadata( projectMetadataFile );
if ( projectMetadataFile.exists() )
{
availableVersions = projectMetadata.getAvailableVersions();
Collections.sort( availableVersions, VersionComparator.getInstance() );
if ( !availableVersions.contains( version ) )
{
availableVersions.add( version );
}
latestVersion = availableVersions.get( availableVersions.size() - 1 );
}
else
{
availableVersions.add( version );
projectMetadata.setGroupId( groupId );
projectMetadata.setArtifactId( artifactId );
}
if ( projectMetadata.getGroupId() == null )
{
projectMetadata.setGroupId( groupId );
}
if ( projectMetadata.getArtifactId() == null )
{
projectMetadata.setArtifactId( artifactId );
}
projectMetadata.setLatestVersion( latestVersion );
projectMetadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
projectMetadata.setAvailableVersions( availableVersions );
if ( !VersionUtil.isSnapshot( version ) )
{
projectMetadata.setReleasedVersion( latestVersion );
}
RepositoryMetadataWriter.write( projectMetadata, projectMetadataFile );
if ( fixChecksums )