Maven 插件依赖项被忽略
我创建了这个配置文件,用于通过 SCP 在服务器上部署工件。我知道 Ant 的 scp 任务是可选的,因此我添加了依赖项。
<profiles>
<profile>
<id>remote-deploy</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>scp</id>
<phase>install</phase>
<configuration>
<tasks>
<scp .../>
<sshexec .../>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.42</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
但是,当我运行配置文件时,我最终得到
发生了 Ant BuildException: 问题:创建任务或类型失败 scp 原因:类 org.apache.tools.ant.taskdefs.可选.ssh.Scp 没有找到。 这看起来像是 Ant 的可选组件之一。行动:检查 适当的可选 JAR 存在于 -ANT_HOME\lib -IDE Ant 配置对话框
别惊慌,这是常见现象 问题。最常见的原因是 缺少 JAR。
这不是一个错误;而是一个错误。这是一个 配置问题
maven 是否可能无法下载这些依赖项或者只是忽略它们?
I created this profile for deploying artifacts on the server via SCP. I know Ant's scp task is optional, therefore I've added the dependencies.
<profiles>
<profile>
<id>remote-deploy</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>scp</id>
<phase>install</phase>
<configuration>
<tasks>
<scp .../>
<sshexec .../>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.42</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
However, when I run the profile, I end up with
An Ant BuildException has occured:
Problem: failed to create task or type
scp Cause: the class
org.apache.tools.ant.taskdefs.optional.ssh.Scp
was not found.
This looks like one of Ant's optional components. Action: Check
that the appropriate optional JAR
exists in
-ANT_HOME\lib
-the IDE Ant configuration dialogsDo not panic, this is a common
problem. The commonest cause is a
missing JAR.This is not a bug; it is a
configuration problem
Is it possible maven wasn't able to download those dependencies or it just ignores them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是 Maven (2.2.1) 没有下载依赖项。我在将Maven升级到版本3后发现。由于某种原因,新版本下载了插件依赖项,并且它奇迹般地开始工作。
我怀疑问题出在旧版本 Maven 的设置中 -
pluginRepository
未配置。The problem was Maven (2.2.1) didn't download the dependencies. I've found out after I upgraded Maven to version 3. For some reason,the new version downloaded the plugin dependencies and it miraculously started to work.
I have a suspicion the problem was in old version Maven's settings -
pluginRepository
wasn't configured.maven 可能已经下载了 jar,但它不在 ant 的类路径中。如果目标是使用 maven 部署工件,您可能应该使用 Maven 部署插件。你正在做的事情似乎是一种迂回的方式。
It is likely that maven has downloaded the jars but it is not in ant's classpath. If the objective is to deploy the artifacts using maven, you should probably use Maven Deploy Plugin. What you are doing seems to be a roundabout way.
有一个 maven-antrun-plugin bug 条目,可以解释为什么会发生这种情况Maven-2,他们还描述了 解决方法
在多模块构建中,如果有多个 poms 配置 maven-antrun-plugin,则第一个(?)似乎获胜,以便构建链中后面的那些重用早期 poms 中的 antrun 配置,从而错过了不同的东西...
在我的问题案例中,我选择使用 Maven-3,问题似乎已得到解决,而不是解决方法与 Maven-2。这还有一个额外的好处,即构建速度也加快了 - 现在只需 6 分钟,而不是之前的 10 分钟。
但是,如果 Maven-3 不适合您,我会尝试解决方法......
There is a maven-antrun-plugin bug entry, that could explain why this is happening in Maven-2, they also describe workarounds
In multi-module builds, if there are multiple poms configuring the maven-antrun-plugin, the first(?) seems to win, so that the ones later in the build chain reuse the antrun config from earlier poms, thus missing out on stuff that is different ...
In my problem case, I opted to use Maven-3, where the issue seems to be fixed, instead of workarounds with Maven-2. This had the additional advantage of the build to also speed up - now taking 6min instead of the 10min before.
However, if Maven-3 is not possible for you, I'd try the workarounds...