1

我有以下内容:

  • eclipse-indigo进去CentOS 6.2
  • 我还安装apache-ant-1.8.4在我的系统ANT_HOME中并在eclipse.
  • 在 Eclipse 中,我安装了maven2使用版本的插件,该maven-3.0.4版本安装在我的系统上(我配置eclipse为使用它)。

我在我的 Eclipse 上有一个 Maven 项目,我希望每次当我install- (maven目标) - 它时,将结果jar文件复制到我服务器上的特定位置 - 通过ssh. 为此,我在我的pom.xml



   <build>
    <plugins >
            <plugin>
        <groupId > org.apache.maven.plugins </groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <phase>install</phase>
                    <configuration>
                        <tasks name="ssh_task">
                            <taskdef name="scp" 
                                      classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp" classpathref="/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jsch.jar" />
                            <scp file="/absolute/path/to/myfile.jar" 
                                 todir="root@$10.3.1.1:/remote/location" 
                                 password="mypass" 
                                 trusted="true"/>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
  </build>


pom.xml在这篇文章之后以这种方式配置了我的:

现在的问题是,当我运行install目标时,eclipse出现以下错误:

错误] 无法执行目标 org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default) on project myprojectname: An Ant BuildException has occurred: Reference /usr/local/apache-ant/apache-ant- 1.8.4/lib/ant-jsch.jar 未找到。-> [帮助 1]

问题是ant-jsch.jar存在。

问题:您对如何处理我的问题有什么建议吗?如果您想知道完整的堆栈跟踪,请告诉我。

编辑:


ant -diagnostics
------- Ant diagnostics report -------
Apache Ant(TM) version 1.8.4 compiled on May 22 2012

-------------------------------------------
 Implementation Version
-------------------------------------------
core tasks     : 1.8.4 in file:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant.jar

-------------------------------------------
 ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
ant.java.version: 1.6
Is this the Apache Harmony VM? no
Is this the Kaffe VM? no
Is this gij/gcj? no
ant.core.lib: /usr/local/apache-ant/apache-ant-1.8.4/lib/ant.jar
ant.home: /usr/local/apache-ant/apache-ant-1.8.4

-------------------------------------------
 ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/local/apache-ant/apache-ant-1.8.4
commons-logging-1.0.4.jar (38015 bytes)
jruby-0.9.8.jar (1683526 bytes)
servlet-api-2.3.jar (77977 bytes)
serializer-2.7.1.jar (278281 bytes)
jasper-compiler-4.1.36.jar (184124 bytes)
commons-logging-api-1.1.jar (44598 bytes)
bcel-5.1.jar (515920 bytes)
xml-apis-1.3.04.jar (194354 bytes)
ant-javamail.jar (13773 bytes)
ant-commons-logging.jar (9715 bytes)
jsch-0.1.42.jar (185746 bytes)
log4j-1.2.14.jar (367444 bytes)
xalan-2.7.1.jar (3176148 bytes)
ant-jai.jar (28241 bytes)
ant-junit4.jar (12923 bytes)
ant-antlr.jar (11550 bytes)
jasper-runtime-4.1.36.jar (72397 bytes)
jai-core-1.1.3.jar (1900631 bytes)
ant-netrexx.jar (16215 bytes)
ant-junit.jar (108138 bytes)
bsh-core-2.0b4.jar (143992 bytes)
ant-jdepend.jar (14024 bytes)
asm-commons-2.2.3.jar (15114 bytes)
regexp-1.2.jar (29871 bytes)
ant.jar (1941731 bytes)
regexp-1.3.jar (25429 bytes)
commons-net-1.4.1.jar (180792 bytes)
ant-jsch.jar (46176 bytes)
asm-2.2.3.jar (34832 bytes)
bsh-2.0b4.jar (281694 bytes)
ant-apache-oro.jar (45515 bytes)
antlr-2.7.7.jar (445288 bytes)
mail-1.4.jar (388864 bytes)
ant-jmf.jar (12541 bytes)
asm-tree-2.2.3.jar (16248 bytes)
js-1.6R7.jar (813521 bytes)
activation-1.1.jar (62983 bytes)
ant-testutil.jar (21004 bytes)
ant-apache-bcel.jar (14548 bytes)
ant-swing.jar (13497 bytes)
ant-commons-net.jar (91451 bytes)
junit-4.8.1.jar (237047 bytes)
ant-apache-xalan2.jar (8097 bytes)
jdepend-2.9.1.jar (57933 bytes)
ant-apache-regexp.jar (9563 bytes)
maven-artifact-ant-2.0.4-dep.jar (887507 bytes)
oro-2.0.8.jar (65261 bytes)
which-1.0.jar (17398 bytes)
jai-codec-1.1.3.jar (258160 bytes)
ant-apache-resolver.jar (9886 bytes)
bsf-2.4.0.jar (113369 bytes)
NetRexxC.jar (355931 bytes)
ant-launcher.jar (18429 bytes)
ant-apache-log4j.jar (8861 bytes)
ant-apache-bsf.jar (9733 bytes)
xml-resolver-1.2.jar (84091 bytes)

