@@ -27,7 +27,6 @@ const LocalProcessManager processManager = LocalProcessManager();
27
27
/// Java 1.8.
28
28
Future <void > main (List <String > args) async {
29
29
final ArgParser argParser = setupOptions ();
30
- await checkJava1_8 ();
31
30
final int exitCode = await runLint (argParser, argParser.parse (args));
32
31
exit (exitCode);
33
32
}
@@ -74,7 +73,7 @@ Future<int> runLint(ArgParser argParser, ArgResults argResults) async {
74
73
<!-- WILL AUTOMATICALLY FIND ALL .java FILES AND INCLUDE THEM HERE -->
75
74
<project>
76
75
<sdk dir="${androidSdkDir .path }" />
77
- <module name="FlutterEngine" android="true" library="true" compile-sdk-version="android-P ">
76
+ <module name="FlutterEngine" android="true" library="true" compile-sdk-version="android-S ">
78
77
<manifest file="${path .join (androidDir .path , 'AndroidManifest.xml' )}" />
79
78
''' );
80
79
for (final FileSystemEntity entity in androidDir.listSync (recursive: true )) {
@@ -89,12 +88,11 @@ Future<int> runLint(ArgParser argParser, ArgResults argResults) async {
89
88
</project>
90
89
''' );
91
90
await projectXml.close ();
92
-
93
91
print ('Wrote project.xml, starting lint...' );
94
92
final List <String > lintArgs = < String > [
95
- path.join (androidSdkDir.path, 'tools' , 'bin' , 'lint' ),
96
- '--project' ,
97
- projectXmlPath ,
93
+ path.join (androidSdkDir.path, 'cmdline- tools' , 'bin' , 'lint' ),
94
+ '--project' , projectXmlPath,
95
+ '--compile-sdk-version' , '31' ,
98
96
'--showall' ,
99
97
'--exitcode' , // Set non-zero exit code on errors
100
98
'-Wall' ,
@@ -106,14 +104,13 @@ Future<int> runLint(ArgParser argParser, ArgResults argResults) async {
106
104
if (html) {
107
105
lintArgs.addAll (< String > ['--html' , argResults['out' ] as String ]);
108
106
}
109
- final String ? javaHome = await getJavaHome ();
107
+ final String javahome = getJavaHome (inArgument);
108
+ print ('Using JAVA_HOME=$javahome ' );
110
109
final Process lintProcess = await processManager.start (
111
110
lintArgs,
112
- environment: javaHome != null
113
- ? < String , String > {
114
- 'JAVA_HOME' : javaHome,
115
- }
116
- : null ,
111
+ environment: < String , String > {
112
+ 'JAVA_HOME' : javahome,
113
+ },
117
114
);
118
115
lintProcess.stdout.pipe (stdout);
119
116
lintProcess.stderr.pipe (stderr);
@@ -166,50 +163,11 @@ ArgParser setupOptions() {
166
163
return argParser;
167
164
}
168
165
169
- /// On macOS, we can try to find Java 1.8.
170
- ///
171
- /// Otherwise, default to whatever JAVA_HOME is already.
172
- Future <String ?> getJavaHome () async {
166
+ String getJavaHome (String src) {
173
167
if (Platform .isMacOS) {
174
- final ProcessResult result = await processManager.run (
175
- < String > ['/usr/libexec/java_home' , '-v' , '1.8' , '-F' ],
176
- );
177
- if (result.exitCode == 0 ) {
178
- return (result.stdout as String ).trim ();
179
- }
180
- }
181
- return Platform .environment['JAVA_HOME' ];
182
- }
183
-
184
- /// Checks that `java` points to Java 1.8.
185
- ///
186
- /// The SDK lint tool may not work with Java > 1.8.
187
- Future <void > checkJava1_8 () async {
188
- print ('Checking Java version...' );
189
-
190
- if (Platform .isMacOS) {
191
- final ProcessResult result = await processManager.run (
192
- < String > ['/usr/libexec/java_home' , '-v' , '1.8' , '-F' ],
193
- );
194
- if (result.exitCode != 0 ) {
195
- print ('Java 1.8 not available - the linter may not work properly.' );
196
- }
197
- return ;
198
- }
199
- final ProcessResult javaResult = await processManager.run (
200
- < String > ['java' , '-version' ],
201
- );
202
- if (javaResult.exitCode != 0 ) {
203
- print ('Could not run "java -version". '
204
- 'Ensure Java is installed and available on your path.' );
205
- print (javaResult.stderr);
206
- }
207
- // `java -version` writes to stderr.
208
- final String javaVersionStdout = javaResult.stderr as String ;
209
- if (! javaVersionStdout.contains ('"1.8' )) {
210
- print ('The Android SDK tools may not work properly with your Java version. '
211
- 'If this process fails, please retry using Java 1.8.' );
168
+ return path.normalize ('$src /third_party/java/openjdk/Contents/Home/' );
212
169
}
170
+ return path.normalize ('$src /third_party/java/openjdk/' );
213
171
}
214
172
215
173
/// The root directory of this project.
0 commit comments