Skip to content
Open
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
49 changes: 35 additions & 14 deletions deps.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
///usr/bin/env jbang "$0" "$@" ; exit $?

// http://mvnrepository.com/artifact/dev.jbang/jash
//DEPS dev.jbang:jash:0.0.3
//DEPS com.fasterxml.jackson.core:jackson-databind:2.20.1

// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
//DEPS com.fasterxml.jackson.core:jackson-databind:2.21.1

// https://mvnrepository.com/artifact/info.picocli/picocli
//DEPS info.picocli:picocli:4.7.7

//DEPS eu.maveniverse.maven.plugins:toolbox:0.11.4
//DEPS org.apache.maven:maven-plugin-api:3.9.11
//DEPS org.apache.maven:maven-settings:3.9.10
//DEPS eu.maveniverse.maven.mima.runtime:standalone-static:2.4.36
// https://mvnrepository.com/artifact/eu.maveniverse.maven.plugins/toolbox
//DEPS eu.maveniverse.maven.plugins:toolbox:0.15.4

// https://mvnrepository.com/artifact/org.apache.maven/maven-plugin-api
//DEPS org.apache.maven:maven-plugin-api:3.9.13

// https://mvnrepository.com/artifact/org.apache.maven/maven-settings
//DEPS org.apache.maven:maven-settings:3.9.13

// https://mvnrepository.com/artifact/eu.maveniverse.maven.mima.runtime/standalone-static
//DEPS eu.maveniverse.maven.mima.runtime:standalone-static:2.4.41

// https://mvnrepository.com/artifact/eu.maveniverse.maven.mima/context
//DEPS eu.maveniverse.maven.mima:context:2.4.41

// https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
//DEPS org.slf4j:slf4j-simple:2.0.17

import static dev.jbang.jash.Jash.*;
Expand All @@ -17,19 +33,23 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.LinkedList;
import java.util.List;

import java.util.concurrent.Callable;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;
import eu.maveniverse.maven.toolbox.plugin.CLI;

import java.util.concurrent.Callable;

@Command(name = "deps", mixinStandardHelpOptions = true, version = "deps 0.1",
@Command(
name = "deps",
mixinStandardHelpOptions = true,
version = "deps 0.1",
description = "Analyze JBang script dependencies")

public class deps implements Callable<Integer> {

@Parameters(index = "0", description = "JBang script alias, filename or GAV to analyze", defaultValue = "")
@Parameters(
index = "0",
description = "JBang script alias, filename or GAV to analyze",
defaultValue = "")
private String name;

public static void main(String... args) throws Exception {
Expand All @@ -51,7 +71,9 @@ public Integer call() throws Exception {

if (!name.contains(":")) {
// name is a script file or alias
String dependencies = $(jbang_launch_cmd + " info tools --quiet --select=dependencies " + name).get();
String dependencies =
$(jbang_launch_cmd + " info tools --quiet --select=dependencies " + name)
.get();
JsonNode deps = new ObjectMapper().readTree(dependencies);

// Build the gavList
Expand All @@ -65,7 +87,7 @@ public Integer call() throws Exception {
}
// Check for version updates
String[] toolbox_args = {"versions", String.join(",", gavList)};
eu.maveniverse.maven.toolbox.plugin.CLI.main(toolbox_args);
CLI.main(toolbox_args);
} catch (dev.jbang.jash.ProcessException e) {
// script file or alias do not contain any //DEPS
return 2;
Expand All @@ -74,5 +96,4 @@ public Integer call() throws Exception {
// Return success
return 0;
}

}