Subversion Repository Public Repository

litesoft

Diff Revisions 313 vs 314 for /trunk/Java/ScarPlus/src/com/esotericsoftware/scar/Project.java

Diff revisions: vs.
  @@ -120,7 +120,7 @@
120 120 throws IOException
121 121 {
122 122 progress( "Clean: " + this );
123 - new Paths( path( "$target$" ) ).delete();
123 + delete( path( "$target$" ) );
124 124 }
125 125
126 126 /**
  @@ -137,7 +137,7 @@
137 137 Paths classpath = classpath();
138 138 Paths source = getSource();
139 139
140 - String classesDir = Utils.mkdir( path( "$target$/classes/" ) );
140 + String classesDir = mkdir( path( "$target$/classes/" ) );
141 141
142 142 if ( source.isEmpty() )
143 143 {
  @@ -223,68 +223,57 @@
223 223 {
224 224 progress( "JAR: " + this );
225 225
226 - if ( !LOGGER.trace.isEnabled() )
227 - {
228 - return null; // todo: ...
229 - }
230 -
231 - String jarDir = Utils.mkdir( path( "$target$/jar/" ) );
226 + String jarDir = mkdir( path( "$target$/jar/" ) );
232 227
233 228 String classesDir = path( "$target$/classes/" );
234 229 new Paths( classesDir, "**/*.class" ).copyTo( jarDir );
235 230 getResources().copyTo( jarDir );
236 231
237 - String jarFile;
238 - if ( hasVersion() )
239 - {
240 - jarFile = path( "$target$/$name$-$version$.jar" );
241 - }
242 - else
243 - {
244 - jarFile = path( "$target$/$name$.jar" );
245 - }
232 + String jarFile = path( "$target$/$name$" + (hasVersion() ? "-$version$" : "") + ".jar" );
246 233
247 234 File manifestFile = new File( jarDir, "META-INF/MANIFEST.MF" );
248 235 if ( !manifestFile.exists() )
249 236 {
250 - LOGGER.debug.log( "Generating JAR manifest: ", manifestFile );
251 - Utils.mkdir( manifestFile.getParent() );
252 - Manifest manifest = new Manifest();
253 - manifest.getMainAttributes().putValue( Attributes.Name.MANIFEST_VERSION.toString(), "1.0" );
254 - if ( hasMain() )
255 - {
256 - LOGGER.debug.log( "Main class: ", getMain() );
257 - manifest.getMainAttributes().putValue( Attributes.Name.MAIN_CLASS.toString(), getMain() );
258 - StringBuilder buffer = new StringBuilder( 512 );
259 - buffer.append( Utils.fileName( jarFile ) );
260 - buffer.append( " ." );
261 - Paths classpath = classpath();
262 - for ( String name : classpath.getRelativePaths() )
263 - {
264 - buffer.append( ' ' );
265 - buffer.append( name );
266 - }
267 - manifest.getMainAttributes().putValue( Attributes.Name.CLASS_PATH.toString(), buffer.toString() );
268 - }
269 - FileOutputStream output = new FileOutputStream( manifestFile );
270 - try
271 - {
272 - manifest.write( output );
273 - }
274 - finally
237 + createDefaultManifestFile( jarFile, manifestFile );
238 + }
239 +
240 + return jar( jarFile, new Paths( jarDir ) );
241 + }
242 +
243 + protected void createDefaultManifestFile( String pJarFile, File pManifestFile )
244 + throws IOException
245 + {
246 + LOGGER.debug.log( "Generating JAR manifest: ", pManifestFile );
247 + mkdir( pManifestFile.getParent() );
248 + Manifest manifest = new Manifest();
249 + manifest.getMainAttributes().putValue( Attributes.Name.MANIFEST_VERSION.toString(), "1.0" );
250 + if ( hasMain() )
251 + {
252 + LOGGER.debug.log( "Main class: ", getMain() );
253 + manifest.getMainAttributes().putValue( Attributes.Name.MAIN_CLASS.toString(), getMain() );
254 + StringBuilder buffer = new StringBuilder( 512 );
255 + buffer.append( Utils.fileName( pJarFile ) );
256 + buffer.append( " ." );
257 + Paths classpath = classpath();
258 + for ( String name : classpath.getRelativePaths() )
275 259 {
276 - try
277 - {
278 - output.close();
279 - }
280 - catch ( Exception ignored )
281 - {
282 - }
260 + buffer.append( ' ' );
261 + buffer.append( name );
283 262 }
263 + manifest.getMainAttributes().putValue( Attributes.Name.CLASS_PATH.toString(), buffer.toString() );
264 + }
265 + OutputStream output = new FileOutputStream( pManifestFile );
266 + try
267 + {
268 + manifest.write( output );
269 + Closeable zCloseable = output;
270 + output = null;
271 + zCloseable.close();
272 + }
273 + finally
274 + {
275 + dispose( output );
284 276 }
285 -
286 - jar( jarFile, new Paths( jarDir ) );
287 - return jarFile;
288 277 }
289 278
290 279 /**
  @@ -304,7 +293,7 @@
304 293 return null; // todo: ...
305 294 }
306 295
307 - String distDir = Utils.mkdir( path( "$target$/dist/" ) );
296 + String distDir = mkdir( path( "$target$/dist/" ) );
308 297 classpath().copyTo( distDir );
309 298 Paths distPaths = getDist();
310 299 dependencyDistPaths( distPaths );