Grails

Inline dependencies are not packaged with 'grails war'

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.2 final
  • Fix Version/s: 1.2.1
  • Component/s: Plugins
  • Labels:
    None
  • Environment:
    Validated bug exists in Linux (Redhat 5 64-bit) and Windows XP

Description

Running 'grails war' should make a deployable war artifact that includes all dependencies required by in-line plugins. This does not currently work in 1.2.

See the below emails:

It appears the inline plugin dependencies are not picked up:

_GrailsWar.groovy

90: target  (war:

...

115: packagePluginsForWar(stagingDir)
_PackagePlugins.groovy

84: packagePluginsForWar
def pluginInfos = pluginSettings.getPluginInfos(pluginsHome)
    for(PluginInfo info in pluginInfos) {
        try {

            def pluginBase = info.pluginDir.file
            def pluginPath = pluginBase.absolutePath
            def pluginName = "${info.name}-${info.version}"

            packageFiles(pluginBase.path)
            if(new File("${pluginPath}/web-app").exists()) {
                ant.mkdir(dir:"${targetDir}/plugins/${pluginName}")
                ant.copy(todir:"${targetDir}/plugins/${pluginName}") {
                    fileset(dir:"${pluginBase}/web-app", includes:"**",
excludes:"**/WEB-INF/**, **/META-INF/**")
                }
            }
        }

The only things copied here (in our case) are css/, images/, and js/.

Bouncing back to _GrailsWar.groovy

172: if(includeJars) {            
        	def pluginInfos = pluginSettings.supportedPluginInfos

            GrailsPluginManager pm = pluginManager
            pluginInfos = pluginInfos.findAll { info ->
pm.supportsCurrentBuildScope(info.name) }


        	if(pluginInfos) {
                ant.copy(todir:"${stagingDir}/WEB-INF/lib",
flatten:true, failonerror:false) {
                    for(PluginInfo info in pluginInfos) {
                        fileset(dir: info.pluginDir.file.path) {
                            include(name:"lib/*.jar")
                        }
                    }
                }
            }
        }

You can see that lib/*.jar files are copied to the war artifact but no
mention of the DSL functionality.

I believe I've scanned this code correctly. If no one objects I will
open a JIRA on the issue.

  • Chris

We are using the inline plugin capability of Grails 1.2 to modularize
our application. It has worked nicely so far but we've hit a bit of a
problem.

Our plugins are used inline to reduce the install plugin cycle.

BuildConfig.groovy:

final String MODULES_DIR = 'modules'
	
grails.plugin.location.foo = "$MODULES_DIR/foo"
grails.plugin.location.bar = "$MODULES_DIR/bar"

Etc.

When we build the main application our plugins are picked up and
executed as expected. So far so good.

Our plugins define their dependencies using the new 1.2 DSL like so:

dependencies {
	final String JBOSS_VERSION = '4.2.3.GA'
    build 'javax.jms:jms:1.1',
          "jboss:concurrent:$JBOSS_VERSION", // concurrent.jar
	    "jboss:jboss-common-client:$JBOSS_VERSION", //
jboss-common-client.jar

Etc.

When we issue a run-app command in our top most Grails app the
dependencies are picked up and things work as expected. We can run the
plugins individually (test-app, run-app) and things work as expected.

The problem begins when we attempt to package the top most Grails app.
Our war does not pick up the dependent jars. Is this expected? Are we
supposed to define the dependencies in our top most application?

We are looking for any guidance here from teams that are doing the same
thing.

Thanks,

Chris

Activity

Hide
Graeme Rocher added a comment -

Examples that work

Show
Graeme Rocher added a comment - Examples that work
Hide
Graeme Rocher added a comment -

I've attached two examples that work for me. The plugin defines a dependencies on the mysql jar. When I run 'grails war' in the application the mysql jar is present in the WAR file.

The code example you present above are there to handle the cases where declarative dependencies are not defined. The code that actually handles this is line 754 of grails/util/BuildSettings.groovy which checks for dependencies.groovy or BuildConfig.groovy of each plugin

Please attach an example that reproduces the issue

Show
Graeme Rocher added a comment - I've attached two examples that work for me. The plugin defines a dependencies on the mysql jar. When I run 'grails war' in the application the mysql jar is present in the WAR file. The code example you present above are there to handle the cases where declarative dependencies are not defined. The code that actually handles this is line 754 of grails/util/BuildSettings.groovy which checks for dependencies.groovy or BuildConfig.groovy of each plugin Please attach an example that reproduces the issue
Hide
Graeme Rocher added a comment -

reduced priority until a reproducible example is provided

Show
Graeme Rocher added a comment - reduced priority until a reproducible example is provided
Hide
Graeme Rocher added a comment -

closing since I cannot reproduce and the attached examples work for me

Show
Graeme Rocher added a comment - closing since I cannot reproduce and the attached examples work for me
Hide
Christopher Stokes added a comment -

This appears to be user error.

Our DSL used 'build' scope instead of 'compile' scope. Once we changed the scope the jars were included in the final war output.

Show
Christopher Stokes added a comment - This appears to be user error. Our DSL used 'build' scope instead of 'compile' scope. Once we changed the scope the jars were included in the final war output.

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: