1

In my maven pom, I have an additional jar-file that I'd like to include with my deployables. I've got the jar-file building successfully, and I figured I'd use the maven-deploy-plugin, like so (version-wise, I'm using 2.8.2 from dependencyManagement):

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-deploy-plugin</artifactId>
      <executions>
        <execution>
          <id>deploy-special-jar</id>
          <phase>deploy</phase>
          <goals>
            <goal>deploy-file</goal>
          </goals>
          <configuration>
            <repositoryId>${project.distributionManagement.repository.id}</repositoryId>
            <url>${project.distributionManagement.repository.url}</url>
            <groupId>${project.groupId}</groupId>
            <artifactId>${project.artifactId}</artifactId>
            <version>${project.version}-special</version>
            <file>${project.build.directory}/special.jar</file>
          </configuration>
        </execution>
      </executions>
    </plugin>

This works great, but there's a slight issue. If you notice, the above pom is using project.distributionManagement.repository.url for both the repositoryId and url parameters. However, this means that regardless of if I'm building a snapshot or a release version, I'm always deploying to me release-area, which is not ideal. What if I'm building a snapshot? Well, the answer seems to be to change project.distributionManagement.repository.url to project.distributionManagement.snapshotRepository.url

I don't like the idea of changing these lines manually because I like to use the maven-release-plugin to switch between snapshot and release versions. Now, I'd have to add some scripting to change these lines each time. That's possible, but not ideal.

It seems that someone asked about this exact problem before back in 2008, and there wasn't really a good answer: http://maven.40175.n5.nabble.com/problems-with-the-maven-deploy-plugin-td107307.html So, I thought I'd add it here to see what people have come up with.

I'm considering using the build-helper plugin to dynamically change this property, but that seems like a potential rabbit-hole, especially since someone tried to do something similar before (for other reasons, but the concept is similar): Check if Maven pom is SNAPSHOT

So, what's the right answer here? Should this be a feature-request? Or, is there a simple way to work around this problem that people use? I'm curious what others have done. Has anyone had any luck with the build-helper plugin?

Thank you!

4

1 回答 1

0

这听起来更像是 maven-jar-plugin 的第二次执行(删除后),这将导致自动上传,mvn deploy无需做这些奇怪的事情......

或者可能正在使用创建补充工件(一个或多个)的 maven-assembly-plugin ...或者可能是 maven-shade-plugin。我不知道你是如何剥离东西的......

于 2015-03-10T18:23:09.670 回答