没有项目来源。存档未创建

时间:2014-10-10 07:18:25

标签: java maven maven-source-plugin

我使用maven-source-plugin生成java-source。然而,做" mvn clean; mvn包"不会在目标目录中生成project-sources.jar。

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

信息:

[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ weibo4j ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ weibo4j ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ weibo4j ---
[INFO] Building jar: F:\step-by-step\weibo4j\target\weibo4j-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-source-plugin:2.3:jar-no-fork (attach-sources) @ weibo4j ---
[INFO] No sources in project. Archive not created.

1 个答案:

答案 0 :(得分:0)

如果您将源代码放在maven不考虑源目录的目录中(例如webapp),那么您的文件将不会放在project-sources.jar中。

解决方案:向maven发信号通知源目录是什么。添加:

<build>
    <sourceDirectory>${basedir}/src/main/webapp</sourceDirectory>
</build>