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