Fixed coding style and removed system.err
diff --git a/src/main/java/org/apache/netbeans/nbm/CreateClusterMojo.java b/src/main/java/org/apache/netbeans/nbm/CreateClusterMojo.java
index 8f64793..96cd934 100644
--- a/src/main/java/org/apache/netbeans/nbm/CreateClusterMojo.java
+++ b/src/main/java/org/apache/netbeans/nbm/CreateClusterMojo.java
@@ -40,122 +40,139 @@
import org.codehaus.plexus.util.io.InputStreamFacade;
/**
- * Create the NetBeans module clusters from reactor. Semi-deprecated; used only
- * for standalone modules and "suites".
+ * Create the NetBeans module clusters from reactor. Semi-deprecated; used only for standalone modules and "suites".
*
* @author Milos Kleint
*/
-@Mojo(name = "cluster", aggregator = true, requiresDependencyResolution = ResolutionScope.RUNTIME)
+@Mojo( name = "cluster", aggregator = true, requiresDependencyResolution = ResolutionScope.RUNTIME )
public class CreateClusterMojo
- extends AbstractNbmMojo {
+ extends AbstractNbmMojo
+{
/**
- * NetBeans module assembly build directory. directory where the the
- * NetBeans jar and nbm file get constructed.
+ * NetBeans module assembly build directory. directory where the the NetBeans jar and nbm file get constructed.
*/
- @Parameter(defaultValue = "${project.build.directory}/nbm", property = "maven.nbm.buildDir")
+ @Parameter( defaultValue = "${project.build.directory}/nbm", property = "maven.nbm.buildDir" )
protected File nbmBuildDir;
/**
- * NetBeans module's cluster. Replaces the cluster element in module
- * descriptor.
+ * NetBeans module's cluster. Replaces the cluster element in module descriptor.
*
*/
- @Parameter(required = true, defaultValue = "extra")
+ @Parameter( required = true, defaultValue = "extra" )
protected String cluster;
/**
* directory where the the NetBeans cluster will be created.
*/
- @Parameter(defaultValue = "${project.build.directory}/netbeans_clusters", required = true)
+ @Parameter( defaultValue = "${project.build.directory}/netbeans_clusters", required = true )
protected File clusterBuildDir;
/**
- * If the executed project is a reactor project, this will contains the full
- * list of projects in the reactor.
+ * If the executed project is a reactor project, this will contains the full list of projects in the reactor.
*/
- @Parameter(required = true, readonly = true, property = "reactorProjects")
+ @Parameter( required = true, readonly = true, property = "reactorProjects" )
private List<MavenProject> reactorProjects;
public void execute()
- throws MojoExecutionException, MojoFailureException {
+ throws MojoExecutionException, MojoFailureException
+ {
Project antProject = registerNbmAntTasks();
- if (!clusterBuildDir.exists()) {
+ if ( !clusterBuildDir.exists() )
+ {
clusterBuildDir.mkdirs();
}
- if (reactorProjects != null && reactorProjects.size() > 0) {
- for (MavenProject proj : reactorProjects) {
+ if ( reactorProjects != null && reactorProjects.size() > 0 )
+ {
+ for ( MavenProject proj : reactorProjects )
+ {
- File nbmDir = new File(nbmBuildDir, "clusters");
- if (nbmDir.exists()) {
- Copy copyTask = (Copy) antProject.createTask("copy");
- copyTask.setTodir(clusterBuildDir);
- copyTask.setOverwrite(true);
+ File nbmDir = new File( nbmBuildDir, "clusters" );
+ if ( nbmDir.exists() )
+ {
+ Copy copyTask = (Copy) antProject.createTask( "copy" );
+ copyTask.setTodir( clusterBuildDir );
+ copyTask.setOverwrite( true );
FileSet set = new FileSet();
- set.setDir(nbmDir);
- set.createInclude().setName("**");
- copyTask.addFileset(set);
+ set.setDir( nbmDir );
+ set.createInclude().setName( "**" );
+ copyTask.addFileset( set );
- try {
+ try
+ {
copyTask.execute();
- } catch (BuildException ex) {
- getLog().error("Cannot merge modules into cluster");
+ }
+ catch ( BuildException ex )
+ {
+ getLog().error( "Cannot merge modules into cluster" );
throw new MojoExecutionException(
- "Cannot merge modules into cluster", ex);
+ "Cannot merge modules into cluster", ex );
}
- } else {
- if ("nbm".equals(proj.getPackaging())) {
+ }
+ else
+ {
+ if ( "nbm".equals( proj.getPackaging() ) )
+ {
String error
- = "The NetBeans binary directory structure for "
- + proj.getId()
- + " is not created yet."
- + "\n Please execute 'mvn install nbm:cluster' to build all relevant projects in the reactor.";
- throw new MojoFailureException(error);
+ = "The NetBeans binary directory structure for "
+ + proj.getId()
+ + " is not created yet."
+ + "\n Please execute 'mvn install nbm:cluster' to build all relevant projects in the reactor.";
+ throw new MojoFailureException( error );
}
- if ("bundle".equals(proj.getPackaging())) {
+ if ( "bundle".equals( proj.getPackaging() ) )
+ {
Artifact art = proj.getArtifact();
- final ExamineManifest mnf = new ExamineManifest(getLog());
+ final ExamineManifest mnf = new ExamineManifest( getLog() );
- File jar = new File(proj.getBuild().getDirectory(), proj.getBuild().getFinalName() + ".jar");
- if (!jar.exists()) {
- getLog().error("Skipping " + proj.getId()
- + ". Cannot find the main artifact in output directory.");
+ File jar = new File( proj.getBuild().getDirectory(), proj.getBuild().getFinalName() + ".jar" );
+ if ( !jar.exists() )
+ {
+ getLog().error( "Skipping " + proj.getId()
+ + ". Cannot find the main artifact in output directory." );
continue;
}
- mnf.setJarFile(jar);
+ mnf.setJarFile( jar );
mnf.checkFile();
- File clusterDir = new File(clusterBuildDir, cluster);
- getLog().debug("Copying " + art.getId() + " to cluster " + cluster);
- File modules = new File(clusterDir, "modules");
+ File clusterDir = new File( clusterBuildDir, cluster );
+ getLog().debug( "Copying " + art.getId() + " to cluster " + cluster );
+ File modules = new File( clusterDir, "modules" );
modules.mkdirs();
- File config = new File(clusterDir, "config");
- File confModules = new File(config, "Modules");
+ File config = new File( clusterDir, "config" );
+ File confModules = new File( config, "Modules" );
confModules.mkdirs();
- File updateTracting = new File(clusterDir, "update_tracking");
+ File updateTracting = new File( clusterDir, "update_tracking" );
updateTracting.mkdirs();
final String cnb = mnf.getModule();
- final String cnbDashed = cnb.replace(".", "-");
- final File moduleArt = new File(modules, cnbDashed + ".jar"); //do we need the file in some canotical name pattern?
+ final String cnbDashed = cnb.replace( ".", "-" );
+ final File moduleArt = new File( modules, cnbDashed + ".jar" ); //do we need the file in some canotical name pattern?
final String specVer = mnf.getSpecVersion();
- try {
- FileUtils.copyFile(jar, moduleArt);
- final File moduleConf = new File(confModules, cnbDashed + ".xml");
- FileUtils.copyStreamToFile(new InputStreamFacade() {
- public InputStream getInputStream() throws IOException {
- return new StringInputStream(CreateClusterAppMojo.createBundleConfigFile(cnb, mnf.isBundleAutoload()), "UTF-8");
+ try
+ {
+ FileUtils.copyFile( jar, moduleArt );
+ final File moduleConf = new File( confModules, cnbDashed + ".xml" );
+ FileUtils.copyStreamToFile( new InputStreamFacade()
+ {
+ public InputStream getInputStream() throws IOException
+ {
+ return new StringInputStream( CreateClusterAppMojo.createBundleConfigFile( cnb, mnf.isBundleAutoload() ), "UTF-8" );
}
- }, moduleConf);
- FileUtils.copyStreamToFile(new InputStreamFacade() {
- public InputStream getInputStream() throws IOException {
- return new StringInputStream(CreateClusterAppMojo.createBundleUpdateTracking(cnb, moduleArt, moduleConf, specVer), "UTF-8");
+ }, moduleConf );
+ FileUtils.copyStreamToFile( new InputStreamFacade()
+ {
+ public InputStream getInputStream() throws IOException
+ {
+ return new StringInputStream( CreateClusterAppMojo.createBundleUpdateTracking( cnb, moduleArt, moduleConf, specVer ), "UTF-8" );
}
- }, new File(updateTracting, cnbDashed + ".xml"));
- } catch (IOException exc) {
- getLog().error(exc);
+ }, new File( updateTracting, cnbDashed + ".xml" ) );
+ }
+ catch ( IOException exc )
+ {
+ getLog().error( exc );
}
}
@@ -163,22 +180,30 @@
}
//in 6.1 the rebuilt modules will be cached if the timestamp is not touched.
File[] files = clusterBuildDir.listFiles();
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- File stamp = new File(files[i], ".lastModified");
- if (!stamp.exists()) {
- try {
+ for ( int i = 0; i < files.length; i++ )
+ {
+ if ( files[i].isDirectory() )
+ {
+ File stamp = new File( files[i], ".lastModified" );
+ if ( !stamp.exists() )
+ {
+ try
+ {
stamp.createNewFile();
- } catch (IOException ex) {
+ }
+ catch ( IOException ex )
+ {
ex.printStackTrace();
}
}
- stamp.setLastModified(new Date().getTime());
+ stamp.setLastModified( new Date().getTime() );
}
}
- getLog().info("Created NetBeans module cluster(s) at " + clusterBuildDir);
- } else {
- throw new MojoExecutionException("This goal only makes sense on reactor projects.");
+ getLog().info( "Created NetBeans module cluster(s) at " + clusterBuildDir );
+ }
+ else
+ {
+ throw new MojoExecutionException( "This goal only makes sense on reactor projects." );
}
}
}
diff --git a/src/main/java/org/apache/netbeans/nbm/RunNetBeansMojo.java b/src/main/java/org/apache/netbeans/nbm/RunNetBeansMojo.java
index 79860fa..27ce2d5 100644
--- a/src/main/java/org/apache/netbeans/nbm/RunNetBeansMojo.java
+++ b/src/main/java/org/apache/netbeans/nbm/RunNetBeansMojo.java
@@ -18,7 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -40,9 +39,9 @@
import org.codehaus.plexus.util.cli.StreamConsumer;
/**
- * Run NetBeans IDE with additional custom module clusters,
- * to be used in conjunction with nbm:cluster.
- * Semi-deprecated; used only for standalone modules and "suites".
+ * Run NetBeans IDE with additional custom module clusters, to be used in conjunction with nbm:cluster. Semi-deprecated;
+ * used only for standalone modules and "suites".
+ *
* @author Milos Kleint
*
*/
@@ -52,14 +51,13 @@
{
/**
- * directory where the module(s)' NetBeans cluster(s) are located.
- * is related to nbm:cluster goal.
+ * directory where the module(s)' NetBeans cluster(s) are located. is related to nbm:cluster goal.
*/
@Parameter( required = true, defaultValue = "${project.build.directory}/netbeans_clusters" )
protected File clusterBuildDir;
/**
- * directory where the the NetBeans platform/IDE installation is,
- * denotes the root directory of NetBeans installation.
+ * directory where the the NetBeans platform/IDE installation is, denotes the root directory of NetBeans
+ * installation.
*/
@Parameter( required = true, property = "netbeans.installation" )
protected File netbeansInstallation;
@@ -69,28 +67,29 @@
@Parameter( required = true, defaultValue = "${project.build.directory}/userdir", property = "netbeans.userdir" )
protected File netbeansUserdir;
/**
- * additional command line arguments.
+ * additional command line arguments.
*/
@Parameter( property = "netbeans.run.params" )
protected String additionalArguments;
-
+
/**
- * Attach a debugger to the application JVM. If set to "true", the process will suspend and wait for a debugger to attach
- * on port 5005. If set to some other string, that string will be appended to the <code>additionalArguments</code>, allowing you to configure
- * arbitrary debug-ability options (without overwriting the other options specified through the <code>additionalArguments</code>
- * parameter).
+ * Attach a debugger to the application JVM. If set to "true", the process will suspend and wait for a debugger to
+ * attach on port 5005. If set to some other string, that string will be appended to the
+ * <code>additionalArguments</code>, allowing you to configure arbitrary debug-ability options (without overwriting
+ * the other options specified through the <code>additionalArguments</code> parameter).
+ *
* @since 3.11.1
*/
@Parameter( property = "netbeans.run.params.debug" )
- protected String debugAdditionalArguments;
+ protected String debugAdditionalArguments;
/**
- *
+ *
* @throws MojoExecutionException if an unexpected problem occurs
* @throws MojoFailureException if an expected problem occurs
*/
public void execute()
- throws MojoExecutionException, MojoFailureException
+ throws MojoExecutionException, MojoFailureException
{
netbeansUserdir.mkdirs();
@@ -98,7 +97,7 @@
if ( !clusterBuildDir.exists() || clusterBuildDir.listFiles() == null )
{
throw new MojoExecutionException(
- "No clusters to include in execution found. Please run the nbm:cluster or nbm:cluster-app goals before this one." );
+ "No clusters to include in execution found. Please run the nbm:cluster or nbm:cluster-app goals before this one." );
}
File[] fls = clusterBuildDir.listFiles();
for ( int i = 0; i < fls.length; i++ )
@@ -118,9 +117,8 @@
{
buff.deleteCharAt( buff.lastIndexOf( ":" ) );
}
-
- System.err.println(">>>>>>>>> " + buff.toString());
-
+
+ getLog().debug( "cluster path:\n" + buff.toString() );
//now check what the exec names are to figure the right XXX.clusters name
File binDir = new File( netbeansInstallation, "bin" );
@@ -147,7 +145,7 @@
if ( !appName.equals( name ) )
{
getLog().debug( "When examining executable names, found clashing results " + f.getName()
- + " " + appName );
+ + " " + appName );
}
}
}
@@ -159,12 +157,10 @@
}
//http://www.netbeans.org/issues/show_bug.cgi?id=174819
- StringReader sr =
- new StringReader( appName + "_extraclusters=\"" + buff.toString() + "\"\n" + "extraclusters=\""
- + buff.toString() + "\"\n" + "extra_clusters=\"" + buff.toString() + "\"" );
+ StringReader sr = new StringReader( appName + "_extraclusters=\"" + buff.toString() + "\"\n" + "extraclusters=\""
+ + buff.toString() + "\"\n" + "extra_clusters=\"" + buff.toString() + "\"" );
// write XXX.conf file with cluster information...
-
File etc = new File( netbeansUserdir, "etc" );
etc.mkdirs();
File confFile = new File( etc, appName + ".conf" );
@@ -182,13 +178,17 @@
{
IOUtil.close( conf );
}
-
- try (InputStream io = new FileInputStream(confFile)) {
- System.err.println(">>>>>>\n" + IOUtil.toString(io));
- }
- catch ( IOException ex )
+
+ if ( getLog().isDebugEnabled() )
{
- throw new MojoExecutionException( "Error writing " + confFile, ex );
+ try ( InputStream io = new FileInputStream( confFile ) )
+ {
+ getLog().debug( "Configuration file content:\n" + IOUtil.toString( io ) );
+ }
+ catch ( IOException ex )
+ {
+ throw new MojoExecutionException( "Error writing " + confFile, ex );
+ }
}
boolean windows = Os.isFamily( "windows" );
@@ -213,7 +213,10 @@
}
}
}
- cmdLine.addArguments( new String[] { "--console", "suppress" } );
+ cmdLine.addArguments( new String[]
+ {
+ "--console", "suppress"
+ } );
}
}
else
@@ -257,13 +260,13 @@
throw new MojoExecutionException( "Failed executing NetBeans", e );
}
}
-
+
private String getDebugAdditionalArguments()
{
- if ( "true".equals( debugAdditionalArguments ) )
+ if ( "true".equals( debugAdditionalArguments ) )
{
return "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005";
}
return debugAdditionalArguments;
- }
+ }
}