views:

24

answers:

2

In a grails project I have added a custom ivy resolver per the reference docs, http://www.grails.org/doc/latest/guide/single.html#12.2%20Plugin%20Repositories .

However, this resolver requires jsch and and some other jars. How can I put them on the project's build classpath so that ivy will use them?

This is my BuildConfig.groovy

grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.war.file = "target/${appName}-${appVersion}.war"

//Configure resolver
def sshResolver = new org.apache.ivy.plugins.resolver.SshResolver()
['libraries', 'builds'].each {
    sshResolver.addArtifactPattern("/home/ivy/[organisation]/[revision]/[artifact].[ext]")
    sshResolver.addIvyPattern("/home/ivy/[organisation]/[revision]/[artifact].[ext]")
}
sshResolver.name = "ssh"
sshResolver.settings = ivySettings

resolver sshResolver

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
    }
    log "warn" 
    repositories {
        grailsPlugins()
        grailsHome()
        grailsCentral()
        ssh()
    }
    dependencies {
        compile 'someorg:somejar:1.0'
        runtime 'mysql:mysql-connector-java:5.1.13'
    }   
}
A: 

Grails uses ivy to implement it's dependency management. All you should need to do is declare the extra libraries you need. Have you tried something like this:

dependencies {
    ..
    compile 'com.jcraft:jsch:0.1.42'
    ..
}   
Mark O'Connor
I tried build 'com.jcraft:jsch:0.1.42'Unfortunately it is not a dependency of the project but of the resolver. So I get the error before the dependencies are processed.
gabe
A: 

Apparently

grails -cp ./lib/jsch.jar 

was the answer, not the -classpath or --classpath that I had initially tried.

If anyone has a better answer I will certainly accept it over mine.

I tried placing the jar in grails/lib but it gets loaded after the resolvers are processed.

I tried this in PreInit.groovy but no luck there either.

grails.compiler.dependencies = { fileset(file:'${basedir}/lib/jsch.jar') } 
gabe