当前位置: 首页 > 知识库问答 >
问题:

疯狂地使用IVY,IVY不检索编译配置

酆英达
2023-03-14

希望有人能帮助我。我有一个多项目配置,我想检索当前项目本地文件夹中的所有conf="compile"依赖项。所以我的ivy.xml如下所示:

   <configurations>
      <conf name="default" description="runtime dependencies and master artifact can be used with this conf" />
      <conf name="master"
         description="contains only the artifact published by this module itself, with no transitive dependencies. E.g. The projects jar itself" />
      <conf name="compile"
         description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths. E.g. commons-lang" />
      <conf name="provided"
         description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive. E.g. Servlet APIs" />
      <conf name="runtime"
         description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath. E.g. An AOP runtime library" />
      <conf name="test" extends="compile"
         description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. E.g. JUnit" />
      <conf name="system"
         description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository. E.g. ??" />
      <conf name="sources" description="this configuration contains the source artifact of this module, if any. E.g. Source for the project" />
      <conf name="javadoc" description="this configuration contains the javadoc artifact of this module, if any. E.g. JavaDoc for the project" />
      <conf name="optional" description="contains all optional dependencies. E.g. Anything optional" />

      <conf name="javascript" description="JS dependencies" />
   </configurations>
   <dependencies>
      <!-- commons deps -->
      <dependency org="org.apache.commons" name="commons-lang3" rev="3.1" conf="compile->default" />
      <dependency org="commons-io" name="commons-io" rev="2.4" conf="compile->default" />
      <dependency org="commons-collections" name="commons-collections" rev="]3.2,4.0[" conf="compile->default" />
      <dependency org="commons-fileupload" name="commons-fileupload" rev="1.3" conf="compile->default" />
   </dependencies>

我的 ANT 文件看起来像这样:

<project name="core-utils" default="default" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:antcontrib="antlib:net.sf.antcontrib">
   <description>
        core-utils tasks
   </description>

   <!-- ant creates for every build file a property named ant.file.${ant.project.name}, e.g. ant.file.common-paths -->
   <dirname property="basedir.core-utils" file="${ant.file.core-utils}" />

   <!-- workspace directory -->
   <property name="dir.workspace" location="${basedir.core-utils}/../" />

   <!-- import the needed files -->
   <import file="${dir.workspace}/dev-environment/build-common-paths.xml" />
   <import file="${dir.workspace}/dev-environment/build-common-antExtensions.xml" />

   <antcontrib:var name="dir.current.project" value="${basedir.core-utils}" />
   <antcontrib:var name="file.ivy.xml" value="${dir.current.project}/ivy.xml"/>


   <!-- ================================= 
          target: default              
         ================================= -->
   <target name="default" depends="init, compile" description="Default target for this project">
   </target>

   <!-- - - - - - - - - - - - - - - - - - 
          target: init                      
         - - - - - - - - - - - - - - - - - -->
   <target name="init">
      <echo>dir.workspace=${dir.workspace}</echo>
      <echo>processing ANT project ${ant.project.name}</echo>
      <echo>dir.current.project=${dir.current.project}</echo>
      <echo>file.ivy.xml=${file.ivy.xml}</echo>
   </target>

   <!-- - - - - - - - - - - - - - - - - - 
          target: resolve
         - - - - - - - - - - - - - - - - - -->
   <target name="resolve">
      <ivy:resolve file="${file.ivy.xml}" checkifchanged="true" />
   </target>

   <!-- - - - - - - - - - - - - - - - - - 
          target: retrieve                      
         - - - - - - - - - - - - - - - - - -->
   <target name="retrieve" depends="resolve">
      <retrieve ivyConfigs="compile" projectRootDir="${dir.current.project}" projectBuildType="${build.artefact.type}" projectParentEarRootDir="${dir.prj.java.my-ear}" />
   </target>


   <!-- ================================= 
          target: ivy-default
         ================================= -->
   <target name="ivy-default" depends="init-common-antExtensions" description="IVY default target for this project">
      <!-- the resulting artefact type, could be WAR, EAR, UTILJAR, RUNTIME -->
      <property name="build.artefact.type" value="UTILJAR" />

      <checkIvyInitialized projectrootdir="${dir.current.project}" />

      <ivy:settings file="${dir.prj.common.devenv}/ivysettings.xml" />
      <antcall target="retrieve" inheritall="true" inheritrefs="true" />
   </target>

   <!-- ================================= 
          target: compile              
         ================================= -->
   <target name="compile" depends="ivy-default" description="compile the project">
      <ivy:resolve conf="compile,test" file="${file.ivy.xml}" checkifchanged="true" refresh="true"/>

      <!-- folder is missing -->
      <mkdir dir="${dir.current.project}/target/ivy" />

      <mkdir dir="${dir.current.project}/target/ivy/compile" />
      <ivy:retrieve conf="compile" refresh="true" file="${file.ivy.xml}" pattern="${dir.current.project}/target/compile/[artifact]-[revision].[ext]" sync="false" overwriteMode="always" />

      <mkdir dir="${dir.current.project}/target/ivy/test" />
      <ivy:retrieve conf="test" file="${file.ivy.xml}" pattern="${dir.current.project}/target/ivy/test/[artifact]-[revision].[ext]" sync="false" overwriteMode="always" />

      <mkdir dir="${dir.current.project}/target/classes" />
      <javac srcdir="${dir.current.project}/src/main/java" destdir="${dir.current.project}/target/classes" debug="on" compiler="javac1.7" source="1.7" target="1.7" fork="true" includeantruntime="no">
         <classpath>
            <fileset dir="${dir.current.project}/target/ivy/compile">
               <include name="*" />
            </fileset>
         </classpath>
      </javac>

      <mkdir dir="${dir.current.project}/target/test-classes" />
      <javac srcdir="${dir.current.project}/src/test/java" destdir="${dir.current.project}/target/test-classes" debug="on" compiler="javac1.7" source="1.7" target="1.7" fork="true" includeantruntime="no">
         <classpath>
            <fileset dir="${dir.current.project}/target/ivy/test">
               <include name="*" />
            </fileset>
         </classpath>
      </javac>
   </target>


