Maven制作空JAR [英] Maven Producing Empty JAR

查看:160
本文介绍了Maven制作空JAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下pom文件:

<build>
    <defaultGoal>package</defaultGoal>
    <sourceDirectory>src/web</sourceDirectory>

    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <includes>
                    <include>src/web/**/*.java</include>
                </includes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <outputDirectory>lib</outputDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

我的源文件位于src / web / org / myCompany /文件夹中。当我运行pom文件时,我得到一个没有类文件生成的JAR。我指定源目录的方式有什么问题?我没有收到任何错误消息,只是一个空的JAR(带有一些META-INF文件)。

My source files are in the src/web/org/myCompany/ folder. When I run the pom file, I get a JAR generated with no class files. What is wrong with the way that I specified the source directories? I do not get any error messages, just an empty JAR (with some META-INF files).

在旁注中,为什么maven同时拥有< sourceDirectory> 标签和maven编译器插件上的< include> 标签?它们似乎是多余的(除了include标签允许多个源目录)。

On a sidenote, why does maven have both the <sourceDirectory> tag and the <include> tag on the maven compiler plugin? They seem to be redundant (except that the include tag allows multiple source directories).

推荐答案

如何使用最新版本进行尝试删除< includes> <后, maven编译器插件 2.3.2 / code> < configuration> 其他人指出的部分?

How about trying this with the latest version of maven compiler plugin, which is 2.3.2 after removing the <includes> <configuration> section as indicated by others?

无论如何,我认为< includes> 将是< sourceDirectory> 内的过滤器,因此无法拥有 src / web 再次指定。

In any case, I think <includes> would be a filter within the <sourceDirectory> and thus cannot have src/web specified again.

这篇关于Maven制作空JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