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

Add all necesary dependencies for ADB #7784

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading