Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell Grails to use Gradle for dependencies resolution

I'm trying to setup a grails project with gradle but i came a problem, i can't make grails to use gradle for dependencies resolution. If i config the dependencies in gradle build file and run gradle grails-run-app, it always report can't find classes in dependencies jars.

When i cut and paste the dependencies into grails BuildConfig.groovy and everything is ok.

How to tell Grails to use Gradle for dependencies resolution?

I paste my build.gradle file here, Any suggestion?

apply plugin: 'grails'
apply plugin: 'java'
apply plugin: 'jetty'

version "1.0-SNAPSHOT"

buildscript {
    repositories {
        mavenCentral()
        mavenRepo urls: 'http://repository.jboss.org/nexus/content/groups/public/'
    }
    dependencies {
        classpath 'com.connorgarvey.gradle:gradle-grails-wrapper:1.0'
    }
}

grails {
    version '2.2.3'
}

repositories {
    mavenLocal()
    mavenCentral()
    mavenRepo urls: 'http://repository.jboss.org/nexus/content/groups/public/'

}


dependencies {
    compile 'org.modeshape.bom:modeshape-bom-embedded:3.3.0.Final'
    compile 'postgresql:postgresql:9.1-901.jdbc4'
    compile 'javax.jcr:jcr:2.0'
    compile 'org.modeshape:modeshape-jcr:3.3.0.Final'
}
like image 927
user2478308 Avatar asked Mar 23 '23 09:03

user2478308


1 Answers

I would recommend using the grails-gradle-plugin instead.

UPDATED ANSWER, cleanup and usage of bootstrap scope to exclude Tomcat jars from war.

General info

I followed a presentation from Luke Daley (aka alkemist) on Youtube at gr8conf 2013. I was able to create a small POC and Gradle seems to work fine with Grails 2.2.3.

Gradle build file

buildscript {
  repositories {
    mavenCentral()
    maven { url 'http://repository.jboss.org/maven2/' }
    maven { url 'http://repo.grails.org/grails/repo' }
    maven { url 'http://repo.grails.org/grails/plugins' }
    maven { url 'http://repository.springsource.com/maven/bundles/release' }
    maven { url 'http://repository.springsource.com/maven/bundles/external' }
    maven { url 'http://repository.springsource.com/maven/libraries/release' }
    maven { url 'http://repository.springsource.com/maven/libraries/external' }
  }

  dependencies {
    classpath 'org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT',
    'org.grails:grails-bootstrap:2.2.3' 
  }
}

version='0.0.1'

apply plugin: 'grails'

repositories {
  mavenCentral()
  maven { url 'http://repository.jboss.org/maven2/' }
  maven { url 'http://repo.grails.org/grails/repo' }
  maven { url 'http://repo.grails.org/grails/plugins' }
  maven { url 'http://repository.springsource.com/maven/bundles/release' }
  maven { url 'http://repository.springsource.com/maven/bundles/external' }
  maven { url 'http://repository.springsource.com/maven/libraries/release' }
  maven { url 'http://repository.springsource.com/maven/libraries/external' }  
}

grails {
  grailsVersion '2.2.3'
  version '2.2.3'
}

configurations {
  all {
    exclude module: 'commons-logging'
    exclude module: 'xml-apis'
  }
  test {
    exclude module: 'groovy-all'
  }
  compile {
    exclude module: 'hibernate'
  }
}

dependencies {
  compile( "org.grails:grails-crud:$grails.grailsVersion",
           'org.grails:grails-gorm:1.3.7')

  bootstrap "org.grails:grails-plugin-tomcat:$grails.grailsVersion"
}
like image 188
rimero Avatar answered Mar 29 '23 05:03

rimero