我正在学习java spring批处理,我正在尝试获取librairies,在教程中我只看到使用maven2获取librairies但我只有ant(我不能得到maven或gradle)所以我该如何为依赖? 我必须创建一个pom.xml然后?
I'm learning java spring batch and I'm trying to get librairies, on tutorials I only see getting librairies with maven2 but I only have ant (I can't get maven or gradle) so how can I do for the dependencies? I have to create an pom.xml and then?
最满意答案
Apache ivy是一个让你的ANT构建Maven超级功能的插件:-)
以下是将填充“lib”目录的检索任务的示例。
<ivy:retrieve pattern="${lib.dir}/[artifact]-[revision](-[classifier]).[ext]"> <dependency org="org.springframework.batch" name="spring-batch-core" rev="3.0.7.RELEASE" conf="default"/> </ivy:retrieve>或者,您可以在单独的ivy.xml文件中指定项目的依赖关系。
例
充分的工作例子。
├── build.xml └── lib ├── aopalliance-1.0.jar ├── com.ibm.jbatch-tck-spi-1.0.jar ├── commons-logging-1.1.3.jar ├── javax.batch-api-1.0.jar ├── jettison-1.2.jar ├── spring-aop-4.0.5.RELEASE.jar ├── spring-batch-core-3.0.7.RELEASE.jar ├── spring-batch-infrastructure-3.0.7.RELEASE.jar ├── spring-beans-4.0.5.RELEASE.jar ├── spring-context-4.0.5.RELEASE.jar ├── spring-core-4.0.5.RELEASE.jar ├── spring-expression-4.0.5.RELEASE.jar ├── spring-retry-1.1.0.RELEASE.jar ├── spring-tx-4.0.5.RELEASE.jar ├── xmlpull-1.1.3.1.jar ├── xpp3_min-1.1.4c.jar └── xstream-1.4.7.jarbuild.xml文件
<project name="demo" default="compile" xmlns:ivy="antlib:org.apache.ivy.ant"> <!-- ================ Build properties ================ --> <property name="src.dir" location="src/main/java"/> <property name="resources.dir" location="src/main/resources"/> <property name="test.src.dir" location="src/test/java"/> <property name="build.dir" location="build"/> <property name="lib.dir" location="lib"/> <property name="dist.dir" location="${build.dir}/dist"/> <property name="jar.main.class" value="org.demo.App"/> <property name="jar.file" value="${dist.dir}/${ant.project.name}.jar"/> <available classname="org.apache.ivy.Main" property="ivy.installed"/> <!-- =============== Compile targets =============== --> <target name="resolve" depends="install-ivy"> <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision](-[classifier]).[ext]"> <dependency org="org.springframework.batch" name="spring-batch-core" rev="3.0.7.RELEASE" conf="default"/> </ivy:retrieve> </target> <target name="compile" depends="resolve"> </target> <!-- =========== Install ivy =========== --> <target name="install-ivy" unless="ivy.installed"> <mkdir dir="${user.home}/.ant/lib"/> <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/> <fail message="Ivy has been installed. Run the build again"/> </target> <!-- ============= Clean targets ============= --> <target name="clean"> <delete dir="${build.dir}"/> <delete dir="${lib.dir}"/> </target> <target name="clean-all" depends="clean"> <ivy:cleancache/> </target> </project>笔记:
有一个目标,如果它是missng,将安装常春藤 还有一个目标可以选择清除常春藤的下载缓存。Apache ivy is a plugin that gives your ANT build Maven superpowers :-)
The following is an example of the retrieve task that will populate a "lib" directory.
<ivy:retrieve pattern="${lib.dir}/[artifact]-[revision](-[classifier]).[ext]"> <dependency org="org.springframework.batch" name="spring-batch-core" rev="3.0.7.RELEASE" conf="default"/> </ivy:retrieve>Alternatively you can specify your project's dependencies in a separate ivy.xml file.
Example
Full working example.
├── build.xml └── lib ├── aopalliance-1.0.jar ├── com.ibm.jbatch-tck-spi-1.0.jar ├── commons-logging-1.1.3.jar ├── javax.batch-api-1.0.jar ├── jettison-1.2.jar ├── spring-aop-4.0.5.RELEASE.jar ├── spring-batch-core-3.0.7.RELEASE.jar ├── spring-batch-infrastructure-3.0.7.RELEASE.jar ├── spring-beans-4.0.5.RELEASE.jar ├── spring-context-4.0.5.RELEASE.jar ├── spring-core-4.0.5.RELEASE.jar ├── spring-expression-4.0.5.RELEASE.jar ├── spring-retry-1.1.0.RELEASE.jar ├── spring-tx-4.0.5.RELEASE.jar ├── xmlpull-1.1.3.1.jar ├── xpp3_min-1.1.4c.jar └── xstream-1.4.7.jarbuild.xml
<project name="demo" default="compile" xmlns:ivy="antlib:org.apache.ivy.ant"> <!-- ================ Build properties ================ --> <property name="src.dir" location="src/main/java"/> <property name="resources.dir" location="src/main/resources"/> <property name="test.src.dir" location="src/test/java"/> <property name="build.dir" location="build"/> <property name="lib.dir" location="lib"/> <property name="dist.dir" location="${build.dir}/dist"/> <property name="jar.main.class" value="org.demo.App"/> <property name="jar.file" value="${dist.dir}/${ant.project.name}.jar"/> <available classname="org.apache.ivy.Main" property="ivy.installed"/> <!-- =============== Compile targets =============== --> <target name="resolve" depends="install-ivy"> <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision](-[classifier]).[ext]"> <dependency org="org.springframework.batch" name="spring-batch-core" rev="3.0.7.RELEASE" conf="default"/> </ivy:retrieve> </target> <target name="compile" depends="resolve"> </target> <!-- =========== Install ivy =========== --> <target name="install-ivy" unless="ivy.installed"> <mkdir dir="${user.home}/.ant/lib"/> <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar"/> <fail message="Ivy has been installed. Run the build again"/> </target> <!-- ============= Clean targets ============= --> <target name="clean"> <delete dir="${build.dir}"/> <delete dir="${lib.dir}"/> </target> <target name="clean-all" depends="clean"> <ivy:cleancache/> </target> </project>Notes:
There is a target that will install ivy if it's missng There is also a target that will optionally purge ivy's download cache.更多推荐
发布评论