本文介绍了可以常春藤或ivyDE在Eclipse中自动添加相关的罐子到Java构建路径库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,当我打开一个发达的开源项目(如Lucene的)到Eclipse(既蚂蚁的build.xml和常春藤ivysetting.xml),我可以运行蚂蚁用的build.xml成功地建立了整个项目。

然而,该项目是的.java类的乱七八糟充满了错误。这是通过解除连结到外部罐造成的。这些罐子已经被常春藤下载并存储在用户{} /。ivy2 /缓存/。此外,当我手动把这些罐子到这个项目的构建路径,这些错误都没有了。

能否常春藤或ivyDE或其他一些工具自动把罐子到Java构建路径?

下面是常春藤Setting.xml的:

\r
\r

<! - \r
   授权给Apache软件基金会(ASF)在一个\r
   以上贡献者许可协议。看到通知文件\r
   这项工作的其他信息分布式\r
   关于版权的所有权。该asf文件许可证\r
   你在Apache许可证,版本2.0(\r
   执照);你可能不使用这个文件除了在合规\r
   该许可。您可以在获得许可证的副本\r
\r
     http://www.apache.org/licenses/LICENSE-2.0\r
\r
   除非适用法律要求或书面同意,\r
   根据许可证分发的软件是在一个\r
   原样的基础,没有担保或内的任何条件\r
   善良,无论是前preSS或暗示的保证。请参阅许可证\r
   特定语言的管辖权限和限制\r
   在协议规定的。\r
- >\r
<常春藤模块版本=2.0的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema-instance\r
       XSI:no​​NamespaceSchemaLocation =htt​​p://ant.apache.org/ivy/schemas/ivy.xsd>\r
    <信息\r
        组织=\r
        模块=的Lucene-5.0.0\r
        状态=一体化>\r
< /信息>\r
< ivysettings>\r
  <设置defaultResolver =默认/>\r
  \r
  <属性名=本地maven2的-dir的值=$ {}的user.home /平方米/库//>\r
  \r
  <属性文件=$ {} ivy.settings.dir /ivy-versions.properties覆盖=FALSE/>\r
  \r
  <包括URL =$ {} ivy.default.settings.dir /ivysettings-public.xml/>\r
  <包括URL =$ {} ivy.default.settings.dir /ivysettings-shared.xml/>\r
  <包括URL =$ {} ivy.default.settings.dir /ivysettings-local.xml/>\r
  <包括URL =$ {} ivy.default.settings.dir /ivysettings-main-chain.xml/>\r
\r
  <缓存lockStrategy =神器锁resolutionCacheDir =$ {} common.build.dir /常春藤解析缓存/>\r
\r
  <&解析器GT;\r
    < ibiblio上NAME =Sonatype的发行版本的根=htt​​ps://oss.sonatype.org/content/repositories/releasesm2compatible =真/>\r
    < ibiblio上NAME =maven.restlet.org根=htt​​p://maven.restlet.orgm2compatible =真/>\r
    < ibiblio上NAME =releases.cloudera.com根=htt​​p://repository.cloudera.com/content/repositories/releasesm2compatible =真/>\r
    \r
    <! - 只需要更新svnkit的版本,例如1.8.x的 - >\r
    < ibiblio上NAME =svnkit-发布的根=htt​​p://maven.tmatesoft.com/content/repositories/releasesm2compatible =真/>\r
\r
    <! - 您可能需要因此它可以从中国这个调整 - >\r
    < ibiblio上NAME =工薪中国镜根=htt​​p://uk.maven.org/maven2m2compatible =真/>\r
    \r
    <! - \r
    <文件系统的名称=本地的maven-2m2compatible =真正的地方=真>\r
      <神器\r
          模式=$ {本地maven2的-DIR} / [机构] / [模块] / [修改] / [模块] - [修改] [转]。/>\r
      <常春藤\r
          模式=$ {本地maven2的-DIR} / [机构] / [模块] / [修改] / [模块] - [修改] .pom/>\r
    < /文件系统>\r
     - >\r
\r
    <*快照链接名称=默认returnFirst =真checkmodified =真changingPattern =>\r
      <解析器REF =本地/>\r
      <! - <解析器REF =本地的maven-2/> - >\r
      <解析器REF =主/>\r
      <解析器REF =maven.restlet.org/>\r
      <解析器REF =Sonatype的-发布/>\r
      <解析器REF =releases.cloudera.com/>\r
      <! - <解析器REF =svnkit-发布/> - >\r
      <解析器REF =工薪中国镜像/>\r
    < /链>\r
  < /解析器>\r
\r
< / ivysettings>\r
< /常春藤模块>

\r

\r
\r


解决方案

这将如果您使用。如果你安装了它,你需要的IVY运行时添加到项目的构建路径。这可以通过项目属性 - > Libraries选项卡下的Java构建路径来实现,选择添加库,然后选择IvyDE管理的依赖关系。

一旦这样做了,常春藤决心将增加在指定的ivy.xml到项目的构建路径中的所有jar文件。

For example, when I open a well developed opensource project (like lucene) into Eclipse (with both ant build.xml and ivy ivysetting.xml), I can run ant with build.xml to build the whole project successfully.

However, the project is full of errors in a mess of .java classes. This is caused by unlinking to the external jars. These jars are already download by ivy and stored in {user}/.ivy2/cache/. Also, when I manually put each of these jars into the build path of this project, the errors are gone.

Can ivy or ivyDE or some other tools put the jars into the JAVA build path automatically?

Here is the ivy-setting.xml:

<!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.    
-->
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
    <info
        organisation=""
        module="lucene-5.0.0"
        status="integration">
	</info>
<ivysettings>
  <settings defaultResolver="default"/>
  
  <property name="local-maven2-dir" value="${user.home}/.m2/repository/" />
  
  <properties file="${ivy.settings.dir}/ivy-versions.properties" override="false"/>
  
  <include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
  <include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
  <include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
  <include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>

  <caches lockStrategy="artifact-lock" resolutionCacheDir="${common.build.dir}/ivy-resolution-cache" /> 

  <resolvers>
    <ibiblio name="sonatype-releases" root="https://oss.sonatype.org/content/repositories/releases" m2compatible="true" />
    <ibiblio name="maven.restlet.org" root="http://maven.restlet.org" m2compatible="true" />
    <ibiblio name="releases.cloudera.com" root="http://repository.cloudera.com/content/repositories/releases" m2compatible="true" />
    
    <!-- needed only for newer svnkit releases, e.g. 1.8.x -->
    <ibiblio name="svnkit-releases" root="http://maven.tmatesoft.com/content/repositories/releases" m2compatible="true" />

    <!-- you might need to tweak this from china so it works -->
    <ibiblio name="working-chinese-mirror" root="http://uk.maven.org/maven2" m2compatible="true" />
    
    <!--
    <filesystem name="local-maven-2" m2compatible="true" local="true">
      <artifact
          pattern="${local-maven2-dir}/[organisation]/[module]/[revision]/[module]-[revision].[ext]" />
      <ivy
          pattern="${local-maven2-dir}/[organisation]/[module]/[revision]/[module]-[revision].pom" />
    </filesystem>
    -->

    <chain name="default" returnFirst="true" checkmodified="true" changingPattern=".*SNAPSHOT">
      <resolver ref="local"/>
      <!-- <resolver ref="local-maven-2" /> -->
      <resolver ref="main"/>
      <resolver ref="maven.restlet.org" />
      <resolver ref="sonatype-releases" />
      <resolver ref="releases.cloudera.com"/>
      <!-- <resolver ref="svnkit-releases" /> -->
      <resolver ref="working-chinese-mirror" />
    </chain>
  </resolvers>

</ivysettings>
</ivy-module>

解决方案

It would if you use the Ivy Eclipse plugin. If you have it installed, you'll need to add the IVY runtime to the build path of the project. This can be done via Project Properties->Java Build Path under the Libraries tab, select Add Library then select IvyDE Managed Dependencies.

Once that's done, an Ivy resolve will add all the jars specified in ivy.xml to the project's build path.

这篇关于可以常春藤或ivyDE在Eclipse中自动添加相关的罐子到Java构建路径库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 18:25