From d60af685ef62de1f86a4cc85de452601e06a777a Mon Sep 17 00:00:00 2001 From: Jan Horvath Date: Mon, 23 Sep 2024 11:37:45 +0200 Subject: [PATCH] Add all necesary dependencies for ADB --- .../oracle/actions/AddDbConnectionToVault.java | 2 +- .../cloud/oracle/actions/ConfigMapUploader.java | 2 +- .../cloud/oracle/assets/AddNewAssetCommand.java | 5 +++-- .../cloud/oracle/assets/DependencyUtils.java | 13 +++++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddDbConnectionToVault.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddDbConnectionToVault.java index 1e43599166ec..a3dc7a0614af 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddDbConnectionToVault.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddDbConnectionToVault.java @@ -221,7 +221,7 @@ private void addDbConnectionToVault(VaultItem vault, KeyItem key, Project projec // Add Vault dependency to the project try { - DependencyUtils.addDependency(project, "io.micronaut.oraclecloud", "micronaut-oraclecloud-vault"); + DependencyUtils.addDependency(project, new String[] {"io.micronaut.oraclecloud", "micronaut-oraclecloud-vault"}); } catch (IllegalStateException e) { LOG.log(Level.INFO, "Unable to add Vault dependency", e); } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/ConfigMapUploader.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/ConfigMapUploader.java index 625484651935..bea62e8a0402 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/ConfigMapUploader.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/ConfigMapUploader.java @@ -262,7 +262,7 @@ private static void updateVault(ProgressHandle h, KeyItem key, VaultItem vault, // Add Vault dependency to the project try { - DependencyUtils.addDependency(project, "io.micronaut.oraclecloud", "micronaut-oraclecloud-vault"); + DependencyUtils.addDependency(project, new String[] {"io.micronaut.oraclecloud", "micronaut-oraclecloud-vault"}); } catch (IllegalStateException e) { LOG.log(Level.INFO, "Unable to add Vault dependency", e); } diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/AddNewAssetCommand.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/AddNewAssetCommand.java index 6861eb0776bc..a6f971cb9774 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/AddNewAssetCommand.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/AddNewAssetCommand.java @@ -56,7 +56,8 @@ public class AddNewAssetCommand implements CommandProvider { private static final Map DEP_MAP = new HashMap() { { - put("Databases", new String[]{"io.micronaut.oraclecloud", "micronaut-oraclecloud-atp"}); //NOI18N + put("Databases", new String[]{"io.micronaut.oraclecloud", "micronaut-oraclecloud-atp", + "io.micronaut.sql", "micronaut-jdbc-hikari"}); //NOI18N put("Bucket", new String[]{"io.micronaut.objectstorage", "micronaut-object-storage-oracle-cloud"}); //NOI18N put("Vault", new String[]{"io.micronaut.oraclecloud", "micronaut-oraclecloud-vault"}); //NOI18N put("MetricsNamespace", new String[]{"io.micronaut.oraclecloud", "micronaut-oraclecloud-micrometer"}); //NOI18N @@ -127,7 +128,7 @@ public CompletableFuture runCommand(String command, List argumen String[] processor = ANNOTATION_PROCESSOR_MAP.get(i.getKey().getPath()); try { if (art != null && art.length > 1) { - DependencyUtils.addDependency(project, art[0], art[1]); + DependencyUtils.addDependency(project, art); } if (processor != null && processor.length > 1) { DependencyUtils.addAnnotationProcessor(project, processor[0], processor[1]); diff --git a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/DependencyUtils.java b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/DependencyUtils.java index 77e63b23b52a..7a70761afde2 100644 --- a/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/DependencyUtils.java +++ b/enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/DependencyUtils.java @@ -19,7 +19,9 @@ package org.netbeans.modules.cloud.oracle.assets; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; import java.util.Set; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectUtils; @@ -41,13 +43,16 @@ */ public class DependencyUtils { - public static void addDependency(Project project, String groupId, String artifactId) { + public static void addDependency(Project project, String[] pairs) { Project projectToModify = getProjectToModify(project, "oci"); if (projectToModify != null) { - ArtifactSpec spec = ArtifactSpec.make(groupId, artifactId); - Dependency dep = Dependency.make(spec, Scopes.COMPILE); - DependencyChange change = DependencyChange.add(Collections.singletonList(dep), Options.skipConflicts); + List dependencies = new ArrayList<> (); + for (int i = 0; i < pairs.length - 1; i += 2) { + ArtifactSpec spec = ArtifactSpec.make(pairs[i], pairs[i + 1]); + dependencies.add(Dependency.make(spec, Scopes.COMPILE)); + } + DependencyChange change = DependencyChange.add(dependencies, Options.skipConflicts); try { ModificationResult mod = ProjectDependencies.modifyDependencies(projectToModify, change); mod.commit();