Open jmini opened 2 years ago
Probably it is more a bug than a feature.
This is problematic:
And the corresponding test: https://github.com/jbangdev/jbang/blob/ef362429c1c9a60aec8200b3f3184cbb74160c98/src/test/java/dev/jbang/source/TestScript.java#L265-L273
The ,
inside a range [1.0.0, 1.1.0)
should be ignored when it comes to split.
Workaround:
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.apache.groovy:groovy:4.0.0
import static java.lang.System.out;
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
import java.util.Arrays;
import groovy.lang.Grab;
import groovy.lang.Grapes;
import groovy.lang.GrabResolver;
@GrabResolver("mavenCentral")
@Grapes({
@Grab(group="ch.qos.reload4j", module="reload4j", version="[1.2.18,1.2.19)")
})
class logdemo {
static final Logger logger = Logger.getLogger(logdemo.class);
public static void main(String[] args) {
BasicConfigurator.configure();
logger.info("Welcome to jbang");
Arrays.asList(args).forEach(arg -> logger.warn("arg: " + arg));
logger.info("Hello from Java!");
}
}
Is correctly resolved.
Check with jbang info tools logdemo
and check the resolvedDependencies
. It contains:
groovy-4.0.0.jar
(just to make the compiler happy)reload4j-1.2.18.5.jar
(witch matches [1.2.18,1.2.19)
)As reaction @maxandersen https://github.com/jbangdev/jbang/pull/1271#issuecomment-1110845388 and @quintesse https://github.com/jbangdev/jbang/pull/1271#issuecomment-1110848139
Currently @Grab
is the only way I found to be able to define version range.
If ,
is a valid separator for
//DEPS blah, blue
Then parsing the line to decide if the ,
is a separator or if this is part of a range (instead of blah
we can have ch.qos.reload4j:reload4j:[1.2.18,1.2.19)
and in this case ,
is no longer a separator) starts to be really difficult.
Is your feature request related to a problem? Please describe. I would like to use a version range like in maven. Example
[1.0.0, 1.1.0)
Describe the solution you'd like Currently only
1.+
is supported. But internally it is turned to a maven range. As seen in the[jbang] Resolving dependencies...
linesAdditional context Example:
Should resolve to
1.2.18.5
.Currently failing with this error: