如何获取maven版本以推送除快照之外的其他内容?

时间:2015-07-04 18:23:26

标签: maven

当我执行mvn -s settings.xml --batch-mode release:prepare release:perform时,上传的文件始终是-SNAPSHOT,我想做一个" final"发布。值得注意的是,它没有将这些标记为快照,而是将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上提供了完整的源代码。

1 个答案:

答案 0 :(得分:0)

这似乎是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>