Gregg
Gregg

Reputation: 35864

Best Way To Tie Together Gradle Module and Grails Module

We have a Project that contains 2 modules; web and client

The web module is a Grails application and the client module is mostly just groovy code and touch of Java code. The client module is being managed by a Gradle build script.

The Grails module has dependencies in the client module. In IntelliJ I can define that in the module config with no problems. However, when building the Grails WAR I really need to build the client JAR and have it placed in the WAR file. I'm wondering what is the best approach for this?

Upvotes: 0

Views: 283

Answers (1)

Gregg
Gregg

Reputation: 35864

Here is what I ended up doing.

In my Gradle script I have the following:

repositories {
  mavenCentral()
  flatDir {
    name "genRocketRepos"
    dirs "${System.properties['user.home']}/.genRocket/repos"
  }
}

uploadArchives {
  repositories {
    add project.repositories.genRocketRepos
  }
}

I then run the uploadArchives task via Gradle. This published the JAR file to a local repos. In Grails BuildConfig.groovy I defined the following:

repositories {
  ...
  flatDir name:'myRepo', dirs:'${userHome}/.genRocket/repo'
}

dependencies {
  ...
  runtime 'genRocket:client:1.0'
}

Now Grails sees the dependency and includes in the classpath as well as places the JAR in the WAR for me.

Upvotes: 1

Related Questions