private DistributionManagement translateDistributionManagement( PomKey pomKey,
org.apache.maven.model.v3_0_0.Model v3Model )
throws PomTranslationException
{
DistributionManagement distributionManagement = new DistributionManagement();
Site site = null;
String siteAddress = v3Model.getSiteAddress();
String siteDirectory = v3Model.getSiteDirectory();
if ( StringUtils.isEmpty( siteAddress ) )
{
if ( !StringUtils.isEmpty( siteDirectory ) )
{
site = new Site();
site.setId( "default" );
site.setName( "Default Site" );
site.setUrl( "file://" + siteDirectory );
}
}
else
{
if ( StringUtils.isEmpty( siteDirectory ) )
{
throw new PomTranslationException( pomKey.groupId(), pomKey.artifactId(), pomKey.version(),
"Missing 'siteDirectory': Both siteAddress and siteDirectory must be"
+ " set at the same time." );
}
site = new Site();
site.setId( "default" );
site.setName( "Default Site" );
StringBuffer url = new StringBuffer( "scp://" );
url.append( siteAddress );
if ( !siteAddress.endsWith( "/" ) && !siteDirectory.startsWith( "/" ) )
{
url.append( "/" );
}
url.append( siteDirectory );
site.setUrl( url.toString() );
}
distributionManagement.setSite( site );
String distributionSite = v3Model.getDistributionSite();
String distributionDirectory = v3Model.getDistributionDirectory();
DeploymentRepository repository = null;
if ( StringUtils.isEmpty( distributionSite ) )
{
if ( !StringUtils.isEmpty( distributionDirectory ) )
{
repository = new DeploymentRepository();
repository.setId( "default" );
repository.setName( "Default Repository" );
repository.setUrl( "file://" + distributionDirectory );
// throw new Exception( "Missing 'distributionSite': Both distributionSite and
// distributionDirectory must be set." );
}
}
else
{
if ( StringUtils.isEmpty( distributionDirectory ) )
{
throw new PomTranslationException( pomKey.groupId(), pomKey.artifactId(), pomKey.version(),
"Missing 'distributionDirectory': must be set if 'distributionSite'"
+ "is set." );
}
repository = new DeploymentRepository();
repository.setId( "default" );
repository.setName( "Default Repository" );
repository.setUrl( distributionSite + "/" + distributionDirectory );
}
distributionManagement.setRepository( repository );
distributionManagement.setStatus( "converted" );
if ( site == null && repository == null )
{
return null;
}