如何使用ant开始使用spring批处理?(How to getting started with spring batch using ant?)

编程入门 行业动态 更新时间:2024-10-28 18:31:46
如何使用ant开始使用spring批处理?(How to getting started with spring batch using ant?)

我正在学习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.jar

build.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.jar

build.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.

更多推荐

本文发布于:2023-08-07 19:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:批处理   如何使用   ant   spring   started

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!