Question

How do I set the http port from the command line for a grails (2.1.0) project running under maven? Grails is being forked.

I've tried:

mvn grails:run-app -Dserver.port=8081 -Dgrails.server.port.http=8081

but no luck. It still runs on port 8080.

I am not specifying the port property anywhere else.

pom snippet:

<plugin>
    <groupId>org.grails</groupId>
    <artifactId>grails-maven-plugin</artifactId>
    <version>2.1.0</version>
    <configuration>
        <fork>true</fork>
    </configuration>
    <extensions>true</extensions>
</plugin>
Was it helpful?

Solution

Like Niels said, if you're forking the Grails process (true by default), you can add forkedVmArgs to the pom:

<plugin>
  <groupId>org.grails</groupId>
  <artifactId>grails-maven-plugin</artifactId>
  <version>${grails.version}</version>
  <configuration>
    <!-- Whether for Fork a JVM to run Grails commands -->
    <fork>true</fork>
    <forkedVmArgs>
      <forkedVmArg>-Dserver.port=9003</forkedVmArg>
    </forkedVmArgs>
  </configuration>
  <extensions>true</extensions>
</plugin>

See http://jira.grails.org/browse/MAVEN-177

OTHER TIPS

Since you use the fork option it spawns a new shell with the execution, which probably doesnt inherit your arguments.

Try not to fork it, and see if that helps.

Alternatively, you can apparently add some fork arguments to the plugin using:

<forkedVmArgs>
  ...
</forkedVmArgs>
mvn grails:exec -Dcommand=run-app -Dserver.port=8081
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top