Search code examples
javamavenjdeveloper

How can I copy dependencies from the local repository to some specific location?


I want copy all the dependencies from the local repository to some specific location without have to specify which dependencies should be copied, I just want that copy all the dependencies that I declared in the pom in specific folder.

http://pastebin.com/3neyQJyp


Solution

  • The included pom produces these files:

    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>