使用 Sharpen java to C#
把java 项目转化为C#项目。
狂搞java 墙角,
前提:
1,下载 Eclipse 或 MyEclipse .其实两个都一样。(我用的版本是 Myeclpse 6.5)
2,安装 Eclipse SVN插件。
好了,我们开始了。
1,先从https://source.db4o.com/db4o/trunk/sharpen 作用SVN检出里边的代码,记住,要把下面的项目作为4个项目分别检出。
2,Export 这4个项目为 “Deployable plug-ins and fragments”,导出的位置为 Eclipse 的根目录,如果是Myeclipse 也是导出到 Eclpse 根目录 。
3,对了, 这4个项目要跟你的项目放在同一个工作区里,后面会用到的。(放在其它的位置我没有试过)。
4,在你将要进行转化的项目里写上加上下面的两个文件
文件1:
sharpen.properties
# eclipse workspace
dir.workspace=C\:/Documents and Settings/Administrator/\u684C\u9762/paoding
# java executable
file.jvm.jdk1.5=D\:/Java/jdk1.5.0/bin/java.exe
# Eclipse home directory
eclipse.home=D\:/Java/MyEclipse 6.5/eclipse
# Eclipse startup jar
eclipse.startup.jar=${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.0.0.v20070606.jar
# Sandcastle can be used to convert javadoc to .NET xml comments
# dir.lib.sandcastle=e:/sandcastle/
# sharpen compile directory
dir.dist.classes.sharp=dist/sharpen
# Eclipse plugins home
plugins.home=${eclipse.home}/plugins
#上面的路径要改成你的系统中的相应的位置
文件2:
Sharpen-Common.Xml
<project name="sharpen common">
<property file="sharpen.properties" />
<macrodef name="reset-dir">
<attribute name="dir" />
<sequential>
<delete dir="@{dir}" />
<mkdir dir="@{dir}" />
</sequential>
</macrodef>
<macrodef name="sharpen">
<attribute name="workspace" />
<attribute name="resource" />
<element name="args" optional="yes" />
<sequential>
<exec executable="${file.jvm.jdk1.5}" failonerror="true"
timeout="1800000">
<arg value="-Xms256m" />
<arg value="-Xmx512m" />
<arg value="-cp" />
<arg value="${eclipse.startup.jar}" />
<arg value="org.eclipse.core.launcher.Main" />
<arg value="-data" />
<arg file="@{workspace}" />
<arg value="-application" />
<arg value="sharpen.core.application" />
<arg value="-header" />
<arg file="config/copyright_comment.txt" />
<arg value="@{resource}" />
<args />
</exec>
</sequential>
</macrodef>
<target name="install-sharpen-plugin">
<property name="sharpen.core.dir" location="../sharpen.core" />
<reset-dir dir="${dir.dist.classes.sharp}" />
<echo>${eclipse.home}/plugins</echo>
<javac fork="true" debug="true" target="1.5" source="1.5"
destdir="${dir.dist.classes.sharp}" srcdir="${sharpen.core.dir}/src"
encoding="UTF-8">
<classpath>
<fileset dir="${eclipse.home}/plugins">
<include name="org.eclipse.osgi_*/osgi.jar" />
<include
name="org.eclipse.core.resources_*/resources.jar" />
<include
name="org.eclipse.core.runtime_*/runtime.jar" />
<include name="org.eclipse.jdt.core_*/jdtcore.jar" />
<!-- redundant entries: in newer eclipse installs those reside in jars -->
<include name="org.eclipse.osgi_*.jar" />
<include name="org.eclipse.core.resources_*.jar" />
<include name="org.eclipse.core.runtime_*.jar" />
<include name="org.eclipse.jdt.core_*.jar" />
<include name="org.eclipse.jdt.launching_*.jar" />
<include name="org.eclipse.equinox.*.jar" />
<include name="org.eclipse.core.jobs_*.jar" />
</fileset>
</classpath>
</javac>
<property name="plugin.dir"
value="${plugins.home}/sharpen.core_1.0.0" />
<reset-dir dir="${plugin.dir}" />
<jar destfile="${plugin.dir}/sharpen.jar"
basedir="${dir.dist.classes.sharp}" />
<copy todir="${plugin.dir}"
file="${sharpen.core.dir}/plugin.xml" />
</target>
</project>
下面加两个图说明一下问题吧。
项目结构:
生成时选项:
其它的也没什么说的了。
参考: http://developer.db4o.com/Resources/view.aspx/Reference/Sharpen/How_To_Setup_Sharpen#