emiller
(Edmund Miller)
September 9, 2024, 8:35pm
1
There are a lot of examples out there of importing groovy files into Nextflow workflows Groovy Imports - training.nextflow.io
There are also some examples of importing java functions
import java.nio.file.Files
How would you import a jar file? The docs claim you can Pipeline sharing — Nextflow v24.08.0-edge documentation
kenibrewer
(Ken Brewer)
September 9, 2024, 8:53pm
2
Hi Edmund!
From what I understand this this is the purpose of the magic lib
directory. Try creating the lib
dir in your pipeline root and dropping the jar in there and seeing if it works.
emiller
(Edmund Miller)
September 10, 2024, 3:26pm
3
Hey Ken!
Thanks, I got that from the docs. I’m looking for what’s the exact syntax to import the jar though, I’ve done that, just struggling to use the library then.
heuermh
(Michael L Heuer)
September 11, 2024, 5:52pm
4
I have an old (DSL1, but perhaps that doesn’t matter) example here,
dsh-bio workflow processes implemented via Nextflow DSL1. Apache 2 licensed.
I don’t think you need to import the jar explicitly, just import classes/methods you want to use.
E.g.
import com.myclass.MyClass
or
import static com.myclass.MyClass.method
4 Likes
emiller
(Edmund Miller)
September 14, 2024, 8:43pm
5
Awesome, thanks for posting that!
I figured it out eventually Fix import · edmundmiller/cid-nf@dfdd730 · GitHub
The part that I also really struggled with was figuring out what the namespace was in the jar.
$ jar tf java-cid-v1.3.8.jar
META-INF/MANIFEST.MF
META-INF/
io/
io/ipfs/
io/ipfs/cid/
META-INF/maven/
META-INF/maven/com.github.ipld/
META-INF/maven/com.github.ipld/java-cid/
io/ipfs/cid/Cid$Codec.class
io/ipfs/cid/Cid.class
io/ipfs/cid/Cid$CidEncodingException.class
META-INF/maven/com.github.ipld/java-cid/pom.xml
META-INF/maven/com.github.ipld/java-cid/pom.properties
Which led to
import io.ipfs.cid.Cid
1 Like
emiller
(Edmund Miller)
Closed
September 21, 2024, 8:44pm
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.