aspose file tools
The moose likes Java in General and the fly likes version based jar file compilation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "version based jar file compilation" Watch "version based jar file compilation" New topic
Author

version based jar file compilation

visshal patel
Greenhorn

Joined: Apr 01, 2004
Posts: 8
Hi,

I have a question related to version based compilation for jar files.

I have a jar file called jtools.jar for our application. I want to include all the versions of jtools.jar e.g. jtools_v_2_1.jar, jtools_v_2_2.jar, jtools_v_4_1.jar� into one single server. To make this possible, I need a class path that also includes the version number. For example, instead of having classes:


com.fisci.activity.adaptors.DoubleAdaptor.java

com.fisci.activity.adaptors.DateAdaptor.java



we want to have classes for version v_2_1:



com.fisci.v_2_1.activity.adaptors.DoubleAdaptor.java

com.fisci.v_2_1.activity.adaptors.DateAdaptor.java



and in a separate java structure for version v_2_2, we want to have classes:



com.fisci.v_2_2.activity.adaptors.DoubleAdaptor.java

com.fisci.v_2_2.activity.adaptors.DateAdaptor.java



and yet in another separate java structure for version v_4_1, we want to have classes:



com.fisci.v_4_1.activity.adaptors.DoubleAdaptor.java

com.fisci.v_4_1.activity.adaptors.DateAdaptor.java



The directory structure is simple:

com/fisci/v_2_1/adaptors/�

com/fisci/v_2_2/adaptors/�

com/fisci/v_4_1/adaptors/�



The question: is there a way in Java language that we can �version� the �import� statements? Example:



Instead of

import java.util.*;

import com.fisci.activity.adaptors.*;





we envision to have it in the form of:

import java.util.*;

import com.fisci.%version%.activity.adaptors.*;



Is there a �macro� in the form above (%version%) that we can it be replaced during compilation with let�s say v_2_2? (and compiler could take the �D symbolic definition what indicates version of interest is let�s say v_2_2)?

I will appreciate any suggestions...

Regards,
Vishal
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
Hi Vishal,

I would recommend the following...

Keep the package names as they are:


Use a directory structure like the following:

You might want to put the versions even higher up the directory tree.

When you are compiling or running a specific version just ensure that your classpath is pointing to the right files/directory.

I'm not aware of any way to do what you're asking and I don't believe that would be a wise choice in any case.

Jules
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56150
    
  13

I concur with Julian. Making the version part of the package name is not a good idea. I create a jar for each version (for example: xyz-4.1.0.jar, xyz-4.1.1.jar and so on), and make sure that the approriate jar is in the classpath for whatever wants to use that version of the facility.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: version based jar file compilation
 
Similar Threads
Unjar Folder
compilation problem
How do i find out the relative path for my jar?
Object "Savvy"
Cannot Access Model Package, While Compiling Servlet