Hi everybody,
as we needed for our project, I created another version of ApplicationDescriptor, which will read in a properties file to configure the version.
I will post the code here:
We use this code to write a buildNumber (which is actually passed via CruiseContol to ant) with ant as the following example shows:Code:package de.hr.ec.fsm.service; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; import org.springframework.richclient.application.ApplicationDescriptor; import org.springframework.richclient.core.LabeledObjectSupport; import org.springframework.richclient.util.Assert; public class PropertiesApplicationDescriptor extends LabeledObjectSupport implements ApplicationDescriptor { /** The version of the application */ private String version; /** The build identifier associated with this build of the application */ private String buildId; public PropertiesApplicationDescriptor(String propertiesFile) { Assert.notNull(propertiesFile); Properties properties = new Properties(); try { properties.load(PropertiesApplicationDescriptor.class.getResourceAsStream(propertiesFile)); setBuildId(properties.getProperty("buildId", "localBuild")); setVersion(properties.getProperty("version", "localBuild")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public String getBuildId() { return buildId; } public void setBuildId(String buildId) { this.buildId = buildId; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } }
Code:<target name="writeBuildNumber"> <propertyfile file="build/version.properties"> <entry key="buildId" value="${label}" /> </propertyfile> </target>


Reply With Quote