`

MAVEN 多源代码目录配置

 
阅读更多

 

 

	<build>
		<!-- 默认源代码和资源文件目录配置 -->
		<sourceDirectory>src/main/java </sourceDirectory>
		<testSourceDirectory>src/test/java</testSourceDirectory>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
			</testResource>
		</testResources>

		<!-- 扩展源代码和资源文件目录 -->
		<plugins>
			<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节点,来添加任意多个源文件夹 -->
								<source>${basedir}/src/multimodule/sources</source>
							</sources>
						</configuration>
					</execution>
					<execution>
						<id>add-resource</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>add-resource</goal>
						</goals>
						<configuration>
							<resources>
								<!-- 我们可以通过在这里添加多个resource节点 -->
								<resource>
									<directory>${basedir}/src/multimodule/resources</directory>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

 

 M2E 插件兼容问题,待解决!~

 

分享到:
评论
3 楼 Mr.TianShu 2016-08-19  
maven 多源文件
http://www.mojohaus.org/build-helper-maven-plugin/usage.html

资源文件本身可以配置多个,配置完成以后右键项目,maven->update
 		
		<resources>
			<resource> <!-- 可以配置多个 -->
				<directory>src</directory>
			</resource>
		</resources>
	

-----------
java源文件需要插件  build-helper-maven-plugin
 
	<plugin>
		<groupId>org.codehaus.mojo</groupId>
		<artifactId>build-helper-maven-plugin</artifactId>
		<version>1.12</version>
		<executions>
			<execution>
				<id>add-source</id>
				<phase>generate-sources</phase>
				<goals>
					<goal>add-source</goal>
				</goals>
				<configuration>
					<sources>
						<source>${basedir}/01_helloStruts2</source>
						<!-- 我们可以通过在这里添加多个source节点,来添加任意多个源文件夹 -->
					</sources>
				</configuration>
			</execution>
		</executions>
	</plugin>
      



----------------------------------------------------------------
解决 maven 插件报错
1.eclipse的安装目录下的plugins下的org.eclipse.m2e.lifecyclemapping.defaults_xxxxxx.jar   -   lifecycle-mapping-metadata.xml

添加如下

 
        <pluginExecution>
            <pluginExecutionFilter>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
	        <versionRange>[1.3,)</versionRange>
                <goals>
                    <goal>compile</goal>
                </goals>
            </pluginExecutionFilter>
            <action>
                <ignore />
            </action>
        </pluginExecution>


2. Window-Perferences-Maven-Lifecycle Mapping  ,选择添加后的文件 lifecycle-mapping-metadata.xml



或者,添加这个标签(不建议)
 
 <pluginManagement>
        <plugins> </plugins>



2 楼 keliso 2016-04-05  
[color=violet][color=yellow]
[flash=200,200][url][img][list]
[*]
引用
[u][i][b] 8) :D :shock: :x :P :P :cry: :twisted: :evil: :!: :?: :arrow: :idea: :cry: :lol: :o [/b][/i][/u]
[/list][/img][/url][/flash]
[/color][/color]
1 楼 keliso 2016-04-05  
[flash=200,200][img][list]
[*]
[/list][/img][/flash]

相关推荐

Global site tag (gtag.js) - Google Analytics