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

Add -Aversion command-line option; fixes #3381 #3464

Merged
merged 14 commits into from
Jul 20, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@

/// Amount of detail in messages

// Print the version of the checker framework
PRITI1999 marked this conversation as resolved.
Show resolved Hide resolved
"version",
mernst marked this conversation as resolved.
Show resolved Hide resolved
// Print info about git repository from which the Checker Framework was compiled
"printGitProperties",

Expand Down Expand Up @@ -781,6 +783,14 @@ public void run() {
}
});
}
if (hasOption("version")) {
String version = getCheckerVersion();
if (version == null) {
messager.printMessage(Kind.NOTE, "Version info not available!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstances is version null? Is that a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its never null for the current version. It can only be null if the tag in release.properties is not found in XML_FILE. Should I remove this check altogether and throw an exception if ever version is null?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since that would indicate an unexpected problem, I think that is the best approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the changes accordingly. Please re-review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PRITI1999 CI does not pass. Please make it pass before requesting a review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize. CI succeeds now.

} else {
messager.printMessage(Kind.NOTE, "checker-framework " + version);
PRITI1999 marked this conversation as resolved.
Show resolved Hide resolved
}
}
} catch (UserError ce) {
logUserError(ce);
} catch (TypeSystemError ce) {
Expand Down Expand Up @@ -2530,4 +2540,28 @@ private void printGitProperties() {
System.out.println("IOException while reading git.properties: " + e.getMessage());
}
}

/** Extract the version of the Checker Framework */
PRITI1999 marked this conversation as resolved.
Show resolved Hide resolved
private String getCheckerVersion() {
String version = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this variable needed?

Properties p = new Properties();
String RLS_FILE = "/docs/developer/release/release.properties";
p.putAll(getProperties(getClass(), RLS_FILE));
PRITI1999 marked this conversation as resolved.
Show resolved Hide resolved
String startTag = p.getProperty("checkers.ver.0");
String endTag = p.getProperty("checkers.ver.1");
String XML_FILE = "/docs/examples/MavenExample/pom.xml";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? It crashed for me when I tried to run it, because neither of the two files is not available in checker.jar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use git.properties instead. See method printGitProperties.

try {
InputStream in = getClass().getResourceAsStream(XML_FILE);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = reader.readLine()) != null && version == null) {
if (line.split(startTag).length > 1) {
version = line.split(startTag)[1].split(endTag)[0];
PRITI1999 marked this conversation as resolved.
Show resolved Hide resolved
}
}
} catch (IOException e) {
System.out.println("IOException while reading version information: " + e.getMessage());
PRITI1999 marked this conversation as resolved.
Show resolved Hide resolved
}
return version;
}
}