@@ -72,12 +72,14 @@ public Path createDist( WrapperConfiguration configuration )
7272 {
7373 distributionUrl = configuration .getDistribution ();
7474 }
75- Logger . info ( "Downloading Maven binary from " + distributionUrl );
75+
7676 boolean alwaysDownload = configuration .isAlwaysDownload ();
7777 boolean alwaysUnpack = configuration .isAlwaysUnpack ();
7878
7979 PathAssembler .LocalDistribution localDistribution = pathAssembler .getDistribution ( configuration );
8080
81+ Logger .info ( "Installing Maven distribution " + localDistribution .getDistributionDir ().getFileName () );
82+
8183 Path localZipFile = localDistribution .getZipFile ();
8284 boolean downloaded = false ;
8385 if ( alwaysDownload || !Files .exists ( localZipFile ) )
@@ -95,30 +97,27 @@ public Path createDist( WrapperConfiguration configuration )
9597
9698 if ( downloaded || alwaysUnpack || dirs .isEmpty () )
9799 {
98- Files . walkFileTree ( distDir . toAbsolutePath (), new SimpleFileVisitor < Path >( )
100+ for ( Path distSubDir : dirs )
99101 {
100- @ Override
101- public FileVisitResult postVisitDirectory ( Path dir , IOException exc )
102- throws IOException
102+ Logger .info ( "Deleting directory " + distSubDir .toAbsolutePath () );
103+ Files .walkFileTree ( distSubDir .toAbsolutePath (), new SimpleFileVisitor <Path >()
103104 {
104- if ( dir .getParent ().equals ( distDir ) )
105+ @ Override
106+ public FileVisitResult postVisitDirectory ( Path dir , IOException exc )
107+ throws IOException
105108 {
106- Logger .info ( "Deleting directory " + distDir .toAbsolutePath () );
107109 Files .delete ( dir );
110+ return FileVisitResult .CONTINUE ;
108111 }
109- return FileVisitResult .CONTINUE ;
110- }
111-
112- public FileVisitResult visitFile ( Path file , BasicFileAttributes attrs )
113- throws IOException
114- {
115- if ( !file .getParent ().equals ( distDir ) )
112+
113+ public FileVisitResult visitFile ( Path file , BasicFileAttributes attrs )
114+ throws IOException
116115 {
117116 Files .delete ( file );
118- }
119- return FileVisitResult . CONTINUE ;
120- };
121- } );
117+ return FileVisitResult . CONTINUE ;
118+ } ;
119+ } ) ;
120+ }
122121
123122 Logger .info ( "Unzipping " + localZipFile .toAbsolutePath () + " to " + distDir .toAbsolutePath () );
124123 unzip ( localZipFile , distDir );
@@ -128,15 +127,15 @@ public FileVisitResult visitFile( Path file, BasicFileAttributes attrs )
128127 {
129128 throw new RuntimeException ( String .format (
130129 "Maven distribution '%s' does not contain any directories. Expected to find exactly 1 directory." ,
131- distributionUrl ) );
130+ distDir ) );
132131 }
133132 setExecutablePermissions ( dirs .get ( 0 ) );
134133 }
135134 if ( dirs .size () != 1 )
136135 {
137136 throw new IllegalStateException ( String .format (
138137 "Maven distribution '%s' contains too many directories. Expected to find exactly 1 directory." ,
139- distributionUrl ) );
138+ distDir ) );
140139 }
141140 return dirs .get ( 0 );
142141 }
@@ -157,15 +156,15 @@ private void setExecutablePermissions( Path mavenHome )
157156 {
158157 return ;
159158 }
160- Path mavenCommand = mavenHome .resolve ( "bin/mvn" );
159+ Path binMvnScript = mavenHome .resolve ( "bin/mvn" );
161160 String errorMessage = null ;
162161 try
163162 {
164- ProcessBuilder pb = new ProcessBuilder ( "chmod" , "755" , mavenCommand .toString () );
163+ ProcessBuilder pb = new ProcessBuilder ( "chmod" , "755" , binMvnScript .toString () );
165164 Process p = pb .start ();
166165 if ( p .waitFor () == 0 )
167166 {
168- Logger .info ( "Set executable permissions for: " + mavenCommand .toString () );
167+ Logger .info ( "Set executable permissions for " + binMvnScript .toString () );
169168 }
170169 else
171170 {
@@ -188,8 +187,8 @@ private void setExecutablePermissions( Path mavenHome )
188187 }
189188 if ( errorMessage != null )
190189 {
191- Logger .warn ( "Could not set executable permissions for: " + mavenCommand );
192- Logger .warn ( "Please do this manually if you want to use maven ." );
190+ Logger .warn ( "Could not set executable permissions for " + binMvnScript );
191+ Logger .warn ( "Please do this manually if you want to use Maven ." );
193192 }
194193 }
195194
0 commit comments