配置Maven scm插件以使用settings.xml

时间:2018-01-10 10:06:17

标签: java maven svn maven-scm-plugin

我有一个设置了一些服务器的settings.xml文件:

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

 ...
  <servers>

    <server>
      <id>server1</id>
      <username>user1</username>
      <!-- encrypted like https://maven.apache.org/guides/mini/guide-encryption.html  -->
      <password>{xxxxx}</password>
    </server>

    <server>
      <id>server2</id>
      <username>user2</username>
      <!-- encrypted like https://maven.apache.org/guides/mini/guide-encryption.html  -->
      <password>{xxxxx}</password>
    </server>

    <server>
      <id>svn</id>
      <username>userSVN</username>
      <!-- encrypted like https://maven.apache.org/guides/mini/guide-encryption.html  -->
      <password>{xxxxx}</password>
    </server>

  </servers>
...

我读到here无法将特定服务器设置为scm插件,并且必须向pom.xml添加属性

  <project>
   ...
    <properties>
      <project.scm.id>my-scm-server<project.scm.id>
    </properties>
  </project>

这是我的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>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.0.M7</version>
  </parent>

  <groupId>org.test</groupId>
  <artifactId>test</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <svnRoot>xxx</svnRoot>
    <projectSvnPath>xxx</projectSvnPath>
    <svnRootUrl>https://xxx</svnRootUrl>
    <scmRoot>scm:svn:${svnRootUrl}</scmRoot>
    <project.scm.id>svn</project.scm.id>
  </properties>

  <scm>
    <connection>${scmRoot}${svnRoot}/trunk/${projectSvnPath}</connection>
    <developerConnection>${scmRoot}${svnRoot}/trunk/${projectSvnPath}</developerConnection>
  </scm>

  <build>
      <plugins>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.1</version>
          <dependencies>
            <dependency>
              <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
              <artifactId>maven-scm-provider-svnjava</artifactId>
              <version>1.10.1</version>
            </dependency>
            <dependency>
              <groupId>org.tmatesoft.svnkit</groupId>
              <artifactId>svnkit</artifactId>
              <version>1.8.7</version>
            </dependency>
          </dependencies>
          <configuration>
            <tagBase>${svnRootUrl}${svnRoot}/tags/${projectSvnPath}</tagBase>
            <branchBase>${svnRootUrl}${svnRoot}/branches/${projectSvnPath}</branchBase>
            <scmCommentPrefix>[maven-release-plugin]</scmCommentPrefix>
            <svn>javasvn</svn>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-scm-plugin</artifactId>
          <version>1.9</version>
          <dependencies>
            <dependency>
              <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
              <artifactId>maven-scm-provider-svnjava</artifactId>
              <version>1.10.1</version>
            </dependency>
            <dependency>
              <groupId>org.tmatesoft.svnkit</groupId>
              <artifactId>svnkit</artifactId>
              <version>1.8.7</version>
            </dependency>
          </dependencies>
          <configuration>
            <connectionType>connection</connectionType>
            <providerImplementations>
              <svn>javasvn</svn>
            </providerImplementations>
            <message>Maven commit</message>
          </configuration>
        </plugin>
      </plugins>
    </build>


  <profiles>
    <profile>
      <id>commit-pom</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-scm-plugin</artifactId>
            <executions>
              <execution>
                <phase>validate</phase>
                <goals>
                  <goal>checkin</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <includes>pom.xml</includes>
              <message>commit with profile commit-pom</message>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
</project>

我尝试运行mvn版本:update-parent,我的构建失败并带有

  

svn:E170001:“https://xxx:443 Subversion存储库'xxx''

所需的身份验证

这是Maven命令:

/bin/apache-maven-3.2.5/bin/mvn clean versions:update-parent -DallowSnapshots=true validate -Pcommit-pom -B -U --settings ../settings-maven/null_settings.xml --global-settings ../settings-maven/full-settings.xml

我尝试使用非加密密码,但它也不起作用......

感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

答案就是page

  

在settings.xml中通过服务器条目,使用连接URL中的主机名作为服务器ID

如果我的SVN服务器网址是&#34; https://myserver.com&#34; settings.xml中服务器的id必须是&#34; myserver.com&#34;