File targetDir = new File( targetDirName );
	public void compile( Device device, Locale locale ) {		// set the class-path:		String[] classPaths = this.libraryManager.getClassPaths(device);		device.setClassPaths( classPaths );		// setting target directory:		String targetDirName = device.getBaseDir() + File.separatorChar + "classes";		device.setClassesDir( targetDirName );		File targetDir = new File( targetDirName );				if (device.getNumberOfChangedFiles() == 0 && !this.lastRunFailed) {			System.out.println("nothing to compile for device [" +  device.getIdentifier() + "]." );			return;					}				Project antProject = getProject();		BooleanEvaluator evaluator = this.environment.getBooleanEvaluator();		// add binary class files, if there are any:		if (this.binaryLibrariesUpdated || (!targetDir.exists() && this.binaryLibraries != null) ) {			System.out.println("copying binary libraries to [" + targetDirName + "]...");			LibrarySetting[] settings = this.binaryLibraries.getLibraries();			for (int i = 0; i < settings.length; i++) {				LibrarySetting setting = settings[i];				if (setting.isActive(evaluator, antProject)) {					setting.copyFromCache( targetDir );				}			}			/*			try {				FileUtil.copyDirectoryContents( this.binaryLibrariesDir, targetDirName, true );			} catch (IOException e) {				e.printStackTrace();				throw new BuildException("Unable to copy binary class files: " + e.toString() + ". Please report this error to j2mepolish@enough.de.", e );			}			*/		}		// invoking all precompilers:		precompile( device, locale );		System.out.println("compiling for device [" +  device.getIdentifier() + "]." );		// init javac task:		CompilerTask compiler = this.buildSetting.getCompiler(evaluator );		compiler.setProject( antProject );		if (!compiler.isTaskNameSet()) {			compiler.setDirectTaskName(getTaskName() + "-javac-" + device.getIdentifier() );		}		//javac.target=1.1 or javac.target=1.2 is needed for the preverification:		if (!compiler.isTargetSet()) {			compiler.setDirectTarget( this.javacTarget );		}		// -source == 1.3 is apparently always needed for J2SE 1.5		if (!compiler.isSourceSet()) {			compiler.setDirectSource( this.sourceCompatibility );		}		if (this.buildSetting.isDebugEnabled() && !compiler.isDebugSet()) {			compiler.setDirectDebug(true);		}		if ( this.buildSetting.isInCompilerMode() && ! this.buildSetting.doPreverifyInCompilerMode()) { // && !this.doObfuscate is not needed			targetDir = this.buildSetting.getCompilerDestDir();		} else {			targetDir = new File( targetDirName );		}		if (!targetDir.exists()) {			targetDir.mkdirs();		}		if (!compiler.isDestDirSet()) {			compiler.setDirectDestdir( targetDir );		}		if (!compiler.isSourceDirSet()) {			compiler.setDirectSrcdir(new Path( getProject(),  device.getSourceDir() ) );		}		//javac.setSourcepath(new Path( getProject(),  "" ));		String classPath = device.getClassPath();		String completePath = classPath; // just used for printing out the classpath in case of an error		if (!compiler.isBootClassPathSet()) {			Path bootClassPath = new Path( antProject, device.getBootClassPath() );			// let postcompilers adjust the bootclasspath:			if (this.doPostCompile) {				String path = bootClassPath.toString();				String originalBootClassPath = path;				PostCompiler[] compilers = getActivePostCompilers();				for (int i = 0; i < compilers.length; i++) {					PostCompiler postCompiler = compilers[i];					path = postCompiler.verifyBootClassPath(device, path);					if ( classPath != null ) {						classPath = postCompiler.verifyClassPath(device, classPath);					}				}				if (path != originalBootClassPath) {					bootClassPath = new Path( antProject, path );				}			}			//device.setBootClassPath( bootClassPath.toString() );			compiler.setDirectBootclasspath( bootClassPath );			if (completePath != null) {				completePath = bootClassPath.toString() + File.pathSeparatorChar + completePath;			} else {				completePath = bootClassPath.toString();							}		//} else {		//	device.setBootClassPath( compiler.getBootclasspath().toString() );		}		if ( !compiler.isClassPathSet()) {			if (classPath != null) {				compiler.setDirectClasspath( new Path(antProject, classPath ) );			} else {				compiler.setDirectClasspath( new Path(antProject, "" ) );			}		}		// start compile:		if (this.polishLogger != null) {			this.polishLogger.setCompileMode( true );		}		String taskName = getTaskName();		try {			//compiler.setTaskName("javac");			setTaskName("javac"  );			compiler.execute();		} catch (BuildException e) {			if (this.polishLogger != null) {				this.polishLogger.setCompileMode(false);				if (this.polishLogger.isInternalCompilationError()) {					System.out.println("An internal class of J2ME Polish could not be compiled. " +							"Please try a clean rebuild by either calling \"ant clean j2mepolish\"" +							" or by removing the working directory \"" 							+ this.buildSetting.getWorkDir().getAbsolutePath() + "\".");					System.out.println("When an API-class was not found, you might need " +							"to define where to find the device-APIs. Following classpath " +							"has been used: [" + completePath + "].");					throw new BuildException( "Unable to compile source code for device [" + device.getIdentifier() + "]: " + e.getMessage(), e );				} else {					System.out.println("When an API-class was not found, you might need to define where to find the device-APIs. Following classpath has been used: [" + completePath + "].");					throw new BuildException( "Unable to compile source code for device [" + device.getIdentifier() + "]: " + e.getMessage(), e );				}			} else {				System.out.println("If an error occured in the J2ME Polish packages, please try a clean rebuild - e.g. [ant clean] and then [ant].");				System.out.println("Alternatively you might need to define where to find the device-APIs. Following classpath has been used: [" + completePath + "].");				throw new BuildException( "Unable to compile source code for device [" + device.getIdentifier() + "]: " + e.getMessage(), e );			}		} finally {			setTaskName( taskName );		}		if (this.polishLogger != null) {			this.polishLogger.setCompileMode( false );		}	}