Skip to content

Commit

Permalink
Add all necesary dependencies for ADB
Browse files Browse the repository at this point in the history
  • Loading branch information
jhorvath committed Sep 23, 2024
1 parent 271279f commit d60af68
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public class AddNewAssetCommand implements CommandProvider {

private static final Map<String, String[]> 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
Expand Down Expand Up @@ -127,7 +128,7 @@ public CompletableFuture<Object> runCommand(String command, List<Object> 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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Dependency> 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();
Expand Down

0 comments on commit d60af68

Please sign in to comment.