开发者

Deploy All Project Dependencies to a Remote Repository

We hava a new project friend and we want to install the project to his enviroment. But there are too many dependencies that not exists in the maven reposit开发者_开发技巧ory. So maven became useless. We installed an archiva server to install our artifacts there, but we dont want to deploy all that dependencies one by one(not only project jar self, all the dependencies). Is there an automated solution for this situation?

Thanks in advance.


Initially if you tweak your projects pom.xml and add:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>localrepo</outputDirectory>
                        <useRepositoryLayout>true</useRepositoryLayout>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

and run mvn package this should create a copy of your dependencies in repository directory format inside the localrepo directory (I tried using the command line options to dependency:copy-dependencies but it wouldn't work for me). Now comment out the above from your pom.xml as you probably don't need it anymore.

I've never used Archiva but I imagine at this point you could install the localrepo repository files onto a local web server and configure your Archiva server to mirror it.

Alternatively, if you wanted to produce a minimal effort install for your end user (and distribution size wasn't an issue) you could include this localrepo directory in your distribution and provide maven with a reference to it by adding the following to your pom.xml:

<repositories>
    <repository>
        <id>local-repo</id>
        <name>local-repo</name>
        <url>file://${basedir}/localrepo</url>
        <releases>
            <enabled>true</enabled>
            <checksumPolicy>ignore</checksumPolicy>
            <updatePolicy>always</updatePolicy>
        </releases>
    </repository>
</repositories>  

This local repository technique is very useful when distributing home grown and 3rd party jar files that are not in public Maven repositories. You can always remove the libraries that are in public repositories.

I find nothing discourages new users from Maven quicker than my trying to explain all that mvn install:install-file palaver that is usually necessary to install 3rd party jars (however enthusiastic I may be about Maven).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