Skip to content

Instantly share code, notes, and snippets.

@jasonwyatt
Last active August 2, 2017 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonwyatt/d358e40027310d7983c6d69b030549d7 to your computer and use it in GitHub Desktop.
Save jasonwyatt/d358e40027310d7983c6d69b030549d7 to your computer and use it in GitHub Desktop.
import java.util.regex.Pattern
class VersionInfo {
private static Pattern VERSION_NAME_PATTERN = Pattern.compile("versionName='([0-9]+(\\.[0-9]+)+)'", Pattern.MULTILINE)
private static Pattern VERSION_CODE_PATTERN = Pattern.compile("versionCode='([0-9]+)'", Pattern.MULTILINE)
public File apkFile;
public String versionName;
public int versionCode;
public VersionInfo(File apkFile, String aaptOutput) {
def nameMatcher = VERSION_NAME_PATTERN.matcher(aaptOutput)
def codeMatcher = VERSION_CODE_PATTERN.matcher(aaptOutput)
nameMatcher.find()
codeMatcher.find()
this.apkFile = apkFile;
this.versionName = nameMatcher.group(1)
this.versionCode = Integer.parseInt(codeMatcher.group(1), 10)
}
@Override
String toString() {
return "VersionInfo(\"${apkFile}\", versionName=\"${versionName}\", versionCode=\"${versionCode}\")"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment