private WagonManager m_wagonManager;
public void execute() throws MojoExecutionException
{
MavenProject project = getProject();
String projectType = project.getPackaging();
// ignore unsupported project types, useful when bundleplugin is configured in parent pom
if ( !supportedProjectTypes.contains( projectType ) )
{
getLog().warn(
"Ignoring project type " + projectType + " - supportedProjectTypes = " + supportedProjectTypes );
return;
}
else if ( "NONE".equalsIgnoreCase( remoteOBR ) || "false".equalsIgnoreCase( remoteOBR ) )
{
getLog().info( "Remote OBR update disabled (enable with -DremoteOBR)" );
return;
}
// if the user doesn't supply an explicit name for the remote OBR file, use the local name instead
if ( null == remoteOBR || remoteOBR.trim().length() == 0 || "true".equalsIgnoreCase( remoteOBR ) )
{
remoteOBR = obrRepository;
}
URI tempURI = ObrUtils.findRepositoryXml( "", remoteOBR );
String repositoryName = new File( tempURI.getSchemeSpecificPart() ).getName();
Log log = getLog();
ObrUpdate update;
RemoteFileManager remoteFile = new RemoteFileManager( m_wagonManager, settings, log );
remoteFile.connect( repositoryId, url );
// ======== LOCK REMOTE OBR ========
log.info( "LOCK " + remoteFile + '/' + repositoryName );
remoteFile.lockFile( repositoryName, ignoreLock );
File downloadedRepositoryXml = null;
try
{
// ======== DOWNLOAD REMOTE OBR ========
log.info( "Downloading " + repositoryName );
downloadedRepositoryXml = remoteFile.get( repositoryName, ".xml" );
String mavenRepository = localRepository.getBasedir();
URI repositoryXml = downloadedRepositoryXml.toURI();
URI obrXmlFile = ObrUtils.toFileURI( obrXml );
URI bundleJar;
if ( null == file )
{
bundleJar = ObrUtils.getArtifactURI( localRepository, project.getArtifact() );
}
else
{
bundleJar = file.toURI();
}
Config userConfig = new Config();
userConfig.setRemoteFile( true );
if ( null != bundleUrl )
{
// public URL differs from the bundle file location
URI uri = URI.create( bundleUrl );
log.info( "Computed bundle uri: " + uri );
userConfig.setRemoteBundle( uri );
}
else if ( null != file )
{
// assume file will be deployed in remote repository, so find the remote relative location
URI uri = URI.create( localRepository.pathOf( project.getArtifact() ) );
log.info( "Computed bundle uri: " + uri );
userConfig.setRemoteBundle( uri );
}
update = new ObrUpdate( repositoryXml, obrXmlFile, project, mavenRepository, userConfig, log );