File[] files = resourceDir.listFiles( cssFilter ); FileUtil.copy( files, classesDir );  resourceDir = new File( resourcePath + device.getVendorName() ); if (resourceDir.exists()) { files = resourceDir.listFiles( cssFilter ); FileUtil.copy( files, classesDir ); }  String[] groups = device.getGroupNames(); for (int i = 0; i < groups.length; i++) { String group = groups[i]; resourceDir = new File( resourcePath + group ); if (resourceDir.exists()) { files = resourceDir.listFiles( cssFilter ); FileUtil.copy( files, classesDir ); } }  resourceDir = new File( resourcePath + device.getVendorName() + File.separatorChar + device.getName() ); if (resourceDir.exists()) { files = resourceDir.listFiles( cssFilter ); FileUtil.copy( files, classesDir ); }
this.resourceManager.copyResources(classesDir, device, locale);
	private void jar( Device device ) {		System.out.println("creating JAR for device [" + device.getIdentifier() + "]." );		File classesDir = new File( device.getClassesDir() );		//copy resources:		File resourceDir = this.buildSetting.getResDir();		String resourcePath = resourceDir.getAbsolutePath() + File.separatorChar; 				FileFilter cssFilter =  new CssFileFilter();		try {			// 1. copy general resources:			File[] files = resourceDir.listFiles( cssFilter );			FileUtil.copy( files, classesDir );			// 2. copy vendor resources:			resourceDir = new File( resourcePath + device.getVendorName() );			if (resourceDir.exists()) {				files = resourceDir.listFiles( cssFilter );				FileUtil.copy( files, classesDir );			}			// 3. copy group resources:			String[] groups = device.getGroupNames();			for (int i = 0; i < groups.length; i++) {				String group = groups[i];				resourceDir = new File( resourcePath + group );				if (resourceDir.exists()) {					files = resourceDir.listFiles( cssFilter );					FileUtil.copy( files, classesDir );				}			}			// 4.: copy device resources:			resourceDir = new File( resourcePath + device.getVendorName() 								+ File.separatorChar + device.getName() );			if (resourceDir.exists()) {				files = resourceDir.listFiles( cssFilter );				FileUtil.copy( files, classesDir );			}		} catch (IOException e) {			throw new BuildException("Unable to copy resources from [" + resourceDir + "]: " + e.getMessage(), e );		}		// retrieve the name of the jar-file:		HashMap infoProperties = new HashMap();		infoProperties.put( "polish.identifier", device.getIdentifier() );		infoProperties.put( "polish.name", device.getName() );		infoProperties.put( "polish.vendor", device.getVendorName() );		infoProperties.put( "polish.version", this.infoSetting.getVersion() );		String jarName = this.infoSetting.getJarName();		jarName = PropertyUtil.writeProperties(jarName, infoProperties);		infoProperties.put( "polish.jarName", jarName );		File jarFile = new File( this.buildSetting.getDestDir().getAbsolutePath() 						+ File.separatorChar + jarName );		device.setJarFile( jarFile );		String test = this.polishProject.getCapability("polish.license");		if ( !this.infoSetting.getlicense().equals(test)) {			throw new BuildException("Encountered invalid license.");		}				// create manifest:		Jad jad = new Jad();		boolean useAttributesFilter = this.buildSetting.hasManifestAttributesFilter();		HashMap attributesByName = null;		if (useAttributesFilter) {			attributesByName = new HashMap();			attributesByName.put( "Manifest-Version", new Attribute( "Manifest-Version", "1.0" ) ); 		} else {			jad.addAttribute( "Manifest-Version", "1.0" );		}		// set MicroEdition-Profile:		String midp = InfoSetting.MIDP1;		if (device.isMidp2()) {			midp = InfoSetting.MIDP2;		}		if (useAttributesFilter) {			attributesByName.put( InfoSetting.MICRO_EDITION_PROFILE, new Attribute(InfoSetting.MICRO_EDITION_PROFILE, midp) );		} else {			jad.addAttribute( InfoSetting.MICRO_EDITION_PROFILE, midp );		}		// set MicroEdition-Configuration:		String config = InfoSetting.CLDC1_0;		if (!device.isCldc10()) {			config = InfoSetting.CLDC1_1;		}		if (useAttributesFilter) {			attributesByName.put( InfoSetting.MICRO_EDITION_CONFIGURATION, new  Attribute(InfoSetting.MICRO_EDITION_CONFIGURATION, config) );		} else {			jad.addAttribute( InfoSetting.MICRO_EDITION_CONFIGURATION, config );		}		// add info attributes:		Attribute[] jadAttributes = this.infoSetting.getManifestAttributes();		for (int i = 0; i < jadAttributes.length; i++) {			Attribute var = jadAttributes[i];			String value = PropertyUtil.writeProperties(var.getValue(), infoProperties);			if (useAttributesFilter) {				attributesByName.put( var.getName(), new  Attribute(var.getName(), value ) );			} else {				jad.addAttribute( var.getName(), value );			}		}				// add build properties - midlet infos:		String[] midletInfos = this.buildSetting.getMidletInfos( this.infoSetting.getIcon() );		for (int i = 0; i < midletInfos.length; i++) {			String info = midletInfos[i];			if (useAttributesFilter) {				attributesByName.put( InfoSetting.NMIDLET + (i+1), new  Attribute(InfoSetting.NMIDLET + (i+1), info ) );			} else {				jad.addAttribute( InfoSetting.NMIDLET + (i+1), info );			}		}				// add user-defined attributes:		Attribute[] attributes = this.buildSetting.getJadAttributes();		BooleanEvaluator evaluator = this.preprocessor.getBooleanEvaluator();		for (int i = 0; i < attributes.length; i++) {			Attribute attribute = attributes[i];			if (attribute.targetsManifest() && attribute.isConditionFulfilled(evaluator, this.project)) {				if (useAttributesFilter) {					attributesByName.put(attribute.getName(),							new Attribute( attribute.getName(), PropertyUtil.writeProperties( attribute.getValue(), infoProperties) ) );									} else {					jad.addAttribute( attribute.getName(), PropertyUtil.writeProperties( attribute.getValue(), infoProperties) );				}			}		}				//add polish version:		if (useAttributesFilter) {			attributesByName.put( "Polish-Version", new Variable("Polish-Version", VERSION ) );		} else {			jad.addAttribute( "Polish-Version", VERSION );		}				// sort and filter the attributes if this is requested:		if (useAttributesFilter) {			Variable[] manifestAttributes = this.buildSetting.filterManifestAttributes(attributesByName);			jad.setAttributes(manifestAttributes);		}		File manifestFile = new File( device.getClassesDir() 				+ File.separator + "META-INF" + File.separator + "MANIFEST.MF");		try {			FileUtil.writeTextFile( manifestFile, jad.getContent() );					JarUtil.jar(classesDir, jarFile, true );		} catch (IOException e) {			e.printStackTrace();			throw new BuildException("Unable to create final JAR file: " + e.getMessage(), e );		}			}