Sunday May 19

Key Concepts

Deploying in file system using Maven

PDFPrintE-mail
Thursday, 21 June 2012 08:56
AddThis Social Bookmark Button

Maven deploying file using deploy plugin

Deploying an artifact in the file system using Maven

The first step require to add wagon file as an extension to the build in your pom.

The wagon file extension allows you to :

  • Deploy files and directories to local file system
  • Get files from file system

Insert the following snippet in your pom.xml :

    <build>
       ...
       <extensions>
              <!-- Enabling the use of Wagon file -->
              <extension>
                <groupId>org.apache.maven.wagon</groupId>
                 <artifactId>wagon-file</artifactId>
                 <version>1.0-beta-6</version>
              </extension>
        </extensions>        
    </build>

You can deploy using the deploy plugin to get you artifact deploy using the maven repository layout or simply deploying one file you have choosen.

Deploy using the repository layout

To deploy your file using the maven layout you should define the distribution management location  :

<project>
    ...
    <distributionManagement>
        <repository>
              <id>myrepository</id>
              <url>file:D:/repository/</url>
        </repository>
      </distributionManagement>
</project>       

Then you just need to execute the following command to get you artifact copied in your file system location

Maven command to deploy a file in the local file system

mvn deploy

   

Deploy in a specific directory

Codehaus provide a plugin called Wagon to view or transfer resources between repositories. The upload goal allows you to upload a set of files to a remote location. In our sample the remote location is located in the file system.

<plugins>        
    ...
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>wagon-maven-plugin</artifactId>
        <version>1.0-beta-3</version>
        <executions>
          <execution>
            <id>upload-jar-to-folder</id>
            <phase>deploy</phase>
            <goals>
              <goal>upload</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <fromDir>${project.build.directory}</fromDir>
          <includes>*</includes>
           <url>file:///d:/</url>
          <toDir>repository</toDir>
        </configuration>
    </plugin>             
</plugins>

Then you can run

command execute wagon upload plugin

mvn wagon:upload

Tags: maven, /groupid, artifactid, /artifactid, system, file, deploying, wagon-file, 1.0-beta-6, /extensions, /build, /extension, org.apache.maven.wagon

Add comment


Security code
Refresh

Java Tutorial on Facebook