How to download files from ftp server using maven?

1.6k views Asked by At

I want to create a pom.xml that will fetch some .dmp files from a remote FTP server ,

to access this server I have it's URL username and password (who ofcourse only have READ permissions).

What is the best way to get those files from the server?

with maven-ant plugin/maven executer/ or any other plugin that I don't know of?

1

There are 1 answers

3
Sarfaraz Khan On BEST ANSWER

try this

 <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <configuration>
            <target>
                <ftp action="get"
                     server="192.168.1.1"
                     remotedir="remoteDir"
                     userid="anonymous"
                     password="anonymous">
                    <fileset dir="${project.build.directory}">
                        <include name="**/*.*"/>
                    </fileset>
                </ftp>
            </target>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>commons-net</groupId>
                <artifactId>commons-net</artifactId>
                <version>1.4.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.ant</groupId>
                <artifactId>ant-commons-net</artifactId>
                <version>1.8.1</version>
            </dependency>
        </dependencies>
    </plugin>

Also you can have a look here