如何将依赖项从本地存储库复制到某个特定位置?

时间:2013-04-02 19:42:32

标签: java maven jdeveloper

我想将本地存储库中的所有依赖项复制到某个特定位置,而不必指定应该复制哪些依赖项,我只想要复制我在特定文件夹中的pom中声明的所有依赖项。

http://pastebin.com/3neyQJyp

1 个答案:

答案 0 :(得分:1)

包含的pom会生成以下文件:

d:\temp\copy-dependencies>dir target /s/b
d:\temp\copy-dependencies\target\librerias
d:\temp\copy-dependencies\target\librerias\aopalliance-1.0.jar
d:\temp\copy-dependencies\target\librerias\commons-logging-1.1.1.jar
d:\temp\copy-dependencies\target\librerias\servlet-api-2.5.jar
d:\temp\copy-dependencies\target\librerias\spring-aop-3.1.3.RELEASE.jar
d:\temp\copy-dependencies\target\librerias\spring-asm-3.1.3.RELEASE.jar
d:\temp\copy-dependencies\target\librerias\spring-beans-3.1.3.RELEASE.jar
d:\temp\copy-dependencies\target\librerias\spring-context-3.1.3.RELEASE.jar
d:\temp\copy-dependencies\target\librerias\spring-context-support-3.1.3.RELEASE.jar
d:\temp\copy-dependencies\target\librerias\spring-core-3.1.3.RELEASE.jar
d:\temp\copy-dependencies\target\librerias\spring-expression-3.1.3.RELEASE.jar
d:\temp\copy-dependencies\target\librerias\spring-web-3.1.3.RELEASE.jar
d:\temp\copy-dependencies\target\librerias\spring-webmvc-3.1.3.RELEASE.jar

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>temp</groupId>
    <artifactId>temp</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.1.3.RELEASE</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>                      
                            <outputDirectory>${project.build.directory}/librerias</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>