Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
36bcdc4c
Unverified
Commit
36bcdc4c
authored
Dec 20, 2017
by
Mikkel Nygaard Ravn
Committed by
GitHub
Dec 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Android templates (#13681)
parent
39c2521f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
28 deletions
+68
-28
gradle_plugin_test.dart
dev/devicelab/bin/tasks/gradle_plugin_test.dart
+64
-22
build.gradle
...ter_tools/templates/create/android-java.tmpl/build.gradle
+2
-0
build.gradle
...r_tools/templates/create/android-kotlin.tmpl/build.gradle
+2
-0
gradle-wrapper.properties
...gin/android.tmpl/gradle/wrapper/gradle-wrapper.properties
+0
-6
No files found.
dev/devicelab/bin/tasks/gradle_plugin_test.dart
View file @
36bcdc4c
...
...
@@ -9,11 +9,19 @@ import 'package:path/path.dart' as path;
import
'package:flutter_devicelab/framework/framework.dart'
;
import
'package:flutter_devicelab/framework/utils.dart'
;
String
javaHome
;
void
main
(
)
{
task
(()
async
{
section
(
'Setting up flutter project'
);
section
(
'Running flutter doctor to get JAVA_HOME'
);
final
String
flutterDoctor
=
await
evalFlutter
(
'doctor'
);
final
RegExp
javaHomeExtractor
=
new
RegExp
(
r'Android Studio at (.*)'
);
javaHome
=
javaHomeExtractor
.
firstMatch
(
flutterDoctor
).
group
(
1
)
+
'/jre'
;
section
(
'Setting up flutter projects'
);
final
Directory
tmp
=
await
Directory
.
systemTemp
.
createTemp
(
'gradle'
);
final
FlutterProject
project
=
await
FlutterProject
.
create
(
tmp
,
'hello'
);
final
FlutterPluginProject
pluginProject
=
await
FlutterPluginProject
.
create
(
tmp
,
'aaa'
);
try
{
section
(
'gradlew assembleDebug'
);
...
...
@@ -63,6 +71,11 @@ void main() {
return
_failure
(
'flutter build apk should not invoke Gradle repeatedly on error'
,
result
);
}
section
(
'gradlew assembleDebug on plugin example'
);
await
pluginProject
.
runGradleTask
(
'assembleDebug'
);
if
(!
pluginProject
.
hasDebugApk
)
return
new
TaskResult
.
failure
(
'Gradle did not produce an apk file at the expected place'
);
return
new
TaskResult
.
success
(
null
);
}
catch
(
e
)
{
return
new
TaskResult
.
failure
(
e
.
toString
());
...
...
@@ -85,20 +98,16 @@ bool _hasMultipleOccurrences(String text, Pattern pattern) {
}
class
FlutterProject
{
FlutterProject
(
this
.
parent
,
this
.
name
,
this
.
javaPath
);
FlutterProject
(
this
.
parent
,
this
.
name
);
final
Directory
parent
;
final
String
name
;
final
String
javaPath
;
static
Future
<
FlutterProject
>
create
(
Directory
directory
,
String
name
)
async
{
await
inDirectory
(
directory
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
name
]);
});
final
String
flutterDoctor
=
await
evalFlutter
(
'doctor'
);
final
RegExp
javaPathExtractor
=
new
RegExp
(
r'Android Studio at (.*)'
);
final
String
javaPath
=
javaPathExtractor
.
firstMatch
(
flutterDoctor
).
group
(
1
)
+
'/jre'
;
return
new
FlutterProject
(
directory
,
name
,
javaPath
);
return
new
FlutterProject
(
directory
,
name
);
}
String
get
rootPath
=>
path
.
join
(
parent
.
path
,
name
);
...
...
@@ -146,24 +155,11 @@ android {
}
Future
<
Null
>
runGradleTask
(
String
task
)
async
{
final
ProcessResult
result
=
await
resultOfGradleTask
(
task
);
if
(
result
.
exitCode
!=
0
)
{
print
(
'stdout:'
);
print
(
result
.
stdout
);
print
(
'stderr:'
);
print
(
result
.
stderr
);
}
if
(
result
.
exitCode
!=
0
)
throw
'Gradle exited with error'
;
return
_runGradleTask
(
workingDirectory:
androidPath
,
task:
task
);
}
Future
<
ProcessResult
>
resultOfGradleTask
(
String
task
)
{
return
Process
.
run
(
'./gradlew'
,
<
String
>[
'app:
$task
'
],
workingDirectory:
androidPath
,
environment:
<
String
,
String
>{
'JAVA_HOME'
:
javaPath
}
);
return
_resultOfGradleTask
(
workingDirectory:
androidPath
,
task:
task
);
}
Future
<
ProcessResult
>
resultOfFlutterCommand
(
String
command
,
List
<
String
>
options
)
{
...
...
@@ -174,3 +170,49 @@ android {
);
}
}
class
FlutterPluginProject
{
FlutterPluginProject
(
this
.
parent
,
this
.
name
);
final
Directory
parent
;
final
String
name
;
static
Future
<
FlutterPluginProject
>
create
(
Directory
directory
,
String
name
)
async
{
await
inDirectory
(
directory
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'-t'
,
'plugin'
,
name
]);
});
return
new
FlutterPluginProject
(
directory
,
name
);
}
String
get
rootPath
=>
path
.
join
(
parent
.
path
,
name
);
String
get
examplePath
=>
path
.
join
(
rootPath
,
'example'
);
String
get
exampleAndroidPath
=>
path
.
join
(
examplePath
,
'android'
);
String
get
debugApkPath
=>
path
.
join
(
examplePath
,
'build'
,
'app'
,
'outputs'
,
'apk'
,
'debug'
,
'app-debug.apk'
);
Future
<
Null
>
runGradleTask
(
String
task
)
async
{
return
_runGradleTask
(
workingDirectory:
exampleAndroidPath
,
task:
task
);
}
bool
get
hasDebugApk
=>
new
File
(
debugApkPath
).
existsSync
();
}
Future
<
Null
>
_runGradleTask
({
String
workingDirectory
,
String
task
})
async
{
final
ProcessResult
result
=
await
_resultOfGradleTask
(
workingDirectory:
workingDirectory
,
task:
task
);
if
(
result
.
exitCode
!=
0
)
{
print
(
'stdout:'
);
print
(
result
.
stdout
);
print
(
'stderr:'
);
print
(
result
.
stderr
);
}
if
(
result
.
exitCode
!=
0
)
throw
'Gradle exited with error'
;
}
Future
<
ProcessResult
>
_resultOfGradleTask
({
String
workingDirectory
,
String
task
})
{
return
Process
.
run
(
'./gradlew'
,
<
String
>[
'app:
$task
'
],
workingDirectory:
workingDirectory
,
environment:
<
String
,
String
>{
'JAVA_HOME'
:
javaHome
}
);
}
packages/flutter_tools/templates/create/android-java.tmpl/build.gradle
View file @
36bcdc4c
...
...
@@ -19,6 +19,8 @@ allprojects {
rootProject
.
buildDir
=
'../build'
subprojects
{
project
.
buildDir
=
"${rootProject.buildDir}/${project.name}"
}
subprojects
{
project
.
evaluationDependsOn
(
':app'
)
}
...
...
packages/flutter_tools/templates/create/android-kotlin.tmpl/build.gradle
View file @
36bcdc4c
...
...
@@ -21,6 +21,8 @@ allprojects {
rootProject
.
buildDir
=
'../build'
subprojects
{
project
.
buildDir
=
"${rootProject.buildDir}/${project.name}"
}
subprojects
{
project
.
evaluationDependsOn
(
':app'
)
}
...
...
packages/flutter_tools/templates/plugin/android.tmpl/gradle/wrapper/gradle-wrapper.properties
deleted
100644 → 0
View file @
39c2521f
#Fri Jun 23 08:50:38 CEST 2017
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.1-all.zip
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment