String jadPath = this.environment.getVariable("polish.jadPath"); File jadFile = new File( jadPath ); try { System.out.println("creating JAD file [" + jadFile.getAbsolutePath() + "]."); FileUtil.writeTextFile(jadFile, jad.getContent(), this.buildSetting.getEncoding() ); } catch (IOException e) { throw new BuildException("Unable to create JAD file [" + jadFile.getAbsolutePath() +"] for device [" + device.getIdentifier() + "]: " + e.getMessage() );
this.environment.set( DescriptorCreator.DESCRIPTOR_ATTRIBUTES_KEY, filteredAttributes ); this.environment.set( DescriptorCreator.DESCRIPTOR_ENCODING_KEY, this.buildSetting.getEncoding() );   String creatorName = this.environment.getVariable( "polish.build.DescriptorCreator" ); if (creatorName == null ) { creatorName = "default";
	protected void jad(Device device, Locale locale) {				// now create the JAD file:		HashMap attributesByName = new HashMap();		// add info attributes:		Attribute[] jadAttributes = this.infoSetting.getJadAttributes( this.environment.getVariables() );		for (int i = 0; i < jadAttributes.length; i++) {			Attribute var  = jadAttributes[i];			attributesByName.put( var.getName(), 					new Attribute(var.getName(), var.getValue() ) );		}				// add build properties - midlet infos:		// add build properties - midlet infos://		String mainClassName = this.environment.getVariable( "polish.classes.main" );//		if (mainClassName != null) {//			//attributesByName.put( "Main-Class", new Attribute( "Main-Class", mainClassName ) );//			attributesByName.put( "MIDlet-1", new Attribute( "MIDlet-1", ",," ) );//		} else {			String[] midletInfos = this.buildSetting.getMidletInfos( this.infoSetting.getIcon(), this.useDefaultPackage, this.environment );			for (int i = 0; i < midletInfos.length; i++) {				String info = midletInfos[i];				attributesByName.put( InfoSetting.NMIDLET + (i+1), 							new Attribute(InfoSetting.NMIDLET + (i+1), info) );			}//		}				// add size of jar:		long size = device.getJarFile().length();		attributesByName.put(InfoSetting.MIDLET_JAR_SIZE,					new Attribute( InfoSetting.MIDLET_JAR_SIZE, "" + size ) );				// add user-defined attributes:		Project antProject = getProject();		BooleanEvaluator evaluator = this.environment.getBooleanEvaluator();		if (this.buildSetting.getJadAttributes() != null) {			Attribute[] attributes = this.buildSetting.getJadAttributes().getAttributes(antProject, evaluator, this.environment);			for (int i = 0; i < attributes.length; i++) {				Attribute attribute = attributes[i];				if ( attribute.targetsJad() ) {					attributesByName.put(attribute.getName(),							new Attribute( attribute.getName(), attribute.getValue() ) );				}			}		}				// sort and filter the JAD attributes if requested:		Attribute[] filteredAttributes = null;		try {			filteredAttributes = this.buildSetting.filterJadAttributes(attributesByName, this.environment.getBooleanEvaluator() );		} catch (BuildException e) {			System.err.println("Unable to filter JAD attributes: " + e.getMessage() );			throw e;		}		Jad jad = new Jad( this.environment );		jad.setAttributes( filteredAttributes );				String jadPath = this.environment.getVariable("polish.jadPath");		File jadFile = new File( jadPath );		try {			System.out.println("creating JAD file [" + jadFile.getAbsolutePath() + "].");			FileUtil.writeTextFile(jadFile, jad.getContent(), this.buildSetting.getEncoding() );		} catch (IOException e) {			throw new BuildException("Unable to create JAD file [" + jadFile.getAbsolutePath() +"] for device [" + device.getIdentifier() + "]: " + e.getMessage() );		}	}