Skip to content

Commit

Permalink
Update Gradle to 3.0/4.1 ; SDK 27
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Oct 26, 2017
1 parent 80824cb commit 135282f
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 106 deletions.
6 changes: 6 additions & 0 deletions .atomignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ app/build
app/.gitignore
app/pom.xml
app/proguard-rules.pro
.hidden
.travis.yml
circle.yml
CODE_OF_CONDUCT*
gradle.properties
LICENSE*
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
language: android
jdk: oraclejdk8

before_cache:
# Do not cache a few Gradle files/directories (see https://docs.travis-ci.com/user/languages/java/#Caching)
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
# Android SDK
- $HOME/android-sdk-dl
- $HOME/android-sdk

# Gradle dependencies
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

# Android build cache (see http://tools.android.com/tech-docs/build-cache)
- $HOME/.android/build-cache

install:
# Download and unzip the Android SDK tools (if not already there thanks to the cache mechanism)
# Latest version available here: https://developer.android.com/studio/index.html#downloads
- if test ! -e $HOME/android-sdk-dl/sdk-tools.zip ; then curl https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip > $HOME/android-sdk-dl/sdk-tools.zip ; fi
- unzip -qq -n $HOME/android-sdk-dl/sdk-tools.zip -d $HOME/android-sdk

# Install or update Android SDK components (will not do anything if already up to date thanks to the cache mechanism)
- echo y | $HOME/android-sdk/tools/bin/sdkmanager 'tools' > /dev/null
- echo y | $HOME/android-sdk/tools/bin/sdkmanager 'platform-tools' > /dev/null
- echo y | $HOME/android-sdk/tools/bin/sdkmanager 'build-tools;26.0.2' > /dev/null
- echo y | $HOME/android-sdk/tools/bin/sdkmanager 'platforms;android-27' > /dev/null
- echo y | $HOME/android-sdk/tools/bin/sdkmanager 'extras;google;m2repository' > /dev/null

branches:
except:
- gh-pages
- l10n_master
- crowdin

env:
global:
- ANDROID_HOME=$HOME/android-sdk
matrix:
- TASK="lintFlavorDefaultDebug --stacktrace"
- TASK="build check --stacktrace"

script: "./gradlew --no-daemon --parallel $TASK"
101 changes: 35 additions & 66 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,38 @@ apply plugin: 'com.android.application'

ext {
version_sdk = [
compileSdk: 26,
buildTools: "26.0.1",
minSdk : 16,
//targetSdk: compileSdk,
compileSdk: 27,
minSdk : 14,
]
version_sdk.targetSdk = version_sdk.compileSdk
version_lib = [
appcompat : "26.1.0",
appcompat : "27.0.0",
butterknife: "8.8.1",
commonmark: "0.10.0",
]
}

