0

Have a project with several module projects and itself having other module projects. I have certain modules generating a special artifact type '.kar', and I am deploying this to artifactory during maven deploy phase.

Now I want to find a way by using this existing pom to download these specific artifacts from artifactory by version.

mvn dependency:copy <> allows me to download this per specific artifact.

I want this to be done via the pom file which generates these artifacts. Problem is when I use the dependency:copy, it only runs on the current pom which may or may not have the special artifact.

If I use it in then it re-deploys all the artifacts and downloads the special artifact correctly. This is not right solution though.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
user2074161
  • 63
  • 1
  • 6

1 Answers1

0

You could add a new module to your project that has <dependencies> to all of your .kar artifacts. In the POM file of this new module you can use the copy-dependencies goal of the maven-dependency-plugin.

<project>

  <!-- Integrate this module into your multi-module project. -->
  <parent>
    <groupId>my.group.id</groupId>
    <artifactId>my-parent-pom</artifactId>
    <version>1.0.0-SNAPSHOT</version<
  </parent>

  ...

  <!-- Add dependencies for all your .kar artifacts. -->
  <dependencies>
    <dependency>
      <groupId>my.group.id</groupId>
      <artifactId>kar-artifact-1</artifactId>
      <version>${project.version}</version>
      <type>kar</type>
    </dependency>
    <dependency>
      <groupId>my.group.id</groupId>
      <artifactId>kar-artifact-2</artifactId>
      <version>${project.version}</version>
      <type>kar</type>
    </dependency>
    ...
  </dependencies>

  <build>
    <plugins>
      <!-- Use the maven-dependency-plugin to copy your .kar artifacts. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.8</version>
        <executions>
          <execution>
            <id>copy-kar-artifacts</id>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <includeTypes>kar</includeTypes>
            </configuration>
          </execution>
        </executions>
      <plugin>
    </plugins>
  </build>

</project>
Stefan Ferstl
  • 5,135
  • 3
  • 33
  • 41