Skip to content

Commit

Permalink
Update to include Pie (28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitry Ivanov committed Sep 25, 2018
1 parent 07be336 commit 99caf7e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 13 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

group 'ru.noties'
version '1.0.1'
version '1.0.2'

apply plugin: 'java'
apply plugin: 'application'
Expand Down Expand Up @@ -36,8 +36,8 @@ dependencies {
compile 'commons-io:commons-io:2.6'
}

task wrapper(type: Wrapper) {
gradleVersion '4.5'
wrapper {
gradleVersion '4.10.2'
distributionType 'all'
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Jan 29 21:52:20 MSK 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -155,7 +155,7 @@ if $cygwin ; then
fi

# Escape application args
save ( ) {
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/ru/noties/enhance/ApiVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@

public class ApiVersion {

@Nonnull
public static ApiVersion latest() {
return VERSIONS[VERSIONS.length - 1];
}

@Nonnull
public static ApiVersion of(int sdkInt) {
final ApiVersion version;
if (sdkInt < 0
|| (sdkInt - 1) >= LENGTH) {
version = new ApiVersion(sdkInt, "unknown", "unknown");
version = new ApiVersion(sdkInt, "unknown", "unknown", true);
} else {
version = VERSIONS[sdkInt - 1];
}
Expand All @@ -19,11 +24,17 @@ public static ApiVersion of(int sdkInt) {
private final int sdkInt;
private final String versionName;
private final String codeName;
private final boolean unknown;

private ApiVersion(int sdkInt, @Nonnull String versionName, @Nonnull String codeName) {
this(sdkInt, versionName, codeName, false);
}

private ApiVersion(int sdkInt, @Nonnull String versionName, @Nonnull String codeName, boolean unknown) {
this.sdkInt = sdkInt;
this.versionName = versionName;
this.codeName = codeName;
this.unknown = unknown;
}

public int getSdkInt() {
Expand All @@ -40,12 +51,17 @@ public String getCodeName() {
return codeName;
}

public boolean isUnknown() {
return unknown;
}

@Override
public String toString() {
return "ApiVersion{" +
"sdkInt=" + sdkInt +
", versionName='" + versionName + '\'' +
", codeName='" + codeName + '\'' +
", unknown=" + unknown +
'}';
}

Expand Down Expand Up @@ -76,7 +92,8 @@ public String toString() {
new ApiVersion(24, "7.0", "Nougat"),
new ApiVersion(25, "7.1", "Nougat"),
new ApiVersion(26, "8.0", "Oreo"),
new ApiVersion(27, "8.1", "Oreo")
new ApiVersion(27, "8.1", "Oreo"),
new ApiVersion(28, "9.0", "Pie")
};

private static final int LENGTH = VERSIONS.length;
Expand Down
33 changes: 30 additions & 3 deletions src/main/java/ru/noties/enhance/Enhance.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import ru.noties.enhance.options.EnhanceOptions;

import javax.annotation.Nonnull;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Locale;

import static ru.noties.enhance.Log.log;

Expand All @@ -15,12 +18,36 @@ public class Enhance {

public static void main(String[] args) {

log("[Enhance] version: %s", EnhanceVersion.NAME);
final ApiVersionFormatter apiVersionFormatter = ApiVersionFormatter.create();

final long start = System.currentTimeMillis();
log("[Enhance] version: %s", EnhanceVersion.NAME);
log("[Enhance] latest SDK version: %s", apiVersionFormatter.format(ApiVersion.latest()));
log("[Enhance] https://github.com/noties/Enhance");

final EnhanceOptions options = EnhanceOptions.create(args);

// @since 1.0.2
// check if we have this version info included and ask user if he/she want to proceed if
// supplied sdk is not known to this library version
final ApiVersion apiVersion = ApiVersion.of(options.sdk());
if (apiVersion.isUnknown()) {

System.err.printf(Locale.US, "[Enhance] WARNING: specified SDK version %d (`%s`) is unknown to this " +
"library version, do you wish to proceed anyway? (Y|N)%n", options.sdk(),
apiVersionFormatter.format(apiVersion));

try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
final String line = reader.readLine();
if (!"y".equalsIgnoreCase(line)) {
return;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}

final long start = System.currentTimeMillis();

log("[Enhance] obtaining required files/folders");

final SdkHelper sdkHelper = SdkHelper.create(options);
Expand Down Expand Up @@ -94,7 +121,7 @@ public static void main(String[] args) {

log("[Enhance] processing source files");

final EnhanceWriter writer = EnhanceWriter.create(options.sourceFormat(), store, ApiVersionFormatter.create());
final EnhanceWriter writer = EnhanceWriter.create(options.sourceFormat(), store, apiVersionFormatter);
writer.write(source, sdkSources);

final long took = System.currentTimeMillis() - start;
Expand Down

0 comments on commit 99caf7e

Please sign in to comment.