Author: aheritier Date: Fri Apr 13 16:59:09 2007 New Revision: 528711 URL: http://svn.apache.org/viewvc?view=rev&rev=528711 Log: Display errors stacks only with -e
Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java?view=diff&rev=528711&r1=528710&r2=528711 ============================================================================== --- maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java (original) +++ maven/maven-1/core/trunk/src/java/org/apache/maven/MavenUtils.java Fri Apr 13 16:59:09 2007 @@ -59,12 +59,11 @@ import com.werken.forehead.ForeheadClassLoader; /** - * Utilities for reading maven project descriptors, profile descriptors and - * workspace descriptors. - * + * Utilities for reading maven project descriptors, profile descriptors and workspace descriptors. + * * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a> - * + * * @todo Remove all the context creation code and make a ContextBuilder class. * @todo [RC2] split getProject (project.properties + defaults) != getPluginProject (plugin.properties only) */ @@ -81,39 +80,46 @@ /** * Create a Project object given a file descriptor. - * - * @param projectDescriptor a maven project.xml + * + * @param projectDescriptor + * a maven project.xml * @return the Maven project object for the given project descriptor - * @throws MavenException when any errors occur + * @throws MavenException + * when any errors occur */ - public static Project getProject( File projectDescriptor ) - throws MavenException + public static Project getProject( File projectDescriptor ) throws MavenException { return getProject( projectDescriptor, null ); } /** * Create a Project object given a file descriptor, and a parent context - * @param projectDescriptor The file to create the project from - * @param parentContext the parent Maven Jelly Context + * + * @param projectDescriptor + * The file to create the project from + * @param parentContext + * the parent Maven Jelly Context * @return a new Project - * @throws MavenException when any error happens. + * @throws MavenException + * when any error happens. */ - public static Project getProject( File projectDescriptor, MavenJellyContext parentContext ) - throws MavenException + public static Project getProject( File projectDescriptor, MavenJellyContext parentContext ) throws MavenException { return getProject( projectDescriptor, parentContext, true ); } /** - * Create a Project object given a file descriptor and optionally a parent Jelly - * context. - * - * @param projectDescriptor a maven project.xml [EMAIL PROTECTED] File} - * @param parentContext the parent context for the new project - * @param useParentPom whether a parent project should be respected + * Create a Project object given a file descriptor and optionally a parent Jelly context. + * + * @param projectDescriptor + * a maven project.xml [EMAIL PROTECTED] File} + * @param parentContext + * the parent context for the new project + * @param useParentPom + * whether a parent project should be respected * @return the MavenSession project object for the given project descriptor - * @throws MavenException when any errors occur + * @throws MavenException + * when any errors occur */ public static Project getProject( File projectDescriptor, MavenJellyContext parentContext, boolean useParentPom ) throws MavenException @@ -158,32 +164,33 @@ } /** - * Get a project, but not a Jelly-ised project. ie Don't evaluate the - * variables. We are doing several things when creating a POM object, the phases - * are outlined here: - * - * 1) The project.xml file is read in using betwixt which creates for us a - * Project object that, at this point, has not been run through Jelly i.e. - * no interpolation has occured yet. - * - * 2) The context for the project is created and set. So each project manages its - * own context. See the createContext() method for the details context creation - * process. - * - * 3) We check to see if the <extend> tag is being employed. If so, the parent - * project.xml file is read in. At this point we have a child and parent POM - * and the values are merged where the child's values override those of the - * parent. - * @param projectDescriptor the project file - * @param parentContext the parent context for the new project - * @param useParentPom whether a parent project should be respected + * Get a project, but not a Jelly-ised project. ie Don't evaluate the variables. We are doing several things when + * creating a POM object, the phases are outlined here: + * + * 1) The project.xml file is read in using betwixt which creates for us a Project object that, at this point, has + * not been run through Jelly i.e. no interpolation has occured yet. + * + * 2) The context for the project is created and set. So each project manages its own context. See the + * createContext() method for the details context creation process. + * + * 3) We check to see if the <extend> tag is being employed. If so, the parent project.xml file is read in. At + * this point we have a child and parent POM and the values are merged where the child's values override those of + * the parent. + * + * @param projectDescriptor + * the project file + * @param parentContext + * the parent context for the new project + * @param useParentPom + * whether a parent project should be respected * @return the project - * @throws MavenException when there are errors reading the descriptor - * @throws IOException when resolving file names and paths + * @throws MavenException + * when there are errors reading the descriptor + * @throws IOException + * when resolving file names and paths */ public static Project getNonJellyProject( File projectDescriptor, MavenJellyContext parentContext, - boolean useParentPom ) - throws MavenException, IOException + boolean useParentPom ) throws MavenException, IOException { // 1) Project project = null; @@ -197,8 +204,8 @@ } // 2) - MavenJellyContext context = MavenUtils.createContextNoDefaults( projectDescriptor.getParentFile(), - parentContext ); + MavenJellyContext context = + MavenUtils.createContextNoDefaults( projectDescriptor.getParentFile(), parentContext ); // 3) String pomToExtend = project.getExtend(); @@ -255,28 +262,36 @@ /** * This is currently used for the reactor but may be generally useful. - * - * @param directory the directory to scan for maven projects - * @param includes the pattern that matches a project that you want included - * @param excludes the pattern that matches a project that you don't want included + * + * @param directory + * the directory to scan for maven projects + * @param includes + * the pattern that matches a project that you want included + * @param excludes + * the pattern that matches a project that you don't want included * @return a {link List} of [EMAIL PROTECTED] Project}s - * @throws MavenException when anything goes wrong. + * @throws MavenException + * when anything goes wrong. */ - public static List getProjects( File directory, String includes, String excludes ) - throws MavenException + public static List getProjects( File directory, String includes, String excludes ) throws MavenException { return getProjects( directory, includes, excludes, null ); } /** * This is currently used for the reactor but may be generally useful. - * - * @param directory the directory to scan for maven projects - * @param includes Patterns to include. - * @param excludes Patterns to exclude. - * @param context the parent context + * + * @param directory + * the directory to scan for maven projects + * @param includes + * Patterns to include. + * @param excludes + * Patterns to exclude. + * @param context + * the parent context * @return a {link List} of [EMAIL PROTECTED] Project}s - * @throws MavenException when anything goes wrong. + * @throws MavenException + * when anything goes wrong. */ public static List getProjects( File directory, String includes, String excludes, MavenJellyContext context ) throws MavenException @@ -295,15 +310,16 @@ } /** - * Take the POM and interpolate the value of the project's context to create - * a new version of the POM with expanded context values. - * - * @param project the maven POM + * Take the POM and interpolate the value of the project's context to create a new version of the POM with expanded + * context values. + * + * @param project + * the maven POM * @return Jelly interpolated project. - * @throws Exception when there are errors reading FIXME + * @throws Exception + * when there are errors reading FIXME */ - public static Project getJellyProject( Project project ) - throws Exception + public static Project getJellyProject( Project project ) throws Exception { // Keep a copy of the original context MavenJellyContext originalContext = project.getContext(); @@ -334,13 +350,16 @@ /** * Get the POM with all variables resolved. - * @param project the project to resolve - * @param context the context to retrieve variables from + * + * @param project + * the project to resolve + * @param context + * the context to retrieve variables from * @return a project with no unresolved elements. - * @throws Exception if there is an error parsing the project FIXME + * @throws Exception + * if there is an error parsing the project FIXME */ - private static Project getInterpolatedPOM( Project project, JellyContext context ) - throws Exception + private static Project getInterpolatedPOM( Project project, JellyContext context ) throws Exception { String projectString = project.getProjectAsString(); Expression e = JellyUtils.decomposeExpression( projectString, context ); @@ -353,9 +372,11 @@ /** * Get a set of files from a specifed directory with a set of includes. - * - * @param directory Directory to scan. - * @param includes Comma separated list of includes. + * + * @param directory + * Directory to scan. + * @param includes + * Comma separated list of includes. * @return files */ public static String[] getFiles( File directory, String includes ) @@ -365,10 +386,13 @@ /** * Get a set of files from a specifed directory with a set of includes. - * - * @param directory Directory to scan. - * @param includes Comma separated list of includes. - * @param excludes Comma separated list of excludes. + * + * @param directory + * Directory to scan. + * @param includes + * Comma separated list of includes. + * @param excludes + * Comma separated list of excludes. * @return files */ public static String[] getFiles( File directory, String includes, String excludes ) @@ -401,22 +425,21 @@ } /** - * Take a dominant and recessive Map and merge the key:value - * pairs where the recessive Map may add key:value pairs to the dominant - * Map but may not override any existing key:value pairs. - * - * If we have two Maps, a dominant and recessive, and - * their respective keys are as follows: - * - * dominantMapKeys = { a, b, c, d, e, f } - * recessiveMapKeys = { a, b, c, x, y, z } - * + * Take a dominant and recessive Map and merge the key:value pairs where the recessive Map may add key:value pairs + * to the dominant Map but may not override any existing key:value pairs. + * + * If we have two Maps, a dominant and recessive, and their respective keys are as follows: + * + * dominantMapKeys = { a, b, c, d, e, f } recessiveMapKeys = { a, b, c, x, y, z } + * * Then the result should be the following: - * + * * resultantKeys = { a, b, c, d, e, f, x, y, z } - * - * @param dominantMap Dominant Map. - * @param recessiveMap Recessive Map. + * + * @param dominantMap + * Dominant Map. + * @param recessiveMap + * Recessive Map. * @return The result map with combined dominant and recessive values. */ public static Map mergeMaps( Map dominantMap, Map recessiveMap ) @@ -445,8 +468,9 @@ // Create the set of keys that will be contributed by the // recessive Map by subtracting the intersection of keys // from the recessive Map's keys. - Collection contributingRecessiveKeys = CollectionUtils.subtract( recessiveMapKeys, CollectionUtils - .intersection( dominantMapKeys, recessiveMapKeys ) ); + Collection contributingRecessiveKeys = + CollectionUtils.subtract( recessiveMapKeys, + CollectionUtils.intersection( dominantMapKeys, recessiveMapKeys ) ); result.putAll( dominantMap ); @@ -462,11 +486,11 @@ } /** - * Take a series of <code>Map</code>s and merge - * them where the ordering of the array from 0..n - * is the dominant order. - * - * @param maps An array of Maps to merge. + * Take a series of <code>Map</code>s and merge them where the ordering of the array from 0..n is the dominant + * order. + * + * @param maps + * An array of Maps to merge. * @return Map The result Map produced after the merging process. */ public static Map mergeMaps( Map[] maps ) @@ -496,7 +520,9 @@ /** * Load the build.properties file for a project. - * @param directory the directory of the project + * + * @param directory + * the directory of the project * @return the properties */ private static Properties loadProjectBuildProperties( File directory ) @@ -510,7 +536,9 @@ /** * Load the project.properties file for a project. - * @param directory the directory of the project + * + * @param directory + * the directory of the project * @return the properties */ private static Properties loadProjectProperties( File directory ) @@ -524,11 +552,10 @@ /** * Create a jelly context given a descriptor directory. - * - * @param descriptorDirectory The directory from which to pull the standard maven - * properties files from. - * @return The generated maven based on the contents of the standard maven - * properties files. + * + * @param descriptorDirectory + * The directory from which to pull the standard maven properties files from. + * @return The generated maven based on the contents of the standard maven properties files. */ public static MavenJellyContext createContext( File descriptorDirectory ) { @@ -536,15 +563,14 @@ } /** - * Create a jelly context given a descriptor directory and parent - * jelly context. - * - * @param descriptorDirectory The directory from which to pull the standard maven - * properties files from. - * @param parentContext The parent jelly context. + * Create a jelly context given a descriptor directory and parent jelly context. + * + * @param descriptorDirectory + * The directory from which to pull the standard maven properties files from. + * @param parentContext + * The parent jelly context. * @todo should premerge driver, etc if they are being kept - * @return The generated maven based on the contents of the standard maven - * properties files. + * @return The generated maven based on the contents of the standard maven properties files. */ public static MavenJellyContext createContext( File descriptorDirectory, MavenJellyContext parentContext ) { @@ -554,15 +580,14 @@ } /** - * Create a jelly context given a descriptor directory and parent - * jelly context, but don't apply any defaults. - * - * @param descriptorDirectory The directory from which to pull the standard maven - * properties files from. - * @param parentContext The parent jelly context. + * Create a jelly context given a descriptor directory and parent jelly context, but don't apply any defaults. + * + * @param descriptorDirectory + * The directory from which to pull the standard maven properties files from. + * @param parentContext + * The parent jelly context. * @todo should premerge driver, etc if they are being kept - * @return The generated maven based on the contents of the standard maven - * properties files. + * @return The generated maven based on the contents of the standard maven properties files. */ private static MavenJellyContext createContextNoDefaults( File descriptorDirectory, MavenJellyContext parentContext ) { @@ -578,15 +603,12 @@ Properties projectProperties = loadProjectProperties( descriptorDirectory ); Properties projectBuildProperties = loadProjectBuildProperties( descriptorDirectory ); - Properties driverProperties = loadProperties( MavenUtils.class - .getResourceAsStream( MavenConstants.DRIVER_PROPERTIES ) ); + Properties driverProperties = + loadProperties( MavenUtils.class.getResourceAsStream( MavenConstants.DRIVER_PROPERTIES ) ); - Map result = MavenUtils.mergeMaps( new Map[] { - systemProperties, - userBuildProperties, - projectBuildProperties, - projectProperties, - driverProperties } ); + Map result = + MavenUtils.mergeMaps( new Map[] { systemProperties, userBuildProperties, projectBuildProperties, + projectProperties, driverProperties } ); MavenJellyContext context; @@ -602,7 +624,7 @@ // Turn off inheritence so parent values are overriden context.setInherit( false ); - //integrate everything else... + // integrate everything else... MavenUtils.integrateMapInContext( result, context ); // Turn inheritance back on to make the parent's values visible. @@ -616,15 +638,16 @@ /** * Apply default settings. - * - * @param context Jelly context to apply the defaults. + * + * @param context + * Jelly context to apply the defaults. */ private static void applyDefaults( MavenJellyContext context ) { - Properties defaultProperties = loadProperties( MavenUtils.class - .getResourceAsStream( MavenConstants.DEFAULTS_PROPERTIES ) ); + Properties defaultProperties = + loadProperties( MavenUtils.class.getResourceAsStream( MavenConstants.DEFAULTS_PROPERTIES ) ); - //integrate defaults... + // integrate defaults... MavenUtils.integrateMapInContext( defaultProperties, context ); // deliberately use the original base directory for these variables @@ -632,12 +655,13 @@ } /** - * Integrate a Map of key:value pairs into a <code>MavenJellyContext</code>. - * The values in the Map may be <code>CompositeExpression</code>s that need - * to be evaluated before being placed into the context. - * - * @param map Map to integrate into the provided jelly context. - * @param context Jelly context to integrate the map into. + * Integrate a Map of key:value pairs into a <code>MavenJellyContext</code>. The values in the Map may be + * <code>CompositeExpression</code>s that need to be evaluated before being placed into the context. + * + * @param map + * Map to integrate into the provided jelly context. + * @param context + * Jelly context to integrate the map into. */ public static void integrateMapInContext( Map map, MavenJellyContext context ) { @@ -688,8 +712,9 @@ /** * Load properties from a <code>File</code>. - * - * @param file Propertie file to load. + * + * @param file + * Propertie file to load. * @return The loaded Properties. */ private static Properties loadProperties( File file ) @@ -729,8 +754,9 @@ /** * Load properties from an <code>InputStream</code>. - * - * @param is InputStream from which load properties. + * + * @param is + * InputStream from which load properties. * @return The loaded Properties. */ private static Properties loadProperties( InputStream is ) @@ -776,8 +802,8 @@ private static ResourceBundle messages; /** - * Load MavenSession user messages from a resource bundle given the - * user's locale. + * Load MavenSession user messages from a resource bundle given the user's locale. + * * @todo Move locale tools into their own class. */ private static void loadMessages() @@ -797,8 +823,9 @@ /** * Retrieve a user message. - * - * @param messageId Id of message type to use. + * + * @param messageId + * Id of message type to use. * @return Message for the user's locale. */ public static String getMessage( String messageId ) @@ -808,9 +835,11 @@ /** * Retrieve a user message. - * - * @param messageId Id of message type to use. - * @param variable Value to substitute for ${1} in the given message. + * + * @param messageId + * Id of message type to use. + * @param variable + * Value to substitute for ${1} in the given message. * @return Message for the user's locale. */ public static String getMessage( String messageId, Object variable ) @@ -840,13 +869,16 @@ /** * Resolve directory against a base directory if it is not already absolute. - * @param basedir the base directory for relative paths - * @param dir the directory to resolve - * @throws IOException if canonical path fails + * + * @param basedir + * the base directory for relative paths + * @param dir + * the directory to resolve + * @throws IOException + * if canonical path fails * @return the canonical path of the directory if not absolute */ - public static String makeAbsolutePath( File basedir, String dir ) - throws IOException + public static String makeAbsolutePath( File basedir, String dir ) throws IOException { File f = new File( dir ); if ( ( f.isAbsolute() ) ) @@ -861,13 +893,16 @@ /** * Convert an absolute path to a relative path if it is under a given base directory. - * @param basedir the base directory for relative paths - * @param path the directory to resolve + * + * @param basedir + * the base directory for relative paths + * @param path + * the directory to resolve * @return the relative path - * @throws IOException if canonical path fails + * @throws IOException + * if canonical path fails */ - public static String makeRelativePath( File basedir, String path ) - throws IOException + public static String makeRelativePath( File basedir, String path ) throws IOException { String canonicalBasedir = basedir.getCanonicalPath(); File pathFile = new File( path ); @@ -904,7 +939,9 @@ /** * Get a list of goals from a CSV list. - * @param goalCsv the goals + * + * @param goalCsv + * the goals * @return the list of goal names */ public static List getGoalListFromCsv( String goalCsv ) @@ -920,7 +957,9 @@ /** * Debugging function. - * @param classLoader the class loader + * + * @param classLoader + * the class loader */ public static void displayClassLoaderContents( ForeheadClassLoader classLoader ) { @@ -941,8 +980,10 @@ } } - public static void displayThrowable( Throwable t, boolean displayStackTrace ) + public static void displayThrowable( Throwable t ) { + LOGGER.error( MavenUtils.getMessage( "line" ) ); + LOGGER.error( MavenUtils.getMessage( "build.errors.stack" ) ); Throwable localThrowable = t; while ( localThrowable != null ) { @@ -956,8 +997,7 @@ LOGGER.error( getMessage( "build.jellyException.file", jellyEx.getFileName() ) ); LOGGER.error( getMessage( "build.jellyException.element", jellyEx.getElementName() ) ); LOGGER.error( getMessage( "build.jellyException.line", Integer.toString( jellyEx.getLineNumber() ) ) ); - LOGGER - .error( getMessage( "build.jellyException.column", Integer.toString( jellyEx.getColumnNumber() ) ) ); + LOGGER.error( getMessage( "build.jellyException.column", Integer.toString( jellyEx.getColumnNumber() ) ) ); } else if ( localThrowable.getLocalizedMessage() != null ) LOGGER.error( getMessage( "exception.cause" ) + localThrowable.getLocalizedMessage() ); @@ -967,10 +1007,7 @@ localThrowable = localThrowable.getCause(); } - if ( displayStackTrace ) - { - LOGGER.error( "" ); - LOGGER.error( getMessage( "build.stacktrace" ), t ); - } + LOGGER.error( "" ); + LOGGER.error( getMessage( "build.stacktrace" ), t ); } } Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java URL: http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java?view=diff&rev=528711&r1=528710&r2=528711 ============================================================================== --- maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java (original) +++ maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java Fri Apr 13 16:59:09 2007 @@ -64,18 +64,15 @@ import org.apache.maven.werkz.UnattainableGoalException; /** - * The CLI wrapper for controlling MavenSession processes which are - * encapsulated in the MavenSession bean. - * + * The CLI wrapper for controlling MavenSession processes which are encapsulated in the MavenSession bean. + * * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> - * + * * @version $Id$ - * - * @todo Separate the computation of the available goals from the display - * of the goals. The goal computation logic needs to be moved - * out of this class and be placed in MavenSession.java proper. - * @todo All logging needs to be done via commons-logging. No - * System.err.* and Jelly needs to be taught to take a + * + * @todo Separate the computation of the available goals from the display of the goals. The goal computation logic needs + * to be moved out of this class and be placed in MavenSession.java proper. + * @todo All logging needs to be done via commons-logging. No System.err.* and Jelly needs to be taught to take a * logger. In an attempt to isolate everything in MavenSession.java. */ public class App @@ -209,8 +206,9 @@ /** * Main CLI entry point for MavenSession. - * - * @param args CLI arguments. + * + * @param args + * CLI arguments. */ public static void main( String[] args ) { @@ -221,9 +219,10 @@ /** * Format a time string. - * - * @param ms Duration in ms. - * @return String The formatted time string. + * + * @param ms + * Duration in ms. + * @return String The formatted time string. */ protected static String formatTime( long ms ) { @@ -234,7 +233,7 @@ if ( min > 0 ) { return min + MavenUtils.getMessage( "formatTime.minutes" ) + secs - + MavenUtils.getMessage( "formatTime.seconds" ); + + MavenUtils.getMessage( "formatTime.seconds" ); } else { @@ -261,9 +260,11 @@ /** * Perform main operations in a non-static method. - * - * @param args Arguments passed in from main(). - * @param fullStart Date the mavenSession process was started. + * + * @param args + * Arguments passed in from main(). + * @param fullStart + * Date the mavenSession process was started. */ public void doMain( String[] args, Date fullStart ) { @@ -310,14 +311,16 @@ { failed = true; displayBuildFailed(); - MavenUtils.displayThrowable( e, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( e ); returnCode = RC_FAILED_DEPENDENCY; } catch ( ChecksumVerificationException e ) { failed = true; displayBuildFailed(); - MavenUtils.displayThrowable( e, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( e ); returnCode = RC_FAILED_DEPENDENCY; } catch ( UnknownGoalException e ) @@ -332,14 +335,16 @@ failed = true; displayBuildFailed(); LOGGER.error( MavenUtils.getMessage( "build.noSuchGoalException" ) ); - MavenUtils.displayThrowable( e, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( e ); returnCode = RC_NO_GOAL; } catch ( RepoConfigException e ) { failed = true; displayBuildFailed(); - MavenUtils.displayThrowable( e, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( e ); returnCode = RC_BAD_REPO; } catch ( NoActionDefinitionException e ) @@ -348,7 +353,8 @@ displayBuildFailed(); LOGGER.error( MavenUtils.getMessage( "build.internalError" ) ); LOGGER.error( MavenUtils.getMessage( "build.noActionDefinitionException", e.getGoal().getName() ) ); - MavenUtils.displayThrowable( e, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( e ); displayBugReportHelp(); returnCode = RC_EMPTY_GOAL; } @@ -356,7 +362,8 @@ { failed = true; displayBuildFailed(); - MavenUtils.displayThrowable( e, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( e ); if ( e.getCause() instanceof JellyException ) { returnCode = RC_JELLY_FAILED; @@ -370,7 +377,8 @@ { failed = true; displayBuildFailed(); - MavenUtils.displayThrowable( e, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( e ); displayBugReportHelp(); returnCode = RC_BAD_JELLY; } @@ -378,7 +386,8 @@ { failed = true; displayBuildFailed(); - MavenUtils.displayThrowable( e, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( e ); if ( MavenUtils.MAVEN_UNKNOWN_ERROR.equals( e.getMessage() ) ) { displayBugReportHelp(); @@ -390,7 +399,8 @@ { failed = true; displayBuildFailed(); - MavenUtils.displayThrowable( t, displayStackTrace ); + if ( displayStackTrace ) + MavenUtils.displayThrowable( t ); displayBugReportHelp(); returnCode = RC_OTHER_FAILURE; } @@ -410,14 +420,14 @@ System.gc(); Runtime r = Runtime.getRuntime(); LOGGER.warn( MavenUtils.getMessage( "build.final.memory", ( ( r.totalMemory() - r.freeMemory() ) / mb ) + "M/" - + ( r.totalMemory() / mb ) + "M" ) ); + + ( r.totalMemory() / mb ) + "M" ) ); LOGGER.warn( MavenUtils.getMessage( "line" ) ); exit( returnCode ); } /** * Retrieve the Jelly rootContext. - * + * * @return The Jelly rootContext. */ public MavenJellyContext getRootContext() @@ -425,19 +435,20 @@ return rootContext; } - /** Perform initialization. - * - * @param args The command-line arguments. - * - * @throws ParseException If there is an error parsing the - * command-line. - * @throws IOException If there is an error while - * reading the project descriptor. - * @throws MalformedURLException If any of the the URLs denoting - * the local or remote repositories is malformed. + /** + * Perform initialization. + * + * @param args + * The command-line arguments. + * + * @throws ParseException + * If there is an error parsing the command-line. + * @throws IOException + * If there is an error while reading the project descriptor. + * @throws MalformedURLException + * If any of the the URLs denoting the local or remote repositories is malformed. */ - public void initialize( String[] args ) - throws ParseException, MalformedURLException, IOException + public void initialize( String[] args ) throws ParseException, MalformedURLException, IOException { setCli( CLIManager.parse( args ) ); @@ -448,8 +459,7 @@ } /** - * Setup any system properties that have been specified on - * the CLI. + * Setup any system properties that have been specified on the CLI. */ public void initializeSystemProperties() { @@ -466,8 +476,9 @@ /** * Set Jelly rootContext. - * - * @param rootContext The mavenSession jelly rootContext. + * + * @param rootContext + * The mavenSession jelly rootContext. */ public void setRootContext( MavenJellyContext rootContext ) { @@ -475,8 +486,7 @@ } /** - * Display helpful information regarding - * all documented goals. + * Display helpful information regarding all documented goals. */ protected void displayGoals() { @@ -485,17 +495,20 @@ /** * Display helpful information regarding all documented goals. - * @param pluginOnly show information for the given plugin only - * @param plugin plugin to show info for + * + * @param pluginOnly + * show information for the given plugin only + * @param plugin + * plugin to show info for */ protected void displayGoals( boolean pluginOnly, String plugin ) { String title = MavenUtils.getMessage( "displayGoals.title" ); if ( pluginOnly ) { - title = ( plugin == null ? MavenUtils.getMessage( "displayGoals.title.pluginOnly.null" ) : MavenUtils - .getMessage( "displayGoals.title.pluginOnly.notNull" ) - + plugin ); + title = + ( plugin == null ? MavenUtils.getMessage( "displayGoals.title.pluginOnly.null" ) + : MavenUtils.getMessage( "displayGoals.title.pluginOnly.notNull" ) + plugin ); } LOGGER.info( title ); LOGGER.info( format( "", title.length(), '=' ) ); @@ -506,21 +519,26 @@ /** * To allow subclasses stop the app from exiting - * @param status the value to exit with + * + * @param status + * the value to exit with */ protected void exit( int status ) { System.exit( status ); } - /** Produce a formatted/padded string. - * - * @param orig The string to format. - * @param width The width of the resulting formatted string. - * @param pad The trailing pad character. - * - * @return The formatted string, or the original string - * if the length is already >= <code>width</code>. + /** + * Produce a formatted/padded string. + * + * @param orig + * The string to format. + * @param width + * The width of the resulting formatted string. + * @param pad + * The trailing pad character. + * + * @return The formatted string, or the original string if the length is already >= <code>width</code>. */ protected String format( String orig, int width, char pad ) { @@ -543,7 +561,7 @@ /** * Get the CLI parser. - * + * * @return CommandLine The command line parser. */ protected CommandLine getCli() @@ -552,13 +570,12 @@ } /** - * Initialize the IO streams. - * - * @throws IOException on error creating XML output and handling System.err - * and out + * Initialize the IO streams. + * + * @throws IOException + * on error creating XML output and handling System.err and out */ - protected void initializeRootContext() - throws IOException + protected void initializeRootContext() throws IOException { this.writer = new OutputStreamWriter( System.out ); XMLOutput output = XMLOutput.createXMLOutput( writer, false ); @@ -654,8 +671,9 @@ /** * Set the cli parser. - * - * @param commandLine The command line parser. + * + * @param commandLine + * The command line parser. */ protected void setCli( CommandLine commandLine ) { @@ -663,13 +681,14 @@ } /** - * Nicely wraps a message for console output, using a word BreakIterator - * instance to determine wrapping breaks. - * - * @param msg the string message for the console - * @param wrapIndent the number of characters to indent all lines - * after the first one - * @param lineWidth the console width that determines where to wrap + * Nicely wraps a message for console output, using a word BreakIterator instance to determine wrapping breaks. + * + * @param msg + * the string message for the console + * @param wrapIndent + * the number of characters to indent all lines after the first one + * @param lineWidth + * the console width that determines where to wrap * @return the message wrapped for the console */ protected String wrapConsoleMessage( String msg, int wrapIndent, int lineWidth ) @@ -694,8 +713,7 @@ } /** - * Customize the log4j configuration from properties - * (read in system, user or project scope). + * Customize the log4j configuration from properties (read in system, user or project scope). */ private void customizeLogging() { @@ -724,16 +742,13 @@ StringBuffer sb = new StringBuffer(); sb.append( MavenUtils.getMessage( "displayBugReportHelp.line1" ) ).append( '\n' ); sb.append( MavenUtils.getMessage( "displayBugReportHelp.line2" ) ).append( '\n' ); - sb.append( MavenUtils.getMessage( "displayBugReportHelp.line3", LINKS_PROPERTIES.get( "faqUrl" ) ) ) - .append( '\n' ); + sb.append( MavenUtils.getMessage( "displayBugReportHelp.line3", LINKS_PROPERTIES.get( "faqUrl" ) ) ).append( + '\n' ); sb.append( MavenUtils.getMessage( "displayBugReportHelp.line4" ) ).append( '\n' ); - sb - .append( - MavenUtils - .getMessage( "displayBugReportHelp.line5", LINKS_PROPERTIES.get( "usersMailingListUrl" ) ) ) - .append( '\n' ); - sb.append( MavenUtils.getMessage( "displayBugReportHelp.line6", LINKS_PROPERTIES.get( "issueTrackingUrl" ) ) ) - .append( '\n' ); + sb.append( MavenUtils.getMessage( "displayBugReportHelp.line5", LINKS_PROPERTIES.get( "usersMailingListUrl" ) ) ).append( + '\n' ); + sb.append( MavenUtils.getMessage( "displayBugReportHelp.line6", LINKS_PROPERTIES.get( "issueTrackingUrl" ) ) ).append( + '\n' ); sb.append( MavenUtils.getMessage( "displayBugReportHelp.line7" ) ); LOGGER.info( "" ); @@ -743,10 +758,13 @@ /** * Display helpful information about the given default goal. - * - * @param goalName goal to show info for - * @param goalDescription the description of the goal - * @param newLine whether to append a newline + * + * @param goalName + * goal to show info for + * @param goalDescription + * the description of the goal + * @param newLine + * whether to append a newline */ private void displayDefaultGoal( String goalName, String goalDescription, boolean newLine ) { @@ -771,9 +789,11 @@ /** * Display helpful information about the given goal. - * - * @param goalName goal to show info for - * @param goalDescription the description of the goal + * + * @param goalName + * goal to show info for + * @param goalDescription + * the description of the goal */ private void displayGoal( String goalName, String goalDescription ) { @@ -789,10 +809,13 @@ /** * Display helpful information regarding all documented goals. - * - * @param pluginOnly show information for the given plugin only - * @param plugin plugin to show info for - * @param goals the set of goals + * + * @param pluginOnly + * show information for the given plugin only + * @param plugin + * plugin to show info for + * @param goals + * the set of goals */ private void displayGoals( boolean pluginOnly, String plugin, Set goals ) { @@ -883,9 +906,11 @@ LOGGER.info( "" ); } - /** Display goals without descriptions. - * - * @param list List of undocument goal names. + /** + * Display goals without descriptions. + * + * @param list + * List of undocument goal names. */ private void displayGoalsWithoutDescriptions( List list ) { @@ -962,10 +987,11 @@ /** * Display the plugin help if the option is present, then exit. - * @throws MavenException when anything goes wrong + * + * @throws MavenException + * when anything goes wrong */ - private void displayPluginHelp() - throws MavenException + private void displayPluginHelp() throws MavenException { if ( getCli().hasOption( OPT_DISPLAY_PLUGIN_HELP ) ) { @@ -988,10 +1014,11 @@ /** * Display the project help if the option is present, then exit. - * @throws MavenException when anything goes wrong + * + * @throws MavenException + * when anything goes wrong */ - private void displayProjectHelp() - throws MavenException + private void displayProjectHelp() throws MavenException { if ( getCli().hasOption( OPT_DISPLAY_USAGE ) ) { @@ -1035,11 +1062,12 @@ } /** - * From the CWD search through the directory hierarchy for - * an XML-based POM. - * - * @param start The starting directory for the POM search. - * @param suffix The suffix for the file to be searched for. + * From the CWD search through the directory hierarchy for an XML-based POM. + * + * @param start + * The starting directory for the POM search. + * @param suffix + * The suffix for the file to be searched for. * @return The found project.xml file. */ private File find( File start, String suffix ) @@ -1056,10 +1084,10 @@ } /** - * From the CWD search through the directory hierarchy for - * an XML-based POM. - * - * @param filename The filename to find. + * From the CWD search through the directory hierarchy for an XML-based POM. + * + * @param filename + * The filename to find. * @return The found file. */ private File find( String filename ) @@ -1070,12 +1098,12 @@ /** * Get the project descriptor file. - * + * * @return The project descriptor file. - * @throws IOException when the project.xml parent can't be resolved + * @throws IOException + * when the project.xml parent can't be resolved */ - private File getDescriptorFile() - throws IOException + private File getDescriptorFile() throws IOException { File descriptorFile = null; String descriptorName = null; @@ -1121,7 +1149,9 @@ /** * Intialize main and exit if failures occur - * @param args command line args + * + * @param args + * command line args */ private void initializeMain( String[] args ) { @@ -1158,10 +1188,11 @@ /** * Initialize the mavenSession bean. - * @throws IOException when the descriptor file parent can't be resolved + * + * @throws IOException + * when the descriptor file parent can't be resolved */ - private void initializeMavenSession() - throws IOException + private void initializeMavenSession() throws IOException { // Even though the rootProject contains the rootContext we set both in // the even that there is no rootProject and the user is requesting goals @@ -1176,8 +1207,9 @@ /** * Set a property based upon a commandline <code>name=value</code> string. - * - * @param defStr The <code>name=value</code> string. + * + * @param defStr + * The <code>name=value</code> string. */ private void setCliProperty( String defStr ) { @@ -1204,10 +1236,13 @@ /** * Reformat a message to display on the console. - * - * @param msg the message to display - * @param wrapIndent indent - * @param lineWidth line width + * + * @param msg + * the message to display + * @param wrapIndent + * indent + * @param lineWidth + * line width * @return String */ private String wrapConsoleLine( String msg, int wrapIndent, int lineWidth ) @@ -1242,7 +1277,7 @@ // start next line buf.append( LS ); - //pad with spaces to create indent + // pad with spaces to create indent for ( int i = 0; ( i != wrapIndent ) && ( i < lineWidth ); i++ ) { buf.append( pad ); @@ -1252,7 +1287,7 @@ // of the string not already appended msg = msg.substring( currentPos ); - //reset the text for another go + // reset the text for another go bIter.setText( msg ); } @@ -1269,9 +1304,6 @@ { LOGGER.error( MavenUtils.getMessage( "line" ) ); LOGGER.error( MavenUtils.getMessage( "build.failed" ) ); - LOGGER.error( MavenUtils.getMessage( "line" ) ); - LOGGER.error( MavenUtils.getMessage( "build.errors.stack" ) ); - } }