Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move HawkEye project version Java constant to hawkeye-core #85

Closed
Tracked by #16
tisonkun opened this issue Aug 27, 2023 · 1 comment · Fixed by #88
Closed
Tracked by #16

Move HawkEye project version Java constant to hawkeye-core #85

tisonkun opened this issue Aug 27, 2023 · 1 comment · Fixed by #88
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@tisonkun
Copy link
Member

It's now under hawkeye-command but it should be in the core module for any other modules usage.

public final class CommandConstants {
public static final String UNKNOWN = "<unknown>";
public static final String VERSION;
static {
ClassLoader classLoader = CommandConstants.class.getClassLoader();
try (InputStream is = classLoader.getResourceAsStream("hawkeye.properties")) {
final Properties properties = new Properties();
properties.load(is);
VERSION = properties.getProperty("project.version", UNKNOWN);
} catch (IOException e) {
throw new UncheckedIOException("cannot load hawkeye properties file: hawkeye.properties", e);
} catch (Exception e) {
throw new UncheckedIOException("cannot load hawkeye properties file: hawkeye.properties", new IOException(e));
}
}
}

Originally made by #79.

@tisonkun tisonkun added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Aug 27, 2023
@tisonkun tisonkun mentioned this issue Aug 27, 2023
20 tasks
@tisonkun
Copy link
Member Author

tisonkun commented Aug 27, 2023

This should also fix a bug that:

$ docker run --rm -v $(pwd):/github/workspace ghcr.io/korandoru/hawkeye-native:v3 -V
Exception in thread "main" java.lang.ExceptionInInitializerError
	at io.korandoru.hawkeye.command.HawkEyeVersionProvider.getVersion(HawkEyeVersionProvider.java:24)
	at picocli.CommandLine$Model$CommandSpec.version(CommandLine.java:7032)
	at picocli.CommandLine.printVersionHelp(CommandLine.java:2749)
	at picocli.CommandLine.executeHelpRequest(CommandLine.java:1920)
	at picocli.CommandLine.executeHelpRequest(CommandLine.java:1909)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2176)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
	at picocli.CommandLine.execute(CommandLine.java:2078)
	at io.korandoru.hawkeye.command.HawkEyeCommandMain.main(HawkEyeCommandMain.java:35)
Caused by: java.io.UncheckedIOException: cannot load hawkeye properties file: hawkeye.properties
	at io.korandoru.hawkeye.command.CommandConstants.<clinit>(CommandConstants.java:37)
	... 9 more
Caused by: java.io.IOException: java.lang.NullPointerException: inStream parameter is null
	... 10 more
Caused by: java.lang.NullPointerException: inStream parameter is null
	at java.base@17.0.5/java.util.Objects.requireNonNull(Objects.java:233)
	at java.base@17.0.5/java.util.Properties.load(Properties.java:407)
	at io.korandoru.hawkeye.command.CommandConstants.<clinit>(CommandConstants.java:32)
	... 9 more

@tisonkun tisonkun self-assigned this Aug 28, 2023
tisonkun added a commit that referenced this issue Aug 28, 2023
This closes #85.

Signed-off-by: tison <wander4096@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant