Maven Release Plugin执行报错:目标需项目但目录无POM文件
解决Maven Release插件执行时的POM缺失错误
问题描述
我有一个Maven项目,日常均在包含pom.xml的项目目录下执行Maven命令。但执行发布命令:mvn release:clean release:prepare -DreleaseVersion=1.1.5 -DdevelopmentVersion=1.1.6-SNAPSHOT -Dtag=1.1.5
时,触发错误:
"你指定的目标需要项目才能执行,但此目录(C:)中没有POM文件,请验证你是否从正确的目录调用Maven"
命令执行日志
C:\Users\sahin.atam\Desktop\milgem_epkis\src\products\common>mvn release:clean release:prepare -DreleaseVersion=1.1.5 -DdevelopmentVersion=1.1.6-SNAPSHOT -Dtag=1.1.5 [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] Milgem IPMS Common Modules Project [INFO] FFDC Ospl Library [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Milgem IPMS Common Modules Project 1.1.5-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-release-plugin:2.5.3:clean (default-cli) @ milgem-common --- [INFO] Cleaning up after release... [INFO] [INFO] --- maven-release-plugin:2.5.3:prepare (default-cli) @ milgem-common --- [INFO] Verifying that there are no local modifications... [INFO] ignoring changes on: **\release.properties, **\pom.xml.next, **\pom.xml.releaseBackup, **\pom.xml.backup, **\pom.xml.branch, **\pom.xml.tag [INFO] Executing: cmd.exe /X /C "svn --username satam --password ***** --no-auth-cache --non-interactive status" [INFO] Working directory: C:\Users\sahin.atam\Desktop\milgem_epkis\src\products\common [INFO] Checking dependencies and plugins for snapshots ... [INFO] Transforming 'Milgem IPMS Common Modules Project'... [INFO] Transforming 'FFDC Ospl Library'... [INFO] Not generating release POMs [INFO] Executing goals 'clean verify'... [WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance. [INFO] C:\ [INFO] [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] BUILD FAILURE [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] Total time: 0.063 s [INFO] [INFO] Finished at: 2023-01-23T16:34:04+02:00 [INFO] [INFO] Final Memory: 6M/242M [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\). Please verify you invoked Maven from the correct directory. -> [Help 1] [INFO] [ERROR] [INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging. [INFO] [ERROR] [INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles: [INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] Milgem IPMS Common Modules Project ................. FAILURE [ 2.910 s] [INFO] FFDC Ospl Library .................................. SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.101 s [INFO] Finished at: 2023-01-23T16:34:04+02:00 [INFO] Final Memory: 12M/242M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) @ milgem-common: Maven execution failed, exit code: '1' -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
项目pom.xml配置
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.yaltes.ipms</groupId> <artifactId>milgem-config</artifactId> <version>1.0.2</version> </parent> <groupId>com.yaltes.ipms</groupId> <artifactId>milgem-common</artifactId> <version>1.1.5</version> <packaging>pom</packaging> <name>Milgem IPMS Common Modules Project</name> <properties> <ipms.tagBase>milgem-common</ipms.tagBase> <ospl.version>6.10.0p2</ospl.version> <ospl_home>C:\IPMS\open-splice\Vortex_v2\Device\VortexOpenSplice\6.10.0p2\HDE\x86_64.win64</ospl_home> </properties> <modules> <module>ffdc-ospl</module> </modules> <dependencyManagement> <dependencies> <dependency> <groupId>org.opensplice.dds</groupId> <artifactId>dcpssaj</artifactId> <version>${ospl.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> </dependencies> </dependencyManagement> <scm> <connection>scm:svn:http://svn/svn/dzkk_epkis/tags/milgem_epkis/milgem- common/1.1.5</connection> <developerConnection>scm:svn:http://svn/svn/dzkk_epkis/tags/milgem_epkis/milgem-common/1.1.5</developerConnection> </scm> </project>
解决方案
1. 修正SCM配置
当前pom.xml的SCM连接指向已存在的Tag目录,而release:prepare需要的是项目开发分支或主干的SVN路径(插件会自动创建Tag)。将SCM配置修改为开发分支地址:
<scm> <connection>scm:svn:http://svn/svn/dzkk_epkis/trunk/milgem_epkis/milgem-common</connection> <developerConnection>scm:svn:http://svn/svn/dzkk_epkis/trunk/milgem_epkis/milgem-common</developerConnection> </scm>
2. 升级Maven Release插件版本
使用的2.5.3版本较老,存在路径处理的已知问题。升级到最新稳定版(如3.0.1),在pom.xml中添加插件配置:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>3.0.1</version> </plugin> </plugins> </build>
3. 确认执行目录正确性
确保执行命令时,当前工作目录确实是包含pom.xml的C:\Users\sahin.atam\Desktop\milgem_epkis\src\products\common,避免路径切换异常。
内容的提问来源于stack exchange,提问作者şahin
相关产品推荐
相关产品推荐

