Commit 5cb90979 authored by Brian Slesinsky's avatar Brian Slesinsky Committed by GitHub

flutter create: enable Java support in IDEA (#9335)

Generates an android.iml file and a package-level library for flutter.jar.

Does not set up an Android SDK in IDEA; this isn't possible with a
template-based approach. But IDEA shows a clear warning, so the
user can fix this by setting the SDK.

(When creating a Flutter project from within IDEA, we can fix this up
afterwards in the plugin.)
parent 9455fb64
......@@ -5,6 +5,7 @@
import 'dart:async';
import '../android/android.dart' as android;
import '../android/android_sdk.dart' as android_sdk;
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/utils.dart';
......@@ -103,7 +104,7 @@ class CreateCommand extends FlutterCommand {
final Map<String, dynamic> templateContext = _templateContext(
projectName, argResults['description'], dirPath,
flutterPackagesDirectory, renderDriverTest: argResults['with-driver-test'],
flutterRoot, renderDriverTest: argResults['with-driver-test'],
withPluginHook: generatePlugin,
);
......@@ -188,10 +189,10 @@ Host platform code is in the android/ and ios/ directories under $relativePlugin
}
Map<String, dynamic> _templateContext(String projectName,
String projectDescription, String dirPath, String flutterPackagesDirectory,
String projectDescription, String dirPath, String flutterRoot,
{ bool renderDriverTest: false, bool withPluginHook: false }) {
flutterPackagesDirectory = fs.path.normalize(flutterPackagesDirectory);
flutterPackagesDirectory = _relativePath(from: dirPath, to: flutterPackagesDirectory);
flutterRoot = fs.path.normalize(flutterRoot);
flutterRoot = _relativePath(from: dirPath, to: flutterRoot);
final String pluginDartClass = _createPluginClassName(projectName);
final String pluginClass = pluginDartClass.endsWith('Plugin')
......@@ -203,8 +204,11 @@ Host platform code is in the android/ and ios/ directories under $relativePlugin
'androidIdentifier': _createAndroidIdentifier(projectName),
'iosIdentifier': _createUTIIdentifier(projectName),
'description': projectDescription,
'flutterPackagesDirectory': flutterPackagesDirectory,
'dartSdk': '$flutterRoot/bin/cache/dart-sdk',
'flutterPackagesDirectory': fs.path.join(flutterRoot, 'packages'),
'androidMinApiLevel': android.minApiLevel,
'androidSdkVersion': android_sdk.minimumAndroidSdkVersion,
'androidFlutterJar': "$flutterRoot/bin/cache/artifacts/engine/android-arm/flutter.jar",
'withDriverTest': renderDriverTest,
'pluginClass': pluginClass,
'pluginDartClass': pluginDartClass,
......
<component name="libraryTable">
<library name="Dart SDK">
<CLASSES>
<root url="file://{{dartSdk}}/lib/async" />
<root url="file://{{dartSdk}}/lib/collection" />
<root url="file://{{dartSdk}}/lib/convert" />
<root url="file://{{dartSdk}}/lib/core" />
<root url="file://{{dartSdk}}/lib/developer" />
<root url="file://{{dartSdk}}/lib/html" />
<root url="file://{{dartSdk}}/lib/indexed_db" />
<root url="file://{{dartSdk}}/lib/io" />
<root url="file://{{dartSdk}}/lib/isolate" />
<root url="file://{{dartSdk}}/lib/js" />
<root url="file://{{dartSdk}}/lib/js_util" />
<root url="file://{{dartSdk}}/lib/math" />
<root url="file://{{dartSdk}}/lib/mirrors" />
<root url="file://{{dartSdk}}/lib/svg" />
<root url="file://{{dartSdk}}/lib/typed_data" />
<root url="file://{{dartSdk}}/lib/web_audio" />
<root url="file://{{dartSdk}}/lib/web_gl" />
<root url="file://{{dartSdk}}/lib/web_sql" />
</CLASSES>
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Flutter for Android">
<CLASSES>
<root url="jar://{{androidFlutterJar}}!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
......@@ -3,6 +3,7 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/{{projectName}}.iml" filepath="$PROJECT_DIR$/{{projectName}}.iml" />
<module fileurl="file://$PROJECT_DIR$/android.iml" filepath="$PROJECT_DIR$/android.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/android">
<sourceFolder url="file://$MODULE_DIR$/android/app/src/main/java" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Android API {{androidSdkVersion}} Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Flutter for Android" level="project" />
</component>
</module>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment