How do I compile grails project using grails command line? - grails

How do I compile my grails project? I want to get a .war file so I can deploy it.
First I installed JDK then I installed grails and I have properly set environment variables for both and checked it.Now I want to compile this grails project using grails command line.how can I do it?
Thanks in advance

If you type "grails help", you'll get a list of all the grails commands. The one you're looking for is "grails war"

Related

Build a new Grails app by Gradle

I get a company's project from Github, and import into the GGTS as a gradle project. Everything runs OK. gradle task show this.
I want to create a new Grails app, so I used the command grails create-app wtf, and then import into GGTS as a Gradle project. What make me confused is that the file named build.gradle or the folder named .gradle do not appear, gradle task shows null like this, while I do the same thing in system of company and it runs fine.
Please tell me what happend? And I did not write a build.gradle in system of company manually.
The problem is Grails 2.4.4 does not use Gradle. That didn't start until Grails 3.0.
I believe you need to import the project as a Grails project (I haven't used ggts in a long time, so my recollection it's foggy). You can read more about IDE integration here.

Using Grails 2.4.3 in IntelliJ

I've been unable to create/import a Grails 2.4.3 project with IntelliJ 13.1.4. For example, when I create a new module, choose Grails, then click the create button (highlighted below) and choose the location where Grails 2.4.3 is installed, the project is not created correctly (I get a module with just a /src directory instead of a Grails project) and Grails 2.4.3 is not added to the list of Global Libraries. I don't have this problem with any earlier version of Grails.
I have used Grails 2.4.2 with Intellij 13.1.4 successfully. What I did is create the application with the grails create-app command and then do a File / Import Project in Intellij. Give that a try.
As an alternative solution to the IntelliJ 13.1.4 and Grails 2.4.3 bug you can:
grails create app <app-name>
cd app-name
grails integrate-with --intellij
This configured the project correctly for me with just minor tweaks to SDK and application server. This is a minor twist on the work around described above.
See grails doc here
I had the same problem with IntelliJ 13.1.4 and Grails 2.4.3, which i just downloaded.
After using the grails create-app command from the command line i had to import the project, by "create from existing sources" (point to the new top level folder), "Configure SDK" (to set for the Grails 2.4.3) and finally edit the run configuration. In a second test run with a new test project i did not have too configure the run config.
Then the Grails libs for the were downloaded and the basic app ran. Also the Grails specific option in the Intellij "Tools2 section were suddenly available.
So the given answer by Joe is the way to setup a new Grails project but the IDE should be fixed anyways.
It is not consistent. After several tries I can get some applications to work but it does not seem to be automatic. I think I am going to go back to Grails 2.4.2 until this is resolved within Intellij 13.1.4.
In the screenshot above, there are options for groovy/grails/griffon, and so far the alternative offered was command-line. Try choosing groovy option within intelliJ.
We are using IDEA 13.1.4 with grails 1.3.7 and grails 2.2.1(diff projects) and saw the same issue. It appears this is an intelliJ issue and not so much the grails version, so reverting your grails won't gain you anything. Choosing groovy, you should see a prompt for grails directory structure. This does work if you are presented with this option. Seeing inconsistencies here. Thanks to all for posting your workarounds; never hurts to have multiple approaches.
-Duane

grails doesn't generate ant build file

I'm a beginner of Grail. I learned from the quick-start tutorial that the grails create-app will generate a build.xml for Ant.
I execute the command. but couldn't get the build.xml file. Is there missing any steps? Any help is appreciated.
As Don said you really don't need it. But if you want the build.xml that used to be automatically created, run
grails integrate-with --ant
See http://grails.org/doc/latest/ref/Command%20Line/integrate-with.html
Grails may generate a build.xml file "under the hood", but there's no reason for you to worry about this, because you don't work with Ant directly when developing with Grails. Instead you use Grails commands (like create-app) to create, build, test, deploy, etc. Grails applications.
The create-app command creates a new application. To run the application, execute the command grails run-app from the root directory of the project.

Grails create-app does not produce build.xml?

It is said here that grails create-app should produce a build.xml for ant or maven. However it does not (at least in version 1.3.7). How can I build it with ant?
In order to allow your project to be built with ant you must tell it to integrate with ant. Use the following grails command from your project directory to do so.
grails integrate-with --ant
With net-beans ide you can run grails command throw the right click option of your project root folder, and select "run/debug grails command...".
Choose "integrate-with" command and put "--ant" as an argument.

Grails war command defaults to development environment under netbeans

When I generate the war in my grails app via right-click / run grails / command / war, it shows "Environment set to development", having it run without parameters. Why is this happening when according to the docs it should default to production (which is what I need)?
BTW, is there a way having built the whole grails application with NetBeans to use the command line to generate the wars ?
Versions: NetBeans 6.7.1, Grails 1.2
OS: Ubuntu 9.1
Thanks
The netbeans plugin is probably running the command "grails dev war" which creates a war file based on the development settings. The normal "grails war" command uses production settings.
You should just be able to change to the directory containing your grails-app and src folders and run the command
grails war
This assumes that you have grails installed and on your path.
No, only that grails war may assume it to be a development. I suggest you specifically type as follow:
grails prod war
you can modify the proyect file gradle.properties and add
org.gradle.jvmargs=-Dgrails.env=dev //for development
org.gradle.jvmargs=-Dgrails.env=prod //for production enviroment
Check https://docs.grails.org/latest/guide/gettingStarted.html

Resources