Skip to content

Commit

Permalink
Install from Module Repository feature does not work under maven+jetty -
Browse files Browse the repository at this point in the history
TRUNK-1852(cherry picked from commit 7ad9ad9)
  • Loading branch information
dkayiwa committed Feb 18, 2013
1 parent 8d39599 commit af1732e
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions api/src/main/java/org/openmrs/util/OpenmrsConstants.java
Expand Up @@ -72,7 +72,7 @@ public final class OpenmrsConstants {
* <i>major</i>.<i>minor</i>.<i>maintenance</i> <i>suffix</i> Build <i>buildNumber</i>
*/
public static final String OPENMRS_VERSION = THIS_PACKAGE.getSpecificationVendor() != null ? THIS_PACKAGE
.getSpecificationVendor() : getBuildVersion();
.getSpecificationVendor() : (getBuildVersion() != null ? getBuildVersion() : getVersion());

/**
* This holds the current openmrs code version in a short space-less string.<br/>
Expand All @@ -81,7 +81,7 @@ public final class OpenmrsConstants {
* >
*/
public static final String OPENMRS_VERSION_SHORT = THIS_PACKAGE.getSpecificationVersion() != null ? THIS_PACKAGE
.getSpecificationVersion() : getBuildVersionShort();
.getSpecificationVersion() : (getBuildVersionShort() != null ? getBuildVersionShort() : getVersion());

/**
* @return build version with alpha characters (eg:1.10.0 SNAPSHOT Build 24858)
Expand Down Expand Up @@ -145,6 +145,41 @@ private static String getBuildVersionShort() {
return null;
}

/**
* Somewhat hacky method to fetch the version from the maven pom.properties file. <br/>
* This method should not be used unless in a dev environment. The preferred way to get the
* version is from the manifest in the api jar file. More detail is included in the properties
* there.
*
* @return version number defined in maven pom.xml file(s)
* @see #OPENMRS_VERSION_SHORT
* @see #OPENMRS_VERSION
*/

private static String getVersion() {
Properties props = new Properties();

// Get hold of the path to the properties file
// (Maven will make sure it's on the class path)
java.net.URL url = OpenmrsConstants.class.getClassLoader().getResource(
"META-INF/maven/org.openmrs.api/openmrs-api/pom.properties");
if (url == null) {
log.error("Unable to find pom.properties file built by maven");
return null;
}

// Load the file
try {
props.load(url.openStream());
return props.getProperty("version"); // this will return something like "1.9.0-SNAPSHOT" in dev environments
}
catch (IOException e) {
log.error("Unable to get pom.properties file into Properties object");
}

return null;
}

/**
* See {@link DatabaseUpdater#updatesRequired()} to see what changesets in the
* liquibase-update-to-latest.xml file in the openmrs api jar file need to be run to bring the
Expand Down

0 comments on commit af1732e

Please sign in to comment.