2011-09-01 3 views
1

ANT를 사용하여 Tomcat에 물건을 배포하고있었습니다. 하지만 필자는 의존성을 잃어 버리는 데 어려움을 겪었고 아이비를 추가하고 싶었습니다. Java, Apache Ivy 문제가있는 Ant 사용

지금 내 build.xml 파일이 추가 : 내 프로젝트에 공통 랭 JAR 파일을 추가하려고이와

<!-- Ivy settings start--> 

    <condition property="ivy.home" value="${env.IVY_HOME}"> 
     <isset property="env.IVY_HOME" /> 
    </condition> 


    <target name="download-ivy" unless="offline"> 
     <mkdir dir="${ivy.jar.dir}"/> 
      <!-- download Ivy from web site so that it can be used even without any special installation --> 
     <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" 
      dest="${ivy.jar.file}" usetimestamp="true"/> 
    </target> 


    <target name="init-ivy" depends="download-ivy"> 
     <!-- try to load ivy here from ivy home, in case the user has not already dropped 
     it into ant's lib dir (note that the latter copy will always take precedence). 
     We will not fail as long as local lib dir exists (it may be empty) and 
     ivy is in at least one of ant's lib dir or the local lib dir. --> 
     <path id="ivy.lib.path"> 
      <fileset dir="${ivy.jar.dir}" includes="*.jar"/> 
     </path> 
     <taskdef resource="org/apache/ivy/ant/antlib.xml" 
     uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> 
    </target> 

    <target name="go" depends="init-ivy" description="--> resolve dependencies, compile and run the project"> 
    <echo message="using ivy to resolve commons-lang 2.1..."/> 
    <!-- 
    here comes the magic line: asks ivy to resolve a dependency on commons-lang 2.1 and to build an ant path with it from its cache 
    --> 
    <ivy:cachepath organisation="commons-lang" module="commons-lang" revision="2.1" pathid="lib.path.id" inline="true"/> 
    </target> 
<!-- Ivy settings end--> 

합니다. 어디 그 JAR 파일 내 프로젝트에 나타나지 않는

1) : 지금 .. 나는 그것이 작동 생각

Buildfile: C:\Users\Jansu\workspace\HelloWorld\build.xml 
build: 
deploywar: 
download-ivy: 
     [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar 
     [get] To: C:\Users\Jansu\.ant\lib\ivy-2.2.0.jar 
     [get] Not modified - so not downloaded 
init-ivy: 
go: 
    [echo] using ivy to resolve commons-lang 2.1... 
[ivy:cachepath] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ :: 
[ivy:cachepath] :: loading settings :: url = jar:file:/C:/Users/Jansu/.ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings.xml 
[ivy:cachepath] :: resolving dependencies :: commons-lang#commons-lang-caller;working 
[ivy:cachepath]  confs: [default, master, compile, provided, runtime, system, sources, javadoc, optional] 
[ivy:cachepath]  found commons-lang#commons-lang;2.1 in public 
[ivy:cachepath] :: resolution report :: resolve 151ms :: artifacts dl 10ms 
    --------------------------------------------------------------------- 
    |     |   modules   || artifacts | 
    |  conf  | number| search|dwnlded|evicted|| number|dwnlded| 
    --------------------------------------------------------------------- 
    |  default  | 1 | 0 | 0 | 0 || 1 | 0 | 
    |  master  | 1 | 0 | 0 | 0 || 1 | 0 | 
    |  compile  | 1 | 0 | 0 | 0 || 0 | 0 | 
    |  provided  | 1 | 0 | 0 | 0 || 0 | 0 | 
    |  runtime  | 1 | 0 | 0 | 0 || 0 | 0 | 
    |  system  | 1 | 0 | 0 | 0 || 0 | 0 | 
    |  sources  | 1 | 0 | 0 | 0 || 1 | 0 | 
    |  javadoc  | 1 | 0 | 0 | 0 || 1 | 0 | 
    |  optional  | 1 | 0 | 0 | 0 || 0 | 0 | 
    --------------------------------------------------------------------- 
BUILD SUCCESSFUL 
Total time: 2 seconds 

2 개 질문 : 이것은 내가 출력으로 무엇을 얻을?

2) 스프링 프레임 워크 파일과 같은 다른 JAR 파일을 어떻게 추가합니까?

+1

Maven 2/3는 처리하기가 훨씬 쉽습니다 ... –

답변

1

이 :

<ivy:cachepath organisation="commons-lang" module="commons-lang" revision="2.1" pathid="lib.path.id" inline="true"/> 
</target> 

inline retrieval라고하고, 단지 프로젝트에 복사되지 않습니다 담쟁이 캐시에서 pathid="lib.path.id"와 개미 경로를 구축 아이비을 알려줍니다. 캐시는 $ {user.home} /. ivy2에 있습니다.

프로젝트에 이슈를 다운로드하려면 retrieve 작업을 사용하고 프로젝트에 ivy.xml을 정의해야합니다.

+0

xml 파일에서 종속성을 선언 할 예정입니다. 아이비를 다운로드해야합니까? – Jaanus

+0

ivy.xml - 아마도 아이비 튜토리얼/빠른 시작이 도움이 될 것입니다 : https://ant.apache.org/ivy/history/latest-milestone/tutorial/start.html – oers

+0

감사합니다 .. 지금 그것은 어떤 종류의 결심자를 찾고 있습니다' commons-lang : commons-lang에 대한 resolver가 없습니다. # commons-lang : 설정을 확인하십시오. @oers – Jaanus

관련 문제