我跟踪了install jar built from ant task into local maven repository的帖子
我不知道是什么问题,但这根本行不通。我不知道他们为什么使用<arg value="mvn.bat"/>而不是<arg value="mvn "/>,反正我有以下的xml文件:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target name="mvn">
<property environment="env" />
<property name="appname" value="hellojavaworld" />
<exec dir="." executable="cmd">
<arg value="/c"/>
<arg value="mvn "/>
<arg value="install:install-file"/>
<arg value="-Dfile=c:\Documents and Settings\bbb\workspace\HelloServlet\hellojavaworld\src\main\java\hellojavaworld.bin\hellojavaworld.jar"/>
<arg value ="-DgroupId=${appname}"/>
<arg value="-DartifactId=${appname}"/>
<arg value="-Dversion=1.0"/>
<arg value="-Dpackaging=jar"/>
<arg value="-DgeneratePOM=true"/>
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>它返回错误:
从存储库中解析插件‘install:install-file -D file=c’的版本时出错local (C:\Documents and Settings\bbb.m2\repository), central ([https://repo.maven.apache.org/maven2)]:plugin在任何插件存储库中都找不到
发布于 2015-10-20 12:01:57
您的问题非常微妙,错误消息在这种情况下没有帮助。
此问题来自于maven-antrun-plugin的以下配置
<arg value="mvn "/>它应该是
<arg value="mvn"/>最后的空格被编码到%20中,这会把事情搞砸。我注意到这一点,因为在运行配置时,我看到了以下日志:
[exec] Downloading: https://repo.maven.apache.org/maven2/%20install/install-file%20-Dfile=c/maven-metadata.xml请注意,在这个日志中,Maven试图查找install-file%20插件,这显然不起作用。
https://stackoverflow.com/questions/33233253
复制相似问题