简体   繁体   English

Maven-与JavaME,JavaSE和Android模块共享多模块项目的记录器

[英]Maven - share a logger for multi-module project with JavaME, JavaSE and Android modules

Short introduction: 简短介绍:

My task is to create a multi-module project (for which I chosen Maven) with modules for JavaME and Android. 我的任务是创建一个包含JavaME和Android模块的多模块项目(为此我选择了Maven)。 More specifically: I'm creating application for phones and my boss obliged me to make a project with shared common code (BTW: I think he puts too much pressure on sharing code between JavaME and Android - these two being based on Java language doesn't mean that sharing code between them is easy). 更具体地说:我正在为手机创建应用程序,而我的老板强迫我创建一个使用共享通用代码的项目(顺便说一句:我认为他对在JavaME和Android之间共享代码施加了太大的压力-这两个基于Java语言的代码并没有这样做。这意味着在它们之间共享代码很容易)。

Problem: 问题:

I have three modules: 我有三个模块:

  • common - this is written against JavaSE 1.1 so it doesn't need emulator to test it and also JavaME would be able to use that module, 常见-这是针对JavaSE 1.1编写的,因此不需要仿真器就可以对其进行测试,并且JavaME也可以使用该模块,
  • jme - this is written against JavaME 2, jme-这是针对JavaME 2编写的
  • android - this is (yet to be) written against Android, android-这是(迄今为止)针对Android编写的,

I want to have three different loggers, one for each module, which share common interface and maybe the logger for common module could be a base (class) for the two other loggers. 我想拥有三个不同的记录器,每个模块一个,共享相同的接口,也许通用模块的记录器可以作为另外两个记录器的基础(类)。 The common classes should use the same logger that the module that incorporates them or a third version of logger for purposes of compiling and testing that common module separately. 公用类应使用与其合并的模块相同的记录器,或使用第三版记录器,以分别编译和测试该公用模块。

Question: 题:

How to configure Maven so that it would include different versions of logger class when compiling & testing different modules? 如何配置Maven,以便在编译和测试不同的模块时包括不同版本的logger类? Or maybe you have different proposals? 也许您有不同的建议?

Update: 更新:

Right now I have my own logger for JavaME which uses RecordStore to store logs and has easy way to retrieve a specified continuous range of logs, convert them to JSON, HTML and text and then send them in batch by email. 现在,我有自己的JavaME记录器,该记录器使用RecordStore来存储日志,并具有简单的方法来检索指定的连续范围的日志,将它们转换为JSON,HTML和文本,然后通过电子邮件批量发送。 Additionally it periodically removes old records from RecordStore. 此外,它会定期从RecordStore中删除旧记录。 I would want to keep such functionality, ie. 我想保留这样的功能,即。 easy way to retrieve and transform log records. 检索和转换日志记录的简便方法。

For the testing you can simply achieve that using the appropriate src/test/resources folder to put the configuration for the logging system into and in your pom you could define different logging system in the different areas 对于测试,您可以简单地实现:使用适当的src / test / resources文件夹将日志记录系统的配置放入pom中,并在pom中可以在不同区域定义不同的日志记录系统

   +-- pom.xml
        +--- common (pom.xml)
        +--- jme (pom.xml)
        +--- android (pom.xml)

and you can define in common (pom.xml) a different logging system than in jme (pom.xml) as dependency (scope: test). 并且您可以在公共(pom.xml)中定义与jme(pom.xml)中不同的日志记录系统作为依赖项(作用域:测试)。 I'm not sure if this will help you but the problem with different logging frameworks has already been solved by slf4j . 我不确定这是否对您有帮助,但是slf4j已经解决了不同日志记录框架的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM