【发布时间】:2012-11-21 21:01:24
【问题描述】:
我正在尝试将现有项目转换为 Maven 项目。它有 3 个模块,其中一个模块有多个源文件夹。 http://i.imgur.com/jZCnR.png
maven clean and install 或 eclipse clean 不会在 classes 和 test-classes 文件夹中创建类文件。项目结构是由于那里没有类文件而创建的。
下面的插件配置是在父pom中定义的。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>src/main/java/**/*.*</source>
<source>src/report/java/**/*.*</source>
<source>src/architect/java/**/*.*</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals><goal>add-test-source</goal></goals>
<configuration>
<sources>
<source>src/test/java/**/*.*</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<debug>false</debug>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals><goal>compile</goal></goals>
<configuration>
<includes>
<include>src/main/java/**/*.*</include>
<include>src/report/java/**/*.*</include>
<include>src/architect/java/**/*.*</include>
</includes>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals><goal>testCompile</goal></goals>
<configuration>
<testIncludes>
<include>src/test/java/**/*.*</include>
</testIncludes>
</configuration>
</execution>
</executions>
</plugin>
我做错了什么?
【问题讨论】:
-
为什么要添加与 src/main/java 或 src/test/java 不同的位置?这真的有必要吗?
-
因为在这个遗留项目中有多个源文件夹,并且它们之间存在双向依赖关系。如果我做了一个特定的来源,比如说前。在这种情况下,“report”src 文件夹,作为一个单独的 maven 模块,那么我不知道如何解决这个双向依赖。
-
根据您提供的信息,您需要将多个源文件夹分成单独的模块。
-
好吧,如果我这样做,并说我创建了一个单独的模块 _GAS2Report 和 _GAS2WebApp 取决于 _GAS2Report 中存在的某些功能,反之亦然。那么我应该在它们中添加一个依赖项吗?
-
如果你有这样的依赖,那就是。但是如果你有一个循环引用,那就有问题了......
标签: maven maven-2 m2eclipse maven-compiler-plugin