Intellij IDEA 14 Errors with grails run-app - grails

I upgraded to IDEA 14 (from 13) and when I attempt to run my grails 2.2.0 application, I am getting the following error:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/gdboling/Projects/GenRocket/web/build.gradle' line: 92
* What went wrong:
A problem occurred evaluating root project 'web'.
> No such property: environment for class: org.gradle.api.internal.project.DefaultProject_Decorated
It would seem that IDEA is attempting to use my build.gradle as part of the grails build process. IDEA 13 didn't do this. I use the build.gradle for some other non-grails related tasks for the project.
If I remove the build.gradle file all together, I get this error:
FAILURE: Build failed with an exception.
* What went wrong:
Task 'grails-run-app' not found in root project 'web'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I do see the Grails View in the IDE but when I try and do a Make, it is telling me to re-import the gradle project. So it would seem that IntelliJ think this is a gradle project. How I can tell it that is is just a grails project?
To confirm my suspicions, I've opened a grails project that did not contain a build.gradle and it works just fine.

I had faced similar issue when unknowingly kept on hit next next in hurry. So, you probably mistakenly created a gradle project as shown in screenshot.
And when you recreated the project created it as "Create project from existing source" which idea well knows as grails-app (default for idea).
See if you can reproduce the error by re-importing the project using import project form external module.

Related

Error in runing grails project after making some modification

So the project was runing in a good way till i made some modification (which i dont remember where ) when i tried to reopen the project and run it , it gave me the output below :
:compileJava UP-TO-DATE
:compileGroovy FAILED
BUILD FAILED
Total time: 10.624 secs
Error |
Gradle build terminated with error: Compilation failed; see the compiler error output for details. (Use --stacktrace to see the full trace)
i've tried to clean the project but it fail like the build , and i have no idea why this is happening cause i'm a newbie in grails and groovy .
i'am using netbeans as ide and grails v 3.0.0
sry for the bad english
i used file history to make it back to what it was , and it work .
https://i.stack.imgur.com/2B5k9.png

auto-reload / hot swap plain groovy dependency in Grails multi-project build

I have a Grails project that includes a separate Gradle project containing utility Java/Groovy classes that are shared among many projects. I am using a multi-project build so that I can develop both projects simultaneously.
The utility classes in the included project are not being hot-swapped / hot-reloaded / auto-reloaded / spring-loaded (I guess there are a lot of synonyms for this concept). This means that every time I make a change in one of the utility classes from the included project, I have to restart the Grails application.
Does anyone know how to make the subproject use the hot-swapping feature that Grails uses? It looks from this comment that Grails does this using Spring Boot's spring-loaded feature: https://github.com/spring-projects/spring-boot/issues/43#issuecomment-24723710
I have even tried setting up the subproject as suggested in this tutorial on using the spring-loaded feature: http://mrhaki.blogspot.com/2015/09/spring-sweets-reload-classes-spring.html. But when I run gradle -t classes, I end up with this output:
Continuous build is an incubating feature.
:compileJava UP-TO-DATE
:compileGroovy FAILED
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.UnsupportedOperationException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.832 secs
Waiting for changes to input files of tasks... (ctrl-d then enter to exit)
The build fails, but the process is still running. So I tried starting the Grails app and checking if the utility classes were being hot-swapped, but they weren't. I hope there is a solution that doesn't require starting a separate process with gradle -t classes before starting the Grails app, but either way, if anyone has any ideas, I'd love to hear them.

Running Grails 3 app on Intellij

I created a default Grails 3 app using the following commandline:
$ grails create-app myapp --profile web --features mongodb,asset-pipeline
And then, I opened the project in IntelliJ IDE 2016.1.
In the first time, the app started correctly. But, I cannot run it anymore due to the following error:
Error running Grails: myapp: Grails application is not found.
I tried to reconfigure the running configurations, but my project is not in the list at all, as shown in the following figure:
IntelliJ Project configuration
Can anybody help me, please?
To restore sanity to IntelliJ configuration files, the simplest solution on Grails > 3 is to let gradle do the work for you. First close the project in Intellij, then from a *sh shell cd to your project directory and run 'gradle cleanIdea idea'. Reopen the project in IntelliJ. If you were able to start your app with 'grails run-app,' you should now be able to run the app again from within IntelliJ Idea. This works for me whenever IntelliJ starts displaying the same 'no Grails application' message on opening a project.

IntelliJ Grails 3 Project: Unable to Run Grails project

