Specify uncompiled dependencies in Maven and pack them as resources

I need to create a jar file that includes (other, external projects) Maven artifacts.

Artifacts should be included as things in src/main/resourceswithout any processing. Despite the fact that they themselves are jar files, they do not compile time dependencies for my code and should not be added to the class path, either at the compilation, test, or execution stages.

I can do this by uploading the files and placing them in src/main/resources, but I would prefer them to be resolved using the Maven repository.

+5
source share
3 answers

, pom - ID .

<plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>id.of.the.project.group.to.include</groupId>
                  <artifactId>id-of-the-project's-artifact-to-include</artifactId>
                  <version>${pom.version}</version>
                </artifactItem>
              </artifactItems>
              <includeArtifactIds>id-of-the-project's-artifact-to-include</includeArtifactIds>
              <outputDirectory>${project.build.directory}/etc-whatever-you-want-to-store-the-dependencies</outputDirectory>
            </configuration>
          </execution>
    </executions>
</plugin>
+2

target/classes -.

+2

, , , , .

<dependencySet> <unpack>, , .

+1

All Articles