我正在尝试在Windows上使用Ant构建Maven。
在maven签出的文件夹中运行ant时,我得到:build.xml:105: localRepository doesn't support the "path" attribute
包含localRepository的第106行是:<localRepository path="${maven.repo.local}" />
Ant输出:构建文件: H:\maven-3.0-SNAPSHOT\build.xml
clean-bootstrap:
initTaskDefs:
[echo] Building Apache Maven ...
isMavenHomeSet:
init:
[echo] maven.home = C:\maven-3.0-SNAPSHOT
[echo] maven.repo.local = C:\Users\XXX/.m2/repository
[echo] distributionId = apache-maven
[echo] distributionName = Apache Maven
[echo] distributionDirectory = apache-maven
prompt-maven-home-exists:
pull:
BUILD FAILED
H:\maven-3.0-SNAPSHOT\build.xml:105: localRepository doesn't support the "path"
attribute在maven.repo.local中将斜杠改为反斜杠也没有帮助。
发布于 2014-05-21 18:18:33
从maven central下载maven-ant-task jar
http://search.maven.org/#artifactdetails%7Corg.apache.maven%7Cmaven-ant-tasks%7C2.1.3%7Cjar
并复制到$ANT_HOME/lib目录。
发布于 2021-12-13 22:05:22
以下方法似乎适用于我们,尽管它可能高度依赖于您的build.xml。我使用的是ant版本1.9.4作为记录。
首先,我的$HOME/.m2/settings.xml中的以下条目似乎确实适用于ant。
<localRepository>/some/path/.m2/repository</localRepository> 然而,这并不是一个很好的解决方案,因为我们不想更改所有开发人员的配置文件。对于build.xml文件,您需要以定义artifact:remoteRepository行的方式定义本地存储库:
<artifact:remoteRepository id="central" url="..."/>
<!-- add the following line after the remoteRepository definitions -->
<artifact:localRepository id="local" path="/some/path/.m2/repository"/>为了使存储库适用于我们所有的构建分支,我们使用类似以下的环境变量:
<artifact:localRepository id="local" path="${env.BUILD_HOME}/.m2/repository/"/> 然后,您将以与使用远程存储库相同的方式使用local存储库:
<remoteRepository refid="central"/>
<!-- add the following line after the remoteRepository usages -->
<localRepository refid="local"/>我们必须将它同时添加到<artifact:pom和<artifact:dependencies部分才能使其正常工作。YMMV.
https://stackoverflow.com/questions/10216530
复制相似问题