Vinod Jayachandran
Vinod Jayachandran

Reputation: 3898

Package Grails App to war using maven

I have a grails app converted to maven project.

When I do mvn compile, I expect class files to be generated in target folder, but I get the below message.

--- maven-compiler-plugin:3.1:compile (default-compile) @ sampleService --- [INFO] Nothing to compile - all classes are up to date

I have the following snippet in my pom.xml. Please help

<build>
  <sourceDirectory>grails-app</sourceDirectory>

  <pluginManagement/>

  <plugins>
    <!-- Disables the Maven surefire plugin for Grails applications, as we have our own test runner -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.18.1</version>
      <configuration>
        <skip>true</skip>
      </configuration>
      <executions>
        <execution>
          <id>surefire-it</id>
          <phase>integration-test</phase>
          <goals>
            <goal>test</goal>
          </goals>
          <configuration>
            <skip>false</skip>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-clean-plugin</artifactId>
      <version>2.4</version>
      <configuration>
        <filesets>
          <fileset>
            <directory>plugins</directory>
            <includes>
              <include>**/*</include>
            </includes>
            <followSymlinks>false</followSymlinks>
          </fileset>
        </filesets>
      </configuration>
    </plugin>

    <plugin>
      <groupId>org.grails</groupId>
      <artifactId>grails-maven-plugin</artifactId>
      <version>2.4.4</version>
      <configuration>
        <grailsVersion>${grails.version}</grailsVersion>
      </configuration>
      <extensions>true</extensions>
      <executions>
        <execution>
          <goals>
            <goal>clean</goal>
            <goal>maven-war</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <configuration>
        <attachClasses>true</attachClasses>
      </configuration>
    </plugin>

  </plugins>
</build>

<repositories>
<repository>
  <id>grails</id>
  <name>grails</name>
  <url>https://repo.grails.org/grails/core</url>
</repository>
<repository>
  <id>grails-plugins</id>
  <name>grails-plugins</name>
  <url>https://repo.grails.org/grails/plugins</url>
</repository>
</repositories>

<profiles>
<profile>
  <id>tools</id>
  <activation>
    <property>
      <name>java.vendor</name>
      <value>Sun Microsystems Inc.</value>
    </property>
  </activation>
  <dependencies>
    <dependency>
      <groupId>com.sun</groupId>
      <artifactId>tools</artifactId>
      <version>${java.version}</version>
      <scope>system</scope>
      <systemPath>${java.home}/../lib/tools.jar</systemPath>
    </dependency>
  </dependencies>
</profile>
</profiles>

Upvotes: 0

Views: 886

Answers (2)

Vinod Jayachandran
Vinod Jayachandran

Reputation: 3898

Either you have Maven folder structure or if its grails-app give packing in pom.xml as below

<packaging>grails-app<packaging>

Upvotes: 1

Craig
Craig

Reputation: 2366

I've encountered this before while working with groovy and maven. The problem was detailed here

Basically, you have to add a src/main/java folder to your project in order for the plugin to suddenly find all your groovy files. Without knowing your folder structure I can't tell if this is the issue or not.

Hope that helps!

Upvotes: 0

Related Questions