</project>

IVY正确地解决了工件,但是复制/检索工作不正常。我不知道出了什么问题。

compile:
     [echo] file.ivy.xml=/mnt/data/00_Synchronized/XenoRealEstate/trunk/Projects/RealEstateDueDiligence/core-utils/ivy.xml
[ivy:retrieve] :: resolving dependencies :: org.xenovation#core-utils;working@ntb-dp
[ivy:retrieve]  confs: [compile]
[ivy:retrieve]  found org.apache.commons#commons-lang3;3.1 in central
[ivy:retrieve]  found commons-io#commons-io;2.4 in central
[ivy:retrieve]  found commons-collections#commons-collections;3.2.1 in central
[ivy:retrieve]  [3.2.1] commons-collections#commons-collections;]3.2,4.0[
[ivy:retrieve]  found commons-fileupload#commons-fileupload;1.3 in central
[ivy:retrieve]  found ch.qos.logback#logback-classic;1.1.2 in central
[ivy:retrieve]  [1.1.2] ch.qos.logback#logback-classic;]1.0,2.0[
[ivy:retrieve]  found ch.qos.logback#logback-core;1.1.2 in central
[ivy:retrieve]  found org.slf4j#slf4j-api;1.7.6 in central
[ivy:retrieve]  found ch.qos.logback#logback-access;1.1.2 in central
[ivy:retrieve]  [1.1.2] ch.qos.logback#logback-access;]1.0,2.0[
[ivy:retrieve]  found org.apache.httpcomponents#httpclient;4.3.1 in central
[ivy:retrieve]  found org.apache.httpcomponents#httpcore;4.3 in central
[ivy:retrieve]  found commons-logging#commons-logging;1.1.3 in central
[ivy:retrieve]  found commons-codec#commons-codec;1.6 in central
[ivy:retrieve]  found org.jsefa#jsefa;0.9.3.RELEASE in central
[ivy:retrieve]  found xmlpull#xmlpull;1.1.2.1 in central
[ivy:retrieve]  found org.json#json;20131018 in central
[ivy:retrieve]  found org.wildfly#wildfly-spec-api;8.0.0.Final in central
[ivy:retrieve]  found org.glassfish#javax.json;1.0.3 in central
[ivy:retrieve]  found org.jboss.resteasy#jaxrs-api;3.0.6.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.batch#jboss-batch-api_1.0_spec;1.0.0.Final in central
[ivy:retrieve]  found javax.inject#javax.inject;1 in central
[ivy:retrieve]  found javax.enterprise#cdi-api;1.1 in central
[ivy:retrieve]  found javax.el#el-api;2.2 in central
[ivy:retrieve]  found org.jboss.spec.javax.interceptor#jboss-interceptors-api_1.1_spec;1.0.0.Beta1 in central
[ivy:retrieve]  found javax.annotation#jsr250-api;1.0 in central
[ivy:retrieve]  found org.jboss.spec.javax.ejb#jboss-ejb-api_3.2_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.el#jboss-el-api_3.0_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.enterprise.concurrent#jboss-concurrency-api_1.0_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.faces#jboss-jsf-api_2.2_spec;2.2.5 in central
[ivy:retrieve]  found org.jboss.spec.javax.interceptor#jboss-interceptors-api_1.2_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.jms#jboss-jms-api_2.0_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.resource#jboss-connector-api_1.7_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.security.auth.message#jboss-jaspi-api_1.1_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.security.jacc#jboss-jacc-api_1.5_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.servlet#jboss-servlet-api_3.1_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.servlet.jsp#jboss-jsp-api_2.3_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.servlet.jstl#jboss-jstl-api_1.2_spec;1.0.4.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.transaction#jboss-transaction-api_1.2_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.websocket#jboss-websocket-api_1.0_spec;1.0.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.xml.bind#jboss-jaxb-api_2.2_spec;1.0.4.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.xml.rpc#jboss-jaxrpc-api_1.1_spec;1.0.1.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.xml.soap#jboss-saaj-api_1.3_spec;1.0.3.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.xml.ws#jboss-jaxws-api_2.2_spec;2.0.2.Final in central
[ivy:retrieve]  found org.hibernate.javax.persistence#hibernate-jpa-2.1-api;1.0.0.Final in central
[ivy:retrieve]  found org.osgi#org.osgi.core;5.0.0 in central
[ivy:retrieve]  found com.sun.mail#javax.mail;1.5.1 in central
[ivy:retrieve]  found javax.activation#activation;1.1.1 in central
[ivy:retrieve]  found org.jboss.spec.javax.annotation#jboss-annotations-api_1.2_spec;1.0.0.Final in central
[ivy:retrieve]  found javax.validation#validation-api;1.1.0.Final in central
[ivy:retrieve]  found org.jboss.spec.javax.management.j2ee#jboss-j2eemgmt-api_1.1_spec;1.0.1.Final in central
[ivy:retrieve]  found org.wildfly#wildfly-build-config;8.0.0.Final in central
[ivy:retrieve] :: resolution report :: resolve 24549ms :: artifacts dl 82ms
[ivy:retrieve]  :: evicted modules:
[ivy:retrieve]  commons-io#commons-io;2.2 by [commons-io#commons-io;2.4] in [compile]
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      compile     |   51  |   3   |   0   |   1   ||   49  |   0   |
    ---------------------------------------------------------------------
