Skip to content

Commit c00c5fb

Browse files
committed
Merge branch 'develop' into telemetry/tag
2 parents 88a085a + e65a986 commit c00c5fb

File tree

63 files changed

+607
-463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+607
-463
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PluginsAndFeatures/azure-toolkit-for-intellij/build.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
plugins {
2-
id "org.jetbrains.intellij" version "0.4.21"
3-
id "org.jetbrains.kotlin.jvm" version "1.3.41"
2+
id "org.jetbrains.intellij" version "0.5.0"
3+
id "org.jetbrains.kotlin.jvm" version "1.3.72"
44
id "de.undercouch.download" version "4.0.4"
55
id "com.github.ben-manes.versions" version "0.28.0"
6+
id 'org.openjfx.javafxplugin' version '0.0.9'
67
id "io.freefair.aspectj.post-compile-weaving" version "5.3.0"
78
id "com.github.spotbugs" version "4.6.0"
89
}
@@ -43,6 +44,11 @@ compileTestKotlin {
4344
kotlinOptions.jvmTarget = javaVersion
4445
}
4546

47+
javafx {
48+
version = '11'
49+
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing']
50+
}
51+
4652
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
4753

4854
//apply plugin: 'checkstyle'
@@ -57,8 +63,8 @@ intellij {
5763
pluginName = 'azure-toolkit-for-intellij'
5864
version = intellij_version
5965
updateSinceUntilBuild = Boolean.valueOf(updateVersionRange)
60-
plugins = ['java', 'maven', 'gradle', dep_plugins, "properties", 'markdown', 'terminal']
61-
downloadSources = Boolean.valueOf(true)
66+
plugins = ['java', 'maven', 'maven-model', 'gradle', dep_plugins, "properties", 'markdown', 'terminal']
67+
downloadSources = Boolean.valueOf(sources)
6268
}
6369

