java格式化打印小票_独立的Java代码格式化器/美化器/漂亮的打印机?

更新:根据我的新理解,基于我提交的不正确的错误报告: https ://bugs.eclipse.org/bugs/show_bug.cgi ? id = 325289 OpenMRSFormatter.xml文件实际上必须是首选项文件,而不是XML文件。

你可以在这里find这样的文件: https : //bugs.eclipse.org/bugs/attachment.cgi?id = 178874

或者将任何XML导出的格式化文件转换为:cat formatter.xml | grep设置| sed's / @@'> formatter.asprefs

谢谢Misha

这是我使用Eclipse 3.6 jar制作的东西。 它是仅限于Java的命令行,并且应该跨平台兼容:

有一个使用捆绑的OpenMRSCodeFormatter.xml文件的shell脚本。 示例输出:

misha@misha-d630:~/openmrs-code-formatter$ cat ../Test.java public class Test { public a() { System.out.println("! I did not format this right!"); } }misha@misha-d630:~/openmrs-code-formatter$ ./format.sh ../Test.java Configuration Name: OpenMRSFormatter.xml Starting format job ... Done. cat ../misha@misha-d630:~/openmrs-code-formatter$ cat ../Test.java public class Test { public a() { System.out.println("! I did not format this right!"); } }misha@misha-d630:~/openmrs-code-formatter$

这是基于这里的post: http : //www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/

因为我不知道这个链接会持续多久,所以我会介绍下面的内容。

这是基于Eclipse 3.6 Helios分发。 我使用的是Linux x86,但它应该适用于任何版本,因为我没有使用任何(据我所知)特定于平台的JAR文件。

tar档案的内容是:

misha@misha-d630:~$ tar tvjf openmrs-code-formatter.tar.bz2 | sort tar: Record size = 8 blocks drwxr-xr-x misha/misha 0 2010-09-11 19:32 openmrs-code-formatter/plugins/ drwxr-xr-x misha/misha 0 2010-09-11 19:33 openmrs-code-formatter/configuration/org.eclipse.equinox.simpleconfigurator/ drwxr-xr-x misha/misha 0 2010-09-11 19:38 openmrs-code-formatter/configuration/ -rw-r--r-- misha/misha 101957 2010-09-11 19:03 openmrs-code-formatter/plugins/org.eclipse.equinox.common_3.6.0.v20100503.jar -rw-r--r-- misha/misha 107210 2010-09-11 19:32 openmrs-code-formatter/plugins/org.eclipse.core.commands_3.6.0.I20100512-1500.jar -rw-r--r-- misha/misha 111098 2010-09-11 19:06 openmrs-code-formatter/plugins/org.eclipse.equinox.preferences_3.3.0.v20100503.jar -rw-r--r-- misha/misha 1147220 2010-09-11 18:45 openmrs-code-formatter/plugins/org.eclipse.osgi_3.6.0.v20100517.jar -rw-r--r-- misha/misha 1812 2010-09-11 19:33 openmrs-code-formatter/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info -rw-r--r-- misha/misha 182596 2010-09-11 19:05 openmrs-code-formatter/plugins/org.eclipse.equinox.registry_3.5.0.v20100503.jar -rw-r--r-- misha/misha 248071 2010-09-11 19:29 openmrs-code-formatter/plugins/org.eclipse.text_3.5.0.v20100601-1300.jar -rw-r--r-- misha/misha 265 2010-09-11 19:21 openmrs-code-formatter/configuration/config.ini -rw-r--r-- misha/misha 28554 2010-09-11 19:34 openmrs-code-formatter/OpenMRSFormatter.xml -rw-r--r-- misha/misha 39331 2010-09-11 19:17 openmrs-code-formatter/plugins/org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503.jar -rw-r--r-- misha/misha 4504121 2010-09-11 19:27 openmrs-code-formatter/plugins/org.eclipse.jdt.core_3.6.0.v_A58.jar -rw-r--r-- misha/misha 47023 2010-09-11 18:42 openmrs-code-formatter/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar -rw-r--r-- misha/misha 52710 2010-09-11 19:29 openmrs-code-formatter/plugins/org.eclipse.core.filesystem_1.3.0.v20100526-0737.jar -rw-r--r-- misha/misha 6451211 2010-09-11 19:32 openmrs-code-formatter/plugins/com.ibm.icu_4.2.1.v20100412.jar -rw-r--r-- misha/misha 70928 2010-09-11 19:01 openmrs-code-formatter/plugins/org.eclipse.core.runtime_3.6.0.v20100505.jar -rw-r--r-- misha/misha 769898 2010-09-11 19:29 openmrs-code-formatter/plugins/org.eclipse.core.resources_3.6.0.v20100526-0737.jar -rw-r--r-- misha/misha 83817 2010-09-11 19:07 openmrs-code-formatter/plugins/org.eclipse.equinox.app_1.3.0.v20100512.jar -rw-r--r-- misha/misha 86986 2010-09-11 19:31 openmrs-code-formatter/plugins/org.eclipse.core.expressions_3.4.200.v20100505.jar -rw-r--r-- misha/misha 90837 2010-09-11 19:05 openmrs-code-formatter/plugins/org.eclipse.core.jobs_3.5.0.v20100515.jar -rw-r--r-- misha/misha 91928 2010-09-11 19:06 openmrs-code-formatter/plugins/org.eclipse.core.contenttype_3.4.100.v20100505-1235.jar -rwxr-xr-x misha/misha 111 2010-09-11 19:39 openmrs-code-formatter/format.sh

插件目录中的相关jar是直接从Eclipse 3.6插件目录中取得的。

config.ini的内容是:

misha@misha-d630:~$ more openmrs-code-formatter/configuration/config.ini osgi.bundles=reference\:file\:org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503.jar@1\:start org.eclipse.equinox.simpleconfigurator.configUrl=file\:org.eclipse.equinox.simpleconfigurator/bundles.info eclipse.application=org.eclipse.jdt.core.JavaCodeFormatter

format.sh是:

misha@misha-d630:~$ more openmrs-code-formatter/format.sh #!/bin/bash java -jar plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar -config OpenMRSFormatter.xml $*

和OpenMRSFormatter.xml在这里可用: http ://wiki.openmrs.org/download/attachments/3346087/OpenMRSFormatter.xml?version=1&modificationDate=1282168038000

我相信应该足以重现。

在这里find一个基于相同概念的有趣项目: http : //code.google.com/p/maven-java-formatter-plugin/

谢谢Misha

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值