From 7dde468d25bb681a4fe2d61b12cf0f53a7037a21 Mon Sep 17 00:00:00 2001 From: "Andy Xu(devdiv)" Date: Fri, 19 Jun 2020 14:58:53 +0800 Subject: [PATCH] Add common modules back which should be supported in Azure Functions, Fix #4307 --- .../pom.xml | 2 +- .../plugin.xml | 58 +++++------ .../pom.xml | 2 +- .../com.microsoft.azuretools.sdk/pom.xml | 2 +- .../resources/ApplicationInsights.xml | 10 +- .../pom.xml | 2 +- .../AddLibrary/AzureLibraries/pom.xml | 34 +++---- .../plugin.xml | 96 +++++++++---------- .../ApplicationInsights.xml | 6 +- .../runner/functions/core/FunctionUtils.java | 54 ++++++----- .../localrun/FunctionRunConfiguration.java | 2 +- Utils/pom.xml | 20 ++-- 12 files changed, 148 insertions(+), 140 deletions(-) diff --git a/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.feature/pom.xml b/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.feature/pom.xml index 1e48e63b95..20a8c46a82 100644 --- a/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.feature/pom.xml +++ b/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.feature/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - ../../../azure-toolkit-for-eclipse/pom.xml + ../../../azure-toolkit-for-eclipse/pom.xml com.microsoft.azuretools.wap4ej.build parent ${azuretool.eclipse.version} diff --git a/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.ui/plugin.xml b/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.ui/plugin.xml index 15cbdf9cc7..24c8192cc2 100644 --- a/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.ui/plugin.xml +++ b/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.ui/plugin.xml @@ -12,13 +12,13 @@ - - - - + + + + @@ -41,27 +41,27 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - + id="com.microsoft.ui.preferencepage.applicationinsights" + class="com.microsoft.applicationinsights.preference.ApplicationInsightsPreferencePage" + name="Application Insights" + category="com.persistent.ui.preferencepage.windowsazure"> diff --git a/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.ui/pom.xml b/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.ui/pom.xml index 4b601f6434..eb4cf4e815 100644 --- a/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.ui/pom.xml +++ b/PluginsAndFeatures/AddLibrary/AppInsights/com.microsoft.applicationinsights.ui/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - ../../../azure-toolkit-for-eclipse/pom.xml + ../../../azure-toolkit-for-eclipse/pom.xml com.microsoft.azuretools.wap4ej.build parent ${azuretool.eclipse.version} diff --git a/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.sdk/pom.xml b/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.sdk/pom.xml index 434348dcc8..ab3349f284 100644 --- a/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.sdk/pom.xml +++ b/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.sdk/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - ../../../azure-toolkit-for-eclipse/pom.xml + ../../../azure-toolkit-for-eclipse/pom.xml com.microsoft.azuretools.wap4ej.build parent ${azuretool.eclipse.version} diff --git a/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.sdk/resources/ApplicationInsights.xml b/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.sdk/resources/ApplicationInsights.xml index f9e0345f18..76f8157e15 100644 --- a/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.sdk/resources/ApplicationInsights.xml +++ b/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.sdk/resources/ApplicationInsights.xml @@ -2,8 +2,8 @@ ${instrkey} @@ -11,9 +11,9 @@ - - - + + + diff --git a/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.wasdkjava.ui/pom.xml b/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.wasdkjava.ui/pom.xml index 2276180290..7724a9bb73 100644 --- a/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.wasdkjava.ui/pom.xml +++ b/PluginsAndFeatures/AddLibrary/AzureLibraries/com.microsoft.azuretools.wasdkjava.ui/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - ../../../azure-toolkit-for-eclipse/pom.xml + ../../../azure-toolkit-for-eclipse/pom.xml com.microsoft.azuretools.wap4ej.build parent ${azuretool.eclipse.version} diff --git a/PluginsAndFeatures/AddLibrary/AzureLibraries/pom.xml b/PluginsAndFeatures/AddLibrary/AzureLibraries/pom.xml index d01a6e75fb..66e5eb568e 100644 --- a/PluginsAndFeatures/AddLibrary/AzureLibraries/pom.xml +++ b/PluginsAndFeatures/AddLibrary/AzureLibraries/pom.xml @@ -56,7 +56,7 @@ com.microsoft.azuretools hdinsight-node-common ${azuretool.version} - + jakarta.xml.bind jakarta.xml.bind-api @@ -80,7 +80,7 @@ bundle-manifest process-classes - + manifest @@ -105,22 +105,22 @@ - - maven-antrun-plugin - 1.8 - - - package - - + + maven-antrun-plugin + 1.8 + + + package + + - - - - run - - - + + + + run + + + org.apache.maven.plugins diff --git a/PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.hdinsight/plugin.xml b/PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.hdinsight/plugin.xml index abe99c044d..d66f841586 100644 --- a/PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.hdinsight/plugin.xml +++ b/PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.hdinsight/plugin.xml @@ -1,66 +1,66 @@ - - - - - - - - + + + + + + + + name="HDInsight Project" + id="com.microsoft.azure.hdinsight.projwizard.category"> - Spark on HDInsight (Scala) + Spark on HDInsight (Scala) - Spark on HDInsight (Java) + Spark on HDInsight (Java) - Spark on HDInsight Local Run Sample (Scala) + Spark on HDInsight Local Run Sample (Scala) - Spark on HDInsight Local Run Sample (Java) + Spark on HDInsight Local Run Sample (Java) - Spark on HDInsight Cluster Run Sample (Scala) + Spark on HDInsight Cluster Run Sample (Scala) @@ -72,39 +72,39 @@ id="com.microsoft.azure.hdinsight.projwizard"> - + - - - + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/resources/applicationinsights/ApplicationInsights.xml b/PluginsAndFeatures/azure-toolkit-for-intellij/resources/applicationinsights/ApplicationInsights.xml index 77c392a65b..1d433115ec 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/resources/applicationinsights/ApplicationInsights.xml +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/resources/applicationinsights/ApplicationInsights.xml @@ -7,9 +7,9 @@ - - - + + + diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/core/FunctionUtils.java b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/core/FunctionUtils.java index c9e834e6a4..093ee06a28 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/core/FunctionUtils.java +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/core/FunctionUtils.java @@ -31,6 +31,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.CompilerModuleExtension; import com.intellij.openapi.roots.OrderEnumerator; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.Library; @@ -104,10 +105,9 @@ public static boolean isValidStagingFolderPath(String stagingFolderPath) { } public static Module[] listFunctionModules(Project project) { - MavenProjectsManager mpm = MavenProjectsManager.getInstance(project); final Module[] modules = ModuleManager.getInstance(project).getModules(); return Arrays.stream(modules).filter(m -> { - if (mpm.findProject(m) == null) { + if (isModuleInTestScope(m)) { return false; } final GlobalSearchScope scope = GlobalSearchScope.moduleWithLibrariesScope(m); @@ -168,24 +168,6 @@ public static final Path createTempleHostJson() { } } - private static void copyFilesWithDefaultContent(Path sourcePath, File dest, String defaultContent) - throws IOException { - final File src = sourcePath == null ? null : sourcePath.toFile(); - if (src != null && src.exists()) { - FileUtils.copyFile(src, dest); - } else { - FileUtils.write(src, defaultContent, Charset.defaultCharset()); - } - } - - private static void updateLocalSettingValues(File target, Map appSettings) throws IOException { - final JsonObject jsonObject = JsonUtils.readJsonFile(target); - final JsonObject valueObject = new JsonObject(); - appSettings.entrySet().forEach(entry -> valueObject.addProperty(entry.getKey(), entry.getValue())); - jsonObject.add("Values", valueObject); - JsonUtils.writeJsonToFile(target, jsonObject); - } - public static void copyLocalSettingsToStagingFolder(Path stagingFolder, Path localSettingJson, Map appSettings) throws IOException { @@ -245,9 +227,6 @@ public static String getTargetFolder(Module module) { } final Project project = module.getProject(); final MavenProject mavenProject = MavenProjectsManager.getInstance(project).findProject(module); - if (mavenProject == null) { - return StringUtils.EMPTY; - } final String functionAppName = mavenProject == null ? null : mavenProject.getProperties().getProperty( "functionAppName"); final String stagingFolderName = StringUtils.isEmpty(functionAppName) ? module.getName() : functionAppName; @@ -428,4 +407,33 @@ private static Binding createBinding(BindingEnum bindingEnum, PsiAnnotation anno } return binding; } + + private static void copyFilesWithDefaultContent(Path sourcePath, File dest, String defaultContent) + throws IOException { + final File src = sourcePath == null ? null : sourcePath.toFile(); + if (src != null && src.exists()) { + FileUtils.copyFile(src, dest); + } else { + FileUtils.write(src, defaultContent, Charset.defaultCharset()); + } + } + + private static void updateLocalSettingValues(File target, Map appSettings) throws IOException { + final JsonObject jsonObject = JsonUtils.readJsonFile(target); + final JsonObject valueObject = new JsonObject(); + appSettings.entrySet().forEach(entry -> valueObject.addProperty(entry.getKey(), entry.getValue())); + jsonObject.add("Values", valueObject); + JsonUtils.writeJsonToFile(target, jsonObject); + } + + private static boolean isModuleInTestScope(Module module) { + if (module == null) { + return false; + } + CompilerModuleExtension cme = CompilerModuleExtension.getInstance(module); + if (cme == null) { + return false; + } + return cme.getCompilerOutputUrl() == null && cme.getCompilerOutputUrlForTests() != null; + } } diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/localrun/FunctionRunConfiguration.java b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/localrun/FunctionRunConfiguration.java index 32e2823747..814c5a80ea 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/localrun/FunctionRunConfiguration.java +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/functions/localrun/FunctionRunConfiguration.java @@ -213,7 +213,7 @@ public void setHostJsonPath(String hostJsonPath) { @Override public void validate() throws ConfigurationException { if (getModule() == null) { - throw new ConfigurationException("Please specify module or add Maven support to the project."); + throw new ConfigurationException("Please specify module"); } if (StringUtils.isEmpty(getFuncPath())) { diff --git a/Utils/pom.xml b/Utils/pom.xml index 45139928d8..709311ac4b 100644 --- a/Utils/pom.xml +++ b/Utils/pom.xml @@ -89,16 +89,16 @@ maven-checkstyle-plugin 3.1.0 - - com.microsoft.azuretools - check-tools - 1.0.0 - - - com.puppycrawl.tools - checkstyle - 8.30 - + + com.microsoft.azuretools + check-tools + 1.0.0 + + + com.puppycrawl.tools + checkstyle + 8.30 + checkstyle.xml