Open jmini opened 2 years ago
I disagree with this implementation:
Or at least it is not compatible with Gradle definition of the +
notation.
A workaround is to use [10.3.0,10.4.0)
instead of 10.3.+
.
And because of issue #1268, the @Grab
notation must be used:
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.apache.groovy:groovy:4.0.0
import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.api.factory.Lists;
import groovy.lang.Grab;
import groovy.lang.Grapes;
import groovy.lang.GrabResolver;
@GrabResolver("mavenCentral")
@Grapes({
@Grab(group="org.eclipse.collections", module="eclipse-collections", version="[10.3.0,10.4.0)")
})
class collection {
public static void main(String[] args) {
ImmutableList<String> list = Lists.immutable.of("One", "One", "Two", "Three");
list.forEach(e -> System.out.println(e));
}
}
Is correctly resolved.
Check with jbang info tools collection
and check the resolvedDependencies
. It contains:
groovy-4.0.0.jar
(just to make the compiler happy)eclipse-collections-10.3.0.jar
(witch matches [10.3.0,10.4.0)
)eclipse-collections-api-10.3.0.jar
(witch matches [10.3.0,10.4.0)
)In method dev.jbang.source.ScriptSource.extractDependencies(String)
Probably the code line.split(" // ")[0].split("[ ;,]+")
should be rewritten to take the first element, parse it and check if there is more to parse.
@maxandersen WDYT ? I could start a PR in this direction if you give a go for this approach.
Or supporting multiple deps in the same // DEPS
line is a bad idea…
Personally I am not doing this, but probably some users do it like this.
We do support multiple deps on one line. If not via //DEPS then via --deps.
About version ranges the current implementation was done to have at least one way to "loosen" the deps. It currently mimick what we do for //JAVA.
Happy to see if we can enable a "richer" version range syntax - just need to be something also somewhat expressible on cli.
Describe the bug When resolving a version range (using a
+
), it just takes the latest.Example
1.3.+
is converted to[1.3.,)
Gradle has a way better definition:
Source https://docs.gradle.org/current/userguide/single_versions.html
So
1.3.+
probably means something like[1.3.,1.4.)
To Reproduce
When executed
Inspecting the classpath with
jbang info tools
shows that theresolvedDependencies
contains:11.0.0
is the newest version available at time of writing.Expected behavior
10.3.0
is the only version in maven central matching10.3.+
As comparison, with a gradle project having:
Extract of the command
gradle dependencies
:JBang version Paste output of
jbang version --verbose
Additional context Related issue: #1267