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
c5999c74
Commit
c5999c74
authored
Jun 26, 2017
by
Mikkel Nygaard Ravn
Committed by
GitHub
Jun 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add gradle wrapper to project template (#10928)
parent
d97b13b5
Changes
15
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
216 additions
and
106 deletions
+216
-106
gradle_wrapper.version
bin/internal/gradle_wrapper.version
+1
-0
file_system.dart
packages/flutter_tools/lib/src/base/file_system.dart
+4
-2
os.dart
packages/flutter_tools/lib/src/base/os.dart
+19
-0
cache.dart
packages/flutter_tools/lib/src/cache.dart
+123
-79
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+21
-0
services.dart
packages/flutter_tools/lib/src/services.dart
+3
-5
build.gradle
...ter_tools/templates/create/android-java.tmpl/build.gradle
+1
-5
build.gradle
...r_tools/templates/create/android-kotlin.tmpl/build.gradle
+1
-5
.gitignore
...es/flutter_tools/templates/create/android.tmpl/.gitignore
+0
-4
gradle-wrapper.properties
...ate/android.tmpl/gradle/wrapper/gradle-wrapper.properties
+6
-0
build.gradle.tmpl
...ools/templates/plugin/android-java.tmpl/build.gradle.tmpl
+1
-1
build.gradle.tmpl
...ls/templates/plugin/android-kotlin.tmpl/build.gradle.tmpl
+1
-1
.gitignore
...es/flutter_tools/templates/plugin/android.tmpl/.gitignore
+0
-4
gradle-wrapper.properties
...gin/android.tmpl/gradle/wrapper/gradle-wrapper.properties
+6
-0
cache_test.dart
packages/flutter_tools/test/cache_test.dart
+29
-0
No files found.
bin/internal/gradle_wrapper.version
0 → 100644
View file @
c5999c74
0b5c1398d1d04ac245a310de98825cb7b3278e2a
packages/flutter_tools/lib/src/base/file_system.dart
View file @
c5999c74
...
...
@@ -71,10 +71,11 @@ void ensureDirectoryExists(String filePath) {
}
}
/// Recursively copies `srcDir` to `destDir`.
/// Recursively copies `srcDir` to `destDir`, invoking [onFileCopied] if
/// specified for each source/destination file pair.
///
/// Creates `destDir` if needed.
void
copyDirectorySync
(
Directory
srcDir
,
Directory
destDir
)
{
void
copyDirectorySync
(
Directory
srcDir
,
Directory
destDir
,
[
void
onFileCopied
(
File
srcFile
,
File
destFile
)]
)
{
if
(!
srcDir
.
existsSync
())
throw
new
Exception
(
'Source directory "
${srcDir.path}
" does not exist, nothing to copy'
);
...
...
@@ -86,6 +87,7 @@ void copyDirectorySync(Directory srcDir, Directory destDir) {
if
(
entity
is
File
)
{
final
File
newFile
=
destDir
.
fileSystem
.
file
(
newPath
);
newFile
.
writeAsBytesSync
(
entity
.
readAsBytesSync
());
onFileCopied
?.
call
(
entity
,
newFile
);
}
else
if
(
entity
is
Directory
)
{
copyDirectorySync
(
entity
,
destDir
.
fileSystem
.
directory
(
newPath
));
...
...
packages/flutter_tools/lib/src/base/os.dart
View file @
c5999c74
...
...
@@ -47,6 +47,8 @@ abstract class OperatingSystemUtils {
void
unzip
(
File
file
,
Directory
targetDirectory
);
void
unpack
(
File
gzippedTarFile
,
Directory
targetDirectory
);
/// Returns a pretty name string for the current operating system.
///
/// If available, the detailed version of the OS is included.
...
...
@@ -97,6 +99,12 @@ class _PosixUtils extends OperatingSystemUtils {
runSync
(<
String
>[
'unzip'
,
'-o'
,
'-q'
,
file
.
path
,
'-d'
,
targetDirectory
.
path
]);
}
// tar -xzf tarball -C dest
@override
void
unpack
(
File
gzippedTarFile
,
Directory
targetDirectory
)
{
runSync
(<
String
>[
'tar'
,
'-xzf'
,
gzippedTarFile
.
path
,
'-C'
,
targetDirectory
.
path
]);
}
@override
File
makePipe
(
String
path
)
{
runSync
(<
String
>[
'mkfifo'
,
path
]);
...
...
@@ -167,7 +175,18 @@ class _WindowsUtils extends OperatingSystemUtils {
@override
void
unzip
(
File
file
,
Directory
targetDirectory
)
{
final
Archive
archive
=
new
ZipDecoder
().
decodeBytes
(
file
.
readAsBytesSync
());
_unpackArchive
(
archive
,
targetDirectory
);
}
@override
void
unpack
(
File
gzippedTarFile
,
Directory
targetDirectory
)
{
final
Archive
archive
=
new
TarDecoder
().
decodeBytes
(
new
GZipDecoder
().
decodeBytes
(
gzippedTarFile
.
readAsBytesSync
()),
);
_unpackArchive
(
archive
,
targetDirectory
);
}
void
_unpackArchive
(
Archive
archive
,
Directory
targetDirectory
)
{
for
(
ArchiveFile
archiveFile
in
archive
.
files
)
{
// The archive package doesn't correctly set isFile.
if
(!
archiveFile
.
isFile
||
archiveFile
.
name
.
endsWith
(
'/'
))
...
...
packages/flutter_tools/lib/src/cache.dart
View file @
c5999c74
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/commands/create.dart
View file @
c5999c74
...
...
@@ -11,6 +11,7 @@ import '../android/android_sdk.dart' as android_sdk;
import
'../android/gradle.dart'
as
gradle
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/os.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../cache.dart'
;
...
...
@@ -167,6 +168,10 @@ class CreateCommand extends FlutterCommand {
}
generatedCount
+=
_renderTemplate
(
'create'
,
appPath
,
templateContext
);
generatedCount
+=
_injectGradleWrapper
(
appPath
);
if
(
appPath
!=
dirPath
)
{
generatedCount
+=
_injectGradleWrapper
(
dirPath
);
}
if
(
argResults
[
'with-driver-test'
])
{
final
String
testPath
=
fs
.
path
.
join
(
appPath
,
'test_driver'
);
generatedCount
+=
_renderTemplate
(
'driver'
,
testPath
,
templateContext
);
...
...
@@ -272,6 +277,22 @@ To edit platform code in an IDE see https://flutter.io/platform-plugins/#edit-co
final
Template
template
=
new
Template
.
fromName
(
templateName
);
return
template
.
render
(
fs
.
directory
(
dirPath
),
context
,
overwriteExisting:
false
);
}
int
_injectGradleWrapper
(
String
projectDir
)
{
int
filesCreated
=
0
;
copyDirectorySync
(
cache
.
getArtifactDirectory
(
'gradle_wrapper'
),
fs
.
directory
(
fs
.
path
.
join
(
projectDir
,
'android'
)),
(
File
sourceFile
,
File
destinationFile
)
{
filesCreated
++;
final
String
modes
=
sourceFile
.
statSync
().
modeString
();
if
(
modes
!=
null
&&
modes
.
contains
(
'x'
))
{
os
.
makeExecutable
(
destinationFile
);
}
},
);
return
filesCreated
;
}
}
String
_createAndroidIdentifier
(
String
organization
,
String
name
)
{
...
...
packages/flutter_tools/lib/src/services.dart
View file @
c5999c74
...
...
@@ -69,20 +69,18 @@ Future<Null> parseServiceConfigs(
if
(
jars
!=
null
&&
serviceConfig
[
'jars'
]
is
Iterable
)
{
for
(
String
jar
in
serviceConfig
[
'jars'
])
jars
.
add
(
fs
.
file
(
await
getServiceFromUrl
(
jar
,
serviceRoot
,
service
,
unzip:
false
)));
jars
.
add
(
fs
.
file
(
await
getServiceFromUrl
(
jar
,
serviceRoot
,
service
)));
}
}
}
Future
<
String
>
getServiceFromUrl
(
String
url
,
String
rootDir
,
String
serviceName
,
{
bool
unzip:
false
}
)
async
{
Future
<
String
>
getServiceFromUrl
(
String
url
,
String
rootDir
,
String
serviceName
)
async
{
if
(
url
.
startsWith
(
"android-sdk:"
)
&&
androidSdk
!=
null
)
{
// It's something shipped in the standard android SDK.
return
url
.
replaceAll
(
'android-sdk:'
,
'
${androidSdk.directory}
/'
);
}
else
if
(
url
.
startsWith
(
"http"
))
{
// It's a regular file to download.
return
await
cache
.
getThirdPartyFile
(
url
,
serviceName
,
unzip:
unzip
);
return
await
cache
.
getThirdPartyFile
(
url
,
serviceName
);
}
else
{
// Assume url is a path relative to the service's root dir.
return
fs
.
path
.
join
(
rootDir
,
url
);
...
...
packages/flutter_tools/templates/create/android-java.tmpl/build.gradle
View file @
c5999c74
...
...
@@ -4,7 +4,7 @@ buildscript {
}
dependencies
{
classpath
'com.android.tools.build:gradle:2.
2
.3'
classpath
'com.android.tools.build:gradle:2.
3
.3'
}
}
...
...
@@ -26,7 +26,3 @@ subprojects {
task
clean
(
type:
Delete
)
{
delete
rootProject
.
buildDir
}
task
wrapper
(
type:
Wrapper
)
{
gradleVersion
=
'2.14.1'
}
packages/flutter_tools/templates/create/android-kotlin.tmpl/build.gradle
View file @
c5999c74
...
...
@@ -4,7 +4,7 @@ buildscript {
}
dependencies
{
classpath
'com.android.tools.build:gradle:2.
2
.3'
classpath
'com.android.tools.build:gradle:2.
3
.3'
classpath
'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
}
}
...
...
@@ -27,7 +27,3 @@ subprojects {
task
clean
(
type:
Delete
)
{
delete
rootProject
.
buildDir
}
task
wrapper
(
type:
Wrapper
)
{
gradleVersion
=
'2.14.1'
}
packages/flutter_tools/templates/create/android.tmpl/.gitignore
View file @
c5999c74
...
...
@@ -7,7 +7,3 @@
/build
/captures
GeneratedPluginRegistrant.java
/gradle
/gradlew
/gradlew.bat
packages/flutter_tools/templates/create/android.tmpl/gradle/wrapper/gradle-wrapper.properties
0 → 100644
View file @
c5999c74
#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-3.3-all.zip
packages/flutter_tools/templates/plugin/android-java.tmpl/build.gradle.tmpl
View file @
c5999c74
...
...
@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.
0
'
classpath 'com.android.tools.build:gradle:2.3.
3
'
}
}
...
...
packages/flutter_tools/templates/plugin/android-kotlin.tmpl/build.gradle.tmpl
View file @
c5999c74
...
...
@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.
0
'
classpath 'com.android.tools.build:gradle:2.3.
3
'
}
}
...
...
packages/flutter_tools/templates/plugin/android.tmpl/.gitignore
View file @
c5999c74
...
...
@@ -6,7 +6,3 @@
.DS_Store
/build
/captures
/gradle
/gradlew
/gradlew.bat
packages/flutter_tools/templates/plugin/android.tmpl/gradle/wrapper/gradle-wrapper.properties
0 → 100644
View file @
c5999c74
#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-3.3-all.zip
packages/flutter_tools/test/cache_test.dart
View file @
c5999c74
...
...
@@ -48,6 +48,34 @@ void main() {
Platform:
()
=>
new
FakePlatform
()..
environment
=
<
String
,
String
>{
'FLUTTER_ALREADY_LOCKED'
:
'true'
},
});
});
group
(
'Cache'
,
()
{
test
(
'should not be up to date, if some cached artifact is not'
,
()
{
final
CachedArtifact
artifact1
=
new
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
new
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
()).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
()).
thenReturn
(
false
);
final
Cache
cache
=
new
Cache
(
artifacts:
<
CachedArtifact
>[
artifact1
,
artifact2
]);
expect
(
cache
.
isUpToDate
(),
isFalse
);
});
test
(
'should be up to date, if all cached artifacts are'
,
()
{
final
CachedArtifact
artifact1
=
new
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
new
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
()).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
()).
thenReturn
(
true
);
final
Cache
cache
=
new
Cache
(
artifacts:
<
CachedArtifact
>[
artifact1
,
artifact2
]);
expect
(
cache
.
isUpToDate
(),
isTrue
);
});
test
(
'should update cached artifacts which are not up to date'
,
()
async
{
final
CachedArtifact
artifact1
=
new
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
new
MockCachedArtifact
();
when
(
artifact1
.
isUpToDate
()).
thenReturn
(
true
);
when
(
artifact2
.
isUpToDate
()).
thenReturn
(
false
);
final
Cache
cache
=
new
Cache
(
artifacts:
<
CachedArtifact
>[
artifact1
,
artifact2
]);
await
cache
.
updateAll
();
verifyNever
(
artifact1
.
update
());
verify
(
artifact2
.
update
());
});
});
}
class
MockFileSystem
extends
MemoryFileSystem
{
...
...
@@ -65,3 +93,4 @@ class MockFile extends Mock implements File {
}
class
MockRandomAccessFile
extends
Mock
implements
RandomAccessFile
{}
class
MockCachedArtifact
extends
Mock
implements
CachedArtifact
{}
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