1

My main project is using java 1.6 and I need to provide an client jar to an system that can only run on java 1.5. The client jar is an separate module so I am able to specify the java version in the maven-compiler-plugin. However, the client jar is dependent on an core jar, which is on 1.6. One way to

I have used "test-jar" goal in maven-jar-plugin to generate an test jar for other module to use. I am hoping to do something similar and use it in my client module with the following dependency:

<dependency>
    <groupId>org.mygroup</groupId>
    <artifactId>module-core</artifactId>
    <classifier>java1_5</classifier>
</dependency> 
ltfishie
  • 2,917
  • 6
  • 41
  • 68
  • I don't have time to post a complete answer, but you can manage these sorts of things using build profiles to set properties that your build looks for and acts accordingly - http://maven.apache.org/guides/introduction/introduction-to-profiles.html – Brian Roach Nov 22 '11 at 22:19

1 Answers1

0

Why do your client projects depends on core?

If it uses the code from the core, you apparently need to compile core JAR for 1.5 as well. You have several options here:

  1. Set the the target globally to 1.5 and make sure you are not using 1.6 JDK stuff in your code (at least, in the part of the code invoked by the client on JDK 1.5).
  2. Use the profiles + classifiers to generate artifacts for different JDKs (see this question). You have to run the built multiple times, though. Actually, each build will compile everything using the same -target version, so this approach is only a little improvement of 1), allowing you to publish your artifact for multiple JDK versions.

If client code actually does not use core (for example, it uses only WSDLs from the core or some other non-Java stuff), you can remove this dependency by moving stuff to separate "shared" module.

Community
  • 1
  • 1
Ivan Dubrov
  • 4,778
  • 2
  • 29
  • 41
  • Thanks, I did it eventually with profiles, and overwrote the default compile and jar configuration to produce the my client jar. – ltfishie Nov 25 '11 at 04:54