buffer.append( apiPaths[i].toString() );
buffer.append( path );
	public void obfuscate(Device device, File sourceFile, File targetFile, String[] preserve, Path bootClassPath) 	throws BuildException 	{		if (this.proGuardJarFile == null) {			ExtensionDefinition definition = getExtensionDefinition();			if (definition != null) {				this.proGuardJarFile = new File( getEnvironment().writeProperties( definition.getClassPath().toString() ) );			}		}		ArrayList argsList = new ArrayList();		// the executable:		argsList.add( "java" );		argsList.add( "-jar" );		argsList.add( this.proGuardJarFile.getAbsolutePath() );		// the input jar file:		argsList.add( "-injars" );		argsList.add( sourceFile.getAbsolutePath() );		// the output jar file:		argsList.add( "-outjars" );		argsList.add( targetFile.getAbsolutePath() );		// the libraries:		argsList.add( "-libraryjars" );		StringBuffer buffer = new StringBuffer();		buffer.append( bootClassPath.toString() );		String[] apiPaths = device.getClassPaths();		for (int i = 0; i < apiPaths.length; i++) {			buffer.append( File.pathSeparatorChar );			buffer.append( apiPaths[i].toString() );		}		argsList.add( buffer.toString() );		// add classes that should be kept from obfuscating:		for (int i = 0; i < preserve.length; i++) {			argsList.add( "-keep" );			argsList.add( "class " + preserve[i] );		}		// add settings:		if (!this.doOptimize) {			argsList.add( "-dontoptimize" );		}		argsList.add( "-allowaccessmodification" );		argsList.add( "-printmapping" );		argsList.add( device.getBaseDir() + File.separator + "obfuscation-map.txt" );		argsList.add( "-overloadaggressively" );		argsList.add( "-defaultpackage" );		argsList.add( "" );		argsList.add( "-dontusemixedcaseclassnames" );				//System.out.println( argsList );		int result = 0;		try {			result = ProcessUtil.exec(argsList, "proguard: ", true, this );			// invoking the main(String[]) method fails because			// ProGuard calls System.exit(0) explicitely (for whatever reason)...			//JarUtil.exec( this.proGuardJarFile, argsList, getClass().getClassLoader() );		} catch (Exception e) {			e.printStackTrace();			System.out.println("ProGuard arguments: " + argsList.toString() );			throw new BuildException("ProGuard is unable to obfuscate: " + e.toString(), e );		}		if (result != 0) {			System.out.println("ProGuard arguments: " + argsList.toString() );			throw new BuildException("ProGuard was unable to obfuscate - got return value [" + result + "].");		}		/*		 * The direct invocation cannot be used anymore, because Eric Lafortune withdraw his permission for this...		argsList.add( "" );		argsList.add( "" );		argsList.add( "" );		// create the configuration for ProGuard:		Configuration cfg = new Configuration();				// set libraries:		cfg.libraryJars  = getPath( bootClassPath.toString(), false );		String[] apiPaths = device.getClassPaths();		for (int i = 0; i < apiPaths.length; i++) {			cfg.libraryJars.addAll( getPath( apiPaths[i], false ) );		}		cfg.allowAccessModification = true;		cfg.programJars = getPath( sourceFile, false );		cfg.programJars.addAll( getPath( targetFile, true ) );        // do not obfuscate the <keep> classes and the defined midlets:        cfg.keep = new ArrayList( preserve.length );        for (int i = 0; i < preserve.length; i++) {			String className = StringUtil.replace( preserve[i], '.', '/');			//System.out.println("\n PROGUARD: preservering: " + className );	        cfg.keep.add(	        		new ClassSpecification(        				ClassConstants.INTERNAL_ACC_PUBLIC,	                    0,	                    className,	                    null,	                    true,	                    false));		}        // some devices do not support mixed-case class names:        cfg.useMixedCaseClassNames = false;        // overload names with different return types:        cfg.overloadAggressively = true;                // optimize the resulting byte-code:        cfg.optimize = this.doOptimize;                // shrink the code:        cfg.shrink = true;                cfg.printMapping = device.getBaseDir() + File.separator + "obfuscation-map.txt";        // move all classes to the root package:        cfg.defaultPackage = "";		                ProGuard proGuard = new ProGuard( cfg );		try {			proGuard.execute();			System.out.println("ProGuard has successfully finished obfuscation.");		} catch (IOException e) {			// check if all preserve-classes are found:			for (int i = 0; i < preserve.length; i++) {				String className = preserve[i];				String fileName = StringUtil.replace( className, '.', File.separatorChar ) + ".java";				File file = new File( device.getSourceDir() + File.separator + fileName );				if (!file.exists()) {					System.err.println("WARNING: the MIDlet or class [" + className + "] was not found: [" + file.getAbsolutePath() + "] does not exist.");					System.err.println("Please check your <midlet>-setting in the file [build.xml].");				}			}			throw new BuildException("ProGuard was unable to obfuscate: " + e.getMessage(), e );		}		*/	}