@@ -26,6 +26,8 @@ public class MavenWrapperDownloader
2626{
2727 private static final String WRAPPER_VERSION = "@project.version@" ;
2828
29+ private static final boolean VERBOSE = Boolean .parseBoolean ( System .getenv ( "MVNW_VERBOSE" ) );
30+
2931 /**
3032 * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
3133 */
@@ -51,9 +53,9 @@ public class MavenWrapperDownloader
5153
5254 public static void main ( String args [] )
5355 {
54- System . out . println ( "- Downloader started" );
56+ log ( " - Downloader started" );
5557 File baseDirectory = new File ( args [0 ] );
56- System . out . println ( "- Using base directory: " + baseDirectory .getAbsolutePath () );
58+ log ( " - Using base directory: " + baseDirectory .getAbsolutePath () );
5759
5860 // If the maven-wrapper.properties exists, read it and check if it contains a custom
5961 // wrapperUrl parameter.
@@ -71,7 +73,7 @@ public static void main( String args[] )
7173 }
7274 catch ( IOException e )
7375 {
74- System .out .println ( "- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" );
76+ System .err .println ( " - ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" );
7577 }
7678 finally
7779 {
@@ -88,27 +90,27 @@ public static void main( String args[] )
8890 }
8991 }
9092 }
91- System . out . println ( "- Downloading from: " + url );
93+ log ( " - Downloading from: " + url );
9294
9395 File outputFile = new File ( baseDirectory .getAbsolutePath (), MAVEN_WRAPPER_JAR_PATH );
9496 if ( !outputFile .getParentFile ().exists () )
9597 {
9698 if ( !outputFile .getParentFile ().mkdirs () )
9799 {
98- System .out .println ( "- ERROR creating output directory '" + outputFile .getParentFile ().getAbsolutePath ()
100+ System .err .println ( "- ERROR creating output directory '" + outputFile .getParentFile ().getAbsolutePath ()
99101 + "'" );
100102 }
101103 }
102- System . out . println ( "- Downloading to: " + outputFile .getAbsolutePath () );
104+ log ( " - Downloading to: " + outputFile .getAbsolutePath () );
103105 try
104106 {
105107 downloadFileFromURL ( url , outputFile );
106- System . out . println ( "Done" );
108+ log ( "Done" );
107109 System .exit ( 0 );
108110 }
109111 catch ( Throwable e )
110112 {
111- System .out .println ( "- Error downloading" );
113+ System .err .println ( "- Error downloading" );
112114 e .printStackTrace ();
113115 System .exit ( 1 );
114116 }
@@ -139,4 +141,12 @@ protected PasswordAuthentication getPasswordAuthentication()
139141 rbc .close ();
140142 }
141143
144+ private static void log ( String msg )
145+ {
146+ if ( VERBOSE )
147+ {
148+ System .out .println ( msg );
149+ }
150+ }
151+
142152}
0 commit comments