简体   繁体   English

maven-deploy-plugin忽略版本号?

[英]maven-deploy-plugin Ignores Version Number?

I am new to Maven, and I am try to deploy my project as a war, and as a jar. 我是Maven的新手,我试图将我的项目部署为战争和罐子。 I would love to split the project to do the same, but it is too large for simple me to do in a reasonable time. 我希望将项目拆分为相同的项目,但对于简单的我来说,在合理的时间内完成该项目太大。

I found maven deploy additional jar file , which suggested I add some plugins. 我发现maven部署了其他jar文件 ,建议我添加一些插件。

The install plugin works great 安装插件效果很好

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <executions>
        <execution>
            <phase>install</phase>
            <goals>
                <goal>install-file</goal>
            </goals>
            <configuration>
                <packaging>jar</packaging>
                <artifactId>${project.artifactId}</artifactId>
                <groupId>${project.groupId}</groupId>
                <version>SNAPSHOT</version>
                <file>
                    ${project.build.directory}/${project.artifactId}-SNAPSHOT.jar
                </file>
            </configuration>
        </execution>
    </executions>
</plugin>

Here is the output: 这是输出:

[INFO] [install:install-file {execution: default}]
[INFO] Installing C:\Server\example\code\server\my-project\target\my-project-SNAPSHOT.jar to C:\Users\Kyle\.m2\repository\com\example\main-project\my-project\SNAPSHOT\my-project-SNAPSHOT.jar

The problem is with the maven-deploy-plugin. 问题出在maven-deploy-plugin。 It seems to ignore the SNAPSHOT version I am forcing it to use: 似乎忽略了我强制使用的SNAPSHOT版本:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-deploy-plugin</artifactId>
    <executions>
        <execution>
            <phase>deploy</phase>
            <goals>
                <goal>deploy-file</goal>
            </goals>
            <configuration>
                <packaging>jar</packaging>
                <generatePom>true</generatePom>
                <url>${project.distributionManagement.snapshotRepository.url}</url>
                <artifactId>${project.artifactId}</artifactId>
                <groupId>${project.groupId}</groupId>
                <version>SNAPSHOT</version>
                <!--${project.version}!="SNAPSHOT" for some reason-->
                <file>${project.build.directory}/${project.artifactId}-SNAPSHOT.jar</file>
            </configuration>
        </execution>
    </executions>
</plugin>

Seems to use some other version number (YYYYMMDD.HHmmSS-#) 似乎使用其他版本号(YYYYMMDD.HHmmSS-#)

[INFO] [deploy:deploy-file {execution: default}]
[INFO] Retrieving previous build number from remote-repository
Uploading: http://build.example.biz:8081/artifactory/libs-snapshots-local/com/example/main-project/my-project/SNAPSHOT/my-project-20120625.161551-2.jar
42993K uploaded  (my-project-20120625.161551-2.jar)

What am I doing wrong? 我究竟做错了什么?

One thing i observed is that you are using the version SNAPSHOT without any kind of preceding numbers like: 我观察到的一件事是您使用的是SNAPSHOT版本,而没有任何前面的数字,例如:

1.0.0-SNAPSHOT

or at least: 或至少:

1-SNAPSHOT

You are just using SNAPSHOT this does not make sense, cause of which development line you are talking in this case. 您只是在使用SNAPSHOT,这是没有意义的,因为在这种情况下,您要讨论的是哪条开发线。

The other thing is that a SNAPSHOT (assuming you are using it in the right way) in Maven is an artifact where a timestamp will be put instead of the SNAPSHOT. 另一件事是,Maven中的SNAPSHOT(假设您以正确的方式使用它)是一个放置时间戳而不是SNAPSHOT的工件。 That's the way to make it possible having multiple SNAPSHOT being released but make them distinguishable. 这样可以释放多个SNAPSHOT,但使它们与众不同。

So the thing you've showed in your output is exactly what Maven makes out of the SNAPSHOT: 因此,您在输出中显示的内容正是Maven从SNAPSHOT中所做的事情:

[INFO] [deploy:deploy-file {execution: default}]
[INFO] Retrieving previous build number from remote-repository
Uploading: http://build.example.biz:8081/artifactory/libs-snapshots-local/com/example/main-project/my-project/SNAPSHOT/my-project-20120625.161551-2.jar
42993K uploaded  (my-project-20120625.161551-2.jar)

In the respective remote repository there is a http://build.example.biz:8081/artifactory/libs-snapshots-local/com/example/main-project/my-project/SNAPSHOT/maven-metadata.xml . 在相应的远程存储库中,有一个http://build.example.biz:8081/artifactory/libs-snapshots-local/com/example/main-project/my-project/SNAPSHOT/maven-metadata.xml If you have a look at it, you will see that the latest timestamp is mapped to your respective SNAPSHOT . 如果您查看一下,将会看到最新的时间戳已映射到您各自的SNAPSHOT This is typical behavior under both Maven 2 and 3. I believe it's the default behavior under Maven 3 to use timestamped SNAPSHOT -s. 这是Maven 2和3的典型行为。我相信这是Maven 3下使用带时间戳的SNAPSHOT -s的默认行为。

When you try downloading the artifact via Maven, I believe it will resolve it correctly for you, so you shouldn't really be alarmed. 当您尝试通过Maven下载工件时,我相信它会为您正确解决它,因此您不必担心。

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

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