-------------------------------------------
 USER_HOME/.ant/lib jar listing
-------------------------------------------
user.home: /root
No such directory.

-------------------------------------------
 Tasks availability
-------------------------------------------
All defined tasks are available

-------------------------------------------
 org.apache.env.Which diagnostics
-------------------------------------------
#---- BEGIN: Which report
Which.version=Which.java:($Revision: 1.2 $) WhichJar.java:($Revision: 1.2 $)
java.version=1.6.0_31
file.encoding=UTF-8
java.ext.dirs=/usr/java/jdk1.6.0_31/jre/lib/ext:/usr/java/packages/lib/ext
java.class.path=/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-launcher.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-logging-1.0.4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jruby-0.9.8.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/servlet-api-2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/serializer-2.7.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jasper-compiler-4.1.36.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-logging-api-1.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bcel-5.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xml-apis-1.3.04.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-javamail.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-commons-logging.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jsch-0.1.42.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/log4j-1.2.14.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xalan-2.7.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jai.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-junit4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-antlr.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jasper-runtime-4.1.36.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jai-core-1.1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-netrexx.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-junit.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsh-core-2.0b4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jdepend.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-commons-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/regexp-1.2.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/regexp-1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-net-1.4.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jsch.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsh-2.0b4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-oro.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/antlr-2.7.7.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/mail-1.4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jmf.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-tree-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/js-1.6R7.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/activation-1.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-testutil.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-bcel.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-swing.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-commons-net.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/junit-4.8.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-xalan2.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jdepend-2.9.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-regexp.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/maven-artifact-ant-2.0.4-dep.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/oro-2.0.8.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/which-1.0.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jai-codec-1.1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-resolver.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsf-2.4.0.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/NetRexxC.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-launcher.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-log4j.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-bsf.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xml-resolver-1.2.jar:/usr/java/jdk1.6.0_31/lib/tools.jar
os.name=Linux
java.vendor=Sun Microsystems Inc.
sun.boot.class.path=/usr/java/jdk1.6.0_31/jre/lib/resources.jar:/usr/java/jdk1.6.0_31/jre/lib/rt.jar:/usr/java/jdk1.6.0_31/jre/lib/sunrsasign.jar:/usr/java/jdk1.6.0_31/jre/lib/jsse.jar:/usr/java/jdk1.6.0_31/jre/lib/jce.jar:/usr/java/jdk1.6.0_31/jre/lib/charsets.jar:/usr/java/jdk1.6.0_31/jre/lib/modules/jdk.boot.jar:/usr/java/jdk1.6.0_31/jre/classes
java.runtime.name=Java(TM) SE Runtime Environment
#----   END: Which report

-------------------------------------------
 XML Parser information
-------------------------------------------
XML Parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
XML Parser Location: unknown
Namespace-aware parser : com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Namespace-aware parser Location: unknown

-------------------------------------------
 XSLT Processor information
-------------------------------------------
XSLT Processor : org.apache.xalan.transformer.TransformerIdentityImpl
XSLT Processor Location: file:/usr/local/apache-ant/apache-ant-1.8.4/lib/xalan-2.7.1.jar

-------------------------------------------
 System properties
-------------------------------------------
java.runtime.name : Java(TM) SE Runtime Environment
sun.boot.library.path : /usr/java/jdk1.6.0_31/jre/lib/i386
java.vm.version : 20.6-b01
ant.library.dir : /usr/local/apache-ant/apache-ant-1.8.4/lib
java.vm.vendor : Sun Microsystems Inc.
java.vendor.url : http://java.sun.com/
path.separator : :
java.vm.name : Java HotSpot(TM) Server VM
file.encoding.pkg : sun.io
user.country : US
sun.java.launcher : SUN_STANDARD
sun.os.patch.level : unknown
java.vm.specification.name : Java Virtual Machine Specification
user.dir : /home/artaxerxe
java.runtime.version : 1.6.0_31-b04
java.awt.graphicsenv : sun.awt.X11GraphicsEnvironment
java.endorsed.dirs : /usr/java/jdk1.6.0_31/jre/lib/endorsed
os.arch : i386
java.io.tmpdir : /tmp
line.separator : 

