`
Josh_Persistence
  • 浏览: 1650055 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类

maven-dependency-plugin is not supported by m2e

阅读更多

在maven的pom配置文件中,有时在eclipse中会出现

maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e. 的编译错误。

例如在如下的一段配置文件中(用于复制文件的plugin),在execution中就会出现该错误:

<plugin>
  			<groupId>org.apache.maven.plugins</groupId>
  			<artifactId>maven-dependency-plugin</artifactId>
  			<executions>
  				<execution>
  					<id>copy-dependencies</id>
  					<phase>package</phase>
  					<goals>
  						<goal>copy-dependencies</goal>
  					</goals>
  					<configuration>
  						<outputDirectory>${project.build.directory}/package</outputDirectory>
  						<overWriteReleases>false</overWriteReleases>
  						<overWriteSnapshots>false</overWriteSnapshots>
  						<overWriteIfNewer>true</overWriteIfNewer>
  					</configuration>
  				</execution>
  			</executions>
  		</plugin>

 

解决方法:

在已有的<plugins> ... </plugins>前面加上另一个plugins的配置:

 

<pluginManagement>
	<plugins>
		<!-- Ignore/Execute plugin execution -->
		<plugin>
			<groupId>org.eclipse.m2e</groupId>
			<artifactId>lifecycle-mapping</artifactId>
			<version>1.0.0</version>
			<configuration>
				<lifecycleMappingMetadata>
					<pluginExecutions>
						<pluginExecution>
							<pluginExecutionFilter>
								<groupId>org.apache.maven.plugins</groupId>
								<artifactId>maven-dependency-plugin</artifactId>
								<versionRange>[1.0.0,)</versionRange>
								<goals>
									<goal>copy-dependencies</goal>
									<goal>unpack</goal>
								</goals>
							</pluginExecutionFilter>
							<action>
								<ignore />
							</action>
						</pluginExecution>
					</pluginExecutions>
				</lifecycleMappingMetadata>
			</configuration>
		</plugin>
	</plugins>
</pluginManagement>

 

编译后即可发现error被清除了。

 

附:用maven复制资源:

<plugin>
           <artifactId>maven-antrun-plugin</artifactId>
           <executions>
             <execution>
               <phase>test</phase>
               <goals>
                 <goal>run</goal>
               </goals>
               <configuration>
                 <tasks>
                   <delete file="${project.build.outputDirectory}/cms_core_config.properties"/>
                   <copy file="src/main/resources/${config.lookup.name}"
                         tofile="${project.build.outputDirectory}/cms_core_config.properties"/>
                   <delete dir="${project.build.outputDirectory}/source"/>
                   <copy todir="${project.build.outputDirectory}/source">
                   	<fileset dir= "src/main/resources/${source.lookup.name}"/>
                   </copy>
                   <!-- Hack to prevent PROD configs getting load to QA  -->
                   <delete dir="${project.build.outputDirectory}/prod/source"/>
                   <delete file="${project.build.outputDirectory}/cms_core_messaging_config.properties"/>
                   <copy file="src/main/resources/${messageconfig.lookup.name}"
                         tofile="${project.build.outputDirectory}/cms_core_messaging_config.properties"/>
                   <!-- <delete file="${project.build.outputDirectory}/cms_platform_log4j.xml"/>
                   <copy file="src/main/resources/${log4jconfig.lookup.name}"
                         tofile="${project.build.outputDirectory}/cms_platform_log4j.xml"/> -->
                   <!-- <delete file="${project.build.outputDirectory}/configDebug.txt"/>
                   <copy file="src/main/resources/${calconfig.lookup.name}"
                         tofile="${project.build.outputDirectory}/configDebug.txt"/>
                   <delete file="${project.build.outputDirectory}/jodb-service.xml"/>
                   <copy file="src/main/resources/${jodbconfig.lookup.name}"
                         tofile="${project.build.outputDirectory}/jodb-service.xml"/> -->
                   <delete file="${project.build.outputDirectory}/cms_core_cmsws_config.properties"/>
                   <copy file="src/main/resources/${cmswsconfig.lookup.name}"
                         tofile="${project.build.outputDirectory}/cms_core_cmsws_config.properties"/>
                 </tasks>
               </configuration>
             </execution>
           </executions>
         </plugin>

 

 

 

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics