in nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateNbmMojo.java [191:373]
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( skipNbm )
{
getLog().info( "Skipping generation of NBM file." );
return;
}
if ( "pom".equals( project.getPackaging() ) )
{
getLog().info(
"Skipping " + project.getId() + ", no nbm:nbm execution for 'pom' packaging" );
return;
}
super.execute();
// 3. generate nbm
File nbmFile = new File( nbmBuildDir, finalName + ".nbm" );
MakeNBM nbmTask = (MakeNBM) antProject.createTask( "makenbm" );
nbmTask.setFile( nbmFile );
nbmTask.setProductDir( clusterDir );
nbmTask.setModule( "modules" + File.separator + moduleJarName + ".jar" );
boolean reqRestart = requiresRestart;
if ( !reqRestart && module.isRequiresRestart() )
{
reqRestart = module.isRequiresRestart();
getLog().warn(
"Module descriptor's requiresRestart field is deprecated, use plugin's configuration in pom.xml" );
}
nbmTask.setNeedsrestart( Boolean.toString( reqRestart ) );
String moduleAuthor = author;
if ( module.getAuthor() != null )
{
moduleAuthor = module.getAuthor();
getLog().warn(
"Module descriptor's requiresRestart field is deprecated, use plugin's configuration in pom.xml" );
}
nbmTask.setModuleauthor( moduleAuthor );
if ( keystore != null && keystorealias != null && keystorepassword != null )
{
File ks = new File( keystore );
if ( !ks.exists() )
{
getLog().warn( "Cannot find keystore file at " + ks.getAbsolutePath() );
}
else
{
Signature sig = nbmTask.createSignature();
sig.setKeystore( ks );
sig.setAlias( keystorealias );
sig.setStorepass( keystorepassword );
if ( tsaurl != null )
{
sig.setTsaurl( tsaurl );
}
if ( tsacert != null )
{
sig.setTsacert( tsacert );
}
getLog().debug( "Setup the Ant task to sign the NBM file." );
}
}
else if ( keystore != null || keystorepassword != null || keystorealias != null )
{
getLog().warn(
"If you want to sign the nbm file, you need to define all three keystore related parameters." );
}
String licName = licenseName;
File licFile = licenseFile;
if ( module.getLicenseName() != null )
{
licName = module.getLicenseName();
getLog().warn(
"Module descriptor's licenseName field is deprecated, use plugin's configuration in pom.xml" );
}
if ( module.getLicenseFile() != null )
{
File lf = new File( project.getBasedir(), module.getLicenseFile() );
licFile = lf;
getLog().warn(
"Module descriptor's licenseFile field is deprecated, use plugin's configuration in pom.xml" );
}
if ( licName != null && licFile != null )
{
if ( !licFile.exists() || !licFile.isFile() )
{
getLog().warn( "Cannot find license file at " + licFile.getAbsolutePath() );
}
else
{
Blurb lb = nbmTask.createLicense();
lb.setFile( licFile );
lb.addText( licName );
}
}
else if ( licName != null || licFile != null )
{
getLog().warn(
"To set license for the nbm, you need to specify both licenseName and licenseFile parameters." );
}
else
{
Blurb lb = nbmTask.createLicense();
lb.addText( createDefaultLicenseHeader() );
lb.addText( createDefaultLicenseText() );
}
String hpUrl = homePageUrl;
if ( module.getHomepageUrl() != null )
{
getLog().warn(
"Module descriptor's homePageUrl field is deprecated, use plugin's configuration in pom.xml" );
hpUrl = module.getHomepageUrl();
}
if ( hpUrl != null )
{
nbmTask.setHomepage( hpUrl );
}
String distribUrl = distributionUrl;
if ( module.getDistributionUrl() != null )
{
distribUrl = module.getDistributionUrl();
getLog().warn(
"Module descriptor's distributionUrl field is deprecated, use plugin's configuration in pom.xml" );
}
if ( distribUrl != null )
{
ArtifactRepository distRepository = CreateUpdateSiteMojo.getDeploymentRepository(
distribUrl, container, getLog() );
String dist = null;
if ( distRepository == null )
{
if ( !distribUrl.contains( "::" ) )
{
dist
= distribUrl + ( distribUrl.endsWith( "/" ) ? "" : "/" )
+ nbmFile.getName();
}
}
else
{
Artifact art = artifactFactory.createArtifact(
project.getGroupId(), project.getArtifactId(),
project.getVersion(), null, "nbm-file" );
dist
= distRepository.getUrl() + ( distRepository.getUrl().endsWith( "/" ) ? "" : "/" )
+ distRepository.pathOf( art );
}
nbmTask.setDistribution( dist );
}
else
{
nbmTask.setDistribution( nbmFile.getName() );
}
if ( !"extra".equals( cluster ) )
{
nbmTask.setTargetcluster( cluster );
}
//MNBMODULE-217 avoid using the static DATE_FORMAT variable in MavenNBM.java (in ant harness)
nbmTask.setReleasedate( DATE_FORMAT.format( new Date( System.currentTimeMillis() ) ) );
try
{
nbmTask.execute();
}
catch ( BuildException e )
{
throw new MojoExecutionException( "Cannot Generate nbm file:" + e.getMessage(), e );
}
try
{
File nbmfile = new File( buildDir, nbmFile.getName() );
FileUtils.getFileUtils().copyFile( nbmFile, nbmfile );
projectHelper.attachArtifact( project, "nbm-file", null, nbmfile );
}
catch ( IOException ex )
{
throw new MojoExecutionException( "Cannot copy nbm to build directory", ex );
}
}