Montag, 12. November 2012

maven: dependency-attach-plugin

Never ever had the need to get a dependency and just redeploy without doing anything to it?  E.g. Download the dependency in version 0.0.5-SNAPSHOT and redeploy as 1.1-RC-5? Maybe this seems strange but we did it exactly this way to create a release based on current SNAPSHOTs from our artifact repository.

See [1] to get an impression. Executing mvn clean deploy would download the list of artifact items and deploy it as

my.releases:distribution:module-a:1.8-RC-5:jar


Of course, you’re right saying that all this makes no sense. Get a hint about how you can pimp your pom to make the version “flexible” at this blog.

[1] example pom

<project>
  <groupId>my.releases</groupId>
  <artifactId>distribution</artifactId>
  <version>1.8-RC-5</version>
  <packaging>pom</packaging>
  <build>
    <plugins>
      <plugin>
        <groupId>ch.rotscher.maven.plugins</groupId>
        <artifactId>dependency-attach-plugin</artifactId>
        <version>0.1.1</version>
        <executions>
          <execution>
            <goals>
              <goal>copy</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <useOriginalArtifactIdInClassifier>true</useOriginalArtifactIdInClassifier>
              <artifactItems>
                <artifactItem>
                  <groupId>my.modules</groupId>
                  <artifactId>module-a</artifactId>
                  <version>2.0.1-SNAPSHOT</version>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

[2] Download

From maven central (http://search.maven.org)
<dependency>
  <groupId>ch.rotscher.maven.plugins</groupId>
  <artifactId>dependency-attach-plugin</artifactId>
  <version>0.1.1</version>
</dependency>

Keine Kommentare:

Kommentar veröffentlichen