蚂蚁/ Eclipse的抱怨神器:依赖 [英] Ant / Eclipse complains about artifact:dependencies

查看:320
本文介绍了蚂蚁/ Eclipse的抱怨神器:依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的战争中使用XML来JSON库。
我也跟着教程并解释说,依赖关系必须在项目中。

但是,当我加入我的蚂蚁的build.xml (用于创建战争文件)以下的,Eclipse的抱怨有关神器:依赖,好像它不喜欢。我有以下错误信息:


  

在preFIX 神器为元素神器:依赖未绑定...


 <神器:依赖filesetId =dependency.fileset
    sourcesFilesetId =sources.dependency.fileset
    javadocFilesetId =javadoc.dependency.fileset
    versionsId =dependency.versions>
    <! - DEPENCIES GO HERE - >
< /神器:依赖>

任何想法?

更新

我有同样的问题试图定义一个在内存与POM:

 <神器:POM ID =mypom的groupId =org.acme的artifactId =PROJECT1版本=1.0>
   <依赖的groupId =JUnit的的artifactId =JUnit的版本=4.1/>
   <依赖的groupId = artifactId的=丛-utils的版本=1.5.5/&GT组织codehaus.plexus。
   <许可证名称=阿帕奇URL =htt​​p://www.apache.org/>
< /神器:POM>


  

在preFIX 神器为元素神器:POM 未绑定...


更新2

我在蚂蚁/ lib中安装Maven的蚂蚁罐和更改的build.xml所以它包含了神器的东西定义,但同时运行它我有一个错误信息。

 <项目名称=测试默认为安装的xmlns:神器=的antlib:org.apache.maven.artifact.ant><神器:依赖PATHID =dependency.classpath>
   <&依赖性GT;
        <&的groupId GT; net.sf.json-LIB和LT; /的groupId>
        <&的artifactId GT; JSON-lib目录下和/ artifactId的>
        <&版GT; 2.3< /版本>
        <&型GT;&罐子LT; /类型>
        <分类器GT; jdk15< /分类>
        <&范围GT;&编译LT; /&范围GT;
       < /依赖性>
       ...

该错误消息的Eclipse了是:

 构建失败
D:\\ J2EE \\工作区\\测试\\ build.xml文件:3:问题:无法创建任务或键入的antlib:org.apache.maven.artifact.ant:依赖
原因:这个名字是不确定的。
操作:检查拼写。
操作:检查所有的自定义任务/类型已经被宣布。
操作:检查任何与LT; presetdef> /< macrodef>声明发生。
任何类型或任务已在此命名空间中定义还
这似乎是一个的antlib声明。
    操作:检查实施库中的一个存在:
    -D:\\日食\\插件\\ org.apache.ant_1.8.2.v20110505-1300 \\ lib中
    -C:\\ Documents和Settings \\吕克\\赵军阳张志利\\ lib中
    -a目录加入在命令行上与-lib论点

Maven的蚂蚁罐子并在 -D存在:\\日食\\插件\\ org.apache.ant_1.8.2.v20110505-1300 \\ lib中

更新3

这是我使用的build.xml文件。

 <! - 
<项目名称=监视默认为安装的xmlns:神器=瓮:Maven的神器 - 蚁族的xmlns:测试=瓮:测试任务>
- >
<项目名称=监视默认为安装的xmlns:神器=的antlib:org.apache.maven.artifact.ant><! - 特定项目的变量 - >
<物业环境=ENV/>
<属性名=PROJECT_HOMEVALUE =D:\\ J2EE \\工作区\\监控/>
<属性名=webapp.dir值=$ {} PROJECT_HOME /目标/>
<属性名=jboss.dirVALUE =D:\\ J2EE \\ jboss的\\独立\\部署/>
<属性名=package.nameVALUE =monitoring.war/>
<属性名=lib.dir值=$ {} PROJECT_HOME / lib目录/>
<属性名=对于src.dir值=$ {} PROJECT_HOME / src目录/>
<属性名=resources.dir值=$ {} PROJECT_HOME /资源/>
<属性名=dest.dir值=$ {} PROJECT_HOME /目标/>
<属性名=package.file值=$ {dest.dir} / $ {} package.name/><! - 构建过程中把一切都放在一个临时文件夹使用正确的结构 - >
<属性名=temp.dir值=$ {} PROJECT_HOME / TEMP/>
<属性名=temp.dir.web-INF值=$ {} temp.dir / WEB-INF/>
<属性名=temp.dir.lib值=$ {temp.dir.web-INF} / lib目录/>
<属性名=temp.dir.classes值=$ {temp.dir.web-INF} /班/>
<属性名=temp.dir.meta-INF值=$ {} temp.dir / META-INF/>
&所述;路径ID =build.class.path>
    <文件集DIR =$ {} env.JAVA_HOME / lib目录>
        <包括姓名=** / *罐子。/>
    < /文件集>
    <文件集DIR =D:\\蚂蚁\\ lib目录>
            <包括姓名=** / *罐子。/>
    < /文件集>
< /路径><目标名称=DEPS>
    <神器:依赖PATHID =dependency.classpath>
        <&依赖性GT;
            <&的groupId GT; net.sf.json-LIB和LT; /的groupId>
            <&的artifactId GT; JSON-lib目录下和/ artifactId的>
            <&版GT; 2.3< /版本>
            <&型GT;&罐子LT; /类型>
            <分类器GT; jdk15< /分类>
            <&范围GT;&编译LT; /&范围GT;
        < /依赖性>
        <&依赖性GT;
            <&的groupId GT; org.apache.commons< /的groupId>
            <&的artifactId GT;公共-IO< / artifactId的>
            <&版GT; 1.3.2< /版本>
            <&型GT;&罐子LT; /类型>
            <&范围GT;&编译LT; /&范围GT;
        < /依赖性>
        <&依赖性GT;
            <&的groupId GT; XOM< /的groupId>
            <&的artifactId GT; XOM< / artifactId的>
            <&版GT; 1.1< /版本>
        < /依赖性>
    < /神器:依赖>
< /目标与GT;<目标名称=干净要看=DEPS>
    <删除>
        <文件集DIR =$ {} dest.dir包括=** / */>
    < /删除>
    <删除DIR =$ {} temp.dir/>
    <删除DIR =$ {} temp.dir.classes/>
    <删除DIR =$ {temp.dir.meta-INF}/>
    <删除DIR =$ {temp.dir.web-INF}/>
< /目标与GT;<目标NAME =prepare取决于=干净>
    < MKDIR DIR =$ {} dest.dir/>
    < MKDIR DIR =$ {} temp.dir/>
    < MKDIR DIR =$ {} temp.dir.lib/>
    < MKDIR DIR =$ {temp.dir.meta-INF}/>
    < MKDIR DIR =$ {temp.dir.web-INF}/>
    < MKDIR DIR =$ {} temp.dir.classes/>
< /目标与GT;<! - COMPILE - >
<目标名称=编译取决于=prepare>
    <回声> === COMPILE ===< /回声>
    <回声>编译$ {} src.dir的文件...< /回声>
    &所述; javac的调试=上SRCDIR =$ {对于src.dir}DESTDIR =$ {temp.dir.classes}包括=** / *includeantruntime =假>
        <类路径REFID =build.class.path/>
        <类路径REFID =dependency.classpath/>
    < / javac的>
< /目标与GT;<! - 包装 - >
<目标名称=包依赖=编译>
  <回声> ===包装===< /回声>  <! - 复制配置文件 - >
  <复制文件=$ {} resources.dir /web.xmlTOFILE =$ {temp.dir.web-INF} /web.xml覆盖=真/>
  <复制文件=$ {} resources.dir /manifest.mfTOFILE =$ {temp.dir.meta-INF} /manifest.mf覆盖=真/>
  <副本todir =$ {} temp.dir.classes>
    <文件集DIR =$ {}对于src.dir>
      <包括姓名=** / * XML。/>
      <包括姓名=** / * XSL/>
    < /文件集>
  < /复制>  <! - 蚂蚁战争任务。在地方的所有资源,创建WAR文件 - >
  <战争destfile =$ {} package.filewebxml =$ {temp.dir.web-INF} /web.xmlBASEDIR =$ {} temp.dir>
    < lib目录=$ {} lib.dir/>
    <类DIR =$ {} temp.dir.classes/>
  < /战争>
