Manifest.Attribute attribute = new Manifest.Attribute(var.getName(), value ); manifest.addConfiguredAttribute( attribute  ); }   String[] midletInfos = this.buildSetting.getMidletInfos( this.infoSetting.getIcon() ); for (int i = 0; i < midletInfos.length; i++) { String info = midletInfos[i]; Manifest.Attribute attribute = new Manifest.Attribute(InfoSetting.NMIDLET + (i+1), info ); manifest.addConfiguredAttribute( attribute  ); }   Attribute[] attributes = this.buildSetting.getJadAttributes(); BooleanEvaluator evaluator = this.preprocessor.getBooleanEvaluator(); for (int i = 0; i < attributes.length; i++) { Attribute var = attributes[i]; String condition = var.getIf(); if (condition == null || evaluator.evaluate( condition, "build.xml", 0)) { String value = PropertyUtil.writeProperties(var.getValue(), infoProperties); Manifest.Attribute attribute = new Manifest.Attribute(var.getName(), value ); manifest.addConfiguredAttribute( attribute  );
if (useAttributesFilter) { attributesByName.put( var.getName(), new Variable(var.getName(), value ) ); } else { jad.addAttribute( var.getName(), value );
	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 );		}				Jar jarTask = new Jar();		jarTask.setProject( this.project );		jarTask.setTaskName( getTaskName() + "-jar-" + device.getIdentifier() );		jarTask.setBasedir( classesDir );		// 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 );		if (!jarFile.getParentFile().exists()) {			jarFile.getParentFile().mkdirs();		}		device.setJarFile( jarFile );		jarTask.setDestFile( jarFile );		String test = this.polishProject.getCapability("polish.license");		if ( !this.infoSetting.getlicense().equals(test)) {			throw new BuildException("Encountered invalid license.");		}		//create manifest:		try {			Manifest manifest = new Manifest();						// set MicroEdition-Profile:			String midp = InfoSetting.MIDP1;			if (device.isMidp2()) {				midp = InfoSetting.MIDP2;			}			Manifest.Attribute meProfile = new Manifest.Attribute( InfoSetting.MICRO_EDITION_PROFILE, midp );			manifest.addConfiguredAttribute(meProfile);			// set MicroEdition-Configuration:			String config = InfoSetting.CLDC1_0;			if (!device.isCldc10()) {				config = InfoSetting.CLDC1_1;			}			Manifest.Attribute meConfiguration = new Manifest.Attribute( InfoSetting.MICRO_EDITION_CONFIGURATION, config );			manifest.addConfiguredAttribute(meConfiguration);			// add info attributes:			Variable[] jadAttributes = this.infoSetting.getManifestAttributes();			for (int i = 0; i < jadAttributes.length; i++) {				Variable var = jadAttributes[i];				String value = PropertyUtil.writeProperties(var.getValue(), infoProperties);				Manifest.Attribute attribute = new Manifest.Attribute(var.getName(), value );				manifest.addConfiguredAttribute( attribute  );			}						// 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];				Manifest.Attribute attribute = new Manifest.Attribute(InfoSetting.NMIDLET + (i+1), info );				manifest.addConfiguredAttribute( attribute  );			}						// add user-defined attributes:			Attribute[] attributes = this.buildSetting.getJadAttributes();			BooleanEvaluator evaluator = this.preprocessor.getBooleanEvaluator();			for (int i = 0; i < attributes.length; i++) {				Attribute var = attributes[i];				String condition = var.getIf();				if (condition == null || evaluator.evaluate( condition, "build.xml", 0)) {					String value = PropertyUtil.writeProperties(var.getValue(), infoProperties);					Manifest.Attribute attribute = new Manifest.Attribute(var.getName(), value );					manifest.addConfiguredAttribute( attribute  );				}			}						//add polish version:			Manifest.Attribute polishVersion = new Manifest.Attribute("Polish-Version", VERSION );			manifest.addConfiguredAttribute( polishVersion  );			jarTask.addConfiguredManifest( manifest );		} catch (ManifestException e) {			e.printStackTrace();			throw new BuildException("Unable to create manifest: " + e.getMessage(), e );		}		jarTask.execute();			}