Commit e1cb3475 authored by Hal Abelson's avatar Hal Abelson

Adding build id to status panel. Still needs to be finished.

parent 2171c813
......@@ -45,14 +45,22 @@
description="Create and populate build/war directory structure"
depends="init">
<mkdir dir="${build.war.dir}" />
<exec executable="hg" outputproperty="mercurial.version.id">
<arg line = "id -n -i " />
</exec>
<filter token="mercurial.version.id" value="${mercurial.version.id}" />
<copy todir="${build.war.dir}/WEB-INF/" file="war/WEB-INF/appengine-web.xml" filtering="true" />
<copy todir="${build.war.dir}/">
<fileset dir="war"/>
<fileset dir="war" >
<exclude name="WEB-INF/appengine-web.xml" />
</fileset>
<fileset dir="src/${appinventor.pkg}">
<!-- canvas is a special case (see MockCanvas.java) -->
<include name="images/canvas.png" />
</fileset>
<fileset dir="${docs.dir}" />
</copy>
</target>
<!-- =====================================================================
......
......@@ -103,10 +103,6 @@ public class Ode implements EntryPoint {
// User information
private User user;
// Timestamp of the build, supplied by the BuildData class
// Warning: This is available only when running the deploy jar
private String buildTimeStamp;
// Collection of projects
private ProjectManager projectManager;
......@@ -443,28 +439,27 @@ public class Ode implements EntryPoint {
/*
* If the server is running in production in Young Android mode,
* this gets the build timestamp, initializes the field buildTimeStamp,
* this gets the build id, initializes the field mercurialBuildId,
* and adds it to the StatusPanel. Otherwise, it has no effect.
****
*/
private void getBuildInfo() {
OdeAsyncCallback<String> buildTimeStampCallback =
// Id of the build, supplied by the BuildData class
OdeAsyncCallback<String> mercurialBuildIdCallback =
new OdeAsyncCallback<String>(
MESSAGES.serverUnavailable()) {
@Override
public void onSuccess(String result) {
buildTimeStamp = result;
onBuildInfoLoaded();
}
private void onBuildInfoLoaded() {
StatusPanel.showBuildTimeStamp(buildTimeStamp);
String mercurialBuildId = result;
StatusPanel.showMercurialBuildId(mercurialBuildId);
}
};
// TODO(halabelson): see the TODO(forster) above:
// Getting the build timestamp adds another RPC call.
// Getting the build id adds another RPC call.
getHelpService().getBuildTimeStamp(buildTimeStampCallback);
getHelpService().getMercurialBuildId(mercurialBuildIdCallback);
}
/*
......
......@@ -15,12 +15,14 @@ import com.google.gwt.user.client.ui.Label;
*
*/
public class StatusPanel extends Composite {
private static Label buildTimeStamp = new Label();
// Note that timestamp will be the real timestamp only
// when running the deploy jar.
public static void showBuildTimeStamp(String timestamp) {
buildTimeStamp.setText("Build: " + timestamp);
private static Label buildId = new Label();
// This shows the id from mercurial hg id -n -i
public static void showMercurialBuildId(String id) {
String[] idAndVersion = id.split("\\s+");
if (idAndVersion.length == 2) {
buildId.setText("Version: " + idAndVersion[1] + " Id: " + idAndVersion[0]);
}
}
private String AppInventorFooter =
......@@ -40,8 +42,8 @@ public class StatusPanel extends Composite {
hpanel.setWidth("100%");
hpanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
hpanel.add(new HTML(AppInventorFooter));
hpanel.add(buildTimeStamp);
hpanel.setCellHorizontalAlignment(buildTimeStamp, HorizontalPanel.ALIGN_RIGHT);
hpanel.add(buildId);
hpanel.setCellHorizontalAlignment(buildId, HorizontalPanel.ALIGN_RIGHT);
initWidget(hpanel);
setStyleName("ode-StatusPanel");
......
......@@ -2,6 +2,7 @@
package com.google.appinventor.server;
import com.google.appinventor.server.util.BuildData;
import com.google.appinventor.shared.rpc.help.HelpService;
......@@ -21,9 +22,10 @@ public class HelpServiceImpl extends OdeRemoteServiceServlet implements HelpServ
private static final Logger LOG = Logger.getLogger(HelpServiceImpl.class.getName());
/*
* Provide the server deploy timestamp
* Provide the Mercurial Id from "hg id -i -n"
*/
public String getBuildTimeStamp() {
return BuildData.getTimestampAsString();
public String getMercurialBuildId() {
return BuildData.getMercurialId();
}
}
......@@ -4,6 +4,9 @@ package com.google.appinventor.server.util;
import com.google.appengine.api.utils.SystemProperty;
import com.google.appinventor.server.flags.Flag;
import java.text.SimpleDateFormat;
import java.util.Date;
......@@ -17,6 +20,7 @@ public class BuildData {
private static long timestamp = 0;
private static Date date = null;
private static final Flag<String> mercurialBuildId = Flag.createFlag("mercurialBuildId", "");
/**
* Returns the timestamp for when the app was deployed (as a Unix time,
......@@ -56,4 +60,9 @@ public class BuildData {
}
return "";
}
// Get the id supplied by hg -n -i
public static String getMercurialId() {
return mercurialBuildId.get();
}
}
......@@ -14,8 +14,8 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
public interface HelpService extends RemoteService {
/**
* Returns the Build TimeStamp, or a message indicating that it could not be provided.
* @return build time stamp
* Returns the Mercurial Id generated by "hg -i -n"
* @return mercurial build id
*/
String getBuildTimeStamp();
String getMercurialBuildId();
}
......@@ -13,7 +13,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public interface HelpServiceAsync {
/**
* @see HelpService#getBuildTimeStamp()
* @see HelpService#getMercurialId()
*/
void getBuildTimeStamp(AsyncCallback<String> callback);
void getMercurialBuildId(AsyncCallback<String> callback);
}
......@@ -46,8 +46,14 @@
resource expensive on App Engine -->
<property name="motd.check.interval.secs" value="0" />
<!-- ant will replace the pattern with the result of "hg -n -i" -->
<property name="mercurialBuildId" value="@mercurial.version.id@" />
</system-properties>
<!-- Enable concurrency in the app engine server -->
<threadsafe>true</threadsafe>
</appengine-web-app>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment