简体   繁体   中英

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. 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).

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,
  • jme - this is written against JavaME 2,
  • android - this is (yet to be) written against 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? 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. Additionally it periodically removes old records from 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

   +-- 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). I'm not sure if this will help you but the problem with different logging frameworks has already been solved by slf4j .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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