Write build information to "version" file and auto-fill error forms.
- Maven version and build date are now written to "res/version". - The GitHub Issues form is auto-filled with error information if available. (reference: fluddokt/opsu@53fe3d9) Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
6cd6938ea5
commit
3df08e5357
14
pom.xml
14
pom.xml
|
@ -4,16 +4,28 @@
|
|||
<groupId>itdelatrisu</groupId>
|
||||
<artifactId>opsu</artifactId>
|
||||
<version>0.6.0</version>
|
||||
|
||||
<properties>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
|
||||
</properties>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>false</filtering>
|
||||
<directory>res</directory>
|
||||
<excludes>
|
||||
<exclude>**/Thumbs.db</exclude>
|
||||
<exclude>**/version</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>res</directory>
|
||||
<includes>
|
||||
<include>**/version</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#Mon, 03 Jun 2013 22:20:24 +0100
|
||||
#Sun May 11 20:17:03 BST 2008
|
||||
# opsu! build info
|
||||
version=${pom.version}
|
||||
build.date=${timestamp}
|
||||
|
||||
# slick build
|
||||
build=237
|
||||
|
|
|
@ -22,6 +22,9 @@ import java.awt.Cursor;
|
|||
import java.awt.Desktop;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JScrollPane;
|
||||
|
@ -29,6 +32,7 @@ import javax.swing.JTextArea;
|
|||
import javax.swing.UIManager;
|
||||
|
||||
import org.newdawn.slick.util.Log;
|
||||
import org.newdawn.slick.util.ResourceLoader;
|
||||
|
||||
/**
|
||||
* Error handler to log and display errors.
|
||||
|
@ -92,10 +96,12 @@ public class ErrorHandler {
|
|||
textArea.append(error);
|
||||
textArea.append("\n");
|
||||
}
|
||||
String trace = null;
|
||||
if (e != null) {
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw));
|
||||
textArea.append(sw.toString());
|
||||
trace = sw.toString();
|
||||
textArea.append(trace);
|
||||
}
|
||||
|
||||
// display popup
|
||||
|
@ -109,8 +115,39 @@ public class ErrorHandler {
|
|||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||
null, optionsR, optionsR[2]);
|
||||
if (n == 0) {
|
||||
Desktop.getDesktop().browse(Options.ISSUES_URI);
|
||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
||||
// auto-fill debug information
|
||||
String issueTitle = (error != null) ? error : e.getMessage();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Properties props = new Properties();
|
||||
props.load(ResourceLoader.getResourceAsStream("version"));
|
||||
String version = props.getProperty("version");
|
||||
if (version != null && !version.equals("${pom.version}")) {
|
||||
sb.append("**Version:** ");
|
||||
sb.append(version);
|
||||
sb.append('\n');
|
||||
}
|
||||
String timestamp = props.getProperty("build.date");
|
||||
if (timestamp != null &&
|
||||
!timestamp.equals("${maven.build.timestamp}") && !timestamp.equals("${timestamp}")) {
|
||||
sb.append("**Build date:** ");
|
||||
sb.append(timestamp);
|
||||
sb.append('\n');
|
||||
}
|
||||
if (error != null) {
|
||||
sb.append("**Error:** `");
|
||||
sb.append(error);
|
||||
sb.append("`\n");
|
||||
}
|
||||
if (trace != null) {
|
||||
sb.append("**Stack trace:**");
|
||||
sb.append("\n```\n");
|
||||
sb.append(trace);
|
||||
sb.append("```");
|
||||
}
|
||||
URI uri = URI.create(String.format(Options.ISSUES_URL,
|
||||
URLEncoder.encode(issueTitle, "UTF-8"),
|
||||
URLEncoder.encode(sb.toString(), "UTF-8")));
|
||||
Desktop.getDesktop().browse(uri);
|
||||
} else if (n == 1)
|
||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
||||
} else {
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
@ -71,19 +70,10 @@ public class Options {
|
|||
public static final String FONT_NAME = "kochi-gothic.ttf";
|
||||
|
||||
/** Repository address. */
|
||||
public static URI REPOSITORY_URI;
|
||||
public static URI REPOSITORY_URI = URI.create("https://github.com/itdelatrisu/opsu");
|
||||
|
||||
/** Issue reporting address. */
|
||||
public static URI ISSUES_URI;
|
||||
|
||||
static {
|
||||
try {
|
||||
REPOSITORY_URI = new URI("https://github.com/itdelatrisu/opsu");
|
||||
ISSUES_URI = new URI("https://github.com/itdelatrisu/opsu/issues/new");
|
||||
} catch (URISyntaxException e) {
|
||||
Log.error("Problem loading URIs.", e);
|
||||
}
|
||||
}
|
||||
public static String ISSUES_URL = "https://github.com/itdelatrisu/opsu/issues/new?title=%s&body=%s";
|
||||
|
||||
/** The beatmap directory. */
|
||||
private static File beatmapDir;
|
||||
|
|
Loading…
Reference in New Issue
Block a user