Skip to content
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

idea maintenance (to support 2019.3) #434

Merged
merged 23 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1190ffb
* jetbrains intellij plugin for gradle version updated
dkimitsa Nov 12, 2019
8f6ba99
* intellij maven pom reworked into stand-alone. as mvn:version is not…
dkimitsa Nov 12, 2019
960c7ed
* added sonatype repo for snapshot dependencies
dkimitsa Nov 12, 2019
939c3d4
* eclipse plugin's maven.pom switched into standalone (without) as ty…
dkimitsa Nov 12, 2019
e8e073d
* release script reworked to properly pick up new idea artifact and u…
dkimitsa Nov 12, 2019
533262e
* Idea: release script updated to use property to specify the depende…
dkimitsa Nov 15, 2019
ed1833a
Merge remote-tracking branch 'remotes/mobivm/jdk12' into jdk12
dkimitsa Nov 17, 2019
3fa7486
* version set to 2.3.10-SNAPSHOT
dkimitsa Nov 26, 2019
fd208a8
* java doc and source plugins are now always (was only for release) a…
dkimitsa Nov 26, 2019
6bfce56
* update commons-compress due to security vulnerability
dkimitsa Nov 28, 2019
14018bf
* upgraded deprecated code, as Idea 2019.3 removed old classes
dkimitsa Dec 11, 2019
d570e36
* ignore gradle files that are created once build with gradle
dkimitsa Dec 11, 2019
2a6605b
* reworked to @NotNull to minimize warnings
dkimitsa Dec 11, 2019
84b674c
* optimized imports
dkimitsa Dec 11, 2019
73e9163
* added RoboFileUtils to handle false result of file api into exceptions
dkimitsa Dec 11, 2019
7cf82c1
Merge remote-tracking branch 'mobivm/jdk12' into jdk12
dkimitsa Dec 11, 2019
15a883c
* readme updated with detailed instructions
dkimitsa Dec 12, 2019
ca22a91
* xcode setup dialog is not blocking now. as if something went wrong …
dkimitsa Dec 12, 2019
0df9f6b
* reworked to gracefully handle cases when there is no simulators in …
dkimitsa Dec 12, 2019
19e94aa
* updated to recent org.jetbrains.intellij
dkimitsa Dec 13, 2019
10ae92d
* added check for GraphicsEnvironment.isHeadless() as during plugin b…
dkimitsa Dec 13, 2019
ca3817a
* source code polish: fixes all lint warning, applied suggestions (li…
dkimitsa Dec 13, 2019
90457bd
Merge branch 'jdk12' into jdk12-wip/idea-maintenance
dkimitsa Dec 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/idea/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/src/main/resources/robovm-dist
/.idea/
/build/
org.robovm.idea.iml
org.robovm.idea.iml
/.gradle/
7 changes: 5 additions & 2 deletions plugins/idea/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ Not supported any more due removed `-extdir` in Java9+
* Install this plugin, it allows us to use Maven for plugin development https://plugins.jetbrains.com/plugin/7127?pr=
* Clone this repo https://github.com/JetBrains/intellij-community.git
* Checkout the branch that corresponds to the respective IDEA version you installed, e.g. 139 for Idea 14.0.x, see http://www.jetbrains.org/pages/viewpage.action?pageId=983225
* Open Intellij IDEA CE, setup the IDEA sdk pointing it at your IDEA installation. Also add following JARs to SDK from IDEA directory:
* Open Intellij IDEA CE, setup the IDEA sdk pointing it at your IDEA installation. Add source path to root of repo cloned above. Also add following JARs to SDK from IDEA directory:
- /Applications/IntelliJ IDEA CE.app/Contents/plugins/maven/lib/maven.jar
- /Applications/IntelliJ IDEA CE.app/Contents/plugins/gradle/lib/gradle-common.jar
- /Applications/IntelliJ IDEA CE.app/Contents/plugins/gradle/lib/gradle-java.jar
- (pre 2019.3) /Applications/IntelliJ IDEA CE.app/Contents/plugins/gradle/lib/gradle-java.jar
- (after 2019.3) /Applications/IntelliJ IDEA CE.app/Contents/plugins/gradle-java/lib/gradle-java.jar!/
* Open the project by selecting it's POM
* Open File -> Project Structure, Click on the Project menu entry, and select the IDEA sdk under Project SDK
* Click OK

* Run `dependency:copy` goal in `RoboVM plugin for Intellij IDEA/Plugins/dependency` to get `src/main/resources/robovm-dist` resolved
* Optionally import the robovm-compiler, robovm-debugger, robovm-ibxcode projects as modules. IDEA will resolve the dependencies to those modules so you can debug and code hotswap the compiler and debugger!
* Create a new run configuration, using the Plugin run config type. Set the module. Happy coding.

Expand Down
2 changes: 1 addition & 1 deletion plugins/idea/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id "org.jetbrains.intellij" version "0.4.12"
id "org.jetbrains.intellij" version "0.4.15"
}

