简体   繁体   English

Maven发布插件使用构建版本命名文件

[英]Maven release plugin name the files with the build version

When I am performing a maven release:perform the name of the files generated are with the build version meaning:artifactId.version . 当我执行Maven release:perform时,生成的文件名带有构建版本,意思是:artifactId.version。 I need that at least the name of the war generated when doing perform will be only the artifactId name. 我至少需要在执行表演时产生的战争名称仅是artifactId名称。

my pom is here:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>me.tingz</groupId>
  <artifactId>dashboard</artifactId>
  <packaging>war</packaging>
  <version>15-SNAPSHOT</version>
  <name>dashboard Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <distributionManagement>
        <repository>
            <id>google</id>
            <url>file:/home/ziv/Documents/dashboard/versions/</url>
        </repository>
    </distributionManagement>



  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
        <version>3.0.4</version>
    </dependency>
    <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>
  </dependencies>
  <build>

       <finalName>dashboard</finalName>
        <plugins>

        <!-- Release plugin Test!!!! -->
        <plugin>

            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.2</version>
            <configuration>

                <tagBase>
                    file:/home/ziv/tag
                </tagBase>
                 <checkModificationExcludes>
            <checkModificationExclude>pom.xml</checkModificationExclude>
        </checkModificationExcludes>
            </configuration>
        </plugin>

        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-plugin</artifactId>
        <version>1.9.4</version>
        <configuration>
          <username>zivziv</username>

        </configuration>
      </plugin>

        <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>

  </build>
  <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1</version>
        </dependency>
    </dependencies>
  </dependencyManagement>
  <scm>
        <connection>xxx</connection>
        <developerConnection>xxxd</developerConnection>
      <tag>dashboard-11</tag>

  </scm>
</project>

The Maven Release plugin does not "generate" any files. Maven Release插件不会“生成”任何文件。 The other plugins involved in the Maven build lifecycle, eg the jar plugin, do generate files. Maven构建生命周期中涉及的其他插件(例如jar插件)也会生成文件。 So setting the "finalName" as you did should do the trick, as far as "generation" is involved. 因此,只要涉及到“生成”,就按您的方式设置“ finalName”就可以解决问题。

What the Release plugin does is Release插件的作用是

  • tagging the code in the SCM 在SCM中标记代码
  • deploying the artifacts to a repository 将工件部署到存储库

The latter one does ALWAYS require a Maven GAV - and the V is for Version. 后者确实总是需要Maven GAV-V是用于Version的。 Otherwise, the Release would not be unique. 否则,发行版将不是唯一的。 So if you want the Release plugin to deploy an artifact to a repository without a version in its name, you will fail. 因此,如果您希望Release插件将工件部署到没有名称版本的存储库,则会失败。 This is impossible by definition. 根据定义,这是不可能的。

You should think about not using the Release plugin at all - after all, it's a crappy plugin. 您应该考虑根本不使用Release插件-毕竟,这是一个糟糕的插件。 See eg https://axelfontaine.com/blog/final-nail.html 参见例如https://axelfontaine.com/blog/final-nail.html

Consider using the wagon-maven-plugin for achieving your goal: http://www.mojohaus.org/wagon-maven-plugin/ 考虑使用wagon-maven-plugin实现您的目标: http : //www.mojohaus.org/wagon-maven-plugin/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM