any+ivy的使用

2 篇文章 0 订阅
2 篇文章 0 订阅
javapro-用ivy编译版本.rar文件时示例代码。

ivysettings.xml文件代码如下:

<ivysettings>
<settings defaultResolver="default"/>
<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"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
</ivysettings>


ivy.xml文件代码如下:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
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="com.shihuan"
module="shihuanjava"
status="integration">
</info>

<dependencies>
<dependency org="log4j" name="log4j" rev="1.2.17" conf="default"></dependency>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.4" conf="default" />
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.6.4" conf="default" />
<dependency org="commons-lang" name="commons-lang" rev="2.6" conf="default" />
<dependency org="com.cloudhopper.proxool" name="proxool" rev="0.9.1" conf="default">
<exclude org="javax.servlet" name="servlet-api" module="servlet-api" conf="default" />
<exclude org="avalon-framework" name="avalon-framework-api" module="avalon-framework-api" conf="default" />
<exclude org="avalon-logkit" name="avalon-logkit" module="avalon-logkit" matcher="exactOrRegexp" conf="default" />
<exclude org="geronimo-spec" name="geronimo-spec-jms" module="geronimo-spec-jms" matcher="exactOrRegexp" conf="default" />
<exclude org="geronimo-spec" name="geronimo-spec-javamail" module="geronimo-spec-javamail" matcher="exactOrRegexp" conf="default" />
<exclude org="com.cloudhopper.proxool" name="proxool-cglib" module="proxool-cglib" matcher="exactOrRegexp" conf="default"></exclude>
</dependency>
<dependency org="mysql" name="mysql-connector-java" rev="5.1.34" conf="default" />
</dependencies>

</ivy-module>


build.xml文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" basedir="." name="TestJavaCl" default="genericjar">

<property name="publish.version" value="0.1" />
<property name="ivy.report.todir" value="build" />
<property name="repository.dir" value="F:/antlvy/ivycatchjars/cache" />

<target name="resolve">
<ivy:configure file="ivysettings.xml" />
<property name="ivy.default.ivy.user.dir" value="F:/antlvy/ivycatchjars/cache"/>
<ivy:resolve file="ivy.xml" conf="default" />
<ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]" />
<ivy:report />
</target>

<path id="lib-classpath">
<fileset dir="${basedir}/lib/default">
<include name="**/*.jar"/>
<exclude name="**/*.bak"/>
</fileset>
</path>

<target name="clean">
<delete dir="${basedir}/bin" />
<delete dir="${basedir}/dist" />
</target>

<target name="init" description="设置初始化打war包需要的路径变量">
<property name="name" value="TestJavaCl"/>
<property name="src" value="${basedir}/src"/>
<property name="resources" value="${basedir}/resources"/>
<property name="packages" value="com.*"/>

<property name="build.class" value="${basedir}/bin"/>
<property name="build.javadocs" value="${basedir}/dist/doc"/>
<property name="jar.dest" value="${basedir}/dist/jar"/>
<property name="mainclass" value="com.shihuan.test.TestUrlClassLoader"/>

<property name="build.encoding" value="utf-8"/>
<property name="year" value="2014"/>
<property name="version" value="1.0.0"/>

<echo message="----------- ${name} ${version} [${year}] ------------" />
<echo message="----------- ${src} ------------" />
<echo message="----------- ${resources} ------------" />
<echo message="----------- ${build.class} ------------" />
<echo message="----------- ${build.javadocs} ------------" />
<echo message="----------- ${jar.dest} ------------" />

<patternset id="ignored.files">
<exclude name="**/.svn/**" />
</patternset>

<filter token="year" value="${year}" />
<filter token="version" value="${version}" />
<filter token="date" value="${TODAY}" />
<filter token="log" value="true" />
<filter token="verbose" value="true" />
</target>

<target name="prepare" depends="clean,init" description="创建打包需要的路径,拷贝源文件到打包路径下">
<tstamp/>
<mkdir dir="${build.class}"/>
<mkdir dir="${jar.dest}"/>
</target>

<target name="compile" depends="prepare,resolve">
<javac encoding="${build.encoding}" srcdir="${src}" destdir="${build.class}" includeantruntime="false" source="1.6" debug="yes" verbose="yes" failonerror="true" optimize="false">
<compilerarg line="-encoding UTF-8"/>
<classpath refid="lib-classpath" />
</javac>
<copy todir="${build.class}">
<fileset dir="${resources}">
<include name="**/*.properties"/>
<include name="**/*.xml"/>
<exclude name="**/*.bak"/>
</fileset>
</copy>
</target>

<target name="antjar" depends="compile">
<!--Create a property containing all .jar files,
prefix lib/, and seperated with a space-->
<pathconvert property="mf.classpath" pathsep=" ">
<mapper>
<chainedmapper>
<!-- jar包文件只留文件名,去掉目录信息 -->
<flattenmapper/>
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/default/*"/>
</chainedmapper>
</mapper>
<path refid="lib-classpath"/>
</pathconvert>
<jar destfile="${jar.dest}/myapp-${DSTAMP}.jar" basedir="${build.class}">
<manifest>
<attribute name="Main-class" value="${mainclass}"/>
<attribute name="Class-Path" value="${mf.classpath}"/>
</manifest>
</jar>
</target>

<target name="genericjar" depends="antjar"></target>

</project>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值