Maven发布:准备:由于您进行了本地修改,因此无法准备发布

Ahm*_*OUR 9 continuum maven maven-release-plugin

我正面临连续体发布的问题:准备阶段在scm-check-modification步骤中失败并出现错误:

[错误] org.apache.maven.shared.release.ReleaseFailureException:无法准备发布,因为您有本地修改:[pom.xml:modified]

我做了什么 :

  1. 我将所有更改(*.java和pom.xml)提交到SVN
  2. 我在Continuum中构建了这个项目
  3. 我发布了该版本的准备工作.

我知道scm-check-modification调用ScmCheckModificationsPhase类来验证与SCM上的内容相比没有本地更改.

我理解,如果我只使用Maven,如果有一些本地更改,或者本地代码和SVN之间的任何差异,例如,release:prepare将不起作用,因为它首先检查修改; 但是使用Continuum,我不知道为什么它应该是本地代码和SVN存储库之间的差异?所以我不知道为什么发布:Continuum的准备目标正面临着这个问题.

我的pom示例:

    <build>
      <plugins>
    ...
       <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <configuration>
                <useReleaseProfile>false</useReleaseProfile>
          </configuration>
       </plugin>

    ...     
      </plugins>

    </build>


<scm>
  <connection>scm:cvs:ext:url:/var/cvs:application_name</connection>         <developerConnection>scm:cvs:ext:url:/var/cvs:application_name</developerConnection>
</scm>

.....
</project>
Run Code Online (Sandbox Code Playgroud)

在父pom.xml中:

...
    <pluginManagement>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.2.2</version>
          <configuration>
            <useReleaseProfile>false</useReleaseProfile>
            <goals>deploy</goals>
            <arguments>-Prelease</arguments>
          </configuration>
        </plugin>
.....
Run Code Online (Sandbox Code Playgroud)

有关信息,项目的构建和发布始终正常,直到现在.

有一个绕道解决方案解决了我的问题,但我仍然想了解这个问题的根源.

旁路解决方案:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.2.2</version>
  <configuration>
    ...
    <checkModificationExcludes>
      <checkModificationExclude>pom.xml</checkModificationExclude>
    </checkModificationExcludes>
  </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

4F2*_*A2E 14

我可以确认,添加插件或配置它以排除pom.xml检查确实有效:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-release-plugin</artifactId>
  <configuration>
    <checkModificationExcludes>
        <checkModificationExclude>pom.xml</checkModificationExclude>
    </checkModificationExcludes>
  </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)


Adi*_*ain 7

target从源代码管理中删除我的项目文件夹为我解决了这个问题.

  • 附带说明一下,maven 的“target”文件夹永远不应该保存在 SCM 中,因为它是 maven 生成中间和最终构建工件的地方。 (5认同)

Lon*_*zak 6

对于每个不想更改pom.xml命令行选项的人来说,可以这样做:

mvn [...] -DcheckModificationExcludeList=pom.xml,.maven/spy.log

我在我们的 hudson / jenkins CI 环境中遇到了问题,它抱怨.maven/spy.log


小智 5

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
    <checkModificationExcludes>
        <checkModificationExclude>pom.xml</checkModificationExclude>
        <checkModificationExclude>**</checkModificationExclude>
    </checkModificationExcludes>
</configuration>
Run Code Online (Sandbox Code Playgroud)