[ivy:retrieve] :: retrieving :: org.xenovation#build
[ivy:retrieve]  confs: [compile]
[ivy:retrieve]  0 artifacts copied, 0 already retrieved (0kB/5ms)

有人能帮我,告诉我我做错了什么吗?

共有1个答案

淳于涛
2023-03-14

不清楚“复制/检索无法正常工作”是什么意思

你的设置似乎过于复杂。这里有一个例子,希望它有助于阐明ivy配置的用法:

  • 如何避免使用Ivy复制依赖项
 类似资料:
  • 更新 我想只排除本地项目,但仍然检索它们的传递依赖关系。我需要在Eclipse之外复制IvyDE工作区解析器的行为。 例 null null null

  • 我从Gradle得到以下错误 这是我的建筑Gradle 调试运行表明它试图用Ivy而不是Maven解决依赖关系?

  • ivy-ui是一个符合 Web Components 规范的由浏览器原生支持的现代 web 组件库。 目标: 高颜值 可访问性(aria-) 通用性/易用性 跨框架。无论是react、vue还是原生项目均可使用 特性 跨框架。无论是react、vue还是原生项目均可使用。 组件化。shadow dom真正意义上实现了样式和功能的组件化。 类原生。一个组件就像一个原生标签一样。 无依赖。纯原生,无需

  • Apache Ivy是一个优秀的管理(记录、跟踪、解析和报告)项目依赖的工具,可与Apache Ant紧密集成。

  • 我必须编写一个二进制搜索树的实现,它可以处理库的库存。它读取一个包含所有书籍的文本文件,并将这些书籍按字母顺序添加到树中。我已经与Insertar()函数代码斗争了几天,但我无法使它正常工作,它基本上接收到一个指针,指向与书相关的所有数据的树根。如果根为NULL,则它将函数中输入的所有值初始化一个节点,并将内存方向指定为NULL节点。问题是,它在本地做,最终它没有分配它。谁能帮我纠正那个具体的功能

  • 问题内容: 我有一个使用netbeans开发的现有项目,我想将Apache Ivy集成到该项目中。我更新了由netbeans生成的build.xml,以下载ivy(如果需要的话)并使用它来检索依赖项。 有谁知道我如何将下载的依赖项添加到项目的构建路径中,以便可以正常编译,并且不会在界面中显示丢失的库错误。 如果可能的话,我宁愿不使用netbeans插件就这样做。如果没有,您建议使用什么插件。 编辑