Use the flutter.jar in the artifact cache by default (#3278)
See https://github.com/flutter/flutter/issues/3233
This commit is contained in:
parent
ec4a6a96f2
commit
3525aa1b0a
@ -8,7 +8,6 @@ To build this project:
|
|||||||
* Create a `local.properties` file with these entries:
|
* Create a `local.properties` file with these entries:
|
||||||
* `sdk.dir=[path to the Android SDK]`
|
* `sdk.dir=[path to the Android SDK]`
|
||||||
* `flutter.sdk=[path to the Flutter SDK]`
|
* `flutter.sdk=[path to the Flutter SDK]`
|
||||||
* `flutter.jar=[path to the flutter.jar file in your build of the Flutter engine]`
|
|
||||||
|
|
||||||
Then run:
|
Then run:
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package org.domokit.sky.gradle
|
package org.domokit.sky.gradle
|
||||||
|
|
||||||
import com.android.builder.model.AndroidProject
|
import com.android.builder.model.AndroidProject
|
||||||
|
import com.google.common.base.Joiner
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.GradleException
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
@ -25,15 +26,6 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
Properties properties = new Properties()
|
Properties properties = new Properties()
|
||||||
properties.load(project.rootProject.file("local.properties").newDataInputStream())
|
properties.load(project.rootProject.file("local.properties").newDataInputStream())
|
||||||
|
|
||||||
String enginePath = properties.getProperty("flutter.jar")
|
|
||||||
if (enginePath == null) {
|
|
||||||
throw new GradleException("flutter.jar must be defined in local.properties")
|
|
||||||
}
|
|
||||||
FileCollection flutterEngine = project.files(enginePath)
|
|
||||||
if (!flutterEngine.singleFile.isFile()) {
|
|
||||||
throw new GradleException("flutter.jar must point to a Flutter engine JAR")
|
|
||||||
}
|
|
||||||
|
|
||||||
String sdkPath = properties.getProperty("flutter.sdk")
|
String sdkPath = properties.getProperty("flutter.sdk")
|
||||||
if (sdkPath == null) {
|
if (sdkPath == null) {
|
||||||
throw new GradleException("flutter.sdk must be defined in local.properties")
|
throw new GradleException("flutter.sdk must be defined in local.properties")
|
||||||
@ -43,6 +35,27 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
throw new GradleException("flutter.sdk must point to the Flutter SDK directory")
|
throw new GradleException("flutter.sdk must point to the Flutter SDK directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File flutterJar
|
||||||
|
String flutterJarPath = properties.getProperty("flutter.jar")
|
||||||
|
if (flutterJarPath != null) {
|
||||||
|
flutterJar = project.file(flutterJarPath)
|
||||||
|
if (!flutterJar.isFile()) {
|
||||||
|
throw new GradleException("flutter.jar must point to a Flutter engine JAR")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
flutterJar = new File(sdkDir, Joiner.on(File.separatorChar).join(
|
||||||
|
"bin", "cache", "artifacts", "engine", "android-arm", "flutter.jar"))
|
||||||
|
if (!flutterJar.isFile()) {
|
||||||
|
project.exec {
|
||||||
|
executable "${sdkDir}/bin/flutter"
|
||||||
|
args "precache"
|
||||||
|
}
|
||||||
|
if (!flutterJar.isFile()) {
|
||||||
|
throw new GradleException("Unable to find flutter.jar in SDK: ${flutterJar}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String engineSrcPath = properties.getProperty("flutter.engineSrcPath")
|
String engineSrcPath = properties.getProperty("flutter.engineSrcPath")
|
||||||
if (engineSrcPath != null) {
|
if (engineSrcPath != null) {
|
||||||
engineSrcDir = project.file(engineSrcPath)
|
engineSrcDir = project.file(engineSrcPath)
|
||||||
@ -52,7 +65,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
project.extensions.create("flutter", FlutterExtension)
|
project.extensions.create("flutter", FlutterExtension)
|
||||||
project.dependencies.add("compile", flutterEngine)
|
project.dependencies.add("compile", project.files(flutterJar))
|
||||||
project.afterEvaluate this.&addFlutterTask
|
project.afterEvaluate this.&addFlutterTask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user