什么是正确的maven groovy gmaven pom配置?

时间:2012-02-03 04:42:21

标签: java maven groovy gmaven-plugin

您好我正在尝试在Java maven项目中使用groovy和Java,我想我提供了运行它所需的每个工件和插件,这是我的pom: pom content     这是尝试构建后捕获的异常     我将它链接到pastebin,因为我启用-X选项以获得完整的堆栈跟踪trace

1 个答案:

答案 0 :(得分:2)

最后,我找到了一种方法,可以使用gmaven 1.4,groovy 2.0和java 7,受到这个项目的启发"primefaces-groovy-cassandra"

这是一个战争类型应用程序的简单pom:

`<?xml version="1.0" encoding="UTF-8"?>`

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>office</groupId>
<artifactId>gmOffice</artifactId>
<name>gmOffice</name>
<version>0.0.1</version>
<packaging>war</packaging>

<properties>
    <!-- Configuration -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.7</java.version>

    <!-- Dependencies -->
    <javax.servlet.api.version>3.0.1</javax.servlet.api.version>
    <primefaces.version>3.2</primefaces.version>
    <myfaces.version>2.1.7</myfaces.version>


    <!-- Maven plugins -->
    <maven.compiler.version>2.4</maven.compiler.version>
    <maven.enforcer.version>1.0.1</maven.enforcer.version>
    <maven.war.version>2.2</maven.war.version>
    <maven.gmaven.version>1.4</maven.gmaven.version>
    <netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
    <slf4j.version>1.6.1</slf4j.version>
</properties>

<repositories>
    <repository>
        <id>sonatype-releases</id>
        <name>Sonatype Releases Repository</name>
        <url>http://oss.sonatype.org/content/repositories/releases/</url>
    </repository>
    <repository>
        <id>primefaces-releases</id>
        <name>PrimeFaces Releases Repository</name>
        <url>http://repository.primefaces.org</url>
    </repository>
</repositories>

<prerequisites>
    <maven>3.0.0</maven>
</prerequisites>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>${primefaces.version}</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.0.0</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.19</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.3.164</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.2.0.Final</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.1.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.1</version>
    </dependency>




    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.7</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.1.7</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>${slf4j.version}</version>
        <scope>test</scope>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.version}</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>${maven.enforcer.version}</version>
            <executions>
                <execution>
                    <id>enforce-versions</id>
                    <goals>
                        <goal>enforce</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <requireMavenVersion>
                                <version>[3.0.0,)</version>
                            </requireMavenVersion>
                            <requireJavaVersion>
                                <version>[1.6.0,)</version>
                            </requireJavaVersion>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>${maven.gmaven.version}</version>
            <configuration>
                <source>src/main/groovy</source>
                <providerSelection>2.0</providerSelection>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <version>2.0.0</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <goals>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>generateTestStubs</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.9.1</version>
            <configuration>
                <configLocation>config/sun_checks.xml</configLocation>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>${maven.war.version}</version>
            <configuration>
                <archive>
                    <manifest>
                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                    </manifest>
                    <manifestEntries>
                        <Implementation-Version>${project.version}</Implementation-Version>
                        <Implementation-Timestamp>${maven.build.timestamp}</Implementation-Timestamp>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>