Skip to content

Commit

Permalink
Add fallback json Gradle project
Browse files Browse the repository at this point in the history
* Use java-mwapi Gradle project when available. Otherwise, use OSSHR
  module dependency.
* Require JDK7 compilation.

The Wikipedia Android app has transitioned from Maven to Gradle and
it's time for the json library to do the same. It has become too
burdensome to maintain a Maven repo and develop across multiple
projects. This patch replaces the Maven Gradle module dependency with a
Gradle Java project dependency, when present.

Json library dependency patch: https://gerrit.wikimedia.org/r/#/c/223718/

Bug: T105235, T103051
Change-Id: I1ea910bfb1200f37980c46b2d8ae8b51b4cfed90
  • Loading branch information
niedzielski authored and berndsi committed Jul 17, 2015
1 parent 826c282 commit 23c3bc4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.7.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -18,6 +19,6 @@ allprojects {
repositories {
mavenLocal()
jcenter()
maven { url 'https://tools.wmflabs.org/android-maven-repo' }
maven { url 'https://oss.sonatype.org/content/groups/staging' }
}
}
18 changes: 18 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
def fileExists = {String filename ->
new File(filename).exists()
}

def hierarchyToFilename = { String hierarchy ->
return hierarchy ? hierarchy.substring(1).replaceAll(':', File.separator) : hierarchy
}

def includeExists = { String projectPath, String name ->
if (fileExists(hierarchyToFilename(projectPath))) {
include projectPath

// Replace a generic name like "lib".
project(projectPath).name = name
}
}

include ':wikipedia'
includeExists ':java-mwapi:lib', 'json'
25 changes: 21 additions & 4 deletions wikipedia/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ def computeVersionName(label) {
return "2.0.${android.defaultConfig.versionCode}-${label}-${date}"
}

final JAVA_VERSION = JavaVersion.VERSION_1_7
if (JavaVersion.current() != JAVA_VERSION) {
throw new IllegalStateException("Incorrect Java Development Kit version; expected "
+ JAVA_VERSION + " but found " + JavaVersion.current())
}

android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
compileOptions {
sourceCompatibility = JAVA_VERSION
_targetCompatibility = JAVA_VERSION
}
defaultConfig {
applicationId 'org.wikipedia'
minSdkVersion 10
Expand Down Expand Up @@ -88,17 +98,24 @@ android {
}
}

def compileSubprojectOrModule = { String projectName,
String moduleName,
String excludeGroup = null,
String excludeModule = null ->
def dependency = project.findProject(projectName) ?: moduleName
project.dependencies.add('compile', dependency, {exclude group: excludeGroup, module: excludeModule })
}

dependencies {
compileSubprojectOrModule ':java-mwapi:json', 'org.mediawiki.api:json:1.3.2-SNAPSHOT', 'org.json', 'json'

// To keep the Maven Central dependencies up-to-date
// use http://gradleplease.appspot.com/ or http://search.maven.org/.
// Debug with ./gradlew -q wikipedia:dependencies --configuration compile

compile 'com.android.support:appcompat-v7:22.2.0' // includes support-v4
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:percent:22.2.0'
compile('org.mediawiki.api:json:1.3.2-SNAPSHOT') {
exclude group: 'org.json', module: 'json'
}
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup:otto:1.3.6'
Expand Down Expand Up @@ -140,4 +157,4 @@ if (propFile.canRead()) {
} else {
System.err.println propFile.toString() + ' not found'
android.buildTypes.release.signingConfig = null
}
}

0 comments on commit 23c3bc4

Please sign in to comment.
  NODES
COMMUNITY 1
Note 2
Project 21
USERS 1