From b6ea74db520f823ac87b8342f9a3f08823ff9409 Mon Sep 17 00:00:00 2001 From: Yohann Roussel Date: Tue, 16 Jun 2015 16:50:29 +0200 Subject: Use schedlib Version in Jill (cherry picked from commit 8ed0a0157dc249d2d79d29099404aaaced3f8965) Change-Id: I851fb9923ea185043f4cbfb7c8c073f2d9343cac --- jill/src/com/android/jill/Jill.java | 13 ++-- jill/src/com/android/jill/Version.java | 122 --------------------------------- 2 files changed, 5 insertions(+), 130 deletions(-) delete mode 100644 jill/src/com/android/jill/Version.java diff --git a/jill/src/com/android/jill/Jill.java b/jill/src/com/android/jill/Jill.java index 0017175..6e1e9ac 100644 --- a/jill/src/com/android/jill/Jill.java +++ b/jill/src/com/android/jill/Jill.java @@ -18,10 +18,10 @@ package com.android.jill; import com.android.jill.frontend.java.JavaTransformer; import com.android.jill.utils.FileUtils; +import com.android.sched.util.Version; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.jar.JarFile; @@ -34,8 +34,6 @@ import javax.annotation.Nonnull; */ public class Jill { - @Nonnull - private static final String PROPERTIES_FILE = "jill.properties"; @CheckForNull private static Version version = null; @@ -66,11 +64,10 @@ public class Jill { @Nonnull public static Version getVersion() { if (version == null) { - InputStream is = Jill.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE); - if (is != null) { - version = new Version(is); - } else { - System.err.println("Failed to open Jack properties file " + PROPERTIES_FILE); + try { + version = new Version("jill", Jill.class.getClassLoader()); + } catch (IOException e) { + System.err.println("Failed to read version properties file: " + e.getMessage()); throw new AssertionError(); } } diff --git a/jill/src/com/android/jill/Version.java b/jill/src/com/android/jill/Version.java deleted file mode 100644 index 2f7f376..0000000 --- a/jill/src/com/android/jill/Version.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.jill; - -import com.android.jill.api.JillProvider.SubReleaseKind; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * A class describing version, release, build & code. - */ -public class Version { - - @Nonnull - private String version; - @Nonnull - private String releaseName; - @Nonnegative - private int releaseCode; - @Nonnull - private SubReleaseKind subReleaseKind; - @Nonnegative - private int subReleaseCode; - @CheckForNull - private String buildId; - @CheckForNull - private String codeBase; - - public Version(@Nonnull InputStream is) { - Properties prop = new Properties(); - try { - prop.load(is); - - version = prop.getProperty("jill.version"); - assert version != null; - - releaseName = prop.getProperty("jill.version.release.name"); - assert releaseName != null; - - releaseCode = Integer.parseInt(prop.getProperty("jill.version.release.code")); - assert releaseCode >= 1; - - subReleaseCode = Integer.parseInt(prop.getProperty("jill.version.sub-release.code")); - assert subReleaseCode >= 1; - - subReleaseKind = - SubReleaseKind.valueOf(SubReleaseKind.class, - prop.getProperty("jill.version.sub-release.kind")); - buildId = prop.getProperty("jill.version.buildid"); - codeBase = prop.getProperty("jill.version.sha"); - - if (codeBase == null || buildId == null) { - subReleaseKind = SubReleaseKind.ENGINEERING; - } - } catch (IOException e) { - System.err.println("Failed to read Jill properties"); - throw new AssertionError(e); - } - } - - @Nonnull - public String getVersion() { - return version; - } - - @Nonnull - public String getReleaseName() { - return releaseName; - } - - @Nonnegative - public int getReleaseCode() { - return releaseCode; - } - - @Nonnull - public SubReleaseKind getSubReleaseKind() { - return subReleaseKind; - } - - @Nonnegative - public int getSubReleaseCode() { - return subReleaseCode; - } - - @CheckForNull - public String getBuildId() { - return buildId; - } - - @CheckForNull - public String getCodeBase() { - return codeBase; - } - - @Nonnull - public String getVerboseVersion() { - return version + " '" + releaseName + "' (" - + (buildId != null ? buildId : "engineering") - + (codeBase != null ? (' ' + codeBase) : "") + ")"; - } -} \ No newline at end of file -- cgit v1.1