grails / grails-gradle-plugin-archived

142 stars 40 forks source link

Resource of nested inline plugins not being built (2.1.0, Grails 2.4.2) #115

Open chrisbrookes opened 10 years ago

chrisbrookes commented 10 years ago

I have a some nested inline plugins that an app depends on:

grails-deploy (app) -> grails-admin -> grails-core -> grails-dynamic-finders

So grails-dynamic-finders is an inline plugin of grails-core which is an inline plugin of grails-admin (etc).

When I run gradle grails-war (or war) the first time the app only has the grails-admin plugin resources files (css, js, etc) contained within the war (plugins/grails-admin), the other plugins' resources are not there. The classes do seem to be there however. The (relevant) output when building is as follows:

| Compiling 6 GSP files for package [grailsDeploy]
| Compiling 17 GSP files for package [grailsAdmin]
| Compiling 13 GSP files for package [grailsCore]
| Compiling 2 GSP files for package [springSecurityCore]
| Building WAR file
| Generating plugin.xml for inline plugin grails-admin
| Done creating WAR build/distributions/grails-deploy.war

If I delete the war (note, not a clean) and build again, the resources files for the other plugins are there, and the output is:

| Compiling 6 GSP files for package [grailsDeploy]
| Compiling 17 GSP files for package [grailsAdmin]
| Compiling 13 GSP files for package [grailsCore]
| Compiling 2 GSP files for package [springSecurityCore]
| Building WAR file
| Generating plugin.xml for inline plugin grails-admin
| Generating plugin.xml for inline plugin grails-core
| Generating plugin.xml for inline plugin grails-dynamic-finders
| Done creating WAR build/distributions/grails-deploy.war

Note how the Generating plugin.xml... line has appeared for the inline plugins where it was not present before.

This doesn't happen with the regular grails war, only through using gradle and the grails-gradle-plugin.

Any ideas?

Thanks, Chris.

johnrengelman commented 10 years ago

How are you doing inline plugins? Are you declaring them using BuildConfig.groovy or do you mean you are including them using Gradle project dependencies?

chrisbrookes commented 10 years ago

I'm declaring them in BuildConfig like:

grails.plugin.location.'grails-dynamic-finders' = "../grails-dynamic-finders"
johnrengelman commented 10 years ago

I haven't tried that, but generally instead of using inline plugins via BuildConfig.groovy, you should create a multi-project Gradle build and include a project dependency instead:

<root>/
+-- my-grails-app/
+-- grails-dynamic-finders/

And in my-grails-app/build.gradle do:

dependencies {
  compile project(':grails-dynamic-finders')
}
chrisbrookes commented 10 years ago

We do have a multi-project build already (the grails apps are part of it, but not the plugins currently), I'll give it a go this way when I get a chance. For now I've worked around it by explicitly including the transitive plugins in the app's BuildConfig. Thanks, Chris.

vahidhedayati commented 10 years ago

I saw this whilst I was being stupid myself mind you in a grails app and wanted to point out in regards to line plugins... when something is declared as grails- and then built it usually has that buit all removed so ..

grails-wschat-plugin becomes wschat....

grails.plugin.location.'wschat' = "../grails-wschat-plugin"

so in order or me to use it as in inline plugin. I need to declare it like above. Hope it helps someone else if you have already fixed your issue.

It may help if it is a plugin to package it first and see what is produced then refer to that name on HS and full folder name on RHS