I recently installed IntelliJ onto my machine after many unsuccessful attempt to get GGTS working reliably. So far the error messages were clear and easy to resolve after I imported my Grails project. GGTS had forced me to downgrade from Grails 3 to 2 because, at the time, GGTS does not seem to support Grails 3. I ran into issues after pointing IntelliJ to Grails 3, but restarting IntelliJ seemed to fix those problems. Now, however, I can't get my project to start and I get the following error:
"C:\Program Files\Java\jdk1.8.0_51\bin\java" ...;C:\dev\grails-3.0.4\lib\xalan\serializer\jars\serializer-2.7.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 15.0\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.grails.cli.GrailsCli run-app
Error |
Problem updating profiles from origin git repository (Use --stacktrace to see the full trace)
Error |
Could not checkout tag for Grails release [3.0.4]: repository not found: C:\Users\Randeep\.grails\repository (Use --stacktrace to see the full trace)
Error |
Error occurred running Grails CLI: No profile found for name [web]. (Use --stacktrace to see the full trace)
Process finished with exit code 1
Note the "Problem updating profiles from origin git repository" message. This is a git project, but I don't know why IntelliJ is trying to do any git operations (I don't want it to, I just want it to run my project).
There's a lot going on behind the scenes with grails here. The CLI (command line interface) is trying to load a profile called web. Basically grails creates a .grails folder in your home directory that contains a set of default profiles (see ~/.grails/repository/profiles).
Somehow this folder got corrupted or modified on my system and the web profile, which is the default profile, disappeared. To fix this I simply deleted the .grails folder from my home directory, ran grails, and it regenerated.
Edit: Deleting your .grails folder may have undesirable behavior if other projects are using data within it, so try deleting the profiles folder first.
I got this error message too after I delete ~/.grails ~/.gradle from my home directory.
Thoses directories seems won't created again for some reason, and grails clean isn't work at the same time.
This how I fixed it, hope it helps.
set up JAVA_HOME / GRAILS_HOME variables.
cd GRAILS_HOME (ie. /etc/grails/grails-3.1.4 )
execute 'bin/grails'
create-profile web
grails will try to create a new web profile, and start downloading dependency jars.
exit. & done.
ps. my environment.
jdk 1.7.0_4
grails 3.1.4
IntelliJ is trying to download a Grails profile called 'web' and it is unable. Enable --stacktrace and dig into the problem.
Or Create a new project in IntelliJ and point it to your source.
Note: Your project should be a Grails 3.0.X to use profiles.
I stumbled across this question when my Grails 3.2.8 app was reporting a similar problem for react.
Error occurred running Grails CLI: No profile found for name [react]
I do not have a .grails/profile folder, for whatever reason, and didn't want to trash the whole .grails folder right off the bat, so I ended up :
reimporting my project into the IDE
refreshed the grails dependencies
cleaned the grails project
and it worked for me.

Can't launch libgdx ios/robovm build in IPhone simulator with gradle

I'm trying to get a basic Hello World libgdx application running on the IPhone Simulator using gradle. I am new to gradle and robovm.
First I should note that I am able to successfully build and run tis example app https://github.com/jtakakura/robovm-sample-ios-app with the command:
./gradlew build launchIPhoneSimulator
Just as a small diversion, I am curious to know why
./gradlew launchIPhoneSimulator
fails. Apparently 'build' needs to be explicit.
wintermute:robovm-sample-ios-app matt$ ./gradlew launchIPhoneSimulator
:launchIPhoneSimulator
Classpath entry /Users/matt/code/robovm-sample-ios-app/build/classes/main does not exist
:launchIPhoneSimulator FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launchIPhoneSimulator'.
> Main class org.robovm.sample.ios.RoboVMSampleIOSApp not found
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7.115 secs
I would have thought that the launchIPhoneSimulator task would depend on the build task and that calling lanuchIPhoneSimulator would implicitly invoke build. Is this a mistake in the gradle-robovm-plugin (https://github.com/jtakakura/gradle-robovm-plugin) or is there something I am missing about gradle?
Ok, sorry back to my main question:
I generated a libgdx project using the command line tool supplied by Gdx-setup (https://github.com/libgdx/libgdx/tree/master/extensions/gdx-setup) with the arguments:
--dir /Users/matt/code/test --name test --package com.foo.bar --mainClass FooTest
I threw the generated project up on github so you can clone it with less hassle:
git clone https://github.com/mattwalters/libgdx-test libgdx-test
Then I'll run
./gradlew build
to build all the sub projects. But I am unable to get the ios build running on the simulator via
./gradlew launchIPhoneSimulator
I get a similar error to the one above:
wintermute:test matt$ ./gradlew ios:launchIPhoneSimulator
:ios:launchIPhoneSimulator
Classpath entry /Users/matt/code/test/ios/build/classes/main does not exist
:ios:launchIPhoneSimulator FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ios:launchIPhoneSimulator'.
> Main class com.foo.bar.IOSLauncher not found
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 12.759 secs
I double checked that there is no typo between the actual name of the main class and the mainClass declared to gradle. And there is indeed no classes directory in ios/build, but I am not sure why.
Can anyone help shed some light on this for me? Thanks very much in advance.
Update 2014-01-24: At least one other user has verified that it now works, so please make sure you try again if you are still having problems.
Update 2014-01-23: I've recently checked in some bugfixes to the libgdx gradle support which has been merged into the daily builds. Assuming you use the daylies they should appear within 24 hours. At my end the new bugfixes makes "./gradlew ios:assemble launchIPhoneSimulator" work out of the box after creating a new project with the GdxSetup class.
Original response below:
First, make sure you use at least version 0.0.2 of the gradle-robovm-plugin. Secondly, try to build the sample project using the plugin from here:
https://github.com/jtakakura/robovm-sample-ios-app
The author of the plugin was kind enough to make this based on my request. I've tested the plugin with the example and it works without a hitch. It was discussed and resolved in a closed issue here:
https://github.com/jtakakura/gradle-robovm-plugin/issues/3
It's also worth noting that on recent libgdx builds, the command line tool for generating libgdx application templates already uses the plugin so you should be ready to go without the need to download and/or muck with the stuff yourself (short of getting libdx and running the command line util for generating a template project).
If you already have a project that you need to adapt, look carefully at the build.gradle file in the robovm-sample-ios-app example from the author of the example. It shows you what is needed to get a robovm build going.
Try to check is roboVMVersion and robovm-gradle-plugin in your main build.gradle points to latest robovm/plugin versions. If no - try to use latest. This helps me several times.

Resources