6470
sourceSets {
@@ -136,6 +142,8 @@ dependencies {
136142
compile group: 'jaxen', name: 'jaxen', version: '1.2.0'
137143
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
138144

145+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72")
146+
139147
// https://mvnrepository.com/artifact/org.projectlombok/lombok
140148
compileOnly 'org.projectlombok:lombok:1.18.8'
141149
annotationProcessor 'org.projectlombok:lombok:1.18.8'
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
javaVersion=1.8
1+
javaVersion=11
22
org.gradle.jvmargs='-Duser.language=en'
33
sources=false
4-
intellij_version=IC-2020.2
5-
dep_plugins=org.intellij.scala:2020.2.14
4+
intellij_version=IC-2020.3
5+
dep_plugins=org.intellij.scala:2020.3.8
66
applicationinsights.key=57cc111a-36a8-44b3-b044-25d293b8b77c
77
updateVersionRange=true
8-
patchPluginXmlSinceBuild=202.6397.94
8+
patchPluginXmlSinceBuild=203.5419.21

PluginsAndFeatures/azure-toolkit-for-intellij/resources/META-INF/plugin.xml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@
2525
<change-notes>
2626
<![CDATA[
2727
<html>
28-
<h3>3.50.0</h3>
29-
<h4>Added</h4>
28+
<h3>3.50.1</h3>
29+
<h4>Fixes</h4>
3030
<ul>
31-
<li>Development workflow for Azure Database for MySQL
32-
<ul>
33-
<li>Connect Azure Database for MySQL Server to local project from Azure Explorer or application.properties file</li>
34-
<li>Automatically inject datasource connection properties into runtime environment for local run</li>
35-
<li>Publish Azure Web App with datasource connection properties in application settings</li>
36-
</ul>
37-
</li>
31+
<li>Fixes: Can't deploy to Azure Web App when there is "Connect Azure Resource" in before launch</li>
32+
<li>Fixes: InvalidParameterException occurs when close a streaming log</li>
33+
<li>Fixes: Failed when select file to deploy to Azure Web App</li>
34+
<li>Fixes: Failed to create MySQL instance as resource provider is not registered</li>
3835
</ul>
3936
<p>You may get the full change log <a
4037
href="https://github.com/Microsoft/azure-tools-for-java/blob/develop/CHANGELOG.md">here</a></p>

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/console/SparkExecuteInConsoleActionPromoter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import com.microsoft.azure.hdinsight.common.logger.ILogger
3030
class SparkExecuteInConsoleActionPromoter : ActionPromoter, ILogger {
3131
private fun shouldPromote(anAction: AnAction): Boolean = anAction is SparkConsoleExecuteAction
3232

33-
override fun promote(actions: MutableList<AnAction>, context: DataContext?): MutableList<AnAction> =
33+
override fun promote(actions: MutableList<AnAction>, context: DataContext): MutableList<AnAction> =
3434
actions.firstOrNull { shouldPromote(it) }
3535
?.let { mutableListOf(it) }
3636
?: mutableListOf()

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/console/SparkScalaLivyConsole.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SparkScalaLivyConsole(module: Module) : ScalaLanguageConsole(module), Spar
3333
super.textSent(codes)
3434
}
3535

36-
override fun attachToProcess(processHandler: ProcessHandler?) {
36+
override fun attachToProcess(processHandler: ProcessHandler) {
3737
super.attachToProcess(processHandler)
3838

3939
// Remove self from ScalaConsoleInfo

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/run/SparkBatchLocalRunState.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.microsoft.azure.hdinsight.spark.run
2424

25+
import com.intellij.core.JavaPsiBundle
2526
import com.intellij.execution.DefaultExecutionResult
2627
import com.intellij.execution.ExecutionException
2728
import com.intellij.execution.ExecutionResult
@@ -32,7 +33,6 @@ import com.intellij.execution.process.KillableColoredProcessHandler
3233
import com.intellij.execution.process.ProcessAdapter
3334
import com.intellij.execution.process.ProcessEvent
3435
import com.intellij.execution.runners.ProgramRunner
35-
import com.intellij.execution.ui.ConfigurationModuleSelector.NO_MODULE_TEXT
3636
import com.intellij.execution.util.JavaParametersUtil
3737
import com.intellij.openapi.module.ModuleManager
3838
import com.intellij.openapi.project.Project
@@ -126,7 +126,8 @@ open class SparkBatchLocalRunState(val myProject: Project,
126126

127127
if (hasJmockit) {
128128
params.vmParametersList.addAll(
129-
getCommandLineVmParameters(executor, params, mainModule?.name ?: NO_MODULE_TEXT))
129+
getCommandLineVmParameters(executor, params,
130+
mainModule?.name ?: JavaPsiBundle.message("list.item.no.module")))
130131
}
131132

132133
if (hasClassPath) {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/hdinsight/spark/run/SparkFailureTaskRunProfileState.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ import com.intellij.execution.DefaultExecutionResult
2626
import com.intellij.execution.ExecutionException
2727
import com.intellij.execution.ExecutionResult
2828
import com.intellij.execution.Executor
29+
import com.intellij.execution.ShortenCommandLine.MANIFEST
2930
import com.intellij.execution.configurations.GeneralCommandLine
3031
import com.intellij.execution.configurations.JavaParameters
3132
import com.intellij.execution.process.KillableColoredProcessHandler
3233
import com.intellij.execution.process.ProcessAdapter
3334
import com.intellij.execution.process.ProcessEvent
3435
import com.intellij.execution.runners.ProgramRunner
3536
import com.intellij.execution.util.JavaParametersUtil
36-
import com.intellij.util.PathUtil
37+
import com.intellij.openapi.util.io.FileUtil
3738
import com.microsoft.azure.hdinsight.spark.common.SparkFailureTaskDebugConfigurableModel
3839
import com.microsoft.azure.hdinsight.spark.ui.SparkJobLogConsoleView
3940
import com.microsoft.azuretools.telemetrywrapper.ErrorType
@@ -118,18 +119,18 @@ open class SparkFailureTaskRunProfileState(val name: String,
118119

119120
JavaParametersUtil.configureConfiguration(params, settingsConfigModel)
120121

122+
// Put failure context runtime at beginning, after JDK6, the classpath support <dir>/*
123+
params.classPath.addAllFiles(File(FileUtil.toCanonicalPath(settingsConfigModel.workingDirectory), "runtime").listFiles())
124+
121125
// The dependent spark-tools.jar is already in the Maven project lib/ directory
122126
JavaParametersUtil.configureProject(project, params, JavaParameters.JDK_AND_CLASSES_AND_TESTS, null)
123127

124128
// Additional VM parameters
125129
additionalVmParameters.forEach { params.vmParametersList.add(it) }
126130

127-
// Put failure context runtime at beginning, after JDK6, the classpath support <dir>/*
128-
params.classPath.addFirst("${PathUtil.getCanonicalPath(settingsConfigModel.workingDirectory)}/runtime/*")
129-
130131
// Prepare log4j.properties file
131132
settingsConfigModel.log4jProperties?.also { log4jProp ->
132-
val log4jPropertiesFile = File("${PathUtil.getCanonicalPath(settingsConfigModel.workingDirectory)}/conf/log4j.properties")
133+
val log4jPropertiesFile = File("${FileUtil.toCanonicalPath(settingsConfigModel.workingDirectory)}/conf/log4j.properties")
133134
.apply {
134135
parentFile.mkdir()
135136
writeText(log4jProp)
@@ -140,6 +141,7 @@ open class SparkFailureTaskRunProfileState(val name: String,
140141

141142
// Helper Main class
142143
params.mainClass = settingsConfigModel.runClass
144+
params.setShortenCommandLine(MANIFEST, null)
143145

144146
return params.toCommandLine()
145147
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/AppServiceComboBox.java

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,72 +12,46 @@
1212
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
1313
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
1414
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
15-
import com.microsoft.tooling.msservices.components.DefaultLoader;
1615
import org.apache.commons.lang3.StringUtils;
17-
import org.apache.commons.lang3.exception.ExceptionUtils;
1816
import rx.Subscription;
1917

2018
import javax.swing.*;
21-
import java.io.InterruptedIOException;
19+
import java.util.List;
2220
import java.util.Objects;
2321

24-
import static com.microsoft.intellij.util.RxJavaUtils.unsubscribeSubscription;
25-
2622
public abstract class AppServiceComboBox<T extends AppServiceComboBoxModel> extends AzureComboBox<T> {
2723

2824
protected Project project;
2925
protected Subscription subscription;
3026

27+
private T configModel;
28+
3129
public AppServiceComboBox(final Project project) {
3230
super(false);
3331
this.project = project;
3432
this.setRenderer(new AppCombineBoxRender(this));
3533
}
3634

37-
// todo: optimize refreshing logic
38-
public synchronized void refreshItemsWithDefaultValue(@NotNull T defaultValue) {
39-
unsubscribeSubscription(subscription);
40-
this.setLoading(true);
41-
this.removeAllItems();
42-
this.addItem(defaultValue);
43-
subscription = this.loadItemsAsync()
44-
.subscribe(items -> DefaultLoader.getIdeHelper().invokeLater(() -> {
45-
synchronized (AppServiceComboBox.this) {
46-
AppServiceComboBox.this.removeAllItems();
47-
items.forEach(this::addItem);
48-
this.resetDefaultValue(defaultValue);
49-
this.setLoading(false);
50-
}
51-
}), this::handleLoadingError);
52-
}
53-
54-
private void resetDefaultValue(@NotNull T defaultValue) {
55-
final AppServiceComboBoxModel model = getItems()
56-
.stream()
57-
.filter(item -> AppServiceComboBoxModel.isSameApp(defaultValue, item) && item != defaultValue)
58-
.findFirst().orElse(null);
59-
if (model != null) {
60-
this.setSelectedItem(model);
61-
this.removeItem(defaultValue);
62-
} else if (defaultValue.isNewCreateResource()) {
63-
return;
64-
} else {
65-
this.setSelectedItem(null);
66-
this.removeItem(defaultValue);
67-
}
35+
public void setConfigModel(T configModel) {
36+
this.configModel = configModel;
37+
setValue(new ItemReference<>(item -> AppServiceComboBoxModel.isSameApp(item, configModel)));
6838
}
6939

40+
@NotNull
7041
@Override
71-
protected void handleLoadingError(final Throwable e) {
72-
final Throwable rootCause = ExceptionUtils.getRootCause(e);
73-
if (rootCause instanceof InterruptedIOException || rootCause instanceof InterruptedException) {
74-
// Swallow interrupted exception caused by unsubscribe
75-
return;
42+
protected List<? extends T> loadItems() throws Exception {
43+
final List<T> items = loadAppServiceModels();
44+
if (configModel != null && configModel.isNewCreateResource()) {
45+
final boolean exist = items.stream().anyMatch(item -> AppServiceComboBoxModel.isSameApp(item, configModel));
46+
if (!exist) {
47+
items.add(configModel);
48+
}
7649
}
77-
this.setLoading(false);
78-
super.handleLoadingError(e);
50+
return items;
7951
}
8052

53+
protected abstract List<T> loadAppServiceModels() throws Exception;
54+
8155
@Nullable
8256
@Override
8357
protected ExtendableTextComponent.Extension getExtension() {

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/common/AzureArtifactManager.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
package com.microsoft.azure.toolkit.intellij.common;
66

77
import com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo;
8+
import com.intellij.openapi.module.Module;
89
import com.intellij.openapi.project.Project;
10+
import com.intellij.openapi.roots.ProjectFileIndex;
11+
import com.intellij.openapi.vfs.LocalFileSystem;
912
import com.intellij.openapi.vfs.VirtualFile;
1013
import com.intellij.packaging.artifacts.Artifact;
1114
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
@@ -15,16 +18,20 @@
1518
import org.apache.commons.compress.utils.FileNameUtils;
1619
import org.apache.commons.lang3.StringUtils;
1720
import org.jetbrains.annotations.NotNull;
21+
import org.jetbrains.annotations.Nullable;
1822
import org.jetbrains.idea.maven.model.MavenConstants;
1923
import org.jetbrains.idea.maven.project.MavenProject;
2024
import org.jetbrains.idea.maven.project.MavenProjectsManager;
2125
import org.jetbrains.plugins.gradle.model.ExternalProject;
2226
import org.jetbrains.plugins.gradle.service.project.data.ExternalProjectDataCache;
2327

28+
import java.io.File;
2429
import java.util.*;
2530
import java.util.function.Predicate;
2631
import java.util.stream.Collectors;
2732

33+
import static com.microsoft.azure.toolkit.intellij.common.AzureArtifactType.File;
34+
2835
public class AzureArtifactManager {
2936
private static Map<Project, AzureArtifactManager> projectAzureArtifactManagerMap = new HashMap<>();
3037
private final Project project;
@@ -47,11 +54,6 @@ public List<AzureArtifact> getSupportedAzureArtifactsForSpringCloud() {
4754
return prepareAzureArtifacts(packaging -> StringUtils.equals(packaging, MavenConstants.TYPE_JAR));
4855
}
4956

50-
@AzureOperation(
51-
name = "common|artifact.get_id",
52-
params = {"artifact.getName()"},
53-
type = AzureOperation.Type.TASK
54-
)
5557
public String getArtifactIdentifier(AzureArtifact artifact) {
5658
switch (artifact.getType()) {
5759
case Gradle:
@@ -93,7 +95,7 @@ public AzureArtifact getAzureArtifactById(String artifactId) {
9395
}
9496

9597
public AzureArtifact getAzureArtifactById(AzureArtifactType azureArtifactType, String artifactId) {
96-
return azureArtifactType == AzureArtifactType.File ? AzureArtifact.createFromFile(artifactId) :
98+
return azureArtifactType == File ? AzureArtifact.createFromFile(artifactId) :
9799
getAllSupportedAzureArtifacts().stream().filter(artifact -> StringUtils.equals(getArtifactIdentifier(
98100
artifact), artifactId)).findFirst().orElse(null);
99101
}
@@ -121,6 +123,28 @@ public boolean equalsAzureArtifactIdentifier(AzureArtifact artifact1, AzureArtif
121123
return StringUtils.equals(getArtifactIdentifier(artifact1), getArtifactIdentifier(artifact2));
122124
}
123125

126+
@Nullable
127+
@AzureOperation(
128+
name = "common|artifact.get_module",
129+
type = AzureOperation.Type.TASK
130+
)
131+
public Module getModuleFromAzureArtifact(AzureArtifact azureArtifact) {
132+
if (azureArtifact == null || azureArtifact.getReferencedObject() == null) {
133+
return null;
134+
}
135+
switch (azureArtifact.getType()) {
136+
case Gradle:
137+
final String gradleModulePath = ((ExternalProjectPojo) azureArtifact.getReferencedObject()).getPath();
138+
final VirtualFile gradleVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(gradleModulePath));
139+
return ProjectFileIndex.getInstance(project).getModuleForFile(gradleVirtualFile);
140+
case Maven:
141+
return ProjectFileIndex.getInstance(project).getModuleForFile(((MavenProject) azureArtifact.getReferencedObject()).getFile());
142+
default:
143+
// IntelliJ artifact is bind to project, can not get the related module, same for File artifact
144+
return null;
145+
}
146+
}
147+
124148
private String getGradleProjectId(ExternalProjectPojo gradleProjectPojo) {
125149
ExternalProject externalProject = getRelatedExternalProject(gradleProjectPojo);
126150
return Objects.nonNull(externalProject) ? externalProject.getQName() : null;

0 commit comments

Comments
 (0)