android {
compileSdkVersion version_sdk.compileSdk
buildToolsVersion version_sdk.buildTools
flavorDimensions "default"

defaultConfig {
minSdkVersion version_sdk.minSdk
targetSdkVersion version_sdk.targetSdk

versionCode 6
versionName "0.1.5"

applicationId "net.gsantner.markor"

targetSdkVersion version_sdk.compileSdk
buildConfigField "boolean", "IS_TEST_BUILD", "false"
buildConfigField "boolean", "IS_GPLAY_BUILD", "false"
buildConfigField("String[]", "APPLICATION_LANGUAGES", '{' + getUsedAndroidLanguages().collect {"\"${it}\""}.join(",") + '}')
buildConfigField "String", "GITHASH", "\"${getGitHash()}\""

applicationId "net.gsantner.markor"
versionName "0.1.5"
versionCode 6
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
minifyEnabled false
Expand Down Expand Up @@ -60,32 +62,32 @@ android {

dependencies {
// Android standard libs
compile "com.android.support:appcompat-v7:${version_lib.appcompat}"
compile "com.android.support:design:${version_lib.appcompat}"
compile "com.android.support:support-v4:${version_lib.appcompat}"
compile "com.android.support:recyclerview-v7:${version_lib.appcompat}"
compile "com.android.support:palette-v7:${version_lib.appcompat}"
implementation "com.android.support:appcompat-v7:${version_lib.appcompat}"
implementation "com.android.support:design:${version_lib.appcompat}"
implementation "com.android.support:support-v4:${version_lib.appcompat}"
implementation "com.android.support:recyclerview-v7:${version_lib.appcompat}"
implementation "com.android.support:palette-v7:${version_lib.appcompat}"

// UI libs
compile 'com.mobsandgeeks:adapter-kit:0.5.3'
compile "com.atlassian.commonmark:commonmark:${version_lib.commonmark}"
compile "com.atlassian.commonmark:commonmark-ext-gfm-strikethrough:${version_lib.commonmark}"
compile "com.atlassian.commonmark:commonmark-ext-gfm-tables:${version_lib.commonmark}"
compile "com.atlassian.commonmark:commonmark-ext-autolink:${version_lib.commonmark}"
compile "com.atlassian.commonmark:commonmark-ext-ins:${version_lib.commonmark}"
compile "com.atlassian.commonmark:commonmark-ext-yaml-front-matter:${version_lib.commonmark}"
compile "com.atlassian.commonmark:commonmark-ext-heading-anchor:${version_lib.commonmark}"
implementation 'com.mobsandgeeks:adapter-kit:0.5.3'
implementation "com.atlassian.commonmark:commonmark:${version_lib.commonmark}"
implementation "com.atlassian.commonmark:commonmark-ext-gfm-strikethrough:${version_lib.commonmark}"
implementation "com.atlassian.commonmark:commonmark-ext-gfm-tables:${version_lib.commonmark}"
implementation "com.atlassian.commonmark:commonmark-ext-autolink:${version_lib.commonmark}"
implementation "com.atlassian.commonmark:commonmark-ext-ins:${version_lib.commonmark}"
implementation "com.atlassian.commonmark:commonmark-ext-yaml-front-matter:${version_lib.commonmark}"
implementation "com.atlassian.commonmark:commonmark-ext-heading-anchor:${version_lib.commonmark}"


// Tool libraries
compile "com.jakewharton:butterknife:${version_lib.butterknife}"
compile 'commons-io:commons-io:2.5'
compile 'com.google.code.gson:gson:2.8.1'
implementation "com.jakewharton:butterknife:${version_lib.butterknife}"
implementation 'commons-io:commons-io:2.5'
implementation 'com.google.code.gson:gson:2.8.1'

// Testing
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.8.0'
testCompile 'org.mockito:mockito-all:1.10.19'
testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:3.8.0'
testImplementation 'org.mockito:mockito-all:1.10.19'
testCompile('org.robolectric:robolectric:3.4.2') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
Expand All @@ -94,36 +96,3 @@ dependencies {
// Processors
annotationProcessor "com.jakewharton:butterknife-compiler:${version_lib.butterknife}"
}


@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection"])
static String[] getUsedAndroidLanguages() {
Set<String> langs = new HashSet<>()
new File('.').eachFileRecurse(groovy.io.FileType.DIRECTORIES) {
final foldername = it.name
if (foldername.startsWith('values-') && !it.canonicalPath.contains("build" + File.separator + "intermediates")) {
new File(it.toString()).eachFileRecurse(groovy.io.FileType.FILES) {
if (it.name.toLowerCase().endsWith(".xml") && it.getCanonicalFile().getText('UTF-8').contains("<string")) {
langs.add(foldername.replace("values-", ""))

}
}
}
}
return langs.toArray(new String[langs.size()])
}

final String RAW_DIR = "app/src/main/res/raw"
final String[] ROOT_TO_RAW_COPYFILES = ["README.md", "LICENSE.txt", "CHANGELOG.md", "CONTRIBUTORS.md"]

// Called before building
task copyRepoFiles(type: Copy) {

// Copy files over to raw dir
from rootProject.files(ROOT_TO_RAW_COPYFILES)
into RAW_DIR.replaceFirst("app/", "")
rename { String fileName ->
fileName.replace(fileName, fileName.toLowerCase())
}
}
tasks.copyRepoFiles.execute()
6 changes: 3 additions & 3 deletions app/src/main/java/net/gsantner/opoc/util/ContextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ public void setTintColorOfButton(AppCompatButton button, @ColorRes int resColor)
));
}

@SuppressLint("MissingPermission") // ACCESS_NETWORK_STATE required
public boolean isConnectedToInternet() {
ConnectivityManager connectivityManager = (ConnectivityManager)
_context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
ConnectivityManager con = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = con == null ? null : con.getActiveNetworkInfo();
return activeNetInfo != null && activeNetInfo.isConnectedOrConnecting();
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/ui__filesystem_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="middle"
android:lines="1"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:textSize="15sp"
tools:text="/sdcard/Documents/somewhere"/>
Expand Down
39 changes: 35 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -20,10 +20,41 @@ allprojects {
google()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

final String[] ROOT_TO_RAW_COPYFILES = ["README.md", "LICENSE.txt", "CHANGELOG.md", "CONTRIBUTORS.md"]
task copyRepoFiles(type: Copy) {
from rootProject.files(ROOT_TO_RAW_COPYFILES)
into "app/src/main/res/raw"
rename { String fileName -> fileName.replace(fileName, fileName.toLowerCase()) }
} ; tasks.copyRepoFiles.execute()

@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection", "GroovyUnusedDeclaration"])
static String[] getUsedAndroidLanguages() {
Set<String> langs = new HashSet<>()
new File('.').eachFileRecurse(groovy.io.FileType.DIRECTORIES) {
final foldername = it.name
if (foldername.startsWith('values-') && !it.canonicalPath.contains("build" + File.separator + "intermediates")) {
new File(it.toString()).eachFileRecurse(groovy.io.FileType.FILES) {
if (it.name.toLowerCase().endsWith(".xml") && it.getCanonicalFile().getText('UTF-8').contains("<string")) {
langs.add(foldername.replace("values-", ""))
}
}
}
}
return langs.toArray(new String[langs.size()])
}

ext.getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
58 changes: 28 additions & 30 deletions gradle.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
# TODO: disable daemon on CI, since builds should be clean and reliable on servers
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true

# Enables new incubating mode that makes Gradle selective when configuring projects.
# Only relevant projects are configured which results in faster builds for large multi-projects.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true


org.gradle.daemon=true

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
# TODO: disable daemon on CI, since builds should be clean and reliable on servers
org.gradle.daemon=true

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true

# Enables new incubating mode that makes Gradle selective when configuring projects.
# Only relevant projects are configured which results in faster builds for large multi-projects.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 26 17:46:57 CEST 2017
#Thu Oct 26 13:46:14 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

0 comments on commit 135282f

Please sign in to comment.