I have a Grails app (2.3.6) that uses the Grails Build Standalone plugin.
The myapp/grails-app/conf/BuildConfig.groovy:
plugins {
runtime ":resources:1.2.7"
compile 'org.grails.plugins:gson:1.1.4'
compile ":standalone:1.2.3"
build ":release:3.0.1"
runtime ":cached-resources:1.0"
compile ":cache-headers:1.0.4"
}
When I go to myapp and run grails build-standalone myapp.jar --tomcat I get:
$ grails build-standalone myapp.jar --tomcat
|Loading Grails 2.3.6
|Configuring classpath
|Running pre-compiled script
|Script 'BuildStandalone' not found, did you mean:
1) InstallDependency
2) Stats
3) CreateMultiProjectBuild_
4) TestApp
5) InstallPlugin
Please make a selection or enter Q to quit:
What is going on here?
Related
Configuration
Following the Plugins and Multi-Project Builds section at the Grails 3.2.11 manual, its suppose that I can setup a Multi-project with the next commands in a terminal:
echo "Creating the root folder..."
mkdir test-multi-project
cd test-multi-project
echo "Creating the settings.gradle file..."
echo "include 'myapp', 'myplugin'" >> settings.gradle
echo "Creating the Grails application..."
grails create-app myapp
echo "Creating the Grails plugin..."
grails create-plugin myplugin
echo "Configuring the dependency between the application and the plugin..."
echo "grails { plugins { compile project(':myplugin') } }" >> myapp/build.gradle
echo "Executing the Grails application..."
cd myapp
grails run-app
Error
However, when I tried those commands for create and configure the Grails Application and the Plugin the grails run-app command throws next error:
FAILURE: Build failed with an exception.
* Where:
Build file '~/test-multi-project/myapp/build.gradle' line: 61
* What went wrong:
A problem occurred evaluating root project 'myapp'.
> Project with path ':myplugin' could not be found in root project 'myapp'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
CONFIGURE FAILED
Total time: 4.835 secs
| Error Error initializing classpath: Project with path ':myplugin' could not be found in root project 'myapp'. (Use --stacktrace to see the full trace)
Additional Information
I already tested the above commands using Grails 3.2.8, 3.2.9, 3.2.10 and 3.2.11 and the code throws the same error.
On the other hand, I tested the above commands using Grails 3.2.3, 3.2.5, and 3.2.7 and the project is executed fine. Also, the Grails landing page shows that 'mypluin' is been used by the application.
Note, I am using sdk to handle the Grails versions. The commands were executed using Java 1.7 and Yosemite:
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.7.0_141 (Azul Systems, Inc. 24.141-b11)
OS: Mac OS X 10.10.5 x86_64
Question:
I am wondering what else I need to do or what I am doing wrong in order to make this code works on Grails 3.2.11
Thanks in advance.
Jeff Brown fixed the above issue removing the multi-project-test2/myapp/settings.gradle file and adding the next line to the multi-project-test2/settings.gradle file:
project(':myapp').name = 'myapp'
As you can see at the next GitHub's commit: https://github.com/esalomon/multi-project-test2/commit/d92c3fbc67156bcd1af9f47dc6f2984534154bad
After the above updated the multi-project-test2 can be downloaded and it will work fine.
It is likely to have gone wrong at around this point:
echo "grails { plugins { compile project(':myplugin') } }" >> myapp/build.gradle
That segment needs to be added to existing block of that file not a new block (not that I have tested)
What happens when you follow the steps manually ? does it work that way and if so have you thought of doing a diff across files that changes to see what is different.
You are providing the script which is great and maybe someone else wishes to run through it but i suspect it is what has already been pointed out.
You should look into ed Something like this example:
I am using a grails 3.2.8 app which in the dependency segment ends like this:
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
Now if I execute
test328$ ed -s build.gradle <<EOF >/dev/null
g/^ testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
a
compile project(':myplugin')
.
w
q
EOF
you can now see:
tail -n20 build.gradle
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
compile project(':myplugin')
}
The new entry added on. You will need to find a pointer in your existing file generated by grails and use like above that pointer to add your entry
The ed script was used to demo this since obviously it wasn't clear enough previously
On a Grails 2.5.6 project I'm having trouble writing a custom asset-pipeline AssetFile / Processor pair for Angular template processing. More specifically, it works when I run in develop mode (grails run-app), but fails when packaging (grails war).
The new AssetFile is a simple customization of angular-template-asset-pipeline 2.2.7 (I need to use a new parameter that was only added on the new version of the plugin, only for Grails 3).
For reference, here are the files:
AngularTemplateAssetFile: https://ideone.com/eyuJVi (on src/groovy)
asset.specs: https://ideone.com/iGuUJv (on web-app/META-INF/asset-pipeline/asset.specs)
I put the following code on Bootstrap.groovy:
if (!AssetHelper.assetSpecs.contains(AngularTemplateAssetFile)) {
AssetHelper.assetSpecs << AngularTemplateAssetFile
}
on _Events.groovy:
eventAssetPrecompileStart = { assetConfig ->
assetConfig.specs << 'vtp.angular.AngularTemplateAssetFile'
}
On grails run-app the processor is called correctly and the angular templates are processed and injected on the page. On grails run-war, I get the following error:
...
.
|Compiling 7 GSP files for package [vtpWeb]
..
|Compiling 2 GSP files for package [springSecurityCore]
.
|Compiling 8 GSP files for package [jodaTime]
.
|Compiling 4 GSP files for package [mail]
.
|Compiling 1 GSP file for package [greenmail]
.
|Compiling 5 GSP files for package [console]
..
|Building WAR file
...................................................................................................
|Precompiling Assets!
.Error
|
WAR packaging error: vtp.angular.AngularTemplateAssetFile
The message just contains the class name, and I could not figure out how to debug the application when it is building the war.
Versions used:
Grails 2.5.6
asset-pipeline: 2.6.7
Original version of angular-template-asset-pipeline used as base for my fork: 2.2.7
I updated a plugin to use cxf 2.0.3 - previously the plugin was using cxf 1.4.7.
Following is the updated buildconfig of the plugin.
plugins {
// starting with Grails 2.3 the tomcat plugin is not updated/released along with Grails, so hard code version
build(":tomcat:2.2.5",
":release:2.2.1",) {
export = false
}
compile ":cxf-client:2.0.3"
}
When my application tries to load the plugin, I get the following error.
I tried using the plugin on an existing project and new project and still get the error.
|Loading Grails 2.5.3
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
....
|Compiling 1 source files
..........................................................Error
|
Error: The following plugins failed to load due to missing dependencies: [msApi]
- Plugin: msApi
- Dependencies:
! cxf-client (Required: 1.4.7, Found: 2.0.3) [INVALID]
Process finished with exit code 1
Is there some cache file I need to delete?
Search for string: "1.4.7" in whole plugin project f.e. by grep -rn "1.4.7" and you will find all occurences of this string in project (and then you will decide to change it or to delete such a file from result).
Please note: Although this question involves a lib called Apache Camel I really think this is just a question about how modern Grails plugins work.
I am on Grails 2.4.2 here, and I am trying to use Apache Camel with Grails and found the Grails Routing plugin annd cannot even get it to install.
The directions say to install by issuing a grails install-plugin routing. When I do this I get:
grails install-plugin routing
Starting process on LT-IE-ZH/10.10.99.14
Loading Grails 2.4.2
|Configuring classpath
.
|Environment set to development
......Warning
|
Since Grails 2.3, it is no longer possible to install plugins using the install-plugin command.
Plugins must be declared in the grails-app/conf/BuildConfig.groovy file.
Example:
grails.project.dependency.resolution = {
...
plugins {
compile ":routing:1.3.2"
}
}
So I modify my BuildConfig.groovy like so:
plugins {
// plugins for the build system only
build ":tomcat:7.0.54"
compile ":routing:1.3.2"
...lots of other stuff omitted for brevity
}
Then the plugin says to create routes, issue a grails create-route <RouteName>. So I do exactly that:
grails create-route OrderListener
Starting process on LT-IE-ZH/10.10.99.14
Loading Grails 2.4.2
|Configuring classpath
|Running pre-compiled script
|Script 'CreateRoute' not found, did you mean:
1) CreateFilters
2) CreatePom
3) CreateApp_
4) CreateController
5) CreateHibernateCfgXml
Please make a selection or enter Q to quit:
What is going on here?!? How do I install/use this plugin?!? Am I losing my mind, or does this plugin simply not work?
Update
I run grails clean-all, then grails refresh-dependencies then grails create-route OrderListener and I get:
Loading Grails 2.4.2
.
|Environment set to development
.....Error
|
groovy.lang.MissingMethodException: No signature of method: CreateRoute.createArtifact() is applicable for argument types: () values: []
Error |
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Error |
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
Error |
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
Error |
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Error |
<huge stacktrace omitted>
Error |
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
Error |
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
Error |
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
Error |
... 68 more
Whenever you make a change in BuildConfig.groovy be sure to run grails compile to trigger dependency resolution, which will download new and updated plugins and jars, and it will also compile your code which helps to ensure that things are minimally compatible at least.
But the core issue here is that the plugin's CreateRoute.groovy script is badly broken. It's missing an important include and doesn't come close to calling createArtifact correctly. As a workaround until the authors get this fixed, create a script in your app's scripts folder called CreateCamelRoute.groovy with this content:
includeTargets << grailsScript('_GrailsCreateArtifacts')
target(createCamelRoute: "Creates a new Camel Route.") {
createArtifact(type: 'Route', path: 'grails-app/routes', name: argsMap.params?.get(0) ?: 'Example', suffix: 'Route')
}
setDefaultTarget(createCamelRoute)
It's intentionally named differently from the original because if Grails finds two with the same name it asks which one to use. This way you can just run
grails create-camel-route com.foo.bar.OrderListener
and it will work. Note that I changed the example a bit to include a package - always use packages :)
I am update grails from 2.3.7 to 2.3.9 and it has error
Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling.
Here is run-app --stacktrace --verbose :
|Loading Grails 2.3.9
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
...........
|Compiling 1 source files
[groovyc] Compiling 1 source file to
Z:\future13_grails\cerp\target\classes
.....................................Error
|
Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
at
org.grails.plugins.tomcat.TomcatServer.(TomcatServer.groovy:81)
at
org.grails.plugins.tomcat.InlineExplodedTomcatServer.(InlineExplodedTomcatServer.groovy)
at
org.grails.plugins.tomcat.TomcatServerFactory.createInline(TomcatServerFactory.groovy:38)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner.runInline(GrailsProjectRunner.groovy:183)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner.runApp(GrailsProjectRunner.groovy:119)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner$runApp$0.call(Unknown
Source)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
...
Error | Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
And here is BuildConfig.groovy
... plugins {
// plugins for the build system only
build ':tomcat:7.0.52.1'
// plugins for the compile step
compile ':scaffolding:2.0.3'
compile ':cache:1.1.1'
compile ":spring-security-core:2.0-RC2"
compile ":searchable:0.6.6"
// plugins needed at runtime but not for compilation
runtime ':hibernate:3.6.10.15' // ':hibernate4:4.3.5.3' for Hibernate 4
runtime ':database-migration:1.4.0'
runtime ":jquery:1.10.2"
runtime ':resources:1.2.8'
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0.1"
//runtime ":cached-resources:1.1"
//runtime ":yui-minify-resources:0.1.5"
runtime ":cors:1.1.2"
} ...
I deleted target folder and run grails, it run successfully.
If deleting the target folder doesn't work for your, use the clean and compile commands before trying to run your project again.
Duplicate question Groovy ShortTypeHandling ClassNotFoundException.
I doubt any of the plugin's version is only compatible with Grails version 2.4.0 and above (which comes with Groovy 2.3.*).