We are developing a Java library which is available in a Java 6 version and in a Java 8 version. The Java 8 version provides a few additional classes but also some classes provide new functionality not available under Java 6. We like to maintain the code under a single repository.
Currently this is achieved via Maven where a profile is activating additional source folders (using a build-helper). The directory layout is
src/main/java
- source files common to both versionssrc/main/java6
- source files only active when building Java 6 versionsrc/main/java8
- source files only active when building Java 8 version
(and the same for src/test). This works quite nice. However, I still have the question:
What is the best practice for maintaining two JDK specific source files for the same class in a single Java project?
Specifically for Maven: What is the preferred naming convention?