Equinox p2 供应框架
2009-12-22 00:00:00 来源:WEB开发网要更新一个现有的更新站点以适用于 Equinox/p2,从这个更新站点的 base 目录运行清单 4 内所示的 Ant 脚本。此脚本对于按条件循环(<for>)并运行(<if>)的任务需要用到 ant-contrib 项目。
清单 4. 能够让您的当前更新站点适用于 Equinox/p2 的 Ant 文件<?xml version="1.0" encoding="utf-8" ?>
<project name="siteUpdater" default="update-site">
<property name="site.name" value="My Site" />
<property name="site.dir" value="/home/nathan/public_html/subclipse" />
<property name="eclipse.home" value="/home/nathan/eclipse" />
<!-- You may have to update this to the newest launcher -->
<property name="launcher.jar"
value="${eclipse.home}/plugins/org.eclipse.equinox.launcher_(version).jar" />
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/opt/ant-contrib/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
<target name="assert-env">
<available property="eclipse.dir.valid" file="${eclipse.home}"
type="dir" />
<fail unless="eclipse.dir.valid"
message="Could not find Eclipse home directory [${eclipse.home}]." />
<available property="launcher.valid" file="${launcher.jar}" type="file" />
<fail unless="launcher.valid"
message="Could not find launcher [${launcher.jar}]." />
</target>
<!-- Updates the site.xml file with new attributes, if they're missing -->
<!-- Note: this is a very basic update based on search/replace. If your site.xml
has attributes for the site element already, perhaps optional xml update tasks
would be a better fit (or manual update).
-->
<target name="update-xml">
<replace file="${site.dir}/site.xml">
<replacetoken><![CDATA[<site>]]></replacetoken>
<!-- Make sure to update the digestURL to your correct URL -->
<replacevalue><![CDATA[<site pack200="true" digestURL="">]]>
</replacevalue>
</replace>
</target>
<target name="update-features">
<echo message="Updating file ${dest}..." />
<touch file="${touch.file}" />
<jar destfile="${dest}" basedir="${src.dir}" update="true" />
</target>
<target name="verify-features">
<for param="file">
<path>
<fileset dir="${site.dir}/features">
<include name="**/*.jar" />
</fileset>
</path>
<sequential>
<echo message="Checking file @{file}..." />
<mkdir dir="${java.io.tmpdir}/${ant.project.name}/@{file}" />
<unjar dest="${java.io.tmpdir}/${ant.project.name}@{file}"
src="@{file}" />
<if>
<not>
<available file="${java.io.tmpdir}/${ant.project.name}@{file}/feature.properties"/>
</not>
<then>
<antcall target="update-features">
<param value="${feature.present}" name="file.exists" />
<param value="${java.io.tmpdir}/${ant.project.name}@{file}/feature.properties"
name="touch.file" />
<param value="${java.io.tmpdir}/${ant.project.name}@{file}" name="src.dir" />
<param value="@{file}" name="dest" />
</antcall>
</then>
</if>
<delete dir="${java.io.tmpdir}/${ant.project.name}@{file}" />
</sequential>
</for>
</target>
<target name="gen-pack-gz">
<echo message="Processing file [${plugin.file}]" />
<java jar="${launcher.jar}" fork="true">
<arg line="-application org.eclipse.update.core.siteOptimizer" />
<arg line="-jarProcessor -verbose -processAll -repack -outputDir ${site.dir}/plugins"
/>
<arg line="${plugin.file}" />
</java>
</target>
<target name="gen-pack-gz-files">
<for param="file">
<path>
<fileset dir="${site.dir}/plugins">
<include name="**/*.jar" />
</fileset>
</path>
<sequential>
<antcall target="gen-pack-gz">
<param name="plugin.file" value="@{file}" />
</antcall>
</sequential>
</for>
<echo message="Optimizing jar files" />
<java jar="${launcher.jar}" fork="true">
<arg line="-application org.eclipse.update.core.siteOptimizer" />
<arg line="-digestBuilder" />
<arg line="-digestOutputDir=${site.dir}" />
<arg line="-siteXML=${site.dir}/site.xml" />
<arg line="-jarProcessor -verbose -pack -outputDir ${site.dir} ${site.dir}" />
</java>
</target>
<target name="create-digest">
<java jar="${launcher.jar}" fork="true">
<arg line="-application org.eclipse.equinox.p2.metadata.generator.EclipseGenerator"
/>
<arg line="-updateSite ${site.dir}" />
<arg line="-site file:${site.dir}/site.xml" />
<arg line="-metadataRepository file:${site.dir}" />
<arg line="-metadataRepositoryName "${site.name} Update Site"" />
<arg line="-artifactRepository file:${site.dir}" />
<arg line="-artifactRepositoryName "${site.name} Artifacts"" />
<arg line="-compress" />
<arg line="-reusePack200Files" />
<arg line="-noDefaultUIs" />
<jvmarg line="-Xmx256M" />
</java>
</target>
<target name="update-site"
depends="assert-env,update-xml,verify-features,gen-pack-gz-files,create-digest" />
</project>
更多精彩
赞助商链接