Maven Producing Empty JAR

南楼画角 提交于 2019-12-12 18:25:16

问题


I have the following pom file:

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

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

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


回答1:


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?

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




回答2:


If memory serves you don't need the includes. The sourceDirectory specification should be enough. Then run

 mvn clean package


来源:https://stackoverflow.com/questions/4741220/maven-producing-empty-jar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!