java - How to load/find a JAR resource from inside GMaven script? -
this gmaven script, trying find , load file located somewhere inside provided dependency (it's section of pom.xml
):
[...] <plugin> <groupid>org.codehaus.gmaven</groupid> <artifactid>gmaven-plugin</artifactid> <executions> <execution> <configuration> <source> <![cdata[ def file = // how my-file.txt? ]]> </source> </configuration> </execution> </executions> <dependencies> <dependency> <groupid>my-group</groupid> <artifactid>my-artifact</artifactid> <version>1.0</version> </dependency> </dependencies> </plugin> [...]
the my-file.txt
located in my-group:my-artifact:1.0
jar file.
the answer simple:
def url = getclass().getclassloader().getresource("my-file.txt");
then url in following format:
jar:file:/usr/me/.m2/repository/grp/art/1.0-snapshot/art.jar!/my-file.tex
the rest trivial.
Comments
Post a Comment