使用环境变量的Maven本地存储库

使用环境变量的Maven本地存储库

问题描述:

如何设置<使用环境用户var的localRepository>标记.我尝试了这条路: %myRepo%/repo,但它不起作用(myRepo = C:/maven/repo).对于移植性问题,我不能使用绝对路径,但可以将%myRepo%设置到每个系统上的正确位置,在该位置绝对路径可能会有所不同,但/repo保持不变.有人能帮我吗?谢谢.使用Windows. Maven 2.2.1.

How can I set up the < localRepository > tag with an environment user var. I tried this path: %myRepo%/repo but it doesn't works (myRepo=C:/maven/repo). I can't use an absolute path for portability issues but I can setup %myRepo% to the correct place on each system in which the absolute path may vary but the /repo stays the same. Can someone help me? Thanks. Using windows. Maven 2.2.1.

您可以使用$ {env.HOME}来引用环境变量%HOME%,以及任何其他环境变量.

You can use ${env.HOME} to refer to the environment variable %HOME%, and similarly any other environment variable.

但是,您可能希望通过在settings.xml中指定每台计算机上的存储库位置来设置存储库的位置,从而允许每个用户输入自己的设置.有关此环境和设置环境的详细信息,请参见 http://maven.apache.org/settings.html 通常是变量(请注意已标记的Maven 3的某些特定部分).

However, you may want to set the repository location on each machine by specifying it in settings.xml which is allows each user to enter their own settings. See http://maven.apache.org/settings.html for detail on this and setting environment variables in general (note some parts specific to Maven 3 as marked).