@@ -72,12 +72,14 @@ public Path createDist( WrapperConfiguration configuration )
72
72
{
73
73
distributionUrl = configuration .getDistribution ();
74
74
}
75
- Logger . info ( "Downloading Maven binary from " + distributionUrl );
75
+
76
76
boolean alwaysDownload = configuration .isAlwaysDownload ();
77
77
boolean alwaysUnpack = configuration .isAlwaysUnpack ();
78
78
79
79
PathAssembler .LocalDistribution localDistribution = pathAssembler .getDistribution ( configuration );
80
80
81
+ Logger .info ( "Installing Maven distribution " + localDistribution .getDistributionDir ().getFileName () );
82
+
81
83
Path localZipFile = localDistribution .getZipFile ();
82
84
boolean downloaded = false ;
83
85
if ( alwaysDownload || !Files .exists ( localZipFile ) )
@@ -95,30 +97,27 @@ public Path createDist( WrapperConfiguration configuration )
95
97
96
98
if ( downloaded || alwaysUnpack || dirs .isEmpty () )
97
99
{
98
- Files . walkFileTree ( distDir . toAbsolutePath (), new SimpleFileVisitor < Path >( )
100
+ for ( Path distSubDir : dirs )
99
101
{
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 >()
103
104
{
104
- if ( dir .getParent ().equals ( distDir ) )
105
+ @ Override
106
+ public FileVisitResult postVisitDirectory ( Path dir , IOException exc )
107
+ throws IOException
105
108
{
106
- Logger .info ( "Deleting directory " + distDir .toAbsolutePath () );
107
109
Files .delete ( dir );
110
+ return FileVisitResult .CONTINUE ;
108
111
}
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
116
115
{
117
116
Files .delete ( file );
118
- }
119
- return FileVisitResult . CONTINUE ;
120
- };
121
- } );
117
+ return FileVisitResult . CONTINUE ;
118
+ } ;
119
+ } ) ;
120
+ }
122
121
123
122
Logger .info ( "Unzipping " + localZipFile .toAbsolutePath () + " to " + distDir .toAbsolutePath () );
124
123
unzip ( localZipFile , distDir );
@@ -128,15 +127,15 @@ public FileVisitResult visitFile( Path file, BasicFileAttributes attrs )
128
127
{
129
128
throw new RuntimeException ( String .format (
130
129
"Maven distribution '%s' does not contain any directories. Expected to find exactly 1 directory." ,
131
- distributionUrl ) );
130
+ distDir ) );
132
131
}
133
132
setExecutablePermissions ( dirs .get ( 0 ) );
134
133
}
135
134
if ( dirs .size () != 1 )
136
135
{
137
136
throw new IllegalStateException ( String .format (
138
137
"Maven distribution '%s' contains too many directories. Expected to find exactly 1 directory." ,
139
- distributionUrl ) );
138
+ distDir ) );
140
139
}
141
140
return dirs .get ( 0 );
142
141
}
@@ -157,15 +156,15 @@ private void setExecutablePermissions( Path mavenHome )
157
156
{
158
157
return ;
159
158
}
160
- Path mavenCommand = mavenHome .resolve ( "bin/mvn" );
159
+ Path binMvnScript = mavenHome .resolve ( "bin/mvn" );
161
160
String errorMessage = null ;
162
161
try
163
162
{
164
- ProcessBuilder pb = new ProcessBuilder ( "chmod" , "755" , mavenCommand .toString () );
163
+ ProcessBuilder pb = new ProcessBuilder ( "chmod" , "755" , binMvnScript .toString () );
165
164
Process p = pb .start ();
166
165
if ( p .waitFor () == 0 )
167
166
{
168
- Logger .info ( "Set executable permissions for: " + mavenCommand .toString () );
167
+ Logger .info ( "Set executable permissions for " + binMvnScript .toString () );
169
168
}
170
169
else
171
170
{
@@ -188,8 +187,8 @@ private void setExecutablePermissions( Path mavenHome )
188
187
}
189
188
if ( errorMessage != null )
190
189
{
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 ." );
193
192
}
194
193
}
195
194
0 commit comments