< /目标与GT;<! - 安装 - >
<目标名称=安装取决于=包>
  <回声> === INSTALL ===< /回声>
  <复制文件=$ {} package.fileTOFILE =$ {webapp.dir} / $ {} package.name覆盖=真/>
  <复制文件=$ {} package.fileTOFILE =$ {jboss.dir} / $ {} package.name覆盖=真/>
< /目标与GT;< /项目>

这是工作好之前,我添加了所有依赖的东西......还不能在这里找到了PB。任何帮助将是非常欢迎的。


解决方案

它看起来像你利用 Maven的Ant任务的。要做到这一点,你会在这里需要从下载区罐子的副本。
一旦(如果)你有,你会需要修改构建文件来使用它。

需要主要的事情是定义神器命名空间,并添加的typedef蚂蚁lib目录下:

 <项目名称=富默认值=富的xmlns:神器=的antlib:org.apache.maven.artifact.ant>  <路径ID =Maven的蚂蚁tasks.classpathPATH =LIB / Maven的蚂蚁任务-2.1.3.jar/>
  <的typedef资源=组织/阿帕奇/行家/神器/ ANT / antlib.xml
       URI =的antlib:org.apache.maven.artifact.ant
       classpathref =Maven的蚂蚁tasks.classpath/>

I need to use XML to JSON lib in my war. I followed a tutorial explaining that dependencies are required in the project.

But when I add the following in my ant build.xml (the file used to create the war), Eclipse complains about the artifact:dependencies, seems like it does not like the :.I have the following error message:

The prefix artifact for element artifact:dependencies is not bound...

<artifact:dependencies filesetId="dependency.fileset"
    sourcesFilesetId="sources.dependency.fileset"
    javadocFilesetId="javadoc.dependency.fileset"
    versionsId="dependency.versions">
    <!-- DEPENCIES GO HERE -->
</artifact:dependencies>

Any idea ?

UPDATE

I have the same problem trying to define an in-memory pom with:

<artifact:pom id="mypom" groupId="org.acme" artifactId="project1" version="1.0">
   <dependency groupId="junit" artifactId="junit" version="4.1"/>
   <dependency groupId="org.codehaus.plexus" artifactId="plexus-utils" version="1.5.5"/>
   <license name="apache" url="http://www.apache.org"/>
</artifact:pom>

The prefix artifact for element artifact:pom is not bound...

UPDATE 2

I installed maven-ant jar in ant/lib and change the build.xml so it contains the definition of the artifact stuff but I have an error message while running it.

<project name="test" default="install" xmlns:artifact="antlib:org.apache.maven.artifact.ant">

<artifact:dependencies pathId="dependency.classpath">
   <dependency>
        <groupId>net.sf.json-lib</groupId>
        <artifactId>json-lib</artifactId>
        <version>2.3</version>
        <type>jar</type>
        <classifier>jdk15</classifier>
        <scope>compile</scope>
       </dependency>
       ...

The error message Eclipse gave is:

BUILD FAILED
D:\J2EE\workspace\Test\build.xml:3: Problem: failed to create task or type antlib:org.apache.maven.artifact.ant:dependencies
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
This appears to be an antlib declaration. 
    Action: Check that the implementing library exists in one of:
    -D:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib
    -C:\Documents and Settings\luc\.ant\lib
    -a directory added on the command line with the -lib argument

The maven-ant jar does exist in -D:\eclipse\plugins\org.apache.ant_1.8.2.v20110505-1300\lib

UPDATE 3

This is the build.xml file I'm using.

<!--
<project name="Monitoring" default="install" xmlns:artifact="urn:maven-artifact-ant" xmlns:test="urn:test-tasks">
-->
<project name="Monitoring" default="install" xmlns:artifact="antlib:org.apache.maven.artifact.ant">

<!-- project-specific variables -->
<property environment="env" />
<property name="project_home" value="D:\J2EE\workspace\Monitoring"/>
<property name="webapp.dir" value="${project_home}/target" />
<property name="jboss.dir" value="D:\J2EE\jboss\standalone\deployments" />  
<property name="package.name" value="monitoring.war" />
<property name="lib.dir" value="${project_home}/lib" />
<property name="src.dir" value="${project_home}/src" />
<property name="resources.dir" value="${project_home}/resources" />
<property name="dest.dir" value="${project_home}/target" />
<property name="package.file" value="${dest.dir}/${package.name}" />

