views:

52

answers:

2
  • The goal: create my first Grails project, in IntelliJ, with Maven support.
  • Myself: Noob to Groovy/Grails, has some Maven experience but not too much
  • The tooling: Groovy 1.7.5, IntelliJ 9.0.3 and Maven 2.0

What I've tried so far, is:

  1. File->New Project
  2. Create Module
  3. Maven Module
  4. Add & choose the Grails Archtype
  5. Right click on the project --> Run --> grails

I'm getting errors:

  • PHP home is not specified - WTF, does Grails require PHP?
  • When I previously tried to use IntelliJ to create a Grails project without Maven, I actually managed to run the application - so I don't understand what is missing now.

P.S. I reported this as an issue, vote it up if you want.

If anyone is interested, here is a github project with all the bootstrap done.

+2  A: 

Let's leave IntelliJ aside for now and try to get started on the command line.

The following steps work for me (basically repeating the official instructions but using version 1.3.4):

First create an application:

mvn archetype:generate -DarchetypeGroupId=org.grails \
    -DarchetypeArtifactId=grails-maven-archetype \
    -DarchetypeVersion=1.3.4 \
    -DgroupId=example -DartifactId=my-app

And update my-app/pom.xml to use Java 6:

  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
  </plugin>

Then cd into my-app and create the project structure (run maven from inside the project folder):

cd my-app
mvn initialize

Edit the application.properties file to add:

plugins.hibernate=1.3.4
plugins.tomcat=1.3.4

And run the following to install the plugins:

mvn compile

When done, you should be able to start your app

mvn grails:run-app

And to access it at http://localhost:8080/my-app/.

Once you get the above working, importing the project inside IntelliJ should be a trivial step. And if you still get a problem, it will be probably an IntelliJ related issue.

Pascal Thivent
I'm following these steps, and get stuck in the 'application.properties' - there is no such file anywhere.
ripper234
Well, the problem was that I ran 'mvn initialize' on the parent dir, instead of on the project dir. Works like a charm now, thanks a lot.
ripper234
@ripper234 You're welcome.
Pascal Thivent