Skip to content

Commit

Permalink
CB-11244: Android Studio 3 work, things have changed with how the pla…
Browse files Browse the repository at this point in the history
…tform is built
  • Loading branch information
infil00p committed Nov 2, 2017
1 parent 8ba0109 commit 18d6884
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions bin/templates/cordova/lib/builders/StudioBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ StudioBuilder.prototype.prepBuildFiles = function () {
'include ":"\n' + settingsGradlePaths.join(''));

// Update dependencies within build.gradle.
var buildGradle = fs.readFileSync(path.join(this.root, 'build.gradle'), 'utf8');
var buildGradle = fs.readFileSync(path.join(this.root, 'app', 'build.gradle'), 'utf8');
var depsList = '';
var root = this.root;
var insertExclude = function (p) {
Expand All @@ -170,8 +170,10 @@ StudioBuilder.prototype.prepBuildFiles = function () {
subProjects.forEach(function (p) {
console.log('Subproject Path: ' + p);
var libName = p.replace(/[/\\]/g, ':').replace(name + '-', '');
depsList += ' implementation(project(path: "' + libName + '", configuration: "release"))';
insertExclude(p);
if(libName !== 'app') {
depsList += ' implementation(project(path: ":' + libName + '"))';
insertExclude(p);
}
});
// For why we do this mapping: https://issues.apache.org/jira/browse/CB-8390
var SYSTEM_LIBRARY_MAPPINGS = [
Expand Down Expand Up @@ -223,7 +225,7 @@ StudioBuilder.prototype.prepEnv = function (opts) {
// If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with.
// For some reason, using ^ and $ don't work. This does the job, though.
var distributionUrlRegex = /distributionUrl.*zip/;
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-3.3-all.zip';
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.1-all.zip';
var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');
shell.chmod('u+w', gradleWrapperPropertiesPath);
shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath);
Expand Down
9 changes: 6 additions & 3 deletions bin/templates/project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:3.0.0'
}
}

Expand All @@ -39,7 +42,7 @@ allprojects {
}

task wrapper(type: Wrapper) {
gradleVersion = '3.3.0'
gradleVersion = '4.1.0'
}

// Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties.
Expand Down Expand Up @@ -227,7 +230,7 @@ android {


dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: ":CordovaLib", configuration: "debug"))
releaseCompile(project(path: ":CordovaLib", configuration: "release"))
Expand Down

0 comments on commit 18d6884

Please sign in to comment.