繁体   English   中英

Groovy&maven - 从src / main / groovy编译源代码

[英]Groovy & maven - compile sourcesfrom src/main/groovy

我一直在寻找几个小时如何用maven建立.jar。 Finnaly我明白了。

但现在我必须在src / main / java中有源代码。

如何在我的项目中“包含”src / main / groovy? 在这里阅读解决方案但我真的不想改变我的pom.xml。 我有这么多麻烦。

这是我的pom.xml

<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>net.thornydev</groupId>
<artifactId>script</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>script</name>
<url>http://maven.apache.org</url>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <compilerId>groovy-eclipse-compiler</compilerId>

            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>2.7.0-01</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>pl.jedro.Main</mainClass>
                    </transformer>
                </transformers>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.0-beta-3</version>
    </dependency>
</dependencies>

我尝试过:

        <sources>
            <source>${basedir}/src/main/groovy</source>
          </sources> 

    <build>
    <resources>
        <resource>
            <directory>src/main/groovy</directory>
        </resource>
    </resources>

但仍然没有。

我有 :

错误:无法找到或加载主类pl.jedro.Main

终于有了解决方案

我补充说:

    <sourceDirectory>src/main</sourceDirectory>
    <resources>
        <resource>
            <directory>groovy</directory>
        </resource>
    </resources>

<build> </build>部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM