Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fvilla committed Dec 22, 2024
1 parent f908193 commit af63248
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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()) {
Expand All @@ -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<File> ret = new AtomicReference<>();
result.artifacts().peek(fetchedArtifact -> ret.set(fetchedArtifact.path().toFile()));
return ret.get();
return result.artifacts().toList().getFirst().path().toFile();
}
return null;
}
Expand Down

0 comments on commit af63248

Please # to comment.