java.vm.specification.vendor : Sun Microsystems Inc.
os.name : Linux
ant.home : /usr/local/apache-ant/apache-ant-1.8.4
sun.jnu.encoding : UTF-8
java.library.path : /usr/java/jdk1.6.0_31/jre/lib/i386/server:/usr/java/jdk1.6.0_31/jre/lib/i386:/usr/java/jdk1.6.0_31/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
java.specification.name : Java Platform API Specification
java.class.version : 50.0
sun.management.compiler : HotSpot Tiered Compilers
os.version : 2.6.32-220.17.1.el6.i686
user.home : /root
user.timezone : Europe/Bucharest
java.awt.printerjob : sun.print.PSPrinterJob
file.encoding : UTF-8
java.specification.version : 1.6
user.name : root
java.class.path : /usr/local/apache-ant/apache-ant-1.8.4/lib/ant-launcher.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-logging-1.0.4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jruby-0.9.8.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/servlet-api-2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/serializer-2.7.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jasper-compiler-4.1.36.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-logging-api-1.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bcel-5.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xml-apis-1.3.04.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-javamail.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-commons-logging.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jsch-0.1.42.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/log4j-1.2.14.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xalan-2.7.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jai.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-junit4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-antlr.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jasper-runtime-4.1.36.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jai-core-1.1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-netrexx.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-junit.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsh-core-2.0b4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jdepend.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-commons-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/regexp-1.2.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/regexp-1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/commons-net-1.4.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jsch.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsh-2.0b4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-oro.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/antlr-2.7.7.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/mail-1.4.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-jmf.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/asm-tree-2.2.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/js-1.6R7.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/activation-1.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-testutil.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-bcel.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-swing.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-commons-net.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/junit-4.8.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-xalan2.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jdepend-2.9.1.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-regexp.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/maven-artifact-ant-2.0.4-dep.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/oro-2.0.8.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/which-1.0.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/jai-codec-1.1.3.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-resolver.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/bsf-2.4.0.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/NetRexxC.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-launcher.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-log4j.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/ant-apache-bsf.jar:/usr/local/apache-ant/apache-ant-1.8.4/lib/xml-resolver-1.2.jar:/usr/java/jdk1.6.0_31/lib/tools.jar
java.vm.specification.version : 1.0
sun.arch.data.model : 32
java.home : /usr/java/jdk1.6.0_31/jre
sun.java.command : org.apache.tools.ant.launch.Launcher -cp  -diagnostics
java.specification.vendor : Sun Microsystems Inc.
user.language : en
java.vm.info : mixed mode
java.version : 1.6.0_31
java.ext.dirs : /usr/java/jdk1.6.0_31/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path : /usr/java/jdk1.6.0_31/jre/lib/resources.jar:/usr/java/jdk1.6.0_31/jre/lib/rt.jar:/usr/java/jdk1.6.0_31/jre/lib/sunrsasign.jar:/usr/java/jdk1.6.0_31/jre/lib/jsse.jar:/usr/java/jdk1.6.0_31/jre/lib/jce.jar:/usr/java/jdk1.6.0_31/jre/lib/charsets.jar:/usr/java/jdk1.6.0_31/jre/lib/modules/jdk.boot.jar:/usr/java/jdk1.6.0_31/jre/classes
java.vendor : Sun Microsystems Inc.
file.separator : /
java.vendor.url.bug : http://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian : little
sun.io.unicode.encoding : UnicodeLittle
sun.desktop : gnome
sun.cpu.isalist : 

-------------------------------------------
 Temp dir
-------------------------------------------
Temp dir is /tmp
Temp dir is writeable
Temp dir alignment with system clock is -731 ms

-------------------------------------------
 Locale information
-------------------------------------------
Timezone Eastern European Time offset=10800000

-------------------------------------------
 Proxy information
-------------------------------------------
Java1.5+ proxy settings:
Direct connection
4

2 回答 2

2

classpathref用于定义对先前定义的属性的引用。

您应该尝试定义您的类路径变量:

<path id="jsch-classpath">
        <fileset dir="/usr/local/apache-ant/apache-ant-1.8.4/lib/" includes="ant-jsch.jar"/>
</path>

然后在任务中使用它:

<taskdef name="scp" classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp" classpathref="jsch-classpath" />
于 2012-06-21T08:30:50.683 回答
0

Maven 的安装阶段旨在将工件安装到本地存储库中,而不是将文件传输到远程服务器。如果您尝试将工件部署到 Tomcat/JBoss 中,那么最好查看用于将工件部署到服务器的cargo2-maven-plugintomcat-maven-plugin 。

此外,我建议使用maven-wagon-plugin将工件上传到服务器,而不是在这种情况下使用 Ant,这将使生活更轻松。

于 2012-06-21T08:13:12.233 回答