【问题标题】:How do I get maven release to push something other than a snapshot? [duplicate]我如何获得 Maven 版本来推送快照以外的东西? [复制]
【发布时间】:2015-09-22 07:15:35
【问题描述】:

当我执行mvn -s settings.xml --batch-mode release:prepare release:perform 时,上传的文件总是-SNAPSHOT,我想做一个“最终”版本。值得注意的是,它没有将这些标记为快照,而是将 POM 向前移动到下一个 SNAPSHOT。我需要更改哪些内容才能发布不是快照的版本?

<?xml version="1.0" encoding="UTF-8"?>
<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">

  <version>0.1.5-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <properties>
    <!-- use UTF-8 for everything -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>

  <parent>
    <groupId>io.spring.platform</groupId>
    <artifactId>platform-bom</artifactId>
    <version>1.1.2.RELEASE</version>
  </parent>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
          <tagNameFormat>v@{version}</tagNameFormat>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>3.0.1</version>
        <configuration>
          <effort>Max</effort>
          <threshold>Low</threshold>
          <xmlOutput>false</xmlOutput>
        </configuration>
        <executions>
          <execution>
            <phase>test-compile</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>2.15</version>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>6.8.1</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <phase>validate</phase>
            <configuration>
              <configLocation>checkstyle.xml</configLocation>
              <encoding>UTF-8</encoding>
              <consoleOutput>true</consoleOutput>
              <failsOnError>true</failsOnError>
            </configuration>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.4</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <configuration>
              <printFailingErrors>true</printFailingErrors>
            </configuration>
            <goals>
              <goal>check</goal>
              <goal>cpd-check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <distributionManagement>
    <repository>
      <id>releases</id>
      <url>${env.MAVEN_RELEASE_REPOSITORY_URL}</url>
    </repository>
    <snapshotRepository>
      <id>snapshots</id>
      <url>${env.MAVEN_SNAPSHOT_REPOSITORY_URL}</url>
    </snapshotRepository>
  </distributionManagement>

  <scm>
    <connection>https://bitbucket.org/xenoterracide/hibernate-hacks.git</connection>
    <developerConnection>scm:git:ssh://git@bitbucket.org/xenoterracide/hibernate-hacks.git</developerConnection>
    <url>https://bitbucket.org/xenoterracide/hibernate-hacks</url>
    <tag>HEAD</tag>
  </scm>

  <groupId>com.xenoterracide</groupId>
  <artifactId>hibernate-hacks</artifactId>
  <modelVersion>4.0.0</modelVersion>
</project>

在我的环境中

MAVEN_RELEASE_REPOSITORY_URL=http://localhost:8081/content/repositories/releases
MAVEN_RELEASE_REPOSITORY_USER=deployment
MAVEN_RELEASE_REPOSITORY_PASS=deployment
MAVEN_SNAPSHOT_REPOSITORY_URL=http://localhost:8081/content/repositories/snapshots
MAVEN_SNAPSHOT_REPOSITORY_USER=deployment
MAVEN_SNAPSHOT_REPOSITORY_PASS=deployment

并且推送到快照似乎工作正常。 Bitbucket 提供完整的源代码。

【问题讨论】:

    标签: maven


    【解决方案1】:

    这似乎是 git scm 插件中的错误的结果。 This question and answer describes other symptoms and a similar fix。所以将它与整个 scm 堆栈一起更新可以修复它。

      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
          <tagNameFormat>v@{version}</tagNameFormat>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-plugin</artifactId>
            <version>1.9.4</version>
          </dependency>
        </dependencies>
      </plugin>
    

    【讨论】:

      猜你喜欢
      • 2010-10-20
      • 2021-11-10
      • 2013-03-04
      • 1970-01-01
      • 1970-01-01
      • 2018-02-03
      • 1970-01-01
      • 2020-11-04
      • 1970-01-01
      相关资源
      最近更新 更多