使用maven将Grails App打包为战争

时间:2015-09-03 05:05:35

标签: java maven grails

我将 grails 应用转换为maven项目。

当我mvn compile时,我希望在目标文件夹中生成类文件,但我收到以下消息。

  

--- maven-compiler-plugin:3.1:compile(default-compile)@ sampleService --- [INFO]无需编译 - 所有类都是   日期

我的 pom.xml 中有以下代码段。请帮忙

<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>

2 个答案:

答案 0 :(得分:1)

要么你有Maven文件夹结构,要么它的grails-app在pom.xml中打包如下

<packaging>grails-app<packaging>

答案 1 :(得分:0)

我在使用groovy和maven之前遇到过这种情况。问题详述here

基本上,您必须在项目中添加src/main/java文件夹,以便插件突然找到所有groovy文件。在不知道您的文件夹结构的情况下,我无法判断这是否是问题。

希望有所帮助!