Commit 26557983 authored by halatmit's avatar halatmit

Change version to come from Git rather than Mercurial

parent b129f4fd
......@@ -162,6 +162,7 @@
<pathelement location="${local.build.dir}/AiSharedLib.jar" />
<pathelement location="${build.dir}/common/CommonUtils.jar" />
<pathelement location="${build.dir}/common/CommonTestUtils.jar" />
<pathelement location="${build.dir}/common/CommonVersion.jar" />
<pathelement location="${build.dir}/components/CommonConstants.jar"/>
<pathelement location="${lib.dir}/guava/guava-10.0.1.jar" />
<pathelement location="${lib.dir}/json/json.jar" />
......@@ -190,7 +191,7 @@
</path>
<target name="AiServerLibTests"
depends="AiServerLib,common_CommonTestUtils,common_CommonUtils,Keystore"
depends="AiServerLib,common_CommonTestUtils,common_CommonUtils,common_CommonVersion,Keystore"
description="build and run the test suite" >
<ai.dojunit aij-testingtarget="AiServerLibTests"
aij-dir="${appinventor.pkg}/server" >
......
......@@ -3,7 +3,7 @@
package com.google.appinventor.client;
import com.google.appinventor.client.utils.Urls;
import com.google.appinventor.common.version.MercurialBuildId;
import com.google.appinventor.common.version.GitBuildId;
/**
* Handles reporting of bugs in the ODE client code.
......@@ -50,11 +50,12 @@ public final class BugReport {
String notes = Urls.escapeQueryParameter("Browser: " + getUserAgent() + "\n\n" +
"Please attach a screenshot to help us fix the problem!\n\n" +
"Steps to reproduce:\n");
String foundIn = Urls.escapeQueryParameter(MercurialBuildId.MERCURIAL_BUILD_ID);
String foundIn = Urls.escapeQueryParameter(GitBuildId.getVersion());
return BUG_REPORT_FORM_LINK;
}
/**
* Returns information regarding the user agent (aka browser).
*/
......
......@@ -170,9 +170,9 @@ public interface OdeMessages extends Messages {
// Used in StatusPanel.java
@DefaultMessage("Release Date: {0} Version: {1} Id: {2}")
@Description("Label showing the Mercurial build id and build date")
String mercurialBuildId(String date, String version, String id);
@DefaultMessage("Build date: {0} Version: {1}")
@Description("Label showing the ant build date and the git version")
String gitBuildId(String date, String version);
@DefaultMessage("About")
@Description("Label of the link for About")
......
......@@ -3,7 +3,7 @@
package com.google.appinventor.client;
import static com.google.appinventor.client.Ode.MESSAGES;
import com.google.appinventor.common.version.MercurialBuildId;
import com.google.appinventor.common.version.GitBuildId;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
......@@ -29,12 +29,11 @@ public class StatusPanel extends Composite {
hpanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
hpanel.add(new HTML(AppInventorFooter));
// This shows the id from mercurial hg id -i -n and the date of the build
String version = MercurialBuildId.getVersion();
String id = MercurialBuildId.getId();
String date = MercurialBuildId.getDate();
if (version != null && id != null && date != null) {
Label buildId = new Label(MESSAGES.mercurialBuildId(date, version, id));
// This shows the git version and the date of the build
String version = GitBuildId.getVersion();
String date = GitBuildId.getDate();
if (version != null && date != null) {
Label buildId = new Label(MESSAGES.gitBuildId(date, version));
hpanel.add(buildId);
hpanel.setCellHorizontalAlignment(buildId, HorizontalPanel.ALIGN_RIGHT);
}
......
......@@ -2,7 +2,7 @@
package com.google.appinventor.server;
import com.google.appinventor.common.version.MercurialBuildId;
import com.google.appinventor.common.version.GitBuildId;
import com.google.appinventor.server.util.BuildData;
import com.google.appengine.api.utils.SystemProperty;
......@@ -77,7 +77,7 @@ public final class CrashReport {
s.append("application.version").append("=").append(version).append("\n");
}
s.append("build.version").append("=").append(buildData).append("\n");
s.append("mercurial.build.id").append("=").append(MercurialBuildId.MERCURIAL_BUILD_ID).append("\n");
s.append("git.build.version").append("=").append(GitBuildId.getVersion()).append("\n");
if (req != null) {
s.append("request.details").append("=").append(req.toString()).append("\n");
}
......
......@@ -2,7 +2,7 @@
package com.google.appinventor.server.project.utils;
import com.google.appinventor.common.version.MercurialBuildId;
import com.google.appinventor.common.version.GitBuildId;
import com.google.appinventor.server.encryption.EncryptionException;
import com.google.appinventor.shared.rpc.ServerLayout;
import com.google.appinventor.shared.rpc.user.UserInfoProvider;
......@@ -23,7 +23,7 @@ public final class JavaWebStart {
public final String userId;
public final long projectId;
/**
* versionOk is true if the version specified in the project path matches the current Mercurial
* versionOk is true if the version specified in the project path matches the current Git
* build version.
*/
public final boolean versionOk;
......@@ -68,12 +68,7 @@ public final class JavaWebStart {
* Returns the version prefix used in the project path.
*/
private static String getVersionPrefix() {
String version = MercurialBuildId.getVersion();
// If there's a trailing +, remove it.
if (version.endsWith("+")) {
version = version.substring(0, version.length() - 1);
}
return version;
return GitBuildId.getVersion();
}
/**
......
......@@ -5,7 +5,7 @@ package com.google.appinventor.server.project.youngandroid;
import com.google.appengine.api.utils.SystemProperty;
import com.google.apphosting.api.ApiProxy;
import com.google.appinventor.common.utils.StringUtils;
import com.google.appinventor.common.version.MercurialBuildId;
import com.google.appinventor.common.version.GitBuildId;
import com.google.appinventor.components.common.YaVersion;
import com.google.appinventor.server.CrashReport;
import com.google.appinventor.server.FileExporter;
......@@ -74,8 +74,8 @@ public final class YoungAndroidProjectService extends CommonProjectService {
private static final Logger LOG = Logger.getLogger(YoungAndroidProjectService.class.getName());
// The value of this flag can be changed in appengine-web.xml
private static final Flag<Boolean> sendMercurialId =
Flag.createFlag("build.send.mercurial.id", true);
private static final Flag<Boolean> sendGitVersion =
Flag.createFlag("build.send.git.version", true);
// Project folder prefixes
public static final String SRC_FOLDER = YoungAndroidSourceAnalyzer.SRC_FOLDER;
......@@ -528,9 +528,9 @@ public final class YoungAndroidProjectService extends CommonProjectService {
throws UnsupportedEncodingException, EncryptionException {
return "http://" + buildServerHost.get() + "/buildserver/build-all-from-zip-async"
+ "?uname=" + URLEncoder.encode(userName, "UTF-8")
+ (sendMercurialId.get()
? "&mercurialBuildId="
+ URLEncoder.encode(MercurialBuildId.MERCURIAL_BUILD_ID, "UTF-8")
+ (sendGitVersion.get()
? "&gitBuildVersion="
+ URLEncoder.encode(GitBuildId.getVersion(), "UTF-8")
: "")
+ "&callback="
+ URLEncoder.encode("http://" + getCurrentHost() + ServerLayout.ODE_BASEURL_NOAUTH
......
......@@ -46,10 +46,10 @@
resource expensive on App Engine -->
<property name="motd.check.interval.secs" value="0" />
<!-- Set this to false if we should not send our Mercurial build id with build requests.
<!-- Set this to false if we should not send the Git build version with build requests.
This is useful when testing new servers where we don't want to require the
buildserver to match -->
<property name="build.send.mercurial.id" value="true" />
<property name="build.send.git.version" value="true" />
</system-properties>
......
......@@ -32,7 +32,7 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.google.appinventor.common.version.MercurialBuildId;
import com.google.appinventor.common.version.GitBuildId;
import openblocks.renderable.BlockNote;
import openblocks.renderable.BlockUtilities;
import openblocks.renderable.RenderableBlock;
......@@ -163,17 +163,16 @@ public class Workspace extends JLayeredPane
explorerPanel.add(factory.getFactorySwitcher(), BorderLayout.NORTH);
explorerPanel.add(factory.getJComponent(), BorderLayout.CENTER);
// Show the Mercurial build id using a non-editable JTextField instead of a JLabel, so the user
// Show the Git version using a non-editable JTextField instead of a JLabel, so the user
// can select and copy it.
JTextField mercurialBuildId = new JTextField("Version: " + MercurialBuildId.getVersion() +
" Id: " + MercurialBuildId.getId());
mercurialBuildId.setEditable(false);
mercurialBuildId.setBorder(null);
mercurialBuildId.setBackground(CGraphite.lightergreen);
mercurialBuildId.setForeground(Color.gray);
mercurialBuildId.setHorizontalAlignment(JTextField.CENTER);
mercurialBuildId.setFont(new Font("Arial", Font.PLAIN, 13));
explorerPanel.add(mercurialBuildId, BorderLayout.SOUTH);
JTextField gitBuildId = new JTextField("Version: " + GitBuildId.getVersion());
gitBuildId.setEditable(false);
gitBuildId.setBorder(null);
gitBuildId.setBackground(CGraphite.lightergreen);
gitBuildId.setForeground(Color.gray);
gitBuildId.setHorizontalAlignment(JTextField.CENTER);
gitBuildId.setFont(new Font("Arial", Font.PLAIN, 13));
explorerPanel.add(gitBuildId, BorderLayout.SOUTH);
blockCanvasLayer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
explorerPanel, blockCanvas.getJComponent());
......
......@@ -80,7 +80,7 @@
<!-- app engine libs -->
<pathelement location="lib/appengine/appengine-java-sdk-1.6.2.1/lib/user/appengine-api-1.0-sdk-1.6.2.1.jar"/>
<pathelement location="lib/appengine/appengine-java-sdk-1.6.2.1/lib/user/orm/geronimo-jpa_3.0_spec-1.1.1.jar"/>
<!-- prevent error importing MercurialBuildId if it has been generated -->
<!-- prevent error importing GitBuildId if it has been generated -->
<pathelement location="common/build/classes/CommonVersion" />
</classpath>
<!-- Ignore non-standard tags used in blockslib. -->
......
package com.google.appinventor.buildserver;
import com.google.appinventor.common.version.MercurialBuildId;
import com.google.appinventor.common.version.GitBuildId;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
......@@ -157,8 +157,8 @@ public class BuildServer {
variables.put("vm-version", runtimeBean.getVmVersion());
//BuildServer Version and Id
variables.put("buildserver-version", MercurialBuildId.getVersion() + "");
variables.put("buildserver-id", MercurialBuildId.getId() + "");
variables.put("buildserver-version", GitBuildId.getVersion() + "");
variables.put("buildserver-git-fingerprint", GitBuildId.getFingerprint() + "");
// OS
OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
......@@ -297,8 +297,8 @@ public class BuildServer {
* files as well as the APK file if the build succeeded and the android.keystore file if it was
* not provided in the input zip
*
* Before building the app, we'll check that the mercurialBuildId parameter (if present) equals
* MercurialBuildId.MERCURIAL_BUILD_ID. If the values are different, we won't even try to build
* Before building the app, we'll check that the gitBuildVersion parameter (if present) equals
* GitBuildId.getVersion(). If the values are different, we won't even try to build
* the app. This may seem too strict, but we need to make sure that when we build apps, we use
* the same version of the code that loads the .blk and .scm files, the same version of
* runtime.scm, and the same version of the App Inventor component classes.
......@@ -307,7 +307,7 @@ public class BuildServer {
* as connection.getResponseCode().
*
* @param userName The user name to be used in making the CN entry in the generated keystore.
* @param mercurialBuildId The value of MercurialBuildId.MERCURIAL_BUILD_ID sent from
* @param gitBuildVersion The value of GitBuildId.getVersion() sent from
* YoungAndroidProjectService.build.
* @param callbackUrlStr An url to send the build results back to.
* @param inputZipFile The zip file representing the App Inventor source code.
......@@ -318,7 +318,7 @@ public class BuildServer {
@Produces(MediaType.TEXT_PLAIN)
public Response buildAllFromZipFileAsync(@QueryParam("uname") final String userName,
@QueryParam("callback") final String callbackUrlStr,
@QueryParam("mercurialBuildId") final String mercurialBuildId,
@QueryParam("gitBuildVersion") final String gitBuildVersion,
final File inputZipFile) throws IOException {
// Set the inputZip field so we can delete the input zip file later in cleanUp.
inputZip = inputZipFile;
......@@ -350,14 +350,14 @@ public class BuildServer {
asyncBuildRequests.incrementAndGet();
if (mercurialBuildId != null && !mercurialBuildId.isEmpty()) {
if (!mercurialBuildId.equals(MercurialBuildId.MERCURIAL_BUILD_ID)) {
if (gitBuildVersion != null && !gitBuildVersion.isEmpty()) {
if (!gitBuildVersion.equals(GitBuildId.getVersion())) {
// This build server is not compatible with the App Inventor instance. Log this as severe
// so the owner of the build server will know about it.
String errorMessage = "Build server version " + MercurialBuildId.MERCURIAL_BUILD_ID +
" is not compatible with App Inventor version " + mercurialBuildId + ".";
String errorMessage = "Build server version " + GitBuildId.getVersion() +
" is not compatible with App Inventor version " + gitBuildVersion + ".";
LOG.severe(errorMessage);
// This request was rejected because the mercurialBuildId parameter did not equal the
// This request was rejected because the gitBuildVersion parameter did not equal the
// expected value.
rejectedAsyncBuildRequests.incrementAndGet();
cleanUp();
......@@ -545,8 +545,8 @@ public class BuildServer {
int port = commandLineOptions.port;
SelectorThread threadSelector = GrizzlyServerFactory.create("http://localhost:" + port + "/");
String hostAddress = InetAddress.getLocalHost().getHostAddress();
LOG.info("App Inventor Build Server - Version: " + MercurialBuildId.getVersion() +
" Id: " + MercurialBuildId.getId());
LOG.info("App Inventor Build Server - Version: " + GitBuildId.getVersion());
LOG.info("App Inventor Build Server - Git Fingerprint: " + GitBuildId.getFingerprint());
LOG.info("Running at: http://" + hostAddress + ":" + port + "/buildserver");
if (commandLineOptions.maxSimultaneousBuilds == 0) {
LOG.info("Maximum simultanous builds = unlimited!");
......
......@@ -3,32 +3,32 @@
package com.google.appinventor.common.version;
/**
* Class containing a constant for the Mercurial build id.
* And another one for the Build date
* Class containing constants for the git version and fingerprint
* and another one for the Ant Build date
*/
public final class MercurialBuildId {
public final class GitBuildId {
// The following values are set during the ant build.
public static final String MERCURIAL_BUILD_ID = "@mercurial.version.id@";
public static final String GIT_BUILD_VERSION = "@git.build.version@";
public static final String GIT_BUILD_FINGERPRINT = "@git.build.fingerprint@";
public static final String ANT_BUILD_DATE = "@ant.build.date@";
private MercurialBuildId() {
private GitBuildId() {
}
public static String getId() {
String[] idAndVersion = MERCURIAL_BUILD_ID.split("\\s+", 2);
if (idAndVersion.length == 2) {
return idAndVersion[0];
public static String getVersion() {
String version = GIT_BUILD_VERSION;
// We can't use isEmpty() here because we want this to run
// in jdk 1.5 for the Blocks Editor
if (version.equals("")) {
return "none" ;
} else {
return version;
}
return null;
}
public static String getVersion() {
String[] idAndVersion = MERCURIAL_BUILD_ID.split("\\s+", 2);
if (idAndVersion.length == 2) {
return idAndVersion[1];
}
return null;
public static String getFingerprint() {
return GIT_BUILD_FINGERPRINT;
}
public static String getDate() {
......
......@@ -92,17 +92,26 @@
<property name="CommonVersion-class.dir" location="${class.dir}/CommonVersion" />
<mkdir dir="${CommonVersion-class.dir}" />
<exec executable="hg" outputproperty="mercurial.version.id">
<arg line = "id -n -i " />
<!-- We extract two pieces of info from Git: the version and the fingerprint.
The version is the tag that was set in the release process. The fingerprint
by Git. We use the version or to check against the buildserver
version. We use the fingerprint only in the logs as an debugging aid. -->
<exec executable="git" outputproperty="git.build.version">
<arg line = "tag " />
</exec>
<filter token="mercurial.version.id" value="${mercurial.version.id}" />
<filter token="git.build.version" value="${git.build.version}" />
<exec executable="git" outputproperty="git.build.fingerprint">
<arg line = "rev-parse HEAD " />
</exec>
<filter token="git.build.fingerprint" value="${git.build.fingerprint}" />
<tstamp/>
<property name="ant.build.date" value="${TODAY}" />
<filter token="ant.build.date" value="${ant.build.date}" />
<mkdir dir="${local.build.dir}/src/${common.pkg}/version/"/>
<copy tofile="${local.build.dir}/src/${common.pkg}/version/MercurialBuildId.java" file="MercurialBuildId.template" filtering="true" />
<copy tofile="${local.build.dir}/src/${common.pkg}/version/GitBuildId.java" file="GitBuildId.template" filtering="true" />
<ai.javac5 destdir="${CommonVersion-class.dir}" srcdir="${src.dir};${local.build.dir}/src">
<include name="${common.pkg}/version/*.java" />
......
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