ext {
Expand Down
6 changes: 4 additions & 2 deletions plugins/idea/src/main/java/org/robovm/idea/RoboVmIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package org.robovm.idea;

import com.intellij.openapi.util.IconLoader;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.util.Objects;

/**
* preloads icons used by various components
*/
public class RoboVmIcons {
public static final Icon ROBOVM_SMALL = IconLoader.findIcon("/icons/robovm_small.png");
public static final Icon ROBOVM_LARGE = IconLoader.findIcon("/icons/robovm_large.png");
public static final @NotNull Icon ROBOVM_SMALL = Objects.requireNonNull(IconLoader.findIcon("/icons/robovm_small.png"));
public static final @NotNull Icon ROBOVM_LARGE = Objects.requireNonNull(IconLoader.findIcon("/icons/robovm_large.png"));
}
260 changes: 106 additions & 154 deletions plugins/idea/src/main/java/org/robovm/idea/RoboVmPlugin.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.intellij.ide.projectWizard.NewProjectWizard;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
import org.jetbrains.annotations.NotNull;

/**
* action to overcome idea studio limitation in creating new project
Expand All @@ -35,8 +35,8 @@ public boolean startInTransaction() {
}

@Override
public void actionPerformed(AnActionEvent e) {
NewProjectWizard wizard = new NewProjectWizard((Project)null, ModulesProvider.EMPTY_MODULES_PROVIDER, (String)null);
NewProjectUtil.createNewProject(getEventProject(e), wizard);
public void actionPerformed(@NotNull AnActionEvent e) {
NewProjectWizard wizard = new NewProjectWizard(null, ModulesProvider.EMPTY_MODULES_PROVIDER, null);
NewProjectUtil.createNewProject(null, wizard); // have to use outdated as replacement was introduced only in 2019.3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull;
import org.robovm.compiler.target.ios.IOSTarget;
Expand All @@ -40,9 +41,9 @@ public class CleanBuildFoldersAction extends AnAction {
private static AtomicBoolean busy = new AtomicBoolean(false);

@Override
public void actionPerformed(AnActionEvent anActionEvent) {
public void actionPerformed(@NotNull AnActionEvent e) {
if (!busy.get()) {
ProgressManager.getInstance().run(new CleanTask(anActionEvent.getProject()));
ProgressManager.getInstance().run(new CleanTask(e.getProject()));
}
}

Expand Down Expand Up @@ -73,12 +74,14 @@ public void run(@NotNull ProgressIndicator progress) {
File moduleBaseDir = RoboVmPlugin.getModuleBaseDir(module);
File robovmBuildDir = new File(moduleBaseDir, "robovm-build");
FileUtils.deleteDirectory(robovmBuildDir);

//Refresh the module folder, so that we see, it has happened
VirtualFile moduleFile = module.getModuleFile();
if (moduleFile != null)
moduleFile.getParent().refresh(false, true);
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
//Refresh the module folder, so that we see, it has happened
project.getBaseDir().refresh(false, true);
}
}

Expand All @@ -94,7 +97,7 @@ public void onFinished() {

// single exit point
if (exceptionIfHappened != null) {
Notifications.Bus.notify(new Notification("RoboVM", "RoboVM Cache Build Folder Clearer",
Notifications.Bus.notify(new Notification("RoboVM", "RoboVM cache build folder clearer",
"Failed due error: " + exceptionIfHappened.getMessage(), NotificationType.ERROR));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public void run(@NotNull ProgressIndicator progress) {
File file = new File(System.getProperty("user.home"), ".robovm/cache");
try {
FileUtils.deleteDirectory(file);
} catch (IOException e) {
} catch (IOException ignored) {
}
}

@Override
public void onError(@NotNull Exception error) {
super.onError(error);
public void onThrowable(@NotNull Throwable error) {
super.onThrowable(error);
exceptionIfHappened = error;
}

Expand All @@ -82,7 +82,7 @@ public void onFinished() {

// single exit point
if (exceptionIfHappened != null) {
Notifications.Bus.notify(new Notification( "RoboVM", "RoboVM Cache Clearer",
Notifications.Bus.notify(new Notification( "RoboVM", "RoboVM cache clearer",
"Failed due error: " + exceptionIfHappened.getMessage(), NotificationType.ERROR));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.compiler.CompileScope;
import com.intellij.openapi.compiler.CompileStatusNotification;
import com.intellij.openapi.compiler.CompilerManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Key;
import org.robovm.idea.RoboVmPlugin;

Expand All @@ -32,19 +32,22 @@ public class CreateFrameworkAction extends AnAction {
public static final Key<FrameworkConfig> FRAMEWORK_CONFIG_KEY = Key.create("FRAMEWORK_CONFIG");

public void actionPerformed(final AnActionEvent e) {
final CreateFrameworkDialog dialog = new CreateFrameworkDialog(e.getProject());
Project project = e.getProject();
if (project == null) {
RoboVmPlugin.logBalloon(null, MessageType.ERROR, "Oops. Project is missing.");
return;
}

final CreateFrameworkDialog dialog = new CreateFrameworkDialog(project);
dialog.show();
if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
// create Framework
FrameworkConfig frameworkConfig = dialog.getFrameworkConfig();
CompileScope scope = CompilerManager.getInstance(e.getProject()).createModuleCompileScope(frameworkConfig.module, true);
CompileScope scope = CompilerManager.getInstance(project).createModuleCompileScope(frameworkConfig.module, true);
scope.putUserData(FRAMEWORK_CONFIG_KEY, frameworkConfig);
CompilerManager.getInstance(e.getProject()).compile(scope, new CompileStatusNotification() {
@Override
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
RoboVmPlugin.logInfo(e.getProject(), "Framework creation complete, %d errors, %d warnings", errors, warnings);
}
});
CompilerManager.getInstance(project).compile(scope, (aborted, errors, warnings, compileContext) ->
RoboVmPlugin.logInfo(project, "Framework creation complete, %d errors, %d warnings", errors, warnings)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,39 @@

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.compiler.CompileScope;
import com.intellij.openapi.compiler.CompileStatusNotification;
import com.intellij.openapi.compiler.CompilerManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.Nullable;
import org.robovm.compiler.config.Arch;
import org.robovm.idea.RoboVmPlugin;

import javax.swing.*;
import java.io.File;
import java.util.List;

public class CreateIpaAction extends AnAction {
public static final Key<IpaConfig> IPA_CONFIG_KEY = Key.create("IPA_CONFIG");

public void actionPerformed(final AnActionEvent e) {
Project project = e.getProject();
if (project == null) {
RoboVmPlugin.logBalloon(null, MessageType.ERROR, "Oops. Project is missing.");
return;
}

final CreateIpaDialog dialog = new CreateIpaDialog(e.getProject());
dialog.show();
if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
// create IPA
IpaConfig ipaConfig = dialog.getIpaConfig();
CompileScope scope = CompilerManager.getInstance(e.getProject()).createModuleCompileScope(ipaConfig.module, true);
CompileScope scope = CompilerManager.getInstance(project).createModuleCompileScope(ipaConfig.module, true);
scope.putUserData(IPA_CONFIG_KEY, ipaConfig);
CompilerManager.getInstance(e.getProject()).compile(scope, new CompileStatusNotification() {
@Override
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
RoboVmPlugin.logInfo(e.getProject(), "IPA creation complete, %d errors, %d warnings", errors, warnings);
}
});
CompilerManager.getInstance(project).compile(scope, (aborted, errors, warnings, compileContext) ->
RoboVmPlugin.logInfo(project, "IPA creation complete, %d errors, %d warnings", errors, warnings)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.robovm.idea.actions;

import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDialog;
import com.intellij.openapi.fileChooser.FileChooserFactory;
Expand All @@ -29,19 +28,16 @@
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.Nullable;
import org.robovm.compiler.config.Arch;
import org.robovm.compiler.target.ios.DeviceType;
import org.robovm.compiler.target.ios.IOSTarget;
import org.robovm.compiler.target.ios.ProvisioningProfile;
import org.robovm.compiler.target.ios.SigningIdentity;
import org.robovm.idea.RoboVmPlugin;
import org.robovm.idea.running.RoboVmRunConfiguration;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class CreateIpaDialog extends DialogWrapper {
private static final String MODULE_NAME = "robovm.ipaConfig.moduleName";
Expand All @@ -54,12 +50,12 @@ public class CreateIpaDialog extends DialogWrapper {
private static final String ARCHS_32BIT = "32-bit (thumbv7)";
private static final String ARCHS_64BIT = "64-bit (arm64)";
private JPanel panel;
private JComboBox archs;
private JComboBox signingIdentity;
private JComboBox provisioningProfile;
private JComboBox<String> archs;
private JComboBox<String> signingIdentity;
private JComboBox<String> provisioningProfile;
private JButton browseButton;
private JTextField destinationDir;
private JComboBox module;
private JComboBox<String> module;
private Project project;

protected CreateIpaDialog(@Nullable Project project) {
Expand Down Expand Up @@ -104,7 +100,7 @@ private void populateControls() {
// populate architectures
for(String arch: new String[] { ARCHS_ALL, ARCHS_32BIT, ARCHS_64BIT }) {
archs.addItem(arch);
if(arch.equals(configProvisioning)) {
if(arch.equals(configArchs)) {
this.archs.setSelectedIndex(this.archs.getItemCount()-1);
}
}
Expand All @@ -113,25 +109,22 @@ private void populateControls() {
destinationDir.setText(configDestDir);
}

browseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDialog fileChooser = FileChooserFactory.getInstance()
.createFileChooser(new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return file.isDirectory();
}

@Override
public boolean isFileSelectable(VirtualFile file) {
return file.isDirectory();
}
}, null, panel);
VirtualFile[] dir = fileChooser.choose(project);
if (dir != null && dir.length > 0) {
destinationDir.setText(dir[0].getCanonicalPath());
}
browseButton.addActionListener(e -> {
FileChooserDialog fileChooser = FileChooserFactory.getInstance()
.createFileChooser(new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return file.isDirectory();
}

@Override
public boolean isFileSelectable(VirtualFile file) {
return file.isDirectory();
}
}, null, panel);
VirtualFile[] dir = fileChooser.choose(project);
if (dir.length > 0) {
destinationDir.setText(dir[0].getCanonicalPath());
}
});
}
Expand Down Expand Up @@ -169,27 +162,32 @@ protected ValidationInfo doValidate() {

public CreateIpaAction.IpaConfig getIpaConfig() {
saveProperties();
Module module = ModuleManager.getInstance(project).findModuleByName(this.module.getSelectedItem().toString());
String signingIdentity = this.signingIdentity.getSelectedItem().toString();
String provisioningProile = this.provisioningProfile.getSelectedItem().toString();
List<Arch> archs = new ArrayList<Arch>();
if(this.archs.getSelectedItem().toString().equals(ARCHS_ALL)) {
archs.add(Arch.thumbv7);
archs.add(Arch.arm64);
} else if(this.archs.getSelectedItem().toString().equals(ARCHS_32BIT)) {
archs.add(Arch.thumbv7);
} else if(this.archs.getSelectedItem().toString().equals(ARCHS_64BIT)) {
archs.add(Arch.arm64);
Module module = ModuleManager.getInstance(project).findModuleByName((String) Objects.requireNonNull(this.module.getSelectedItem()));
String signingIdentity = (String) Objects.requireNonNull(this.signingIdentity.getSelectedItem());
String provisioningProile = (String) Objects.requireNonNull(this.provisioningProfile.getSelectedItem());
String arch = (String) Objects.requireNonNull(this.archs.getSelectedItem());
List<Arch> archs = new ArrayList<>();
switch (arch) {
case ARCHS_ALL:
archs.add(Arch.thumbv7);
archs.add(Arch.arm64);
break;
case ARCHS_32BIT:
archs.add(Arch.thumbv7);
break;
case ARCHS_64BIT:
archs.add(Arch.arm64);
break;
}
return new CreateIpaAction.IpaConfig(module, new File(this.destinationDir.getText()), signingIdentity, provisioningProile, archs);
}

private void saveProperties() {
PropertiesComponent properties = PropertiesComponent.getInstance(project);
properties.setValue(MODULE_NAME, module.getSelectedItem().toString());
properties.setValue(SIGNING_IDENTITY, signingIdentity.getSelectedItem().toString());
properties.setValue(PROVISIONING_PROFILE, provisioningProfile.getSelectedItem().toString());
properties.setValue(ARCHS, archs.getSelectedItem().toString());
properties.setValue(MODULE_NAME, (String)module.getSelectedItem());
properties.setValue(SIGNING_IDENTITY, (String)signingIdentity.getSelectedItem());
properties.setValue(PROVISIONING_PROFILE, (String)provisioningProfile.getSelectedItem());
properties.setValue(ARCHS, (String)archs.getSelectedItem());
properties.setValue(DESTINATION_DIR, destinationDir.getText());
}
}
Loading