【问题标题】:GMaven project from mvn archetype:generate doesn't `mvn compile`来自 mvn archetype:generate 的 GMaven 项目不会“mvn compile”
【发布时间】:2012-04-30 22:08:50
【问题描述】:

我生成了一个空项目:

mvn archetype:generate -DarchetypeGroupId=org.codehaus.gmaven.archetypes -DarchetypeArtifactId=gmaven-archetype-basic -DarchetypeVersion=1.4

它无法通过mvn compile 发送一堆消息"package groovy.lang does not exist"

(对于archetypeVersion我刚刚选择了最后一个GMaven发布版本)

我的 Maven/GMaven/Groovy 出了什么问题?

<?xml version="1.0" encoding="UTF-8"?>
<!--
    Generated from archetype; please customize.
-->

<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>a</groupId>
    <artifactId>asd</artifactId>
    <name>asd project</name>
    <version>1.0-SNAPSHOT</version>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.4</version>
                <configuration>
                    <providerSelection>1.8</providerSelection>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generateStubs</goal>
                            <goal>compile</goal>
                            <goal>generateTestStubs</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

【问题讨论】:

    标签: maven groovy gmaven-plugin


    【解决方案1】:

    我为Groovy in Maven 做了一个完整的例子。看看吧。

    【讨论】:

    • 感谢您提供样品。我的错,那时我已经有了一个工作配置。我会将其作为替代答案发布。
    【解决方案2】:

    让它以我自己的方式工作 - 这是版本的问题。 @khmarbaise 的版本有一些不错的想法,比如版本灵活性。

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <groovy.version>2.0.0-beta-2</groovy.version>
    </properties>
    
    <dependencies>
    
        <!-- ... something ... -->
    
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
            <version>${groovy.version}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.gmaven.runtime</groupId>
            <artifactId>gmaven-runtime-1.7</artifactId>
            <version>1.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    
    <!-- ... something ... -->
    
    <build>
        <!-- make Java compile from groovy folders as well... -->
        <sourceDirectory>src/main/groovy</sourceDirectory>
        <testSourceDirectory>src/test/groovy</testSourceDirectory>
    
    <plugins>
        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.3</version>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy</artifactId>
                    <version>${groovy.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.gmaven.runtime</groupId>
                    <artifactId>gmaven-runtime-1.7</artifactId>
                    <version>1.3</version>
                    <exclusions>
                        <exclusion>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <configuration>
                        <providerSelection>1.7</providerSelection>
                    </configuration>
                    <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-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
    </plugins>
    

    【讨论】:

    • 显然它不适用于 Groovy 2 中的某个人,因为我投了反对票。
    猜你喜欢
    • 1970-01-01
    • 2011-07-09
    • 2015-11-16
    • 1970-01-01
    • 2015-01-22
    • 1970-01-01
    • 2021-07-23
    • 1970-01-01
    • 2012-04-28
    相关资源
    最近更新 更多