views:

139

answers:

2

First of all I should state that I understand that typically with Maven this is not how you should do things...

What I am looking for is how you would deploy maven artifacts to a repository existing in the lib folder of your project. I know how to add a repository on my local filesystem to pom.xml like this...

 <repositories>
            <repository>
                    <id>lib-repo</id>
                    <name>lib-repository</name>
                    <url>file://${basedir}/lib</url>                
                    <releases>
                            <checksumPolicy>ignore</checksumPolicy>
                    </releases>
            </repository>
    </repositories>

The confusing part is how I would get artifacts in to this "lib" folder. It's not as simply as dropping in files, I have the feeling I need to use the mvn install:install-file command somehow.

+1  A: 

It looks like I can use this (I answered my own question rather fast it seems!).

http://maven.apache.org/plugins/maven-install-plugin/examples/specific-local-repo.html

Benju
A: 

Do you mean deploy or install? In maven's vocabulary, deploying is adding your artifact(s) to a remote repository and typically occurs during the deploy phase. This is done using the depoy plugin that has two goals: deploy:deploy and deploy:deploy-file.

To use the plugin, declare where to deploy to the pom.xml by adding a repository element under the distributionManagement element:

<project>
  ...
  <distributionManagement>
    <repository>
      <id>projectRepository</id>
      <name>Repository Name</name>
      <url>Wagon Url</url>
    </repository>
  </distributionManagement>
  ...
</project>

About the repository:

  • The id is a unique id for this repository (so you can refer to it in ~/.m2/settings.xml for authentication settings).
  • The name is a human-readable name for the repository.
  • The url is a Wagon URL, most often scp.

As you can see in Wagon's documentation, wagon has a File provider too. It enables Maven to use remote repositories stored in local file system and to store Maven sites there also. In other words, you can use file://C:\m2-repo or file://${basedir}/lib as url.

Pascal Thivent