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>
|
<groupId>itdelatrisu</groupId>
|
||||||
<artifactId>opsu</artifactId>
|
<artifactId>opsu</artifactId>
|
||||||
<version>0.6.0</version>
|
<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>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
<filtering>false</filtering>
|
||||||
<directory>res</directory>
|
<directory>res</directory>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/Thumbs.db</exclude>
|
<exclude>**/Thumbs.db</exclude>
|
||||||
|
<exclude>**/version</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>res</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/version</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
#Mon, 03 Jun 2013 22:20:24 +0100
|
# opsu! build info
|
||||||
#Sun May 11 20:17:03 BST 2008
|
version=${pom.version}
|
||||||
|
build.date=${timestamp}
|
||||||
|
|
||||||
|
# slick build
|
||||||
build=237
|
build=237
|
||||||
|
|
|
@ -22,6 +22,9 @@ import java.awt.Cursor;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
@ -29,6 +32,7 @@ import javax.swing.JTextArea;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
import org.newdawn.slick.util.Log;
|
import org.newdawn.slick.util.Log;
|
||||||
|
import org.newdawn.slick.util.ResourceLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error handler to log and display errors.
|
* Error handler to log and display errors.
|
||||||
|
@ -92,10 +96,12 @@ public class ErrorHandler {
|
||||||
textArea.append(error);
|
textArea.append(error);
|
||||||
textArea.append("\n");
|
textArea.append("\n");
|
||||||
}
|
}
|
||||||
|
String trace = null;
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
e.printStackTrace(new PrintWriter(sw));
|
||||||
textArea.append(sw.toString());
|
trace = sw.toString();
|
||||||
|
textArea.append(trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
// display popup
|
// display popup
|
||||||
|
@ -109,8 +115,39 @@ public class ErrorHandler {
|
||||||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||||
null, optionsR, optionsR[2]);
|
null, optionsR, optionsR[2]);
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
Desktop.getDesktop().browse(Options.ISSUES_URI);
|
// auto-fill debug information
|
||||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
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)
|
} else if (n == 1)
|
||||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
Desktop.getDesktop().open(Options.LOG_FILE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -71,19 +70,10 @@ public class Options {
|
||||||
public static final String FONT_NAME = "kochi-gothic.ttf";
|
public static final String FONT_NAME = "kochi-gothic.ttf";
|
||||||
|
|
||||||
/** Repository address. */
|
/** Repository address. */
|
||||||
public static URI REPOSITORY_URI;
|
public static URI REPOSITORY_URI = URI.create("https://github.com/itdelatrisu/opsu");
|
||||||
|
|
||||||
/** Issue reporting address. */
|
/** Issue reporting address. */
|
||||||
public static URI ISSUES_URI;
|
public static String ISSUES_URL = "https://github.com/itdelatrisu/opsu/issues/new?title=%s&body=%s";
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The beatmap directory. */
|
/** The beatmap directory. */
|
||||||
private static File beatmapDir;
|
private static File beatmapDir;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user