From af63248b1e30e3f3685f3d0bbf8e786c2f8443b5 Mon Sep 17 00:00:00 2001 From: Ferdinando Villa Date: Sun, 22 Dec 2024 14:13:26 +0100 Subject: [PATCH] Fixes --- .../klab/components/ComponentRegistry.java | 2 +- .../klab/runtime/libraries/ExtentLibrary.java | 3 +++ .../integratedmodelling/klab/utilities/Utils.java | 15 ++++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/klab.core.services/src/main/java/org/integratedmodelling/klab/components/ComponentRegistry.java b/klab.core.services/src/main/java/org/integratedmodelling/klab/components/ComponentRegistry.java index 2240a44a0..9a87d1e63 100644 --- a/klab.core.services/src/main/java/org/integratedmodelling/klab/components/ComponentRegistry.java +++ b/klab.core.services/src/main/java/org/integratedmodelling/klab/components/ComponentRegistry.java @@ -307,7 +307,7 @@ public FunctionDescriptor getFunctionDescriptor(ServiceCall call) { */ public String registerComponent(File componentJar, String mavenCoordinates, Scope scope) { var result = installComponent(componentJar, mavenCoordinates, scope); - if (result != null && result.getSecond().isEmpty()) { + if (result != null && !result.getSecond().isEmpty()) { return result.getFirst().id(); } return null; diff --git a/klab.core.services/src/main/java/org/integratedmodelling/klab/runtime/libraries/ExtentLibrary.java b/klab.core.services/src/main/java/org/integratedmodelling/klab/runtime/libraries/ExtentLibrary.java index 1ebf6c91a..6219e320d 100644 --- a/klab.core.services/src/main/java/org/integratedmodelling/klab/runtime/libraries/ExtentLibrary.java +++ b/klab.core.services/src/main/java/org/integratedmodelling/klab/runtime/libraries/ExtentLibrary.java @@ -34,6 +34,9 @@ import org.integratedmodelling.klab.runtime.scale.time.TimeImpl; import org.integratedmodelling.klab.utilities.Utils; +/** + * @deprecated these should be accessed through defines + */ @Library(name = Library.CORE_LIBRARY, description = "Core extent functions to declare space and time " + "extents.") public class ExtentLibrary { diff --git a/klab.core.services/src/main/java/org/integratedmodelling/klab/utilities/Utils.java b/klab.core.services/src/main/java/org/integratedmodelling/klab/utilities/Utils.java index b8f146d40..16084c5ac 100644 --- a/klab.core.services/src/main/java/org/integratedmodelling/klab/utilities/Utils.java +++ b/klab.core.services/src/main/java/org/integratedmodelling/klab/utilities/Utils.java @@ -64,17 +64,19 @@ public static void main(String[] args) { .fetchArtifacts(new MavenFetchRequest( "org.integratedmodelling:klab.component.generators:1.0-SNAPSHOT")); - result.artifacts().peek(fetchedArtifact -> System.out.println(fetchedArtifact.coordinates() + ": " + fetchedArtifact.path())).toList(); + result.artifacts().peek(fetchedArtifact -> System.out.println("CIUCCIA " + fetchedArtifact.coordinates() + ": " + fetchedArtifact.path())).toList(); - } + System.out.println("FETCHATO: MO' PROVO CON L'ALTRO: " + Maven.synchronizeArtifact("org" + + ".integratedmodelling", "klab.component.generators", "1.0-SNAPSHOT", true)); + } /** * Functions to access Maven artifacts */ public static class Maven { - private static MavenFetcher mavenFetcher = new MavenFetcher() + private static final MavenFetcher mavenFetcher = new MavenFetcher() .localRepositoryPath(System.getProperty("user.home") + "/.m2/repository") .addRemoteRepository("ossrh", "https://oss.sonatype.org/content/repositories/snapshots"); @@ -93,6 +95,7 @@ public static boolean needsUpdate(String mavenGroupId, String mavenArtifactId, S return true; } + // NAH we should find a way to not fetch if it's there. No help from public API var request = new MavenFetchRequest(mavenGroupId + ":" + mavenArtifactId + ":" + version); var result = mavenFetcher.fetchArtifacts(request); if (result.artifacts().findAny().isPresent()) { @@ -105,13 +108,11 @@ public static boolean needsUpdate(String mavenGroupId, String mavenArtifactId, S } public static File synchronizeArtifact(String mavenGroupId, String mavenArtifactId, String version, - boolean verifySignature) { + boolean verifySignature) { var request = new MavenFetchRequest(mavenGroupId + ":" + mavenArtifactId + ":" + version); var result = mavenFetcher.fetchArtifacts(request); if (result.artifacts().findAny().isPresent()) { - AtomicReference ret = new AtomicReference<>(); - result.artifacts().peek(fetchedArtifact -> ret.set(fetchedArtifact.path().toFile())); - return ret.get(); + return result.artifacts().toList().getFirst().path().toFile(); } return null; }