If you work with javax.print and want to know which parameters are sent to the printing device use following VM parameter to enable some debug information on standard out:
-Dsun.print.ippdebug=true
Friday, January 9, 2015
Saturday, January 3, 2015
Quick Dependency resolving with Grape
Most of the time i use Groovy with the GroovyShell or as a Groovy-Shell Script (remember my Blog-Post in October). Doing it that way you can achieve a lot with some lines of Groovy Script and the Groovy Standard Library Classes. But what if you need some classes from some third party libraries?
If you run your Groovy Script inside the GroovyShell you can simply modify the file groovy-starter.conf (resides in the conf folder of your GroovyShell installation). Add the classpath to the required library and you are done.
But this can get quite difficult if the library has further dependencies and you did not have these ones. Or you have these dependencies but only as maven dependencies, living in a gigantic maven repo on your local harddrive.
To get around this issue Groovy provides a Maven like mechanism called Grape. Grape does all the dependency resolving for you by doing lookups in well known Maven Repositories. So for example, if you like to have the FTPClient class from org.apache.commons.net in your Groovy Script, add the following Grape Statement:
@Grapes(
@Grab(group='commons-net', module='commons-net', version='3.2')
)
Then add the import statement for the FTPClient class and you are done! The full script with its overwhelming functionality ;-):
@Grapes(
@Grab(group='commons-net', module='commons-net', version='3.2')
)
import org.apache.commons.net.ftp.*;
FTPClient ftpClient = new FTPClient();
If the required dependency does not exist in the repositories known by Grape you can tell Grape where to go to find it. Simply add this statement:
@GrabResolver(name='myrepo', root='http://mymavenrepo.org/')
Grape is "supported" by mvnrepository.com. If you look for a dependency mvnrepository.com tells you the grape-code for instant usage!
If you run your Groovy Script inside the GroovyShell you can simply modify the file groovy-starter.conf (resides in the conf folder of your GroovyShell installation). Add the classpath to the required library and you are done.
But this can get quite difficult if the library has further dependencies and you did not have these ones. Or you have these dependencies but only as maven dependencies, living in a gigantic maven repo on your local harddrive.
To get around this issue Groovy provides a Maven like mechanism called Grape. Grape does all the dependency resolving for you by doing lookups in well known Maven Repositories. So for example, if you like to have the FTPClient class from org.apache.commons.net in your Groovy Script, add the following Grape Statement:
@Grapes(
@Grab(group='commons-net', module='commons-net', version='3.2')
)
Then add the import statement for the FTPClient class and you are done! The full script with its overwhelming functionality ;-):
@Grapes(
@Grab(group='commons-net', module='commons-net', version='3.2')
)
import org.apache.commons.net.ftp.*;
FTPClient ftpClient = new FTPClient();
If the required dependency does not exist in the repositories known by Grape you can tell Grape where to go to find it. Simply add this statement:
@GrabResolver(name='myrepo', root='http://mymavenrepo.org/')
Grape is "supported" by mvnrepository.com. If you look for a dependency mvnrepository.com tells you the grape-code for instant usage!
Subscribe to:
Posts (Atom)