<!-- put everything in a temp folder with the right structure during the build -->
<property name="temp.dir" value="${project_home}/temp" />
<property name="temp.dir.web-inf" value="${temp.dir}/WEB-INF" />
<property name="temp.dir.lib" value="${temp.dir.web-inf}/lib" />
<property name="temp.dir.classes" value="${temp.dir.web-inf}/classes" />
<property name="temp.dir.meta-inf" value="${temp.dir}/META-INF" />


<path id="build.class.path">
    <fileset dir="${env.JAVA_HOME}/lib">
        <include name="**/*.jar" />
    </fileset>
    <fileset dir="D:\ant\lib">
            <include name="**/*.jar" />
    </fileset>
</path>

<target name="deps">
    <artifact:dependencies pathId="dependency.classpath">
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.3</version>
            <type>jar</type>
            <classifier>jdk15</classifier>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>xom</groupId>
            <artifactId>xom</artifactId>
            <version>1.1</version>
        </dependency>
    </artifact:dependencies>
</target>

<target name="clean" depends="deps">
    <delete>
        <fileset dir="${dest.dir}" includes="**/*"/>
    </delete>
    <delete dir="${temp.dir}" />
    <delete dir="${temp.dir.classes}" />
    <delete dir="${temp.dir.meta-inf}" />
    <delete dir="${temp.dir.web-inf}" />
</target>

<target name="prepare" depends="clean">
    <mkdir dir="${dest.dir}" />
    <mkdir dir="${temp.dir}" />
    <mkdir dir="${temp.dir.lib}" />
    <mkdir dir="${temp.dir.meta-inf}" />
    <mkdir dir="${temp.dir.web-inf}" />
    <mkdir dir="${temp.dir.classes}" />
</target>

<!-- COMPILE -->
<target name="compile" depends="prepare">
    <echo>=== COMPILE ===</echo>
    <echo>Compiling ${src.dir} files ...</echo>
    <javac debug="on" srcdir="${src.dir}" destdir="${temp.dir.classes}" includes="**/*" includeantruntime="false">
        <classpath refid="build.class.path" />
        <classpath refid="dependency.classpath" />
    </javac>
</target>

<!-- PACKAGE -->
<target name="package" depends="compile">
  <echo>=== PACKAGE ===</echo>

  <!-- copy the config files -->
  <copy file="${resources.dir}/web.xml" tofile="${temp.dir.web-inf}/web.xml" overwrite="true" />
  <copy file="${resources.dir}/manifest.mf" tofile="${temp.dir.meta-inf}/manifest.mf" overwrite="true" />
  <copy todir="${temp.dir.classes}">
    <fileset dir="${src.dir}">
      <include name="**/*.xml"/>
      <include name="**/*.xsl"/>
    </fileset>
  </copy>

  <!-- the ant war task. with all resources in place, create the war file -->
  <war destfile="${package.file}" webxml="${temp.dir.web-inf}/web.xml" basedir="${temp.dir}">
    <lib dir="${lib.dir}" />
    <classes dir="${temp.dir.classes}" />
  </war>
</target>

<!-- INSTALL -->
<target name="install" depends="package">
  <echo>=== INSTALL ===</echo>
  <copy file="${package.file}" tofile="${webapp.dir}/${package.name}" overwrite="true" />
  <copy file="${package.file}" tofile="${jboss.dir}/${package.name}" overwrite="true" />        
</target>

</project>

It was working well before I added all the dependencies stuff... still cannot find out the pb here. Any help would be very welcome.

解决方案

It looks like you're making use of Maven Ant Tasks. To do this you'll need a copy of the jar from the download area here. Once (or if) you've got that, you'll need to modify your buildfile to use it.

The main things that are needed are to define the artifact namespace, and add the typedef for the ant-lib:

<project name="foo" default="foo" xmlns:artifact="antlib:org.apache.maven.artifact.ant">

  <path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
  <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
       uri="antlib:org.apache.maven.artifact.ant"
       classpathref="maven-ant-tasks.classpath" />

这篇关于蚂蚁/ Eclipse的抱怨神器:依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