【问题标题】:How to set where maven installs plugins?如何设置maven安装插件的位置?
【发布时间】:2011-05-21 12:47:54
【问题描述】:

我尝试使用 maven 2.2.1 构建项目并收到以下错误
请注意“无法创建目录” - 我认为 D: 是一个由 TrueCrypt 加密的驱动器,现在实际上是 H: (D: 仍然是一个无法通过 Windows 访问的物理驱动器)

如何让 maven 尝试将插件安装在 H: 而不是 D: 上?

C:\dev\some-project>mvn -f uberPom.xml install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Declarations
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
Downloading: http://download.java.net/maven/2/org/apache/maven/plugins/maven-site-plugin/2.0-beta-7/maven-site-plugin-2.0-beta-7.pom
[INFO] Unable to find resource 'org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7' in repository maven2-repository.dev.java.net (http://download.java.net/maven/2)
Downloading: http://repo.marketcetera.org/maven/org/apache/maven/plugins/maven-site-plugin/2.0-beta-7/maven-site-plugin-2.0-beta-7.pom
[INFO] Unable to find resource 'org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7' in repository internal (http://repo.marketcetera.org/maven)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-site-plugin/2.0-beta-7/maven-site-plugin-2.0-beta-7.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7' from repository central (http://repo1.maven.org/maven2): Specified destination directory cannot be created: D:\.m2\repository\org\apache\
maven\plugins\maven-site-plugin\2.0-beta-7
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-site-plugin/2.0-beta-7/maven-site-plugin-2.0-beta-7.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7' from repository central (http://repo1.maven.org/maven2): Specified destination directory cannot be created: D:\.m2\repository\org\apache\
maven\plugins\maven-site-plugin\2.0-beta-7
Downloading: http://download.java.net/maven/2/org/apache/maven/plugins/maven-site-plugin/2.0-beta-7/maven-site-plugin-2.0-beta-7.pom
[INFO] Unable to find resource 'org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7' in repository java.net (http://download.java.net/maven/2)
Downloading: http://repo.marketcetera.org/maven/org/apache/maven/plugins/maven-site-plugin/2.0-beta-7/maven-site-plugin-2.0-beta-7.pom
[INFO] Unable to find resource 'org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7' in repository internal (http://repo.marketcetera.org/maven)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.apache.maven.plugins:maven-site-plugin

Reason: POM 'org.apache.maven.plugins:maven-site-plugin' not found in repository: Unable to download the artifact from any repository

  org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7

from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  java.net (http://download.java.net/maven/2),
  internal (http://repo.marketcetera.org/maven),
  maven2-repository.dev.java.net (http://download.java.net/maven/2)

 for project org.apache.maven.plugins:maven-site-plugin


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Sat May 21 14:45:51 IDT 2011
[INFO] Final Memory: 2M/46M
[INFO] ------------------------------------------------------------------------

【问题讨论】:

  • 意味着首先你已经改变了你的 settings.xml 来为你的本地存储库使用不同的位置(可能是用户家是根据我不知道的 Windows 中的配置而改变的)..进一步为什么要使用不同的 pom?
  • @khmarbaise - 不同的 pom 是什么意思?
  • 你为什么使用 mvn -f ueberPom.xml install 而不是简单的 mvn install...
  • @khmarbaise - 构建项目有两个步骤 - 这一步是第一个设置后续 POM 文件中使用的所有 Maven 库依赖项,第二步实际构建项目。这样更容易。
  • 可能是我错过了一些东西,但听起来你不了解 Maven,因为它会处理所有依赖项并在需要时下载..?

标签: plugins maven installation directory


【解决方案1】:

您可以通过修改全局设置文件(位于 \conf\settings.xml 中)将本地存储库的位置设置为不同的文件夹。然后将安装/下载任何插件和工件到该位置。

例如,以下 sn-p 会将本地存储库设置为 h:\Maven\repository

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                  http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>h:\Maven\repository</localRepository>
  ...

【讨论】:

    猜你喜欢
    • 2010-11-29
    • 2012-02-18
    • 1970-01-01
    • 2016-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多