Remove the duplicate Version class
We had two different com.google.gerrit.common.Version classes which meant that under the GWT debug environment the server didn't have access to its own version number. Fix that by using ClientVersion from within the GWT UI, and leave the real Version name for the rest of the runtime. Change-Id: I3b5af1a866fb1b4a6dbe25269962fe80d8d26436 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
1
gerrit-common/.gitignore
vendored
1
gerrit-common/.gitignore
vendored
@@ -2,4 +2,3 @@
|
|||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
/.settings/org.maven.ide.eclipse.prefs
|
/.settings/org.maven.ide.eclipse.prefs
|
||||||
/src/main/resources/com/google/gerrit/common/Version.properties
|
|
||||||
|
@@ -67,14 +67,14 @@ limitations under the License.
|
|||||||
<phase>generate-resources</phase>
|
<phase>generate-resources</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tasks>
|
<tasks>
|
||||||
<property name="src" location="${basedir}/src/main/resources/" />
|
<property name="dst" location="${project.build.outputDirectory}" />
|
||||||
<property name="pkg" location="${src}/com/google/gerrit/common" />
|
<property name="pkg" location="${dst}/com/google/gerrit/common" />
|
||||||
<mkdir dir="${pkg}" />
|
<mkdir dir="${pkg}" />
|
||||||
<exec executable="git" outputproperty="v">
|
<exec executable="git" outputproperty="v">
|
||||||
<arg value="describe"/>
|
<arg value="describe"/>
|
||||||
<arg value="HEAD"/>
|
<arg value="HEAD"/>
|
||||||
</exec>
|
</exec>
|
||||||
<echo file="${pkg}/Version.properties">version=${v}</echo>
|
<echo file="${pkg}/Version">${v}</echo>
|
||||||
</tasks>
|
</tasks>
|
||||||
</configuration>
|
</configuration>
|
||||||
<goals>
|
<goals>
|
||||||
|
@@ -14,13 +14,11 @@
|
|||||||
|
|
||||||
package com.google.gerrit.common;
|
package com.google.gerrit.common;
|
||||||
|
|
||||||
import com.google.gwt.i18n.client.Constants;
|
import com.google.gwt.resources.client.ClientBundle;
|
||||||
|
import com.google.gwt.resources.client.TextResource;
|
||||||
|
|
||||||
/**
|
public interface ClientVersion extends ClientBundle {
|
||||||
* Automatically generated version code.
|
/** Version number of this client software build. */
|
||||||
* <p>
|
@Source("Version")
|
||||||
* Do not translate this constants interface.
|
TextResource version();
|
||||||
*/
|
|
||||||
public interface Version extends Constants {
|
|
||||||
String version();
|
|
||||||
}
|
}
|
@@ -20,8 +20,8 @@ import com.google.gerrit.client.rpc.GerritCallback;
|
|||||||
import com.google.gerrit.client.ui.LinkMenuBar;
|
import com.google.gerrit.client.ui.LinkMenuBar;
|
||||||
import com.google.gerrit.client.ui.LinkMenuItem;
|
import com.google.gerrit.client.ui.LinkMenuItem;
|
||||||
import com.google.gerrit.client.ui.Screen;
|
import com.google.gerrit.client.ui.Screen;
|
||||||
|
import com.google.gerrit.common.ClientVersion;
|
||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
import com.google.gerrit.common.Version;
|
|
||||||
import com.google.gerrit.common.auth.SignInMode;
|
import com.google.gerrit.common.auth.SignInMode;
|
||||||
import com.google.gerrit.common.data.GerritConfig;
|
import com.google.gerrit.common.data.GerritConfig;
|
||||||
import com.google.gerrit.common.data.HostPageData;
|
import com.google.gerrit.common.data.HostPageData;
|
||||||
@@ -65,7 +65,6 @@ public class Gerrit implements EntryPoint {
|
|||||||
public static final SystemInfoService SYSTEM_SVC;
|
public static final SystemInfoService SYSTEM_SVC;
|
||||||
|
|
||||||
private static String myHost;
|
private static String myHost;
|
||||||
private static String myVersion;
|
|
||||||
private static GerritConfig myConfig;
|
private static GerritConfig myConfig;
|
||||||
private static Account myAccount;
|
private static Account myAccount;
|
||||||
|
|
||||||
@@ -322,25 +321,22 @@ public class Gerrit implements EntryPoint {
|
|||||||
keyHelp.setStyleName(RESOURCES.css().keyhelp());
|
keyHelp.setStyleName(RESOURCES.css().keyhelp());
|
||||||
btmmenu.add(keyHelp);
|
btmmenu.add(keyHelp);
|
||||||
|
|
||||||
final String vs = getVersion();
|
String vs;
|
||||||
|
if (GWT.isScript()) {
|
||||||
|
final ClientVersion v = GWT.create(ClientVersion.class);
|
||||||
|
vs = v.version().getText();
|
||||||
|
if (vs.startsWith("v")) {
|
||||||
|
vs = vs.substring(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vs = "dev";
|
||||||
|
}
|
||||||
|
|
||||||
final HTML version = new HTML(M.poweredBy(vs));
|
final HTML version = new HTML(M.poweredBy(vs));
|
||||||
version.setStyleName(RESOURCES.css().version());
|
version.setStyleName(RESOURCES.css().version());
|
||||||
btmmenu.add(version);
|
btmmenu.add(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return version number of the Gerrit application software */
|
|
||||||
public static String getVersion() {
|
|
||||||
if (myVersion == null) {
|
|
||||||
if (GWT.isScript()) {
|
|
||||||
final Version v = GWT.create(Version.class);
|
|
||||||
myVersion = v.version();
|
|
||||||
} else {
|
|
||||||
myVersion = "dev";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return myVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onModuleLoad2(final RootPanel starting) {
|
private void onModuleLoad2(final RootPanel starting) {
|
||||||
refreshMenuBar();
|
refreshMenuBar();
|
||||||
|
|
||||||
|
@@ -14,9 +14,10 @@
|
|||||||
|
|
||||||
package com.google.gerrit.common;
|
package com.google.gerrit.common;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class Version {
|
public class Version {
|
||||||
private static final String version;
|
private static final String version;
|
||||||
@@ -30,18 +31,24 @@ public class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String loadVersion() {
|
private static String loadVersion() {
|
||||||
InputStream in = Version.class.getResourceAsStream("Version.properties");
|
InputStream in = Version.class.getResourceAsStream("Version");
|
||||||
if (in == null) {
|
if (in == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final Properties p = new Properties();
|
BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF-8"));
|
||||||
try {
|
try {
|
||||||
p.load(in);
|
String vs = r.readLine();
|
||||||
} finally {
|
if (vs != null && vs.startsWith("v")) {
|
||||||
in.close();
|
vs = vs.substring(1);
|
||||||
|
}
|
||||||
|
if (vs != null && vs.isEmpty()) {
|
||||||
|
vs = null;
|
||||||
|
}
|
||||||
|
return vs;
|
||||||
|
} finally {
|
||||||
|
r.close();
|
||||||
}
|
}
|
||||||
return p.getProperty("version");
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user