-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define proto module system #1819
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ public void run() { | |
ApplicationInfo info = ApplicationInfo.getInstance(); | ||
if ("Google".equals(info.getCompanyName())) { | ||
String version = info.getFullVersion(); | ||
if (version.startsWith("2.") || (version.contains("Beta") && !version.endsWith("7"))) { | ||
if (version.startsWith("2.")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This likely address #1824 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I updated the intro to make that clear. |
||
reportVersionIncompatibility(info); | ||
} | ||
else if (version.contains("Canary")) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright 2018 The Chromium Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
package io.flutter.project; | ||
|
||
import com.android.tools.idea.projectsystem.AndroidModuleSystem; | ||
import com.android.tools.idea.projectsystem.AndroidProjectSystem; | ||
import com.android.tools.idea.projectsystem.ProjectSystemSyncManager; | ||
import com.android.tools.idea.projectsystem.gradle.GradleProjectSystem; | ||
import com.intellij.openapi.module.Module; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.nio.file.Path; | ||
|
||
public class FlutterProjectSystem implements AndroidProjectSystem { | ||
@NotNull final private GradleProjectSystem gradleProjectSystem; | ||
|
||
public FlutterProjectSystem(Project project) { | ||
gradleProjectSystem = new GradleProjectSystem(project); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public VirtualFile getDefaultApkFile() { | ||
return gradleProjectSystem.getDefaultApkFile(); // TODO find the flutter binary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this todo:? If so, can you provide more context (for whoever comes through here net)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed. |
||
} | ||
|
||
@NotNull | ||
@Override | ||
public Path getPathToAapt() { | ||
return gradleProjectSystem.getPathToAapt(); | ||
} | ||
|
||
@Override | ||
public void buildProject() { | ||
// flutter build ? | ||
} | ||
|
||
@Override | ||
public boolean allowsFileCreation() { | ||
return true; // Enable File>New>New Module | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public AndroidModuleSystem getModuleSystem(@NotNull Module module) { | ||
return gradleProjectSystem.getModuleSystem(module); | ||
} | ||
|
||
@Override | ||
public boolean upgradeProjectToSupportInstantRun() { | ||
return false; // Already done. | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String mergeBuildFiles(@NotNull String dependencies, | ||
@NotNull String destinationContents, | ||
@Nullable String supportLibVersionFilter) { | ||
return gradleProjectSystem.mergeBuildFiles(dependencies, destinationContents, supportLibVersionFilter); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public ProjectSystemSyncManager getSyncManager() { | ||
return gradleProjectSystem.getSyncManager(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,11 @@ | |
"ideaVersion": "171.4408382", | ||
"dartPluginVersion": "171.4424.10", | ||
"sinceBuild": "171.1", | ||
"untilBuild": "171.*" | ||
"untilBuild": "171.*", | ||
"filesToSkip": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
"flutter-studio/src/io/flutter/project/FlutterProjectSystemProvider.java", | ||
"flutter-studio/src/io/flutter/project/FlutterProjectSystem.java" | ||
] | ||
}, | ||
{ | ||
"name": "Android Studio", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!-- Defines Android Studio IDE-specific contributions and implementations. --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may want to look into a system to generate plugin.xml and studio-contribs.xml from the templates and remove the others from source control. Or, have a task on travis fail if changes are made to one file but not to the the other (template and non-template), else they risk getting out of sync. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this sounds good, lets open an issue to track. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We really need to get into the habit of using Adding a fail-safe check to travis sounds good, too. See #1842. |
||
<idea-plugin> | ||
|
||
<extensions defaultExtensionNs="com.android"> | ||
<!-- Add Flutter module types to the New Module wizard --> | ||
<moduleDescriptionProvider implementation="io.flutter.module.FlutterDescriptionProvider"/> | ||
</extensions> | ||
|
||
<extensions defaultExtensionNs="com.android.project"> | ||
@PROJECTSYSTEM@ | ||
</extensions> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<!-- TODO(messick): Remove this extension if the class is never needed. --> | ||
<androidStudioInitializer implementation="io.flutter.FlutterStudioInitializer"/> | ||
</extensions> | ||
|
||
<actions> | ||
|
||
<!-- Define the 'New Flutter Project' menu item --> | ||
<action id="flutter.NewProject" class="io.flutter.actions.FlutterNewProjectAction" | ||
text="New Flutter Project..." | ||
description="Create a new Flutter project"> | ||
<add-to-group group-id="NewProjectOrModuleGroup" anchor="after" relative-to-action="NewProject"/> | ||
</action> | ||
|
||
<!-- The icon isn't being used here, but the same syntax works for menu items --> | ||
<!-- We can't change it in a StartupActivity because those don't run until a project is opened --> | ||
<action id="flutter.NewProject.welcome" class="io.flutter.actions.FlutterNewProjectAction" | ||
text="Start a new Flutter project" | ||
icon="FlutterIcons.Flutter" | ||
description="Create a new Flutter project"> | ||
<add-to-group group-id="WelcomeScreen.QuickStart.IDEA" anchor="after" relative-to-action="WelcomeScreen.CreateNewProject"/> | ||
</action> | ||
|
||
</actions> | ||
|
||
</idea-plugin> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,12 +136,20 @@ List<String> findJavaFiles(String path) { | |
.toList(); | ||
} | ||
|
||
Future<File> genPluginXml(BuildSpec spec, String destDir) async { | ||
var file = await new File(p.join(rootPath, destDir, 'META-INF/plugin.xml')) | ||
.create(recursive: true); | ||
var dest = file.openWrite(); | ||
Future<bool> genPluginFiles(BuildSpec spec, String destDir) async { | ||
//TODO(devoncarew): Move the change log to a separate file and insert it here. | ||
await new File(p.join(rootPath, 'resources/META-INF/plugin.xml.template')) | ||
var result = await genPluginXml(spec, destDir, 'META-INF/plugin.xml'); | ||
if (result == null) return false; | ||
result = await genPluginXml(spec, destDir, 'META-INF/studio-contribs.xml'); | ||
if (result == null) return false; | ||
return true; | ||
} | ||
|
||
Future<File> genPluginXml(BuildSpec spec, String destDir, String path) async { | ||
var file = | ||
await new File(p.join(rootPath, destDir, path)).create(recursive: true); | ||
var dest = file.openWrite(); | ||
await new File(p.join(rootPath, 'resources', '$path.template')) | ||
.openRead() | ||
.transform(UTF8.decoder) | ||
.transform(new LineSplitter()) | ||
|
@@ -291,6 +299,11 @@ String substitueTemplateVariables(String line, BuildSpec spec) { | |
return spec.isSynthetic | ||
? 'com.intellij.modules.androidstudio' | ||
: 'com.android.tools.apk'; | ||
case 'PROJECTSYSTEM': | ||
// Temporary work-around for 3.0 vs 3.1 AS incompatibility. | ||
return spec.version == '3.1' | ||
? '<projectsystem implementation="io.flutter.project.FlutterProjectSystemProvider"/>' | ||
: ''; | ||
default: | ||
throw 'unknown template variable: $name'; | ||
} | ||
|
@@ -523,7 +536,13 @@ class BuildCommand extends ProductCommand { | |
|
||
separator('Building flutter-intellij.jar'); | ||
await removeAll('build'); | ||
for (var file in spec.filesToSkip) { | ||
await new File(file).rename('$file~'); | ||
} | ||
result = await runner.javac2(spec); | ||
for (var file in spec.filesToSkip) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this block may want to be in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
await new File('$file~').rename(file); | ||
} | ||
if (result != 0) { | ||
return new Future(() => result); | ||
} | ||
|
@@ -534,7 +553,7 @@ class BuildCommand extends ProductCommand { | |
copyResources(from: 'gen', to: 'build/classes'); | ||
copyResources( | ||
from: 'third_party/intellij-plugins-dart/src', to: 'build/classes'); | ||
await genPluginXml(spec, 'build/classes'); | ||
await genPluginFiles(spec, 'build/classes'); | ||
|
||
// create the jars | ||
createDir('build/flutter-intellij/lib'); | ||
|
@@ -625,7 +644,8 @@ compile | |
return await exec('ant', args.split(new RegExp(r'\s'))); | ||
} on ProcessException catch (x) { | ||
if (x.message == 'No such file or directory') { | ||
log('\nThe build command requires ant to be installed. ' | ||
log( | ||
'\nThe build command requires ant to be installed. ' | ||
'\nPlease ensure ant is on your \$PATH.', | ||
indent: false); | ||
exit(x.errorCode); | ||
|
@@ -649,6 +669,7 @@ class BuildSpec { | |
final String untilBuild; | ||
final String pluginId = 'io.flutter'; | ||
final String release; | ||
final List<String> filesToSkip; | ||
|
||
ArtifactManager artifacts = new ArtifactManager(); | ||
|
||
|
@@ -663,7 +684,8 @@ class BuildSpec { | |
ideaVersion = json['ideaVersion'], | ||
dartPluginVersion = json['dartPluginVersion'], | ||
sinceBuild = json['sinceBuild'], | ||
untilBuild = json['untilBuild'] { | ||
untilBuild = json['untilBuild'], | ||
filesToSkip = json['filesToSkip'] ?? [] { | ||
createArtifacts(); | ||
} | ||
|
||
|
@@ -795,7 +817,7 @@ class GenCommand extends ProductCommand { | |
var spec = new SyntheticBuildSpec.fromJson(json.first, release, json.last); | ||
log('writing pluginl.xml'); | ||
var value = 1; | ||
var result = await genPluginXml(spec, 'resources'); | ||
var result = await genPluginFiles(spec, 'resources'); | ||
if (result != null) { | ||
log('writing .travis.yml'); | ||
genTravisYml(specs); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious - these were added automatically by IntelliJ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. They are all required by new code.